From a10da16f12cff6ba43babd129378530e4971dc34 Mon Sep 17 00:00:00 2001 From: maxluli Date: Tue, 31 May 2022 14:19:33 +0200 Subject: [PATCH] Formatted code with visual studio --- Paint_2/Form1.cs | 12 ++++++------ Paint_2/PaintTool.cs | 4 ++-- Paint_2/Pencil.cs | 24 ++++++++++++------------ Paint_2/Sketch.cs | 21 +++++++++++---------- 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/Paint_2/Form1.cs b/Paint_2/Form1.cs index 9957f79..0026135 100644 --- a/Paint_2/Form1.cs +++ b/Paint_2/Form1.cs @@ -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) { @@ -154,7 +154,7 @@ namespace Paint_2 value = value.Replace("#", String.Empty); int R, G, B; try - { + { R = Convert.ToInt32(String.Concat(value[0], value[1]), fromBase); G = Convert.ToInt32(String.Concat(value[2], value[3]), fromBase); B = Convert.ToInt32(String.Concat(value[4], value[4]), fromBase); @@ -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(); } diff --git a/Paint_2/PaintTool.cs b/Paint_2/PaintTool.cs index c0f5481..6ac488a 100644 --- a/Paint_2/PaintTool.cs +++ b/Paint_2/PaintTool.cs @@ -24,13 +24,13 @@ 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(); void Redo(); void Clear(); - List GetLastColors(int colorNumber); + List GetLastColors(int colorNumber); void Paint(Bitmap canvas); string ToString(); } diff --git a/Paint_2/Pencil.cs b/Paint_2/Pencil.cs index de1b5f1..a3c7cc1 100644 --- a/Paint_2/Pencil.cs +++ b/Paint_2/Pencil.cs @@ -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); } } diff --git a/Paint_2/Sketch.cs b/Paint_2/Sketch.cs index e2868f0..c861882 100644 --- a/Paint_2/Sketch.cs +++ b/Paint_2/Sketch.cs @@ -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 toolList) + public Sketch(Size sketchSize, List toolList) { IsDrawing = false; SketchSize = sketchSize; @@ -43,7 +43,7 @@ namespace Paint_2 CurrentTool = null; } } - public Sketch(List toolList) : this(new Size(500, 500),toolList) + public Sketch(List 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) { @@ -101,14 +102,14 @@ namespace Paint_2 tool.Clear(); } } - public Bitmap Paint() + public Bitmap Paint() { CurrentTool.Paint(Drawing); return Drawing; } 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); } } }