private StartedLineState(GraphVisual graphVisual, NumEllipse startingEllipse, Line workingLine, double weight) : base(graphVisual) { StartingEllipse = startingEllipse; WorkingLine = workingLine; Weight = weight; }
public static StartedLineState Create(GraphVisual graphVisual, NumEllipse startingEllipse, Point currentPoint) { var ellipseCenter = startingEllipse.Ellipse.GetCanvasCenter(); var weight = (graphVisual.MinWeight + graphVisual.MaxWeight) / 2.0; var thickness = (graphVisual.MinLineThickness + graphVisual.MaxLineThickness) / 2.0; var line = LineUtils.CreateLine(ellipseCenter, currentPoint, graphVisual.LineBrush, thickness, graphVisual.PenLineCap); graphVisual.Canvas.Children.Add(line); return(new StartedLineState(graphVisual, startingEllipse, line, weight)); }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { if (Case == 1) { if (PenCase == 1) { pen = new Pen(color, size) { StartCap = System.Drawing.Drawing2D.LineCap.Round }; if (curPoints.Count > 1) { e.Graphics.DrawCurve(pen, curPoints.ToArray()); } } else if (PenCase == 2) { pen = new Pen(color, size) { StartCap = System.Drawing.Drawing2D.LineCap.Round }; if (curPoints.Count > 1) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; e.Graphics.DrawCurve(pen, curPoints.ToArray()); } } // other lines or curves foreach (List <Point> points in allPoints) { if (points.Count > 1) { pen = new Pen(color, size) { StartCap = System.Drawing.Drawing2D.LineCap.Round }; if (PenCase == 1) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; } else if (PenCase == 2) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; } e.Graphics.DrawCurve(pen, points.ToArray()); } } allPoints.Clear(); } else if (Case == 2) { Pen p = new Pen(Color.Red, 3); e.Graphics.DrawRectangle(p, Rect); } else if (Case == 4) { if (NumEllipse < 100) { if (stopdraw % 2 == 0) { string str = NumEllipse.ToString(); Font f = new Font("arial", 15, FontStyle.Bold); e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; e.Graphics.FillEllipse(Brushes.Blue, P1.X, P1.Y, 30, 30); e.Graphics.DrawEllipse(Pens.White, P1.X, P1.Y, 28, 28); if (str.Length == 1) { P1.X = P1.X + 6; } else { P1.X = P1.X + 1; } e.Graphics.DrawString(str, f, Brushes.White, P1.X, P1.Y + 3); NumEllipse += 1; } else { return; } } else { NumEllipse = 1; } } else if (Case == 5) { pen = new Pen(Color.Red, 8) { StartCap = System.Drawing.Drawing2D.LineCap.Round }; pen.EndCap = LineCap.ArrowAnchor; pen.StartCap = LineCap.RoundAnchor; e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; e.Graphics.DrawLine(pen, RectStartPoint, PLine); } }