コード例 #1
0
        public void Draw(CoordinatePlane cp, Graphics g)
        {
            var fromScaled = new PointF(cp.GetScaledX(From.X), cp.GetScaledY(From.Y));
            var toScaled   = new PointF(cp.GetScaledX(To.X), cp.GetScaledY(To.Y));

            Style.DrawVector(fromScaled.X, fromScaled.Y, toScaled.X, toScaled.Y, g);

            if (Style.DrawFirstPoint)
            {
                From.Draw(cp, g);
            }

            if (Name == "" || !Style.DrawName)
            {
                return;
            }
            var nameSize = System.Windows.Forms.TextRenderer.MeasureText(Name, Style.Font);
            var strform  = new StringFormat()
            {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
            };

            var x = Style.PositionOfNameType == CornerPositionType.LeftBottom ||
                    Style.PositionOfNameType == CornerPositionType.LeftTop ? toScaled.X - nameSize.Width : toScaled.X;
            var y = Style.PositionOfNameType == CornerPositionType.LeftTop ||
                    Style.PositionOfNameType == CornerPositionType.RightTop ? toScaled.Y - nameSize.Height : toScaled.Y;

            g.DrawString(Name, Style.Font, Style.TextBrush,
                         new RectangleF(x, y, nameSize.Width, nameSize.Height), strform);
        }
コード例 #2
0
        public void Draw(CoordinatePlane cp, Graphics g)
        {
            var fromScaled = new PointF(cp.GetScaledX(From.X), cp.GetScaledY(From.Y));
            var toScaled   = new PointF(cp.GetScaledX(To.X), cp.GetScaledY(To.Y));
            var pen        = new Pen(Color, LineWidth);

            g.DrawLine(pen, fromScaled.X, fromScaled.Y, toScaled.X, toScaled.Y);

            var v0         = new PointF(toScaled.X - fromScaled.X, toScaled.Y - fromScaled.Y);
            var c          = (float)Math.Sqrt(Math.Pow(v0.X, 2) + Math.Pow(v0.Y, 2));
            var normalized = new PointF(v0.Y / c, v0.X / c);
            var a1         = new PointF((float)Math.Sin(Math.Asin(normalized.Y) + Math.PI / 8), (float)Math.Cos(Math.Acos(normalized.X) + Math.PI / 8));
            var a2         = new PointF((float)Math.Sin(Math.Asin(normalized.Y) - Math.PI / 8), (float)Math.Cos(Math.Acos(normalized.X) - Math.PI / 8));

            g.DrawLines(pen,
                        new[]
            {
                new PointF(toScaled.X - a1.X * 10, toScaled.Y - a1.Y * 10),
                new PointF(toScaled.X, toScaled.Y),
                new PointF(toScaled.X - a2.X * 10, toScaled.Y - a2.Y * 10)
            });
            if (Name != "")
            {
                g.DrawString(Name, new Font("Arial", 8), Brushes.Black, new RectangleF(toScaled.X, toScaled.Y - 20, 20, 20));
            }
        }
コード例 #3
0
        public void Draw(CoordinatePlane cp, Graphics g)
        {
            var x = cp.GetScaledX(X);
            var y = cp.GetScaledY(Y);

            Style.DrawPoint(x, y, g);
            if (Name == "" || !Style.DrawName)
            {
                return;
            }
            var strform = new StringFormat()
            {
                Alignment     = StringAlignment.Center,
                LineAlignment = StringAlignment.Center
            };
            var right =
                Style.PositionOfNameType == CornerPositionType.RightTop ||
                Style.PositionOfNameType == CornerPositionType.RightBottom;
            var bottom =
                Style.PositionOfNameType == CornerPositionType.LeftBottom ||
                Style.PositionOfNameType == CornerPositionType.RightBottom;

            g.DrawString(Name, Style.Font, Style.TextBrush,
                         new RectangleF(x - (right ? 0 : 30), y - (bottom ? 0 : 30), 30, 30), strform);
        }
コード例 #4
0
 public void Draw(CoordinatePlane cp, Graphics g)
 {
     if (Style.DrawPoints)
     {
         Points.ToList().ForEach(p => p.Draw(cp, g));
     }
     g.DrawLines(Style.Pen, Points.Select(p => new PointF(cp.GetScaledX(p.X), cp.GetScaledY(p.Y))).ToArray());
 }
コード例 #5
0
        public void Draw(CoordinatePlane cp, Graphics g)
        {
            var x    = cp.GetScaledX(X);
            var y    = cp.GetScaledY(Y);
            var size = cp.GetScaledSize(W, H);

            g.DrawEllipse(Style.Pen, x - size.Width / 2, y - size.Height / 2, size.Width, size.Height);
        }
コード例 #6
0
ファイル: CoordinateLine.cs プロジェクト: Steiner-bot/Work
 public void Draw(CoordinatePlane cp, Graphics g)
 {
     if (drawPoints)
     {
         P1.Draw(cp, g); P2.Draw(cp, g);
     }
     g.DrawLine(new Pen(Color, LineWidth), cp.GetScaledX(P1.X), cp.GetScaledY(P1.Y), cp.GetScaledX(P2.X), cp.GetScaledY(P2.Y));
 }
コード例 #7
0
        public void Draw(CoordinatePlane cp, Graphics g)
        {
            Style.DrawLine(
                cp.GetScaledX(P1.X), cp.GetScaledY(P1.Y),
                cp.GetScaledX(P2.X), cp.GetScaledY(P2.Y), g);

            if (Style.DrawPoints)
            {
                P1.Draw(cp, g);
                P2.Draw(cp, g);
            }
        }
