Formatted code with visual studio

This commit is contained in:
2022-05-31 14:19:33 +02:00
parent 730c09d94e
commit a10da16f12
4 changed files with 31 additions and 30 deletions

View File

@@ -53,7 +53,7 @@ namespace Paint_2
}
else
{
sketch.StartDrawing(MousePositionToCanvasPosition(),sketch.CurrentTool.Color, (int)nupPencilWidth.Value);
sketch.StartDrawing(MousePositionToCanvasPosition(), sketch.CurrentTool.Color, (int)nupPencilWidth.Value);
}
}
private void canvas_MouseUp(object sender, MouseEventArgs e)
@@ -89,7 +89,7 @@ namespace Paint_2
private void ForceRefresh()
{
canvas.Image = sketch.ForcePaint();
//RefreshUi();
RefreshUi();
}
private void RefreshUi()
{
@@ -108,8 +108,8 @@ namespace Paint_2
lsbTools.DataSource = toolList;
lblWidth.Text = "Width: "+canvas.Width.ToString();
lblHeight.Text = "Height: "+canvas.Height.ToString();
lblWidth.Text = "Width: " + canvas.Width.ToString();
lblHeight.Text = "Height: " + canvas.Height.ToString();
if (randomColor)
{
@@ -237,7 +237,7 @@ namespace Paint_2
private void PaintForm_Resize(object sender, EventArgs e)
{
canvas.Size = new Size(this.Width - (this.Width - panelTools.Location.X) - canvas.Location.X - WINDOW_OFFSET, this.Height-(this.Height-panelHoverColor.Location.Y) - WINDOW_OFFSET - (panelFile.Location.Y + panelFile.Height));
canvas.Size = new Size(this.Width - (this.Width - panelTools.Location.X) - canvas.Location.X - WINDOW_OFFSET, this.Height - (this.Height - panelHoverColor.Location.Y) - WINDOW_OFFSET - (panelFile.Location.Y + panelFile.Height));
sketch.Resize(canvas.Size);
RefreshUi();
}

View File

@@ -24,7 +24,7 @@ namespace Paint_2
int Width { get; set; }
string Name { get; set; }
void Start(Color color,int width);
void Start(Color color, int width);
void Stop(Point point);
void Add(Point point);
void Undo();

View File

@@ -46,9 +46,9 @@ namespace Paint_2
}
public void Add(Point point)
{
Drawings[Drawings.Count -1].Add(point);
Drawings[Drawings.Count - 1].Add(point);
}
public void Paint(Bitmap canvas)
public void Paint(Bitmap canvas)
{
Graphics gr = Graphics.FromImage(canvas);
int drawingCounter = 0;
@@ -62,8 +62,8 @@ namespace Paint_2
if (pointCounter > 0)
{
pointSize = new Size(Widths[drawingCounter], Widths[drawingCounter]);
gr.FillEllipse(new SolidBrush(Colors[drawingCounter]),new Rectangle(new Point(p.X - pointSize.Width/2,p.Y - pointSize.Height/2), pointSize));
gr.DrawLine(new Pen(Colors[drawingCounter],Widths[drawingCounter]),drawing[pointCounter -1],p);
gr.FillEllipse(new SolidBrush(Colors[drawingCounter]), new Rectangle(new Point(p.X - pointSize.Width / 2, p.Y - pointSize.Height / 2), pointSize));
gr.DrawLine(new Pen(Colors[drawingCounter], Widths[drawingCounter]), drawing[pointCounter - 1], p);
}
pointCounter += 1;
@@ -98,9 +98,9 @@ namespace Paint_2
{
result.Add(Colors[(Colors.Count) - i]);
}
for (int i = colorNumber - Colors.Count;i > 0; i--)
for (int i = colorNumber - Colors.Count; i > 0; i--)
{
result.Add(Color.FromArgb(0x00,0x00,0x00));
result.Add(Color.FromArgb(0x00, 0x00, 0x00));
}
}
else
@@ -123,11 +123,11 @@ namespace Paint_2
if (Drawings.Count > 1)
{
DrawingsRedo.Add(Drawings[last]);
Drawings.RemoveAt(Drawings.Count -1);
Drawings.RemoveAt(Drawings.Count - 1);
ColorsRedo.Add(Colors[last]);
Colors.RemoveAt(Colors.Count -1);
Colors.RemoveAt(Colors.Count - 1);
WidthsRedo.Add(Widths[last]);
Widths.RemoveAt(Widths.Count -1);
Widths.RemoveAt(Widths.Count - 1);
}
else
{
@@ -144,11 +144,11 @@ namespace Paint_2
{
if (DrawingsRedo.Count > 0 && WidthsRedo.Count > 0 && ColorsRedo.Count > 0)
{
Drawings.Add(DrawingsRedo[DrawingsRedo.Count -1]);
Drawings.Add(DrawingsRedo[DrawingsRedo.Count - 1]);
DrawingsRedo.RemoveAt(DrawingsRedo.Count - 1);
Colors.Add(ColorsRedo[ColorsRedo.Count -1]);
Colors.Add(ColorsRedo[ColorsRedo.Count - 1]);
ColorsRedo.RemoveAt(ColorsRedo.Count - 1);
Widths.Add(WidthsRedo[WidthsRedo.Count -1]);
Widths.Add(WidthsRedo[WidthsRedo.Count - 1]);
WidthsRedo.RemoveAt(WidthsRedo.Count - 1);
}
}

View File

@@ -28,7 +28,7 @@ namespace Paint_2
public Size SketchSize { get => _sketchSize; set => _sketchSize = value; }
public string Name { get => _name; set => _name = value; }
public Sketch(Size sketchSize,List<PaintTool> toolList)
public Sketch(Size sketchSize, List<PaintTool> toolList)
{
IsDrawing = false;
SketchSize = sketchSize;
@@ -43,7 +43,7 @@ namespace Paint_2
CurrentTool = null;
}
}
public Sketch(List<PaintTool> toolList) : this(new Size(500, 500),toolList)
public Sketch(List<PaintTool> toolList) : this(new Size(500, 500), toolList)
{
//empty
}
@@ -60,7 +60,8 @@ namespace Paint_2
try
{
CurrentTool = ToolList[toolId];
}catch (Exception ex)
}
catch (Exception ex)
{
Console.WriteLine("Oooops...");
}
@@ -73,18 +74,18 @@ namespace Paint_2
{
CurrentTool.Redo();
}
public void StartDrawing(Point location,Color color,int width)
public void StartDrawing(Point location, Color color, int width)
{
CurrentTool.Start(color,width);
CurrentTool.Start(color, width);
CurrentTool.Add(location);
}
public void ChangePaintToolColor(Color color)
{
CurrentTool.Start(color,CurrentTool.Width);
CurrentTool.Start(color, CurrentTool.Width);
}
public void ChangePaintToolWidth(int width)
{
CurrentTool.Start(CurrentTool.Color,width);
CurrentTool.Start(CurrentTool.Color, width);
}
public void StopDrawing(Point location)
{
@@ -108,7 +109,7 @@ namespace Paint_2
}
public Bitmap ForcePaint()
{
Drawing = new Bitmap(SketchSize.Width,SketchSize.Height);
Drawing = new Bitmap(SketchSize.Width, SketchSize.Height);
foreach (PaintTool tool in ToolList)
{
tool.Paint(Drawing);
@@ -118,7 +119,7 @@ namespace Paint_2
public Color GetColor(Point location)
{
//Todo
return Color.FromArgb(0x34,0xF4,0xFF);
return Color.FromArgb(0x34, 0xF4, 0xFF);
}
}
}