Example #1
0
        protected override void AddLines()
        {
            var pen = new Pen(Color.Red, 3);

            pen.CustomEndCap = new AdjustableArrowCap(4, 4);
            Shapes.AddRange(СonnectLines(pen, new [] { BeginEllipse.GetDown(), InitializationIndex.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new [] { InitializationIndex.GetDown(), Cycle.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new [] { Cycle.GetDown(), CycleBodySum.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new [] { CycleBodySum.GetDown(), CycleBodyIndex.GetUp() }));
            Shapes.AddRange(СonnectLines(pen, new []
            {
                Cycle.GetRight(), new Point(Cycle.GetRight().X + 25, Cycle.GetRight().Y),
                new Point(Cycle.GetRight().X + 25, Result.GetUp().Y - 25),
                new Point(Result.GetUp().X, Result.GetUp().Y - 25),
                Result.GetUp()
            }));
            Shapes.AddRange(СonnectLines(pen, new []
            {
                CycleBodyIndex.GetDown(), new Point(CycleBodyIndex.GetDown().X, CycleBodyIndex.GetDown().Y + 25),
                new Point(Cycle.GetLeft().X - 25, CycleBodyIndex.GetDown().Y + 25),
                new Point(Cycle.GetLeft().X - 25, Cycle.GetLeft().Y),
                Cycle.GetLeft()
            }));
            Shapes.AddRange(СonnectLines(pen, new [] { Result.GetDown(), EndEllipse.GetUp() }));
        }
Example #2
0
        protected override void InitializationShapes()
        {
            RectangleTextCode = new RectangleText(
                new Size(400, 400),
                Brushes.Red,
                new Text()
            {
                Point    = new Point(LeftBorder.X + 350, LeftBorder.Y + 50),
                TextLine = UpdateTextCode()
            }
                );

            BeginEllipse = new Ellipse(
                new Point(LeftBorder.X, LeftBorder.Y + 25),
                new Size(200, 30),
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, LeftBorder.Y + 25), TextLine = "begin"
            }
                );

            InitializationIndex = new ClosedLine(
                new[]
            {
                new Point(LeftBorder.X, BeginEllipse.GetDown().Y + 25),
                new Point(LeftBorder.X + 200, BeginEllipse.GetDown().Y + 25),
                new Point(LeftBorder.X + 200, BeginEllipse.GetDown().Y + 75),
                new Point(LeftBorder.X, BeginEllipse.GetDown().Y + 75)
            },
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, BeginEllipse.GetDown().Y + 30), TextLine = $"i := {StartCycleIndex}"
            }
                );

            Cycle = new ClosedLine(
                new[]
            {
                new Point(InitializationIndex.GetLeft().X, InitializationIndex.GetLeft().Y + 75),
                new Point(InitializationIndex.GetDown().X, InitializationIndex.GetDown().Y + 25),
                new Point(InitializationIndex.GetRight().X, InitializationIndex.GetRight().Y + 75),
                new Point(InitializationIndex.GetDown().X, InitializationIndex.GetDown().Y + 75)
            },
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 60, InitializationIndex.GetDown().Y + 30), TextLine = $"i < {EndCycleIndex}"
            }
                );
            CycleBodySum = new ClosedLine(
                new[]
            {
                new Point(LeftBorder.X, Cycle.GetDown().Y + 50),
                new Point(LeftBorder.X + 200, Cycle.GetDown().Y + 50),
                new Point(LeftBorder.X + 200, Cycle.GetDown().Y + 100),
                new Point(LeftBorder.X, Cycle.GetDown().Y + 100)
            },
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, Cycle.GetDown().Y + 60), TextLine = "sum += i"
            }
                );
            CycleBodyIndex = new ClosedLine(
                new[]
            {
                new Point(LeftBorder.X, CycleBodySum.GetDown().Y + 50),
                new Point(LeftBorder.X + 200, CycleBodySum.GetDown().Y + 50),
                new Point(LeftBorder.X + 200, CycleBodySum.GetDown().Y + 100),
                new Point(LeftBorder.X, CycleBodySum.GetDown().Y + 100)
            },
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, CycleBodySum.GetDown().Y + 60), TextLine = "i += 1"
            }
                );
            Result = new ClosedLine(
                new[]
            {
                new Point(LeftBorder.X, CycleBodyIndex.GetDown().Y + 75),
                new Point(LeftBorder.X + 200, CycleBodyIndex.GetDown().Y + 75),
                new Point(LeftBorder.X + 200, CycleBodyIndex.GetDown().Y + 125),
                new Point(LeftBorder.X, CycleBodyIndex.GetDown().Y + 125)
            },
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, CycleBodyIndex.GetDown().Y + 80), TextLine = "sum"
            }
                );

            EndEllipse = new Ellipse(
                new Point(LeftBorder.X, Result.GetDown().Y + 50),
                new Size(200, 30),
                Brushes.White,
                new Text()
            {
                Point = new Point(LeftBorder.X + 50, Result.GetDown().Y + 50), TextLine = "end"
            }
                );
        }