コード例 #8
0
ファイル: CoordinateMarkerX.cs プロジェクト: Steiner-bot/Work
        public void Draw(CoordinatePlane cp, Graphics g)
        {
            var x = cp.GetScaledX(X);
            var y = cp.GetScaledY(0);

            g.DrawLine(Pens.Black, x, y - 5 * Position, x, y + 5 * Position);
            var strform = new StringFormat()
            {
                Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center
            };

            g.DrawString(X.ToString("0.##"), new Font("Arial", 8), Brushes.Black, x, y - 15 * Position, strform);
        }
コード例 #9
0
 public void Draw(CoordinatePlane cp, Graphics g)
 {
     if (minX > maxX)
     {
         Lines = CalculateLines(Function, cp.ScaledBounds.Left, cp.ScaledBounds.Right, cp.ScaledBounds.Bottom, cp.ScaledBounds.Top);
     }
     foreach (var line in Lines)
     {
         g.DrawLines(Style.Pen, line.Select(p => new PointF(cp.GetScaledX(p.X), cp.GetScaledY(p.Y))).ToArray());
         if (Style.DrawPoints)
         {
             line.ToList().ForEach(p => p.Draw(cp, g));
         }
     }
 }
コード例 #10
0
ファイル: CoordinateMarkerY.cs プロジェクト: Steiner-bot/Work
        public void Draw(CoordinatePlane cp, Graphics g)
        {
            var x = cp.GetScaledX(0);
            var y = cp.GetScaledY(Y);

            g.DrawLine(Pens.Black, x - 5 * Position, y, x + 5 * Position, y);
            var strform = new StringFormat()
            {
                Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center
            };

            if (Position < 0)
            {
                strform.Alignment = StringAlignment.Far;
            }
            g.DrawString(Y.ToString("0.##"), new Font("Arial", 8), Brushes.Black, x + 5 * Position + (Position > 0 ? 5 : -5), y, strform);
        }
コード例 #11
0
        public override void Draw(CoordinatePlane cp, Graphics g)
        {
            base.Draw(cp, g);
            if (Name == "")
            {
                return;
            }
            var strform = new StringFormat()
            {
                Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Center
            };

            if (namePos == 1 || namePos == 2)
            {
                strform.Alignment = StringAlignment.Near;
            }
            g.DrawString(Name, new Font("Arial", 10), Brushes.Black,
                         cp.GetScaledX(X) + (namePos == 1 || namePos == 2 ? 10 : -10),
                         cp.GetScaledY(Y) + (namePos == 2 || namePos == 3 ? 10 : -10), strform);
        }
コード例 #12
0
        public void Draw(CoordinatePlane cp, Graphics g)
        {
            var x   = cp.GetScaledX(X);
            var y   = cp.GetScaledY(0);
            var top = (X > 0 && Style.MarkerXPosition == MarkerXPosition.TopPlusBottomMinus) ||
                      (X < 0 && Style.MarkerXPosition == MarkerXPosition.BottomPlusTopMinus) ||
                      Style.MarkerXPosition == MarkerXPosition.Top;

            if (Style.IntersectOx)
            {
                g.DrawLine(Style.Pen, x, y - Style.LineSize, x, y + Style.LineSize);
            }
            else
            {
                if (top)
                {
                    g.DrawLine(Style.Pen, x, y - Style.LineSize, x, y);
                }
                else
                {
                    g.DrawLine(Style.Pen, x, y, x, y + Style.LineSize);
                }
            }

            if (!Style.DrawTextOx)
            {
                return;
            }

            var strform = new StringFormat()
            {
                Alignment = StringAlignment.Center
            };

            strform.LineAlignment = top ? StringAlignment.Far : StringAlignment.Near;

            g.DrawString(X.ToString("0.##"), Style.Font, Style.TextBrush,
                         x, top ? y - Style.LineSize - 5 : y + Style.LineSize + 5, strform);
        }
コード例 #13
0
        public void Draw(CoordinatePlane cp, Graphics g)
        {
            var x    = cp.GetScaledX(0);
            var y    = cp.GetScaledY(Y);
            var left = (Y > 0 && Style.MarkerYPosition == MarkerYPosition.LeftPlusRightMinus) ||
                       (Y < 0 && Style.MarkerYPosition == MarkerYPosition.RightPlusLeftMinus) ||
                       Style.MarkerYPosition == MarkerYPosition.Left;

            if (Style.IntersectOy)
            {
                g.DrawLine(Style.Pen, x - Style.LineSize, y, x + Style.LineSize, y);
            }
            else
            {
                if (left)
                {
                    g.DrawLine(Style.Pen, x - Style.LineSize, y, x, y);
                }
                else
                {
                    g.DrawLine(Style.Pen, x, y, x + Style.LineSize, y);
                }
            }
            if (!Style.DrawTextOy)
            {
                return;
            }
            var strform = new StringFormat()
            {
                LineAlignment = StringAlignment.Center
            };

            strform.Alignment = left ? StringAlignment.Far : StringAlignment.Near;
            g.DrawString(Y.ToString("0.##"), Style.Font, Style.TextBrush,
                         left ? x - Style.LineSize - 5 : x + Style.LineSize + 5, y, strform);
        }
コード例 #14
0
 public virtual void Draw(CoordinatePlane cp, Graphics g) =>
 g.FillEllipse(new SolidBrush(Color), cp.GetScaledX(X) - Size / 2, cp.GetScaledY(Y) - Size / 2, Size, Size);