Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patterns "Strategy" #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions ConsoleApplication1/ConsoleApplication1.sln

This file was deleted.

63 changes: 0 additions & 63 deletions ConsoleApplication1/ConsoleApplication1/Program.cs

This file was deleted.

25 changes: 25 additions & 0 deletions Puint/Puint.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.852
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Puint", "Puint\Puint.csproj", "{F196685D-929E-4B2E-996E-56510F509574}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F196685D-929E-4B2E-996E-56510F509574}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F196685D-929E-4B2E-996E-56510F509574}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F196685D-929E-4B2E-996E-56510F509574}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F196685D-929E-4B2E-996E-56510F509574}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9EFED7D6-A972-4A89-90D3-78989FA85DE6}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions Puint/Puint/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
101 changes: 101 additions & 0 deletions Puint/Puint/Circle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Runtime.Serialization;

namespace Puint
{
[DataContract]
public class Circli: Figures
{
[DataMember]
private Point oldPoint;
[DataMember]
private Point newPoint;
[DataMember]
private Color _color;
[DataMember]
private float _size;

public override Point OldPoint
{
get { return oldPoint; }
}
public override Point NewPoint
{
get { return newPoint; }
}
public override Color color
{
get { return _color; }
}
public override float size
{
get { return _size; }
}
public Circli()
{
}
public Circli(Color color, Point OldPoint, Point NewPoint, float size)
{
oldPoint = OldPoint;
newPoint = NewPoint;
_color = color;
_size = size;
}
public override void Draw(Graphics gr, float size)
{
if (oldPoint != null && newPoint != null)
{
if (newPoint.X < oldPoint.X && newPoint.Y < oldPoint.Y)
{
Point p = newPoint;
newPoint = oldPoint;
oldPoint = p;
}
else if (newPoint.X < oldPoint.X && newPoint.Y > oldPoint.Y)
{
int p = oldPoint.X;
oldPoint.X = newPoint.X;
newPoint.X = p;
}
else if (newPoint.X > oldPoint.X && newPoint.Y < oldPoint.Y)
{
int p = oldPoint.Y;
oldPoint.Y = newPoint.Y;
newPoint.Y = p;
}
Pen pen = new Pen(_color, _size);
Rectangle r = new Rectangle(oldPoint, new Size(newPoint.X - oldPoint.X, newPoint.Y - oldPoint.Y));
gr.DrawEllipse(pen, r);
}
}
public static void Draw(Graphics gr, Color color, Point OldPoint, Point NewPoint, float size)
{
Pen pen = new Pen(color, size);
if (NewPoint.X < OldPoint.X && NewPoint.Y < OldPoint.Y)
{
Point p = NewPoint;
NewPoint = OldPoint;
OldPoint = p;
}
else if (NewPoint.X < OldPoint.X && NewPoint.Y > OldPoint.Y)
{
int p = OldPoint.X;
OldPoint.X = NewPoint.X;
NewPoint.X = p;
}
else if (NewPoint.X > OldPoint.X && NewPoint.Y < OldPoint.Y)
{
int p = OldPoint.Y;
OldPoint.Y = NewPoint.Y;
NewPoint.Y = p;
}
Rectangle r = new Rectangle(OldPoint, new Size(NewPoint.X - OldPoint.X, NewPoint.Y - OldPoint.Y));
gr.DrawEllipse(pen, r);
}
}
}
20 changes: 20 additions & 0 deletions Puint/Puint/Figures.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Runtime.Serialization;

namespace Puint
{
[DataContract]
abstract public class Figures //Strategy
{
public abstract void Draw(Graphics gr, float size);
public abstract Point OldPoint { get; }
public abstract Point NewPoint { get; }
public abstract Color color { get; }
public abstract float size { get; }
}
}
Loading