Esempio n. 1
0
        //double  lon0,lat0;
        //double  lon1,lat1;
        //wei=(lat1-lat0)*(2*pi*R2+4*(R1-R2))/360;//R1=6378004;%地球极半径. R2=6356755;%地球赤道半径
        //jing=(lon1-lon0)*2*pi*R1*cos(lat0*pi/180)/360;
        //shuiping=sqrt(wei^2+jing^2); double  lon0,lat0;

        public void DrawAxis(Graphics g, SplitGroupPanel panel)
        {
            axisArea.Width  = panel.Size.Width - 2 * axisMargin.X;
            axisArea.Height = panel.Size.Height - 2 * axisMargin.Y;

            axisO.X = panel.Size.Width / 2f;
            axisO.Y = panel.Size.Height / 2f;

            radius = (axisArea.Width > axisArea.Height) ? (axisArea.Height / 4f) : (axisArea.Width / 4f);

            System.Drawing.Drawing2D.AdjustableArrowCap lineCap = new System.Drawing.Drawing2D.AdjustableArrowCap(6, 6, true);
            Pen pen = new Pen(Color.DimGray, 0.5f)
            {
                CustomEndCap = lineCap
            };

            g.DrawLine(pen, new PointF(axisMargin.X, axisO.Y), new PointF(axisMargin.X + axisArea.Width, axisO.Y));
            g.DrawLine(pen, new PointF(axisO.X, axisMargin.Y + axisArea.Height), new PointF(axisO.X, axisMargin.Y));

            //pen.DashStyle = DashStyle.Custom;
            //pen.DashPattern = new float[] { 1f, 3f };
            pen.DashStyle = DashStyle.Solid;
            pen.Color     = Color.LightGray;
            pen.Width     = 0.1f;
            g.DrawEllipse(pen, new RectangleF(axisO.X - radius, axisO.Y - radius, radius * 2, radius * 2));

            g.DrawString("N", new Font("宋体", emSize), new SolidBrush(Color.Black), axisO.X + 5, axisMargin.Y + 5);
            //g.DrawString("O", new Font("宋体", emSize), new SolidBrush(Color.Black), axisO.X, axisO.Y);
            g.DrawString(radiusM.ToString("f1") + "m", new Font("宋体", emSize), new SolidBrush(Color.Black), axisO.X + radius + 5, axisO.Y);
            g.DrawString("E", new Font("宋体", emSize), new SolidBrush(Color.Black), axisArea.Width + axisMargin.X, axisO.Y);

            DrawAddPoint(g);
        }
Esempio n. 2
0
 public static Pen largeDashedArrow(Color c)
 {
     CustomLineCap arrowCap = new AdjustableArrowCap(LARGESIZEARROW, LARGESIZEARROW, true);
     Pen pen = largeDashed(c);
     pen.CustomEndCap = arrowCap;
     return pen;
 }
Esempio n. 3
0
        public override void Render(WidgetRenderingContext context)
        {
            Graphics g = context.Graphics;

            if (!(Element is Arc))
            {
                throw new InvalidOperationException("Petri Net Element must be convertible to Arc for ArcWidget.");
            }
            Arc arc = (Arc)Element;

            if (arc.StartElement == null || arc.EndElement == null)
            {
                throw new InvalidOperationException("StartElement and EndElement of arc cannot be null.");
            }

            PetriNetElementWidget startWidget = (PetriNetElementWidget)context.WidgetLocator.FindWidget(arc.StartElement.ID);
            PetriNetElementWidget endWidget = (PetriNetElementWidget)context.WidgetLocator.FindWidget(arc.EndElement.ID);

            Point arcStartPoint = startWidget.GetLineIntersectionPoint(endWidget.Location);
            Point arcEndPoint = endWidget.GetLineIntersectionPoint(startWidget.Location);

            using (Pen arrowPen = new Pen(Brushes.Black))
            {
                using (AdjustableArrowCap arrowCap = new AdjustableArrowCap(2, 1))
                {
                    arrowCap.WidthScale = 5;
                    arrowCap.BaseCap = LineCap.Square;
                    arrowCap.Height = 2;
                    arrowPen.CustomEndCap = arrowCap;
                    g.DrawLine(arrowPen, arcStartPoint, arcEndPoint);
                }
            }
        }
 public SubgraphViewerDrawer(Graphics g)
 {
     m_Graphics = g;
     m_LinePen = new Pen(Color.Black, ViewerConfig.LinePenWidth);
     m_Font = new Font(ViewerConfig.FontName, ViewerConfig.FontSize);
     m_Brush = new SolidBrush(ViewerConfig.BrushColor);
     m_LineCap = new System.Drawing.Drawing2D.AdjustableArrowCap(5, 5, true);
 }
Esempio n. 5
0
        protected void DrawLine(Graphics grf, Pen penLine, Rectangle box1, Rectangle box2, bool isHorizontal)
        {
            Point[]   pts      = new Point[4];
            Rectangle boxStart = box1;
            Rectangle boxEnd   = box2;

            System.Drawing.Drawing2D.AdjustableArrowCap lineCap =
                new System.Drawing.Drawing2D.AdjustableArrowCap(5, 5, true);

            if (isHorizontal)
            {
                if (boxStart.Top > boxEnd.Top)
                {
                    boxStart  = box2;
                    boxEnd    = box1;
                    boxEnd.Y -= BUTTONSIZE; // / 2;
                                            //  penLine.EndCap = LineCap.ArrowAnchor;
                    penLine.CustomEndCap = lineCap;
                }
                else
                {
                    boxStart.Height += BUTTONSIZE; // / 2;
                                                   // penLine.StartCap = LineCap.ArrowAnchor;
                    penLine.CustomStartCap = lineCap;
                }

                pts[0] = new Point(boxStart.X + boxStart.Width / 2, boxStart.Bottom);
                pts[1] = new Point(pts[0].X, boxStart.Bottom + (boxEnd.Top - boxStart.Bottom) / 2);
                pts[2] = new Point(boxEnd.X + boxEnd.Width / 2, pts[1].Y);
                pts[3] = new Point(pts[2].X, boxEnd.Top);
            }
            else
            {
                if (boxStart.Left > boxEnd.Left)
                {
                    boxStart  = box2;
                    boxEnd    = box1;
                    boxEnd.X -= BUTTONSIZE;/// 2;
                    // penLine.EndCap = LineCap.ArrowAnchor;
                    penLine.CustomEndCap = lineCap;
                }
                else
                {
                    boxStart.Width += BUTTONSIZE;// / 2;
                    // penLine.StartCap = LineCap.ArrowAnchor;
                    penLine.CustomStartCap = lineCap;
                }

                pts[0] = new Point(boxStart.Right, boxStart.Top + boxStart.Height / 2);
                pts[1] = new Point(boxStart.Right + (boxEnd.Left - boxStart.Right) / 2, pts[0].Y);
                pts[2] = new Point(pts[1].X, boxEnd.Top + boxEnd.Height / 2);
                pts[3] = new Point(boxEnd.Left, pts[2].Y);
            }
            grf.SmoothingMode      = SmoothingMode.HighQuality;
            grf.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            grf.CompositingQuality = CompositingQuality.HighQuality;
            grf.DrawLines(penLine, pts);
        }
Esempio n. 6
0
        protected override void DrawLine(Graphics g, Pen pen)
        {
            using (AdjustableArrowCap arrowCap = new AdjustableArrowCap(4, 6))
            {
                pen.CustomEndCap = arrowCap;

                g.DrawLine(pen, StartPosition, EndPosition);
            }
        }
Esempio n. 7
0
        protected override void DrawLine(Graphics g, Pen pen)
        {
            using (AdjustableArrowCap arrowCap = new AdjustableArrowCap(4, 6))
            {
                pen.CustomEndCap = arrowCap;

                base.DrawLine(g, pen);
            }
        }
Esempio n. 8
0
 public Line(UnitPoint point, UnitPoint endpoint, float width, Color color)
 {
     P1         = point;
     P2         = endpoint;
     Width      = width;
     Color      = color;
     Selected   = false;
     m_guid     = System.Guid.NewGuid().ToString();
     m_arrowCap = new System.Drawing.Drawing2D.AdjustableArrowCap(5, 5);
 }
Esempio n. 9
0
 private void CreateArrowCap(ref AdjustableArrowCap arrowCap, Graphics.Size size)
 {
     if (arrowCap == null)
     {
         arrowCap = new System.Drawing.Drawing2D.AdjustableArrowCap(size.Width, size.Height);
     }
     else
     {
         arrowCap.Width  = size.Width;
         arrowCap.Height = size.Height;
     }
 }
Esempio n. 10
0
        public void Paint(Graphics g)
        {
            createLine();
            Pen pen = new Pen(Color.Red, 1);

            using ( pen )
            {
                System.Drawing.Drawing2D.AdjustableArrowCap bigArrow = new System.Drawing.Drawing2D.AdjustableArrowCap(5, 5);
                pen.CustomEndCap = bigArrow;
                g.DrawLine(pen, origin, destination);
            }
        }
Esempio n. 11
0
 public MultiConnectionLines(List <UnitPoint> allPts, float width, Color color)
 {
     m_allPts = new List <UnitPoint>();
     foreach (var pt in allPts)
     {
         m_allPts.Add(pt);
     }
     Width      = width;
     Color      = color;
     Selected   = false;
     m_guid     = System.Guid.NewGuid().ToString();
     m_arrowCap = new System.Drawing.Drawing2D.AdjustableArrowCap(5, 5);
 }
Esempio n. 12
0
        protected override void Draw_Logo(Graphics g, Rectangle rectVirtualEntityWithOffset)
        {
            if (!this.ShowLogo)
            {
                return;
            }
            //Image img = Util.get_image("logolr");
            //if (img == null)
            //    return;
            //Rectangle rt = rectVirtualEntityWithOffset;
            //int nsize = LOGO_SIZE;
            //rt.X = rt.Right - nsize;
            //rt.Width = nsize;
            //rt.Height = nsize;
            //g.DrawImage(img, rt);



            System.Drawing.Drawing2D.AdjustableArrowCap lineCap =
                new System.Drawing.Drawing2D.AdjustableArrowCap(4, 2, true);

            Pen redArrowPen = new Pen(this.ForeColor, 1);
            //redArrowPen.CustomEndCap = lineCap;
            //redArrowPen.CustomStartCap = lineCap;
            Rectangle rt      = rectVirtualEntityWithOffset;
            int       nsize   = LOGO_SIZE;
            Point     ptStart = new Point(rt.Right - nsize, rt.Y + LOGO_SIZE / 2);
            Point     ptEnd   = new Point(rt.Right, rt.Y + LOGO_SIZE / 2);

            g.DrawLine(redArrowPen, ptStart, ptEnd);//


            //header top
            int nSizeX = 3;
            int nSizeY = 3;

            Point[] ptsLeft = new Point[] {
                new Point(ptStart.X, ptStart.Y),
                new Point(ptStart.X + nSizeX + 2, ptStart.Y - nSizeY - 2),
                new Point(ptStart.X + nSizeX + 2, ptStart.Y + nSizeY + 2),
            };
            g.FillPolygon(new SolidBrush(this.ForeColor), ptsLeft);//, FillMode.Winding);

            //header bottom
            Point[] ptsRight = new Point[] {
                new Point(ptEnd.X + 1, ptEnd.Y),
                new Point(ptEnd.X - nSizeX - 2, ptEnd.Y - nSizeY - 2),
                new Point(ptEnd.X - nSizeX - 1, ptEnd.Y + nSizeY + 2),
            };
            g.FillPolygon(new SolidBrush(this.ForeColor), ptsRight, FillMode.Winding);
        }
Esempio n. 13
0
        public override void Draw(Graphics g)
        {
            System.Drawing.Drawing2D.AdjustableArrowCap lineCap = new System.Drawing.Drawing2D.AdjustableArrowCap(6, 6, true);

            g.SmoothingMode = SmoothingMode.AntiAlias;

            Pen pen = new Pen(Color, PenWidth);

            pen.CustomEndCap = lineCap;

            g.DrawLine(pen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);

            pen.Dispose();
        }
Esempio n. 14
0
        public GestureThumbnail(PointF[] Points, Size Size, bool WithArrow)
        {
            _Points = Points;
            _Size = Size;
            _DrawingPen.StartCap = _DrawingPen.EndCap = LineCap.Round;
            _ArrowPen = _DrawingPen.Clone() as Pen;

            // Create new large arrow cap
            AdjustableArrowCap arrowCap = new AdjustableArrowCap(3, 3, true);
            arrowCap.BaseCap = LineCap.Square;

            _ArrowPen.CustomEndCap = arrowCap;

            _WithArrow = WithArrow;
        }
Esempio n. 15
0
        protected override void DrawLine(Graphics g, Pen pen)
        {
            using (AdjustableArrowCap arrowCap = new AdjustableArrowCap(4, 6))
            {
                pen.CustomEndCap = arrowCap;

                if (CenterNodeActive)
                {
                    g.DrawCurve(pen, new Point[] { StartPosition, CenterPosition, EndPosition });
                }
                else
                {
                    g.DrawLine(pen, StartPosition, EndPosition);
                }
            }
        }
Esempio n. 16
0
 //旋转的箭头
 private void DemoRotate(Graphics g)
 {
     //还可以旋转
     using (Pen p = new Pen(Color.Red))
     {
         g.TranslateTransform((float)(Width / 2 * 0.8), (float)(Height / 2 * 0.8));
         for (int i = 0; i < 12; i++)
         {
             System.Drawing.Drawing2D.AdjustableArrowCap myLineArrow =
                 new System.Drawing.Drawing2D.AdjustableArrowCap(4, 4, true);
             p.CustomEndCap = myLineArrow;
             g.DrawLine(p, new Point(0, 15), new Point(180, 15));
             g.RotateTransform(30);
         }
     }
     g.ResetTransform();
 }
Esempio n. 17
0
        public void drawSmth()
        {
            int size = 40;
            Point[] p = calc.calcPoints(A.GetLength(0), 210, w, h);// for other firgures point array
            PointF[] pp = calc.calcPointsF(A.GetLength(0), 210, w, h);//char pointf array
            Rectangle[] rect = calc.vertices(p, size);

            Pen arrowPen = new Pen(Color.FromArgb(0, 0, 255), 8);    // pen for relations
            AdjustableArrowCap arrow = new AdjustableArrowCap(5, 5);  // custom arrow
            arrowPen.CustomEndCap = arrow;

            char[] alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();   //
            Font fnt = new Font("Arial", 16);                            //Chars things

            for (int i = 0; i < A.GetLength(0); i++) //Draw Verticies and Chars
            {
                g.FillEllipse(Brushes.Violet, rect[i]);
                g.DrawString(alpha[i].ToString(), fnt, Brushes.Black, pp[i]);
            }

            calc.lines(g, A, p, arrowPen); // draw relations
        }
Esempio n. 18
0
        private void DemoMyArrow(Graphics g)
        {
            //定义新画笔
            //Pen pen1 = new Pen(Color.Black);
            //Pen pen1 = new Pen(Color.LightGray, 1);
            Pen pen1 = new Pen(Color.FromArgb(95, 0, 0, 0));//从rgb定义颜色

            for (int i = 2; i < 15; i++)
            {
                //定义画笔宽度
                pen1.Width = i;
                //定义画笔尖端
                pen1.EndCap = LineCap.ArrowAnchor;
                //定义点
                Point point1 = new Point(100, 25 * i);
                Point point2 = new Point(500, 25 * i);
                //划线
                g.DrawLine(pen1, point1, point2);
                //画标注
                g.DrawString(i.ToString(), new Font("宋体", 12), new SolidBrush(Color.Red), point2.X, point2.Y - 10);
            }

            //以上箭头都太丑了,自定义一个
            // http://bbs.csdn.net/topics/390311725
            Pen penSmall = new Pen(Color.Orange, 1);

            System.Drawing.Drawing2D.AdjustableArrowCap lineArrow =
                new System.Drawing.Drawing2D.AdjustableArrowCap(4, 4, true);
            penSmall.CustomEndCap = lineArrow;
            g.DrawLine(penSmall, new Point(100, 10), new Point(500, 10));


            //定义画笔-画空心圆圈
            Brush BlueBrush = new SolidBrush(Color.Blue); //定义刷子
            Pen   pen       = new Pen(BlueBrush);         //凑够刷子创建画笔

            g.DrawEllipse(pen, 20, 30, 10, 10);           //画空心圆
            g.DrawEllipse(pen, 20, 50, 10, 10);           //画另一个空心圆
        }
Esempio n. 19
0
 public MultiConnectionLines()
 {
     m_allPts   = new List <UnitPoint>();
     m_guid     = System.Guid.NewGuid().ToString();
     m_arrowCap = new System.Drawing.Drawing2D.AdjustableArrowCap(5, 5);
 }
Esempio n. 20
0
        private void afnDraw_Paint(object sender, PaintEventArgs e)
        {
            if (button6Clicked)
            {
             //   oldAutomataAfn = (Hashtable)automataAfn.Clone();
             //   oldEstadosAfn = (Hashtable)estadosAfn.Clone();
             //   oldLineasAfn = (Hashtable)lineasAfn.Clone();
                if (afnminimizaclicked)
                {
                    if (afnetapasCounterTD == 0)
                    {
                        afntopleft.Enabled = afnleft.Enabled = false;
                        afntopright.Enabled = afnright.Enabled = true;
                        afnclose.Enabled = true;
                    }
                    else
                    {
                        if (afnetapasCounterTD == (afnetapasMinimizacionTD.Count - 1))
                        {
                            afntopleft.Enabled = afnleft.Enabled = true;
                            afntopright.Enabled = afnright.Enabled = false;
                            afnclose.Enabled = true;
                        }
                        else
                        {
                            afntopleft.Enabled = afnleft.Enabled = afntopright.Enabled = afnright.Enabled = true;
                            afnclose.Enabled = false;
                        }
                    }

                    Hashtable paraActualizar = (Hashtable)afnetapasMinimizacionTD[afnetapasCounterTD];
                    estadosAfn = (Hashtable)paraActualizar["estados"];
                    lineasAfn = (Hashtable)paraActualizar["lineas"];
                    automataAfn = (Hashtable)paraActualizar["automata"];

                    if (automataAfn.Count == 0)
                        afnAnimate.Enabled = false;
                    else
                        afnAnimate.Enabled = true;

                    afnlabel2.Text = (String)afnetapasMinimizacionExplicacionTD[afnetapasCounterTD];

                }
             /*   else
                {
                    automataAfn = automataNuevoAfd;
                    estadosAfn = EstadosDAfd;
                    lineasAfn = lineasNuevasAfd;
                }*/
            }

            int x = 0, y = 0;
            Pen pencil = new Pen(Color.Black, 2);
            Font font = new Font("Arial", 10);
            SolidBrush brush = new SolidBrush(Color.Black);
            AdjustableArrowCap aac = new AdjustableArrowCap(5, 5, true);
            pencil.CustomEndCap = aac;
            foreach (DictionaryEntry d in estadosAfn)
            {
                pencil.Width = 2;
                x = ((State)d.Value).x;
                y = ((State)d.Value).y;
                if (((State)d.Value).isActualState)
                {
                    pencil.Color = Color.Blue;
                    brush.Color = Color.Blue;
                }
                else
                {
                    pencil.Color = ((State)d.Value).color;
                    brush.Color = ((State)d.Value).color;
                }

                gafn.DrawString((String)d.Key, font, brush, x + 5, y + 8);

                if (((State)d.Value).isFinal)
                {
                    pencil.Width = 2;
                    gafn.DrawEllipse(pencil, x, y, 30, 30);
                    pencil.Width = 3;
                    gafn.DrawEllipse(pencil, x - 4, y - 4, 38, 38);
                }
                else
                    gafn.DrawEllipse(pencil, x, y, 30, 30);
                if (((State)d.Value).isInitial)
                {
                    Point[] p = new Point[3];
                    p[2].X = ((State)d.Value).x;
                    p[2].Y = ((State)d.Value).y + 15;
                    p[1].X = ((State)d.Value).x - 15;
                    p[1].Y = ((State)d.Value).y;
                    p[0].X = ((State)d.Value).x - 30;
                    p[0].Y = ((State)d.Value).y - 5;
                    gafn.DrawCurve(pencil, p);
                }
            }
            pencil.Width = 2;
            foreach (DictionaryEntry d in lineasAfn)
            {
                String[] s = breakKey((String)d.Key);
                int sourceX = ((State)estadosAfn[s[0]]).x;
                int sourceY = ((State)estadosAfn[s[0]]).y;
                foreach (DictionaryEntry d2 in (Hashtable)d.Value)
                {
                    int destX = ((State)estadosAfn[(String)d2.Key]).x;
                    int destY = ((State)estadosAfn[(String)d2.Key]).y;
                    int interX = ((Line)d2.Value).intermediatePointX;
                    int interY = ((Line)d2.Value).intermediatePointY;

                    int dxSource = interX - sourceX;
                    int dxDest = interX - destX;
                    int dySource = interY - sourceY;
                    int dyDest = interY - destY;
                    Point[] p = new Point[3];
                    p[1] = new Point(interX, interY);
                    if (Math.Abs(dxSource) < Math.Abs(dySource))
                        if (dySource > 0)
                            p[0] = new Point((sourceX + 15), (sourceY + 30));
                        else
                            p[0] = new Point((sourceX + 15), sourceY);
                    else
                        if (dxSource > 0)
                        p[0] = new Point((sourceX + 30), (sourceY + 15));
                    else
                        p[0] = new Point(sourceX, sourceY + 15);

                    if (Math.Abs(dxDest) < Math.Abs(dyDest))
                        if (dyDest > 0)
                            p[2] = new Point((destX + 15), (destY + 30));
                        else
                            p[2] = new Point((destX + 15), destY);
                    else
                        if (dxDest > 0)
                        p[2] = new Point((destX + 30), (destY + 15));
                    else
                        p[2] = new Point(destX, (destY + 15));

                    if (s[0] == (String)d2.Key)
                    {
                        if (interX < sourceX)
                            if (interY < sourceY)
                            {
                                p[0] = new Point(sourceX, sourceY + 15);
                                p[2] = new Point(destX + 15, destY);
                            }
                            else
                            {
                                p[0] = new Point(sourceX, sourceY + 15);
                                p[2] = new Point(destX + 15, destY + 30);
                            }
                        if (interX > sourceX)
                            if (interY < sourceY)
                            {
                                p[0] = new Point(sourceX + 30, sourceY + 15);
                                p[2] = new Point(destX + 15, destY);
                            }
                            else
                            {
                                p[0] = new Point(sourceX + 30, sourceY + 15);
                                p[2] = new Point(destX + 15, destY + 30);
                            }
                    }
                    if (((Line)d2.Value).isActualLine)
                    {
                        pencil.Color = Color.Blue;
                        brush.Color = Color.Blue;
                    }
                    else
                    {
                        pencil.Color = ((Line)d2.Value).color;
                        brush.Color = ((Line)d2.Value).color;
                    }
                    gafn.DrawCurve(pencil, p);
                    if (((Line)d2.Value).label != "")
                    {
                        Font f = new Font("Arial", 10, FontStyle.Bold);
                        gafn.DrawString(((Line)d2.Value).label, f, brush, p[1].X - 15, p[1].Y - 15);
                    }
                    else
                    {
                        Font f = new Font("Symbol", 10, FontStyle.Bold);
                        gafn.DrawString("l", f, brush, p[1].X - 15, p[1].Y - 15);
                    }
                }
            }
        }
Esempio n. 21
0
 // Método para dibujar los arcos
 public void DibujarArco(Graphics g)
 {
     float distancia;
         int difY, difX;
         foreach(CArco arco in ListaAdyacencia) {
             difX = this.Posicion.X - arco.nDestino.Posicion.X;
             difY = this.Posicion.Y - arco.nDestino.Posicion.Y;
             distancia = (float) Math.Sqrt((difX * difX + difY * difY));
             AdjustableArrowCap bigArrow = new AdjustableArrowCap(4, 4, true);
             bigArrow.BaseCap = System.Drawing.Drawing2D.LineCap.Triangle;
             g.DrawLine(new Pen(new SolidBrush(arco.color), arco.grosor_flecha) {
                     CustomEndCap = bigArrow, Alignment = PenAlignment.Center
                 },
                 _posicion,
                 new Point(arco.nDestino.Posicion.X + (int)(radio * difX / distancia),
                     arco.nDestino.Posicion.Y + (int)(radio * difY / distancia)
                 )
             );
             g.DrawString(
                 arco.peso.ToString(),
                 new Font("Times New Roman ", 12),
                 new SolidBrush(Color.Black),
                 this._posicion.X - (int)((difX / 3)),
                 this._posicion.Y - (int)((difY / 3)),
                 new StringFormat() {
                     Alignment = StringAlignment.Center,
                         LineAlignment = StringAlignment.Far
                 }
             );
         }
 }
Esempio n. 22
0
    public MemoryStream draw(string sql)
    {
        Bitmap   img = new Bitmap(2600, 2500);   //创建Bitmap对象
        Graphics g   = Graphics.FromImage(img);  //创建Graphics对象

        Pen Bp        = new Pen(Color.Black, 5); //定义黑色画笔
        Pen AxisPoint = new Pen(Color.Black, 5); //标尺画笔
        Pen Rp        = new Pen(Color.Red, 4);   //红色画笔
        Pen Sp        = new Pen(Color.Blue, 5);  //蓝色坐标系画笔

        Color[] colors = new Color [] { Color.Red, Color.Orange, Color.Maroon, Color.Green, Color.MediumBlue, Color.Olive, Color.Gold, Color.Black, Color.Salmon, Color.Aquamarine, Color.Violet, Color.Yellow, Color.DarkRed, Color.Peru, Color.MistyRose, Color.MediumSlateBlue };

        Font Arrowfont   = new Font("Arial", 50);           //箭头字体
        Font Axisfont    = new Font("Arial", 40);           //坐标值字体
        Font Biaoshifont = new Font("Microsoft Yahei", 35); //坐标值字体

        //画Glass背景
        Color     glasscolor      = Color.FromArgb(208, 206, 206);
        Brush     glassbrush      = new SolidBrush(glasscolor);
        Brush     backgroundbrush = new SolidBrush(Color.White);
        Rectangle backgroundrec   = new Rectangle(0, 0, 2600, 2500);
        Rectangle glassrec        = new Rectangle(100, 0, 2600, 2200);

        g.FillRectangle(backgroundbrush, backgroundrec);
        g.FillRectangle(glassbrush, glassrec);
        g.DrawLine(Bp, 2500, 0, 2600, 100);

        ////黑色过度型笔刷
        LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.Black, Color.Black, 1.2F, true);
        ////蓝色过度型笔刷
        LinearGradientBrush Bluebrush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.Blue, Color.Blue, 1.2F, true);

        AdjustableArrowCap aac;  //定义箭头帽

        aac             = new System.Drawing.Drawing2D.AdjustableArrowCap(20, 20);
        Sp.CustomEndCap = aac;               //开始端箭头帽
        g.DrawLine(Sp, 1350, 0, 1350, 2300); //纵坐标
        g.DrawLine(Sp, 2600, 1100, 0, 1100); //横坐标
        g.DrawString("X", Arrowfont, brush, 20, 1150);
        g.DrawString("Y", Arrowfont, brush, 1400, 2220);

        //画标尺
        int x        = 1200;
        int xpoint   = 150;
        int xaxisstr = 100;

        for (int i = 0; i < 6; i++)
        {
            g.DrawLine(AxisPoint, xpoint, 1070, xpoint, 1100);
            string xaxis = x.ToString();
            g.DrawString(xaxis, Axisfont, brush, xaxisstr, 1020);
            xaxisstr += 200;
            xpoint   += 200;
            x        -= 200;
        }
        x        = -200;
        xpoint   = 1550;
        xaxisstr = 1450;
        for (int i = 0; i < 6; i++)
        {
            g.DrawLine(AxisPoint, xpoint, 1070, xpoint, 1100);
            string xaxis = x.ToString();
            g.DrawString(xaxis, Axisfont, brush, xaxisstr, 1020);
            xaxisstr += 200;
            xpoint   += 200;
            x        -= 200;
        }

        int y        = -1000;
        int ypoint   = 100;
        int yaxisstr = 70;

        for (int i = 0; i < 5; i++)
        {
            g.DrawLine(AxisPoint, 1350, ypoint, 1380, ypoint);
            string yasix = y.ToString();
            g.DrawString(yasix, Axisfont, brush, 1390, yaxisstr);
            yaxisstr += 200;
            ypoint   += 200;
            y        += 200;
        }
        y        = 200;
        ypoint   = 1300;
        yaxisstr = 1270;

        for (int i = 0; i < 5; i++)
        {
            g.DrawLine(AxisPoint, 1350, ypoint, 1380, ypoint);
            string yasix = y.ToString();
            g.DrawString(yasix, Axisfont, brush, 1390, yaxisstr);
            yaxisstr += 200;
            ypoint   += 200;
            y        += 200;
        }

        g.FillRectangle(glassbrush, 100, 2350, 2500, 150);

        int jitaix    = 120;
        int jitaistrx = 260;

        for (int i = 0; i < 10; i++)
        {
            Brush jitai = new SolidBrush(colors[i]);
            g.FillRectangle(jitai, jitaix, 2360, 80, 50);
            string str = (i + 1).ToString() + "#";
            g.DrawString(str, Biaoshifont, brush, jitaistrx, 2360);
            jitaix    += 240;
            jitaistrx += 240;
        }

        jitaix    = 120;
        jitaistrx = 260;
        for (int i = 0; i < 10; i++)
        {
            Brush jitai = new SolidBrush(colors[i + 6]);
            g.FillRectangle(jitai, jitaix, 2440, 80, 50);
            string str = (i + 11).ToString() + "#";
            g.DrawString(str, Biaoshifont, brush, jitaistrx, 2440);
            jitaix    += 240;
            jitaistrx += 240;
        }

        //x = 200;
        //y = 200;
        //x=-x+1200-10;
        //y=y+1250-10;
        //g.FillEllipse(brush, x, y, 20, 20);

        string          ConnectionString = ConfigurationManager.ConnectionStrings["mdbcon"].ConnectionString;
        OleDbConnection conn             = new OleDbConnection(ConnectionString);
        OleDbCommand    cmd = new OleDbCommand(sql, conn);

        conn.Open();
        OleDbDataReader rd = cmd.ExecuteReader();

        while (rd.Read())
        {
            int   lindex   = int.Parse(rd["lindex"].ToString()) - 1;
            int   penwidth = int.Parse(rd["size"].ToString());
            Pen   dp       = new Pen(colors[lindex], penwidth);
            Brush db       = new SolidBrush(colors[lindex]);
            if (rd["muraname"].ToString() != "")
            {
                if (rd["shape"].ToString() == "Point")
                {
                    float spx = 0, spy = 0;
                    float.TryParse(rd["spx"].ToString(), out spx);
                    float.TryParse(rd["spy"].ToString(), out spy);
                    spx = -spx + 1350 - (penwidth / 2);
                    spy = spy + 1100 - (penwidth / 2);
                    g.FillEllipse(db, spx, spy, penwidth, penwidth);
                }
                if (rd["shape"].ToString() == "Line")
                {
                    float spx = 0, spy = 0, epx = 0, epy = 0;
                    float.TryParse(rd["spx"].ToString(), out spx);
                    float.TryParse(rd["spy"].ToString(), out spy);
                    float.TryParse(rd["epx"].ToString(), out epx);
                    float.TryParse(rd["epy"].ToString(), out epy);
                    spx = -spx + 1350;
                    spy = spy + 1100;
                    epx = -epx + 1350;
                    epy = epy + 1100;
                    if (rd["sizename"].ToString() == "Small")
                    {
                        dp.Width = 10;
                    }
                    if (rd["sizename"].ToString() == "Medium")
                    {
                        dp.Width = 20;
                    }
                    if (rd["sizename"].ToString() == "Large")
                    {
                        dp.Width = 40;
                    }
                    g.DrawLine(dp, spx, spy, epx, epy);
                }
            }
        }


        MemoryStream stream = new MemoryStream();   //保存绘制的图片

        img.Save(stream, ImageFormat.Jpeg);         //保存绘制的图片
        return(stream);
    }
Esempio n. 23
0
        /// <summary>
        /// Metodo que dibuja el Automatum AFD en forma gráfica. 
        /// Se recorren las tablas que guardan los estados y las lineas y se van dibujando segun 
        /// la información guardada en esos objetos. 
        /// Para dibujar los estados se utiliza el metodo drawEllipse y se escribe su identificador.
        /// Para dibujar las lineas se utiliza el metodo drawCurve, utilizando los puntos 
        /// medios de los estados origen y destino dependiendo de su posición y dirección; las curvas son 
        /// dibujadas de tal manera que a la punta "final" se le dibuje una punta de flecha, esto es realizado
        /// con la clase AdjustableArrowCap.
        /// Tambien se revisan atributos de los estados creados, como si son estados finales o iniciales.
        /// Minimización:
        /// <para>
        /// En los algoritmos de minimización, se van guardando las etapas de la minimización en arreglos que 
        /// contienen las Hashtable estados, lineas y automata, por lo que en este metodo se revisa si
        /// existen las etapas de minimización y en que étapa se encuentra, para dibujar la etapa elegida por
        /// el usuario.
        /// </para>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void afdDraw_Paint(object sender, PaintEventArgs e)
        {
            if (minimizaclicked)
            {
                States.Enabled = Lineas.Enabled = delete.Enabled = clear.Enabled = Animate.Enabled = false;
                if (etapasCounterTD == 0)
                {
                    topleft.Enabled = left.Enabled = false;
                    topright.Enabled = right.Enabled = true;
                    cerrar.Enabled = true;
                }
                else
                {
                    if (etapasCounterTD == (etapasMinimizacionTD.Count - 1))
                    {
                        topleft.Enabled = left.Enabled = true;
                        topright.Enabled = right.Enabled = false;
                        cerrar.Enabled = true;
                    }
                    else
                    {
                        topleft.Enabled = left.Enabled = topright.Enabled = right.Enabled = true;
                        cerrar.Enabled = false;
                    }
                }

                Hashtable paraActualizar = (Hashtable)etapasMinimizacionTD[etapasCounterTD];
                estados = (Hashtable)paraActualizar["estados"];
                lineas = (Hashtable)paraActualizar["lineas"];
                automata = (Hashtable)paraActualizar["automata"];

                if (automata.Count == 0)
                    Animate.Enabled = false;
                else
                    Animate.Enabled = true;

                explicacion.Text = (String)etapasMinimizacionExplicacionTD[etapasCounterTD];

            }
            Pen pencil = new Pen(Color.Black, 2);
            AdjustableArrowCap aac = new AdjustableArrowCap(5, 5, true);
            pencil.CustomEndCap = aac;
            Font font = new Font("Arial", 10);
            SolidBrush brush = new SolidBrush(Color.Black);
            foreach (DictionaryEntry de in estados)
            {
                State s = (State)de.Value;
                pencil.Color = s.color;
                brush.Color = s.color;
                if (s.isActualState)
                    pencil.Color = Color.Blue;
                if (s.isFinal)
                {
                    pencil.Width = 3;
                    g.DrawEllipse(pencil, s.x -4, s.y - 4, 38, 38);
                    pencil.Width = 2;
                    g.DrawEllipse(pencil, s.x, s.y, 30, 30);
                }
                else
                    g.DrawEllipse(pencil, s.x, s.y, 30, 30);
                g.DrawString(s.label, font, brush, (s.x + 5), (s.y + 8));
                if (s.isInitial)
                {
                    Point[] p = new Point[3];
                    p[2].X = s.x;
                    p[2].Y = s.y + 15;
                    p[1].X = s.x - 15;
                    p[1].Y = s.y;
                    p[0].X = s.x - 30;
                    p[0].Y = s.y - 5;
                    g.DrawCurve(pencil, p);
                }
            }
            foreach (DictionaryEntry de in lineas)
            {
                Line l = (Line)de.Value;
                Point[] p = new Point[3];
                pencil.Color = l.color;
                brush.Color = l.color;
                int dxSource = l.intermediatePointX - l.source.x;
                int dxDest = l.intermediatePointX - l.dest.x;
                int dySource = l.intermediatePointY - l.source.y;
                int dyDest = l.intermediatePointY - l.dest.y;
                p[1] = new Point(l.intermediatePointX, l.intermediatePointY);
                if (Math.Abs(dxSource) < Math.Abs(dySource))
                    if (dySource > 0)
                        p[0] = new Point((l.source.x + 15), (l.source.y + 30));
                    else
                        p[0] = new Point((l.source.x + 15), l.source.y);
                else
                    if (dxSource > 0)
                    p[0] = new Point((l.source.x + 30), (l.source.y + 15));
                else
                    p[0] = new Point(l.source.x, l.source.y + 15);

                if (Math.Abs(dxDest) < Math.Abs(dyDest))
                    if (dyDest > 0)
                        p[2] = new Point((l.dest.x + 15), (l.dest.y + 30));
                    else
                        p[2] = new Point((l.dest.x + 15), l.dest.y);
                else
                    if (dxDest > 0)
                    p[2] = new Point((l.dest.x + 30), (l.dest.y + 15));
                else
                    p[2] = new Point(l.dest.x, (l.dest.y + 15));

                if (l.source.label == l.dest.label)
                {
                    if (l.intermediatePointX < l.source.x)
                        if (l.intermediatePointY < l.source.y)
                        {
                            p[0] = new Point(l.source.x, l.source.y + 15);
                            p[2] = new Point(l.dest.x + 15, l.dest.y);
                        }
                        else
                        {
                            p[0] = new Point(l.source.x, l.source.y + 15);
                            p[2] = new Point(l.dest.x + 15, l.dest.y + 30);
                        }
                    if (l.intermediatePointX > l.source.x)
                        if (l.intermediatePointY < l.source.y)
                        {
                            p[0] = new Point(l.source.x + 30, l.source.y + 15);
                            p[2] = new Point(l.dest.x + 15, l.dest.y);
                        }
                        else
                        {
                            p[0] = new Point(l.source.x + 30, l.source.y + 15);
                            p[2] = new Point(l.dest.x + 15, l.dest.y + 30);
                        }
                }

                if (l.isActualLine)
                    pencil.Color = Color.Blue;
                g.DrawCurve(pencil, p);
                Font f = new Font("Arial", 10, FontStyle.Bold);
                g.DrawString(l.label, f, brush, p[1].X - 15, p[1].Y - 15);
            }
        }
Esempio n. 24
0
        private void LineCapToLineCap2(LineCap2 cap2, out LineCap capResult, out CustomLineCap customCapResult)
        {
            switch (cap2)
            {
                case LineCap2.Flat:
                    capResult = LineCap.Flat;
                    customCapResult = null;
                    break;

                case LineCap2.Arrow:
                    capResult = LineCap.ArrowAnchor;
                    customCapResult = new AdjustableArrowCap(5.0f * this.capScale, 5.0f * this.capScale, false);
                    break;

                case LineCap2.ArrowFilled:
                    capResult = LineCap.ArrowAnchor;
                    customCapResult = new AdjustableArrowCap(5.0f * this.capScale, 5.0f * this.capScale, true);
                    break;

                case LineCap2.Rounded:
                    capResult = LineCap.Round;
                    customCapResult = null;
                    break;

                default:
                    throw new InvalidEnumArgumentException();
            }
        }
Esempio n. 25
0
        private static void DrawTree(Graphics g, DocLine docSub, double factor, Point ptLast, DiagramFormat format)
        {
            Point ptNext = Point.Empty;
            if (docSub.DiagramLine != null)
            {
                float penwidth = 0.0f;
                if(format == DiagramFormat.ExpressG)
                {
                    penwidth = 3.0f;
                }
                else if (format == DiagramFormat.UML)
                {
                    // draw arrow at supertype
                    if (ptLast == Point.Empty && docSub.DiagramLine.Count >= 2)
                    {
                        using (Pen penAttr = new Pen(Color.Black))
                        {
                            AdjustableArrowCap cap = new AdjustableArrowCap(6.0f, 6.0f, true);

                            penAttr.StartCap = LineCap.Custom;
                            penAttr.CustomStartCap = cap;
                            g.DrawLine(penAttr,
                                (float)(docSub.DiagramLine[0].X * factor),
                                (float)(docSub.DiagramLine[0].Y * factor),
                                (float)(docSub.DiagramLine[1].X * factor),
                                (float)(docSub.DiagramLine[1].Y * factor));

                        }
                    }
                }

                using (Pen pen = new Pen(Color.Black, penwidth))
                {
                    for (int i = 0; i < docSub.DiagramLine.Count - 1; i++)
                    {
                        Point ptA = new Point((int)(docSub.DiagramLine[i].X * factor), (int)(docSub.DiagramLine[i].Y * factor));
                        Point ptB = new Point((int)(docSub.DiagramLine[i].X * factor), (int)(docSub.DiagramLine[i + 1].Y * factor));
                        Point ptC = new Point((int)(docSub.DiagramLine[i + 1].X * factor), (int)(docSub.DiagramLine[i + 1].Y * factor));

                        if (i == 0 && ptLast != Point.Empty)
                        {
                            g.DrawLine(pen, ptLast, ptA);
                        }
                        ptNext = ptC;

                        g.DrawLine(pen, ptA, ptB);
                        g.DrawLine(pen, ptB, ptC);
                    }
                }
            }

            foreach (DocLine docInner in docSub.Tree)
            {
                DrawTree(g, docInner, factor, ptNext, format);
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Draws the player's actions' ways to their target on the graphics depending on the current line Settings.
        /// </summary>
        /// <param name="graphics">The directionlinePanel's graphics</param>
        /// <param name="action"></param>
        /// <param name="player">The player who executes the actions</param>
        private void DrawActionWays(Graphics graphics, Player player)
        {
            Pathfinding pathfinding = new Pathfinding();
            AdjustableArrowCap arrow = new AdjustableArrowCap(3, 3);
            Pen myPen = new Pen(Color.Blue, 1);

            PlayerAction[] playerActions = player.PlayerActions.ToArray();
            Point lastAimPoint = pathfinding.GetExactLocation(player.Location);
            bool drawOneCell = informationPanel.LineSetting == DirectionLineSetting.OneCell;

            for (int i = 0; i < playerActions.Length; i++)
            {
                PlayerAction action = playerActions[i];

                myPen.Color = (action.Type == ActionType.Shoot || action.Type == ActionType.Pass) ? Color.Black : (currentGame.FirstTeam.Players.Contains(player)) ? currentGame.FirstTeam.TeamColor : (currentGame.SecondTeam.Players.Contains(player)) ? currentGame.SecondTeam.TeamColor : Color.DarkBlue;

                //set the correct dash pattern for each action type
                if (action.Type == ActionType.Pass || action.Type == ActionType.Shoot)
                {
                    myPen.DashPattern = new float[] { 5f, 7f, 5f, 2f };
                }
                else
                {
                    myPen.DashPattern = new float[] { 1f };
                }

                Point nextPoint = pathfinding.GetExactLocation(action.TargetPoint);

                if (informationPanel.LineSetting != DirectionLineSetting.DirectWay && action.Type == ActionType.Run || action.Type == ActionType.Tackle)
                {
                    lock (action.WayToTarget)
                    {
                        List<Point> waypoints = action.WayToTarget.ToList();
                        foreach (Point waypoint in waypoints)
                        {
                            nextPoint = pathfinding.GetExactLocation(waypoint);

                            if (waypoint.Equals(action.WayToTarget.ElementAt(action.WayToTarget.Count - 1)) || drawOneCell)
                            {
                                myPen.CustomEndCap = arrow;
                            }
                            else
                            {
                                myPen.EndCap = LineCap.NoAnchor;
                            }

                            graphics.DrawLine(myPen, lastAimPoint, nextPoint);
                            lastAimPoint = nextPoint;

                            if (drawOneCell)
                            {
                                lastAimPoint = pathfinding.GetExactLocation(action.TargetPoint);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    myPen.CustomEndCap = arrow;
                    graphics.DrawLine(myPen, lastAimPoint, nextPoint);
                }

                if (action.Type != ActionType.Shoot && action.Type != ActionType.Pass)
                {
                    lastAimPoint = nextPoint;
                    if (drawOneCell)
                    {
                        break;
                    }
                }
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Draws an arrow line from the start location to the target point of every players' action.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void directionLinesPanel_Paint(object sender, PaintEventArgs e)
        {
            Graphics graphics = e.Graphics;
            graphics.CompositingQuality = CompositingQuality.HighQuality;
            graphics.SmoothingMode = SmoothingMode.AntiAlias;

            int cellWidth = fieldCell[0, 0].Size.Width;
            int cellHeight = fieldCell[0, 0].Size.Height;

            Pathfinding pathfinding = new Pathfinding();

            AdjustableArrowCap arrow = new AdjustableArrowCap(3, 3);
            Pen myPen = new Pen(Color.Blue, 1);
            myPen.CustomEndCap = arrow;

            Pen dp = new Pen(Brushes.Plum, 1.3f);
            dp.DashPattern = new float[] { 5f, 7f, 5f, 2f };
            dp.Color = Pathfinding.CurrentBlockedRoom.AllowedTeam.TeamColor;

            //draws the blocked room rectangle
            Rectangle drawRoom = new Rectangle(Pathfinding.CurrentBlockedRoom.Room.X * cellWidth, Pathfinding.CurrentBlockedRoom.Room.Y * cellHeight, Pathfinding.CurrentBlockedRoom.Room.Width * cellWidth, Pathfinding.CurrentBlockedRoom.Room.Height * cellHeight);
            graphics.DrawRectangle(dp, drawRoom);

            //draws the throw-room
            if (currentGame.CurrentAction.GameStatus == Status.ThrowIn && currentGame.GameBall.HasPlayerContact)
            {
                dp.DashPattern = new float[] { 20, 5 };
                dp.Color = Color.Black;
                Rectangle throwRoom = currentGame.CurrentAction.ThrowRoom;
                graphics.DrawRectangle(dp, throwRoom.X * cellWidth, throwRoom.Y * cellHeight, throwRoom.Width * cellWidth, throwRoom.Height * cellHeight);
            }

            if (informationPanel.LineSetting != DirectionLineSetting.NoCell)
            {
                //draw the player-directions
                List<Player> allPlayers = new List<Player>();
                allPlayers.AddRange(currentGame.FirstTeam.Players);
                allPlayers.AddRange(currentGame.SecondTeam.Players);
                foreach (Player player in allPlayers)
                {
                    if (player.PlayerActions.Count > 0 && !new Point(player.XCoordinate, player.YCoordinate).Equals(player.PlayerActions.Peek().TargetPoint))
                    {
                        DrawActionWays(graphics, player);
                    }
                }
            }

            //draw the ball direction if the setting "no-direction-lines" is not selected.
            if (informationPanel.LineSetting != DirectionLineSetting.NoCell && currentGame.GameBall.TargetPoint.HasValue && !currentGame.GameBall.HasPlayerContact)
            {
                myPen.Color = Color.Black;
                myPen.DashPattern = new float[] { 5f, 7f, 5f, 2f };
                Point from = currentGame.GameBall.ExactLocation;
                Point targetPoint = currentGame.GameBall.ExactTargetLocation;

                graphics.DrawLine(myPen, from, targetPoint);
            }
        }
        private Bitmap DrawArrowHeadsButton(ArrowHeads arrowHeads, Rectangle rect)
        {
            Bitmap img = new Bitmap(rect.Width, rect.Height);
            Graphics g = Graphics.FromImage(img);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            Pen pen = new Pen(Color.Black) { Width = 1 };

            AdjustableArrowCap aac = new AdjustableArrowCap(4, 5);
            if (arrowHeads == ArrowHeads.Start || arrowHeads == ArrowHeads.Both) pen.CustomStartCap = aac;
            if (arrowHeads == ArrowHeads.End || arrowHeads == ArrowHeads.Both) pen.CustomEndCap = aac;

            g.DrawLine(pen, 3, rect.Height / 2, rect.Width - 3, rect.Height / 2);
            return img;
        }
Esempio n. 29
0
        void FuncFormPaint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;             //创建画板,这里的画板是由Form提供的.就不应调用Disposal()
//			Graphics  g = this.CreateGraphics();
            Pen p = new Pen(Color.Black, 2);     //定义了一个蓝色,宽度为的画笔
//			int leftbottom=0;
            int    size   = 150;
            string xlable = "X";
            string ylable = "Y";

            int righttop = size;

            #region 画坐标系

            g.TranslateTransform(righttop, righttop);
            g.ScaleTransform(1, -1);            //y轴反向 或者下面这个
//		    g.Transform.Multiply(new Matrix(1, 0, 0, -1, 0, 0));

            Rectangle  rect = new Rectangle(-righttop, -righttop, 2 * righttop, 2 * righttop);
            SolidBrush b1   = new SolidBrush(Color.AliceBlue);          //定义单色画刷

            p.Brush       = b1;
            p.DashPattern = new  float[] { 2, 1 };
//			g.DrawRectangle(p, -righttop, -righttop, righttop, righttop);//在画板上画矩形,起始坐标为(10,10),宽为,高为
            g.FillRectangle(b1, rect);            //填充这个矩形
            p.DashStyle = DashStyle.Solid;        //恢复实线
            p.EndCap    = LineCap.ArrowAnchor;    //定义线尾的样式为箭头

            //画箭头,只对不封闭曲线有用
            System.Drawing.Drawing2D.AdjustableArrowCap _LineCap = new System.Drawing.Drawing2D.AdjustableArrowCap(9, 9, false);               //设置一个线头
            Pen _Pen = new Pen(Brushes.Black, 1);
            _Pen.CustomEndCap = (System.Drawing.Drawing2D.CustomLineCap)_LineCap;
            g.DrawLine(_Pen, -righttop + righttop / 10, 0, righttop - righttop / 10, 0);   //X轴 在画板上画直线,起始坐标为(10,10),终点坐标为(100,100)
            g.DrawLine(_Pen, 0, -righttop + righttop / 10, 0, righttop - righttop / 10);   //在画板上画直线,起始坐标为(10,10),终点坐标为(100,100)
            //写坐标名
            g.ScaleTransform(1, -1);
            g.DrawString(xlable, new Font("宋体", 12), _Pen.Brush, righttop - righttop / 10, 0);
            g.DrawString(ylable, new Font("宋体", 12), _Pen.Brush, -righttop / 10, -righttop + righttop / 20);
            g.DrawString("O", new Font("宋体", 12), _Pen.Brush, righttop / 20, -righttop / 10);

            #endregion


//			g.Dispose();
            p.Dispose();

//			g.DrawEllipse(p, 10, 10, 100, 100);//在画板上画椭圆,起始坐标为(10,10),外接矩形的宽为,高为



//			g.DrawLine(p, 10, 10, 100, 100);//在画板上画直线,起始坐标为(10,10),终点坐标为(100,100)
            //画虚线
//			p.DashStyle = DashStyle.Dot;//定义虚线的样式为点
//			g.DrawLine(p, 10, 10, 200, 10);
//
//			//自定义虚线
//			p.DashPattern = new  float[] { 2, 1 };//设置短划线和空白部分的数组
//			g.DrawLine(p, 10, 20, 200, 20);

            //单色填充
            //SolidBrush b1 = new SolidBrush(Color.Blue);//定义单色画刷
//			g.FillRectangle(b1, rect);//填充这个矩形
//
//			//字符串
//			g.DrawString("字符串", new Font("宋体", 10), b1, new PointF(90, 10));
//
//			//用图片填充
//			TextureBrush b2 = new TextureBrush(Image.FromFile(@"e:\picture\1.jpg"));
//			rect.Location = new Point(10, 70);//更改这个矩形的起点坐标
//			rect.Width = 200;//更改这个矩形的宽来
//			rect.Height = 200;//更改这个矩形的高
//			g.FillRectangle(b2, rect);
//
//			//用渐变色填充
//			rect.Location = new Point(10, 290);
//			LinearGradientBrush b3 = new  LinearGradientBrush(rect, Color.Yellow , Color.Black , LinearGradientMode.Horizontal);
//			g.FillRectangle(b3, rect);



//			Pen p = new Pen(Color.Blue,1);
//
//			//转变坐标轴角度
//			for (int i = 0; i < 90; i++)
//			{
//				g.RotateTransform(i);//每旋转一度就画一条线
//				g.DrawLine(p, 0, 0, 100, 0);
//				g.ResetTransform();//恢复坐标轴坐标
//			}
//
//			//平移坐标轴
//			g.TranslateTransform(100, 100);
//			g.DrawLine(p, 0, 0, 100, 0);
//			g.ResetTransform();
//
//			//先平移到指定坐标,然后进行度旋转
//			g.TranslateTransform(100,200);
//			for (int i = 0; i < 8; i++)
//			{
//				g.RotateTransform(45);
//				g.DrawLine(p, 0, 0, 100, 0);
//			}
//
//			g.Dispose();
//			public  void  DrawLineFloat(PaintEventArgs  e)
//			{
//				//  Create  pen.
//				Pen  blackPen  =  new  Pen(Color.Black,  3);
//				//  Create  coordinates  of  points  that  define  line.
//				float  x1  =  100.0F;
//				float  y1  =  100.0F;
//				float  x2  =  500.0F;
//				float  y2  =  100.0F;
//				//  Draw  line  to  screen.
//				e.Graphics.DrawLine(blackPen,  x1,  y1,  x2,  y2);
//			}
//			2、正方形
//				g.DrawRectangle(thepen, ps.X, ps.Y, 0.5F, 0.5F);
//			3、指定的图形
//				Bitmap  bm=new  Bitmap(2,2);    //这里调整点的大小
//			bm.SetPixel(0,  0,  color);      //设置点的颜色
//			bm.SetPixel(0,  1,  color);
//			bm.SetPixel(1,  0,  color);
//			bm.SetPixel(1,  1,  color);
//			Graphics  g  =  Graphics.FromHwnd(this.panel1.Handle);    //画在哪里
//			g.DrawImageUnscaled(bm,  e.X,  e.Y);      //具体坐标
//
//
//			关于最后一种方法,还有一个详细的例子,如下:
//				用Bitmap的SetPixel()函数来实现。其实现是通过设置像素点生成一张图片,然后显示图片。
//				//定义图片
//				Bitmap bmp;
//			private void Form1_Load(object sender, EventArgs e)
//			{
//				bmp = new Bitmap(this.ClientRectangle.Width,this.ClientRectangle.Height);
//
//				Graphics graphics = Graphics.FromImage(bmp);
//
//				int i,j;
//				int w= bmp.Width;
//				int h = bmp.Height;
//
//				int interval = 5;
//				//每隔5个像素点画设置一个黑颜色点,生成图片。
//				for (i = 0; i < w; i += interval)
//				{
//					for (j = 0; j < h; j += interval)
//					{
//						//使用SetPixel()来设置像素点。
//						bmp.SetPixel(i,j,Color.Black);
//					}
//				}
//			}
//
//			private void Form1_Paint(object sender, PaintEventArgs e)
//			{
//				Graphics graphics = e.Graphics;
//				//显示图片
//				graphics.DrawImage(bmp,new Rectangle(0,0,this.ClientRectangle.Width,this.ClientRectangle.Height));
//			}
            if (!Controls.Contains(mchart))
            {
                Controls.Add(mchart);
            }
            mchart.BackImageAlignment = ChartImageAlignmentStyle.Center;
            mchart.SetBounds(20, 30, 350, 350);
        }
Esempio n. 30
0
        private void DrawingShapes(List<MyShape> ListShapes)
        {
            try
            {
                if (ListShapes==null)
                {
                    return;
                }
                pictureEdit1.Refresh();
                Graphics graphics = pictureEdit1.CreateGraphics();
                graphics.SmoothingMode = SmoothingMode.AntiAlias;
                //画完整的图
                foreach (var v in ListShapes)
                {
                    if (v is MyLine)
                    {
                        graphics.DrawLine(v.MyPen,(v as MyLine).P1,(v as MyLine).P2);
                    }
                    else if (v is MyArrow)
                    {
                        //画箭头的笔
                        float arrowWidth = 6;
                        float arrowHeight = 6;
                        bool arrowFill = true;
                        AdjustableArrowCap myArrow = new AdjustableArrowCap(arrowWidth, arrowHeight, arrowFill);
                        CustomLineCap customArrow = myArrow;
                        arrowpen.EndCap = LineCap.Custom;
                        arrowpen.CustomEndCap = customArrow;
                        arrowpen.Color = v.MyPen.Color;
                        arrowpen.Width = v.MyPen.Width;

                        //画箭头
                        graphics.DrawLine(arrowpen, (v as MyArrow).P1, (v as MyArrow).P2);
                    }
                    else if (v is MyRect)
                    {
                        graphics.DrawRectangle(v.MyPen, (v as MyRect).P1.X, (v as MyRect).P1.Y, (v as MyRect).Width, (v as MyRect).Height);
                    }
                    else
                    {
                        graphics.DrawPolygon(v.MyPen, (v as MyPoly).ListPoint.ToArray());

                    }
                }
                //画最后一个不完整的多边形
                if ((currentMyPoly!=null)&& (currentMyPoly.ListPoint.Count > 1))
                {
                    graphics.DrawLines(mypen, currentMyPoly.ListPoint.ToArray());
                }

                graphics.Dispose();
            }
            catch (Exception ex)
            {

                XtraMessageBox.Show(ex.ToString());
            }
        }
Esempio n. 31
0
 private void initPens()
 {
     CustomLineCap arrowCap = new AdjustableArrowCap(5, 5, true);
     pen = Pens.largeSolidArrow(Color.HotPink);
     supportPen = Pens.largeDashedArrow(Color.HotPink);
 }
Esempio n. 32
0
        public static string CreateArrow(float angles, float strength, float length)
        {
            if (strength == 0)
                return string.Empty;

            var rootPath = HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["iconsPath"]);

            angles = (float)Math.Round(angles, 0); // reduce number of images
            while (angles > 360) angles -= 360;
            while (angles < 0) angles += 360;

            strength = (float)Math.Round(strength, 0);
            if (strength > MAX_STRENGTH)
                strength = MAX_STRENGTH;

            if (length > Math.Min(ICON_WIDTH, ICON_HEIGHT))
                length = Math.Min(ICON_WIDTH, ICON_HEIGHT);

            string fileId = ICON_WIDTH + "x" + ICON_HEIGHT + "_bft" + strength + "-" + length + "_" + ((int)angles).ToString("d3");
            string fileName = fileId + ".png";
            string fullFilePath = Path.Combine(rootPath, fileName);

            // do only generate the image if it does not exist.
            if (System.IO.File.Exists(fullFilePath))
                return fileName;

            using (Bitmap bmap = new Bitmap(ICON_WIDTH, ICON_HEIGHT))
            using (Graphics objGraphics = Graphics.FromImage(bmap))
            {
                // Then to translate, appending to world transform.
                int penWidth = (int)strength;
                var radius = length / 2;
                double rx = ICON_WIDTH / 2.0;
                double ry = ICON_HEIGHT / 2.0;

                double coeff = Math.PI * (angles / 180.0);
                double dx = rx + radius * Math.Cos(coeff);
                double dy = ry - radius * Math.Sin(coeff);
                double dx1 = rx - radius * Math.Cos(coeff);
                double dy1 = ry + radius * Math.Sin(coeff);

                // objGraphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), 1,1, width-2,height-2); // DEBUG
                objGraphics.SmoothingMode = SmoothingMode.HighQuality;

                // Draw rotated, translated arrow to screen.
                Pen pen = new Pen(Color.Black, penWidth);
                AdjustableArrowCap arrow = new AdjustableArrowCap(3, 3, true);
                pen.CustomStartCap = arrow;
                pen.EndCap = LineCap.Round;

                objGraphics.DrawLine(pen, (float)dx1, (float)dy1, (float)dx, (float)dy);

                try
                {
                    bmap.Save(fullFilePath, ImageFormat.Png);
                }
                catch (Exception ex)
                {
                    throw new Exception("There was a problem while saving the file '"
                        + fullFilePath + "'. Please check if the directory exists and the ASPNET user has enough privileges. "
                        + ex.Message, ex);
                }

                return fileName;
            }
        }
Esempio n. 33
0
 public Line()
 {
     m_guid     = System.Guid.NewGuid().ToString();
     m_arrowCap = new System.Drawing.Drawing2D.AdjustableArrowCap(5, 5);
 }
 private void imageProcessBox1_MouseMove(object sender, MouseEventArgs e)
 {
     this.m_ptCurrent = e.Location;
     if ((this.imgpb.SelectedRectangle.Contains(e.Location) && this.HaveSelectedToolButton()) && this.imgpb.IsDrawed)
     {
         this.Cursor = Cursors.Cross;
     }
     else if (!this.imgpb.SelectedRectangle.Contains(e.Location))
     {
         this.Cursor = Cursors.Default;
     }
     if (this.imgpb.IsStartDraw && this.panel1.Visible)
     {
         this.SetToolBarLocation();
     }
     if (this.m_isStartDraw && (this.m_bmpLayerShow != null))
     {
         using (Graphics g = Graphics.FromImage(this.m_bmpLayerShow))
         {
             int tempWidth = 1;
             if (this.toolButton2.IsSelected)
             {
                 tempWidth = 3;
             }
             if (this.toolButton3.IsSelected)
             {
                 tempWidth = 5;
             }
             Pen p = new Pen(this.colorBox1.SelectedColor, (float) tempWidth);
             g.SmoothingMode = SmoothingMode.HighQuality;
             if (this.tBtn_Rect.IsSelected)
             {
                 int tempX = ((e.X - this.m_ptOriginal.X) > 0) ? this.m_ptOriginal.X : e.X;
                 int tempY = ((e.Y - this.m_ptOriginal.Y) > 0) ? this.m_ptOriginal.Y : e.Y;
                 g.Clear(Color.Transparent);
                 g.DrawRectangle(p, tempX - this.imgpb.SelectedRectangle.Left, tempY - this.imgpb.SelectedRectangle.Top, Math.Abs((int) (e.X - this.m_ptOriginal.X)), Math.Abs((int) (e.Y - this.m_ptOriginal.Y)));
                 this.imgpb.Invalidate();
             }
             if (this.tBtn_Ellipse.IsSelected)
             {
                 g.DrawLine(Pens.Red, 0, 0, 200, 200);
                 g.Clear(Color.Transparent);
                 g.DrawEllipse(p, (int) (this.m_ptOriginal.X - this.imgpb.SelectedRectangle.Left), (int) (this.m_ptOriginal.Y - this.imgpb.SelectedRectangle.Top), (int) (e.X - this.m_ptOriginal.X), (int) (e.Y - this.m_ptOriginal.Y));
                 this.imgpb.Invalidate();
             }
             if (this.tBtn_Arrow.IsSelected)
             {
                 g.Clear(Color.Transparent);
                 AdjustableArrowCap lineArrow = new AdjustableArrowCap(4f, 4f, true);
                 p.CustomEndCap = lineArrow;
                 g.DrawLine(p, (System.Drawing.Point) (((System.Drawing.Size) this.m_ptOriginal) - ((System.Drawing.Size) this.imgpb.SelectedRectangle.Location)), (System.Drawing.Point) (((System.Drawing.Size) this.m_ptCurrent) - ((System.Drawing.Size) this.imgpb.SelectedRectangle.Location)));
                 this.imgpb.Invalidate();
             }
             if (this.tBtn_Brush.IsSelected)
             {
                 System.Drawing.Point ptTemp = (System.Drawing.Point) (((System.Drawing.Size) this.m_ptOriginal) - ((System.Drawing.Size) this.imgpb.SelectedRectangle.Location));
                 p.LineJoin = LineJoin.Round;
                 g.DrawLine(p, ptTemp, (System.Drawing.Point) (((System.Drawing.Size) e.Location) - ((System.Drawing.Size) this.imgpb.SelectedRectangle.Location)));
                 this.m_ptOriginal = e.Location;
                 this.imgpb.Invalidate();
             }
             p.Dispose();
         }
     }
 }
 public void Paint(Graphics g)
 {
     createLine();
     Pen pen = new Pen(Color.Red, 1);
     using( pen )
     {
         System.Drawing.Drawing2D.AdjustableArrowCap bigArrow = new System.Drawing.Drawing2D.AdjustableArrowCap(5, 5);
         pen.CustomEndCap = bigArrow;
         g.DrawLine(pen, origin, destination);
     }
 }
Esempio n. 36
0
        public static void Init()
        {
            AdjustableArrowCap  cap = new AdjustableArrowCap(5, 7, true);
            AdjustableArrowCap capUnfilled = new AdjustableArrowCap(8, 7, false);
            AdjustableArrowCap wideCap = new AdjustableArrowCap(15, 7, true);

            singleArrow.EndCap = LineCap.Custom;

            doubleArrow.CustomStartCap = cap;
            doubleArrow.CustomEndCap = cap;

            dashedArrow.CustomEndCap = cap;
        }
Esempio n. 37
0
        private void DrawBattlePaths(Graphics g, Battle battle)
        {
            using (Pen attackerLine = new Pen(Color.Black, 3))
            using (Pen defenderLine = new Pen(Color.Black, 3))
            using (AdjustableArrowCap victorCap = new AdjustableArrowCap(4, 6))
            using (AdjustableArrowCap loserCap = new AdjustableArrowCap(5, 6))
            {
                attackerLine.DashStyle = DashStyle.Dot;
                defenderLine.DashStyle = DashStyle.Dot;

                loserCap.Filled = false;

                Site attackerSite = GetClosestSite(battle.Attacker, battle.Coordinates);
                Site defenderSite = GetClosestSite(battle.Defender, battle.Coordinates);

                attackerLine.Color = battle.Attacker.LineColor;
                defenderLine.Color = battle.Defender.LineColor;
                if (battle.Victor == battle.Attacker)
                {
                    attackerLine.CustomEndCap = victorCap;
                    defenderLine.CustomEndCap = loserCap;
                }
                else if (battle.Victor == battle.Defender)
                {
                    attackerLine.CustomEndCap = loserCap;
                    defenderLine.CustomEndCap = victorCap;
                }

                g.DrawLine(attackerLine, SiteToScreen(attackerSite.Coordinates), SiteToScreen(battle.Coordinates));
                if (defenderSite != null && defenderSite.Coordinates != battle.Coordinates)
                    g.DrawLine(defenderLine, SiteToScreen(defenderSite.Coordinates), SiteToScreen(battle.Coordinates));
            }
        }
Esempio n. 38
0
 private void Pizarra_MouseMove(object sender, MouseEventArgs e)
 {
     switch (var_control)
     {
         case 2: //Creando nuevo nodo
             if (nuevoNodo != null)
             {
                 int posX = e.Location.X;
                 int posY = e.Location.Y;
                 if (posX < nuevoNodo.Dimensiones.Width / 2)
                     posX = nuevoNodo.Dimensiones.Width / 2;
                 else if (posX > Pizarra.Size.Width - nuevoNodo.Dimensiones.Width / 2)
                     posX = Pizarra.Size.Width - nuevoNodo.Dimensiones.Width / 2;
                 if (posY < nuevoNodo.Dimensiones.Height / 2)
                     posY = nuevoNodo.Dimensiones.Height / 2;
                 else if (posY > Pizarra.Size.Height - nuevoNodo.Dimensiones.Width / 2)
                     posY = Pizarra.Size.Height - nuevoNodo.Dimensiones.Width / 2;
                 nuevoNodo.Posicion = new Point(posX, posY);
                 Pizarra.Refresh();
                 nuevoNodo.DibujarVertice(Pizarra.CreateGraphics());
             }
             break;
         case 1: // Dibujar arco
             AdjustableArrowCap bigArrow = new AdjustableArrowCap(4, 4, true);
             bigArrow.BaseCap = System.Drawing.Drawing2D.LineCap.Triangle;
             Pizarra.Refresh();
             if (NoDigrafo)
             {
                 Pizarra.CreateGraphics().DrawLine(new Pen(Brushes.Black, 2), NodoOrigen.Posicion, e.Location);
             }
             else
             {
                 Pizarra.CreateGraphics().DrawLine(new Pen(Brushes.Black, 2)
                 {
                     CustomEndCap = bigArrow
                 },
                     NodoOrigen.Posicion, e.Location);
             }
             break;
     }
 }
Esempio n. 39
0
    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler                                                              //
    ///////////////////////////////////////////////////////////////////////////////
    #region EVENTS

    ///////////////////////////////////////////////////////////////////////////////
    // Eventhandler for UI, Menu, Buttons, Toolbars etc.                         //
    ///////////////////////////////////////////////////////////////////////////////
    #region WINDOWSEVENTHANDLER

    /// <summary>
    /// The <see cref="Control.Paint"/> event handler for
    /// the <see cref="Panel"/> panelHue.
    /// Redraws the hue panel.
    /// </summary>
    /// <param name="sender">Event sender</param>
    /// <param name="e">Paint arguments</param>
    private void panelHue_Paint(object sender, PaintEventArgs e)
    {
      Graphics g = e.Graphics;

      //// fill in the background 
      //SolidBrush brBack = new SolidBrush(this.BackColor);
      //g.FillRectangle(brBack, this.ClientRectangle);

      // Paint the checkerboard style background 
      Rectangle hueRect = new Rectangle(0, HUE_SELECT_ARROW_HEIGHT + 1,
           panelHue.Width, panelHue.Height - 2 * HUE_SELECT_ARROW_HEIGHT - 2);

      using (HatchBrush hb = new HatchBrush(HatchStyle.LargeCheckerBoard, Color.White, Color.LightGray))
        e.Graphics.FillRectangle(hb, hueRect);

      // draw the hue bar
      int kk = 0;
      int NumShades = panelHue.Width;
      float Hue = 0.0f;
      float HueMinimumDiff = float.MaxValue;
      float HueAtMinimum = 0.0f;
      for (kk = 0; kk < NumShades; kk++)
      {
        // draw the hue shade
        Color clrShade = HSLToRGB(Hue, m_Saturation, m_Luminance, m_Transparency);
        Pen penColor = new Pen(clrShade, 1.0f);
        g.DrawLine(penColor,
           kk,
           HUE_SELECT_ARROW_HEIGHT + 1,
           kk,
           panelHue.Height - 2 * HUE_SELECT_ARROW_HEIGHT + 1);

        // are we closest to the selected value?
        float Diff = Math.Abs(m_Hue - Hue);
        if (Diff < HueMinimumDiff)
        {
          HueMinimumDiff = Diff;
          HueAtMinimum = Hue;
        }

        // go to the next Hue
        Hue += m_HuePixelStep;
      }

      // determine the X-offset of the currently selected hue
      int XOffset = 0;
      if (m_HuePixelStep > 0.0f)
      {
        XOffset = (int)(m_Hue / m_HuePixelStep);
      }

      // draw the arrows for the currently selected color
      AdjustableArrowCap myArrow = new AdjustableArrowCap(HUE_SELECT_ARROW_HEIGHT * 2 - 1,
         HUE_SELECT_ARROW_HEIGHT, true);

      Pen capPen = new Pen(Color.Black);
      capPen.CustomEndCap = myArrow;
      g.DrawLine(capPen,
         XOffset,
         0,
         XOffset,
         0 + HUE_SELECT_ARROW_HEIGHT + 1);

      g.DrawLine(capPen,
         XOffset,
         panelHue.Bottom,
         XOffset,
         panelHue.Bottom - (2 * HUE_SELECT_ARROW_HEIGHT + 2));
    }
Esempio n. 40
0
        private void Render(IGraphics ig)
        {
            string s = cbWhat.Text;

            if (s == "Clipping")
            {
                Pen pn = new Pen(Color.LightGray, 5);
                Pen pn2 = new Pen(Color.Yellow);

                ig.Clear(Color.Black);

                GraphicsContainer cnt = ig.BeginContainer();

                ig.SmoothingMode = SmoothingMode.HighQuality;

                ig.SetClip(new Rectangle(35,35,120,120));

                ig.DrawRectangle(pn, 5,5,45,70);
                ig.DrawRectangle(pn, 15,25,90,120);
                ig.DrawRectangle(pn, 50,30,100,170);
                ig.DrawRectangle(pn, 5,80,180,30);
                ig.DrawRectangle(pn, 75,10,40,160);

                ig.EndContainer(cnt);

                ig.DrawRectangle(pn2, 5,5,45,70);
                ig.DrawRectangle(pn2, 15,25,90,120);
                ig.DrawRectangle(pn2, 50,30,100,170);
                ig.DrawRectangle(pn2, 5,80,180,30);
                ig.DrawRectangle(pn2, 75,10,40,160);
            }
            else if (s == "Transforms")
            {

                ig.Clear(Color.Black);

                ig.RotateTransform(15);
                ig.DrawRectangle(new Pen(Color.Red,2), 260,80,50,40);
                ig.ResetTransform();
                ig.DrawRectangle(new Pen(Color.Red,2), 260,80,50,40);

                ig.TranslateTransform(15,-5);

                GraphicsContainer cnt = ig.BeginContainer();

                    ig.SmoothingMode = SmoothingMode.HighQuality;

                    ig.RotateTransform(5);
                    ig.FillEllipse(new SolidBrush(Color.Orange), 100,100,80,40);
                    ig.DrawRectangle(new Pen(Color.Orange,2), 60,80,40,40);

                    GraphicsContainer cnt2  = ig.BeginContainer();

                        ig.SmoothingMode = SmoothingMode.None;

                        ig.RotateTransform(5);
                        ig.ScaleTransform(1.1f, 1.2f);

                        ig.FillEllipse(new SolidBrush(Color.YellowGreen), 130,180,80,40);
                        ig.DrawRectangle(new Pen(Color.YellowGreen,2), 62,80,40,40);

                        GraphicsContainer cnt3  = ig.BeginContainer();

                            ig.SmoothingMode = SmoothingMode.HighQuality;

                            Matrix mm = new Matrix();
                            mm.Shear(0.3f, 0f);
                            ig.Transform = mm;

                            ig.FillEllipse(new SolidBrush(Color.Green), 180,120,80,40);
                            ig.DrawRectangle(new Pen(Color.Green,2), 62,84,40,40);

                        ig.EndContainer(cnt3);

                    ig.EndContainer(cnt2);

                    ig.FillEllipse(new SolidBrush(Color.Blue), 120,150,80,40);
                    ig.DrawRectangle(new Pen(Color.Blue,2), 64,80,40,40);

                ig.EndContainer(cnt);

                ig.FillEllipse(new SolidBrush(Color.Indigo), 80,210,80,40);
                ig.DrawRectangle(new Pen(Color.Indigo,2), 66,80,40,40);

                ig.DrawRectangle(new Pen(Color.White,2), 270,30,50,40);
                ig.ResetTransform();
                ig.DrawRectangle(new Pen(Color.White,2), 270,30,50,40);

            }
            else if (s == "Lines")
            {
                ig.SmoothingMode = SmoothingMode.AntiAlias;

                Pen ow = new Pen(Color.Purple, 12);
                ow.EndCap = LineCap.Round;
                ow.StartCap = LineCap.Round;
                ow.MiterLimit = 6f;
                ow.LineJoin = LineJoin.Miter;

                ig.SmoothingMode = SmoothingMode.None;

                Pen tp = new Pen(Color.Red, 2);
                tp.DashStyle = DashStyle.DashDot;

                ig.DrawLine(tp, 70,20,190,20);

                tp.DashStyle = DashStyle.Dash;

                ig.DrawLine(tp, 70,30,190,30);

                tp.DashStyle = DashStyle.Custom;
                tp.DashPattern = new float[] {1,8,2,2};

                ig.DrawLine(tp, 70,40,190,40);

                ig.SmoothingMode = SmoothingMode.AntiAlias;

                PointF[] pts = new PointF[4];
                pts[0] = new PointF(20,50);
                pts[1] = new PointF(30,90);
                pts[2] = new PointF(65,60);
                pts[3] = new PointF(50,40);
                ig.DrawLines(ow, pts);

                Point[] polly = new Point[]
                {
                new Point(200, 40),
                new Point(220, 140),
                new Point(240, 100),
                new Point(290, 70),
                new Point(230, 10)
                };

                ig.DrawPolygon(tp, polly);

                //arrows
                Pen arr = new Pen(Color.DarkGoldenrod, 5);
                AdjustableArrowCap aac = new AdjustableArrowCap(5,3, false);
                arr.EndCap = LineCap.Custom;
                arr.CustomEndCap = aac;
                arr.StartCap = LineCap.ArrowAnchor;
                ig.DrawLine(arr, 50,120, 150,200);

                arr.Width = 7f;
                arr.EndCap = LineCap.RoundAnchor;
                arr.StartCap = LineCap.SquareAnchor;
                ig.DrawLine(arr, 100,120, 200,200);

                arr.Width = 9;
                arr.EndCap = LineCap.DiamondAnchor;
                arr.StartCap = LineCap.ArrowAnchor;
                ig.DrawLine(arr, 150,120, 250,200);

                Point[] al = new Point[]
                {
                    new Point(200, 100),
                    new Point(300, 200),
                    new Point(300, 150)
                };

                arr.EndCap = LineCap.DiamondAnchor;
                arr.StartCap = LineCap.DiamondAnchor;
                ig.DrawLines(arr, al);

            }
            else if (s == "Curves")
            {

                PointF[] bezzie = new PointF[]
            {
                new PointF(20, 150),

                new PointF(110, 190),
                new PointF(120, 200),
                new PointF(50, 220),

                new PointF(60, 200),
                new PointF(140, 180),
                new PointF(100, 160),

                new PointF(180, 260),
                new PointF(200, 210),
                new PointF(190, 210)
            };

                Pen bpn = new Pen(Color.MediumSeaGreen, 2);
                bpn.DashStyle = DashStyle.Custom;
                bpn.DashPattern = new float[]{6,1,5,2,4,3,3,4,2,5,6,1};
                ig.DrawBeziers(bpn, bezzie);

                PointF[] curvy = new PointF[]
            {
                new PointF(130, 40),
                new PointF(70, 70),
                new PointF(50, 20),
                new PointF(120, 120),
                new PointF(150, 80),
                new PointF(80, 150),
                new PointF(80, 110)
            };

                ig.DrawCurve(new Pen(Color.Blue, 5), curvy);
                ig.DrawCurve(new Pen(Color.Red, 2), curvy, 2, 3);
                ig.DrawCurve(new Pen(Color.Yellow, 1), curvy, 1f);

                Point[] ccurvy = new Point[]
            {
                new Point(280, 30),
                new Point(260, 60),
                new Point(200, 20),
                new Point(290, 120),
                new Point(290, 80),
                new Point(230, 150),
                new Point(150, 50)
            };
                ig.DrawClosedCurve(new Pen(Color.Green, 3), ccurvy, 1f, FillMode.Alternate);
                ig.DrawClosedCurve(new Pen(Color.Purple, 1), ccurvy, 0f, FillMode.Alternate);

                Point[] fcc = new Point[]
            {
                new Point(160, 350),
                new Point(190, 370),
                new Point(130, 390),
                new Point(190, 400),
                new Point(195, 410),
                new Point(100, 430),
                new Point(160, 450)
            };
                ig.FillClosedCurve(new SolidBrush(Color.Red), fcc, FillMode.Winding, 1f);
                ig.FillClosedCurve(new SolidBrush(Color.Aquamarine), fcc, FillMode.Alternate, .2f);

            }
            else if (s == "Transparency")
            {
                Point[] fillpoly = new Point[]
                {
                    new Point(20, 130),
                    new Point(60, 90),
                    new Point(30, 20),
                    new Point(80, 20),
                    new Point(15, 90),
                    new Point(100, 50),
                    new Point(0, 50)
                };

                Color col = Color.FromArgb(96,255,0,0);

                ig.FillEllipse(new SolidBrush(Color.Ivory), 60, 140, 60, 30);
                ig.FillPolygon(new SolidBrush(Color.Ivory), fillpoly, FillMode.Winding);

                ig.TranslateTransform(10,10);
                ig.FillEllipse(new SolidBrush(col), 60, 140, 60, 30);
                ig.FillPolygon(new SolidBrush(col), fillpoly, FillMode.Alternate);
                ig.ResetTransform();

                ig.FillPie(new SolidBrush(Color.FromArgb(100,255,0,0)), 10, 200, 200, 80, 315, 90);
                ig.FillPie(new SolidBrush(Color.FromArgb(100,128,128,0)), 10, 200, 200, 80, 250, -90);
                ig.FillPie(new SolidBrush(Color.FromArgb(100,128,0,128)), 15, 205, 190, 70, 180, 270);
                ig.FillPie(new SolidBrush(Color.FromArgb(100,200,60,60)), 20, 210, 180, 60, 45, -270);

            }
            else if (s == "Fills")
            {

                LinearGradientBrush gbr1 = new LinearGradientBrush(new Point(0,0), new Point(30,20), Color.Blue, Color.Plum);

                ColorBlend blend = new ColorBlend(3);
                blend.Colors =  new Color[] {Color.Red, Color.Yellow, Color.MediumSlateBlue};
                blend.Positions = new float[] {0, .3f, 1f};
                gbr1.InterpolationColors = blend;

                Point[] sp = new Point[]
                {
                    new Point(145, 145),
                    new Point(305, 250),
                    new Point(220, 250),
                    new Point(180, 250)
                };
                ig.FillPolygon(gbr1, sp);

                LinearGradientBrush gbr2 = new LinearGradientBrush(new Point(0,0), new Point(10,20), Color.WhiteSmoke, Color.CornflowerBlue);
                gbr2.WrapMode = WrapMode.TileFlipXY;
                Point[] sp2 = new Point[]
                {
                    new Point(25, 205),
                    new Point(75, 150),
                    new Point(110, 110),
                    new Point(40, 80)
                };
                ig.FillPolygon(gbr2, sp2);

                ig.FillRectangle(new HatchBrush(HatchStyle.DiagonalBrick, Color.Khaki, Color.Peru), 000,5,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Vertical, Color.Bisque, Color.Peru), 020,5,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.DarkVertical, Color.Tan, Color.Peru), 040,5,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.DiagonalCross, Color.Chocolate, Color.Peru), 060,5,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.WideDownwardDiagonal, Color.BurlyWood, Color.Peru), 080,5,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.LargeConfetti, Color.Wheat, Color.Peru), 100,5,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.ZigZag, Color.SaddleBrown, Color.Peru), 120,5,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.HorizontalBrick, Color.Linen, Color.Peru), 140,5,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.LightHorizontal, Color.Maroon, Color.Peru), 160,5,20,20);

                ig.FillRectangle(new HatchBrush(HatchStyle.Percent05, Color.CornflowerBlue, Color.LemonChiffon), 000,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent10, Color.CornflowerBlue, Color.LemonChiffon), 020,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent20, Color.CornflowerBlue, Color.LemonChiffon), 040,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent25, Color.CornflowerBlue, Color.LemonChiffon), 060,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent30, Color.CornflowerBlue, Color.LemonChiffon), 080,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent40, Color.CornflowerBlue, Color.LemonChiffon), 100,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent50, Color.CornflowerBlue, Color.LemonChiffon), 120,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent60, Color.CornflowerBlue, Color.LemonChiffon), 140,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent70, Color.CornflowerBlue, Color.LemonChiffon), 160,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent75, Color.CornflowerBlue, Color.LemonChiffon), 180,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent80, Color.CornflowerBlue, Color.LemonChiffon), 200,30,20,20);
                ig.FillRectangle(new HatchBrush(HatchStyle.Percent90, Color.CornflowerBlue, Color.LemonChiffon), 220,30,20,20);

            }
            else if (s == "Arcs/Pies")
            {
                //GDI does not seem to draw arcs correctly except when the ellipse is a circle.
                //These arcs demonstrate the problem.  SVGGraphics calculates arcs correctly.
                ig.DrawArc(new Pen(Color.Black, 2), 120+5*3, 120, 110*3, 110, 0, 240);
                ig.DrawArc(new Pen(Color.Black, 2), 120+10*3, 125, 100*3, 100, 0, 210);
                ig.DrawArc(new Pen(Color.Black, 2), 120+15*3, 130, 90*3, 90, 0, 180);
                ig.DrawArc(new Pen(Color.Black, 2), 120+20*3, 135, 80*3, 80, 0, 150);
                ig.DrawArc(new Pen(Color.Black, 2), 120+25*3, 140, 70*3, 70, 0, 120);
                ig.DrawArc(new Pen(Color.Black, 2), 120+30*3, 145, 60*3, 60, 0, 90);
                ig.DrawArc(new Pen(Color.Black, 2), 120+35*3, 150, 50*3, 50, 0, 60);
                ig.DrawArc(new Pen(Color.Black, 2), 120+40*3, 155, 40*3, 40, 0, 270);

                ig.DrawPie(new Pen(Color.Pink, 2), 110, 50, 100, 100, 315, 90);
                ig.DrawPie(new Pen(Color.Purple, 2), 110, 50, 100, 100, 250, -90);
                ig.DrawPie(new Pen(Color.DarkRed, 2), 115, 55, 90, 90, 180, 270);
                ig.DrawPie(new Pen(Color.Red, 2), 120, 60, 80, 80, 45, -270);

            }
            else if (s == "Text")
            {

                Font fnt1 = new Font("Helvetica", 12, FontStyle.Italic | FontStyle.Bold);
                Font fnt2 = new Font(FontFamily.GenericMonospace, 16, FontStyle.Bold);
                Font fnt3 = new Font("", 40, FontStyle.Underline);

                Rectangle rc1 = new Rectangle(30, 30, 220,20);
                StringFormat fmt1= new StringFormat();
                fmt1.Alignment = StringAlignment.Near;

                ig.DrawRectangle(new Pen(Color.Blue),  rc1);
                ig.DrawString("Text...1", fnt1, new SolidBrush(Color.DarkGreen), rc1, fmt1);

                Rectangle rc2 = new Rectangle(0,0, 120,20);
                StringFormat fmt2= new StringFormat();
                fmt2.Alignment = StringAlignment.Center;

                ig.TranslateTransform(30,160);
                ig.RotateTransform(90);

                ig.DrawRectangle(new Pen(Color.Blue),  rc2);
                ig.DrawString("Text...2", fnt2, new SolidBrush(Color.DarkGreen), rc2, fmt2);

                ig.ResetTransform();

                Rectangle rc3 = new Rectangle(30, 90, 300,30);
                StringFormat fmt3= new StringFormat();
                fmt3.Alignment = StringAlignment.Far;

                ig.DrawRectangle(new Pen(Color.Blue),  rc3);
                ig.DrawString("Text...3", fnt3, new SolidBrush(Color.DarkGreen), rc3, fmt3);

                //measurestring
                string mme = "MeasureString Is Impossible To Emulate";
                SizeF siz = ig.MeasureString(mme, fnt1);
                ig.DrawRectangle(new Pen(Color.Red), 20, 200, siz.Width, siz.Height);
                siz = ig.MeasureString(mme, fnt1, 150);
                ig.DrawRectangle(new Pen(Color.Orange), 20, 230, siz.Width, siz.Height);
                siz = ig.MeasureString(mme, fnt1,  new SizeF(150, 150), new StringFormat(StringFormatFlags.DirectionVertical));
                ig.DrawRectangle(new Pen(Color.Yellow), 20, 200, siz.Width, siz.Height);

            }
            else if (s == "Images")
            {

                Icon ike = new Icon(GetType(), "App.ico");
                ig.DrawIcon(ike, 10,10);
                //ig.DrawIcon(ike, new Rectangle(270, 400, 30, 40));

                Bitmap bmp = new Bitmap(GetType(), "test.bmp");
                ig.DrawImage(bmp, 100f, 150f);
                GraphicsContainer cnt = ig.BeginContainer();
                ig.RotateTransform(5);
                ig.DrawImage(bmp, 160f, 50f, 120f, 70f);
                ig.EndContainer(cnt);
                //ig.DrawImageUnscaled(bmp, 270, 450, 20, 20);

            }
            else
            {

            }
        }
Esempio n. 41
0
 /// <summary>
 /// ��ʼ��
 /// </summary>
 private void init()
 {
     //
     //imageArr
     //
     imageArr[0] = new Bitmap(GetType(), "images.back1.gif");
     imageArr[1] = new Bitmap(GetType(), "images.back2.gif");
     imageArr[2] = new Bitmap(GetType(), "images.back3.gif");
     imageArr[3] = new Bitmap(GetType(), "images.back4.gif");
     imageArr[4] = new Bitmap(GetType(), "images.back5.gif");
     this.menus.Start(this);//ʵ�ֲ˵����
     bgImage = new Bitmap(GetType(), "images.back1.gif");//��������
     size = SystemInformation.PrimaryMonitorMaximizedWindowSize;
     this.bitmapMemeory = new Bitmap(size.Width, size.Height);
     this.graDrawPanel = Graphics.FromImage(this.bitmapMemeory);
     this.graDrawPanel.SmoothingMode = SmoothingMode.AntiAlias;
     this.bckColor = this.BackColor;
     this.graDrawLine = this.CreateGraphics();
     this.penDrawLine = new Pen(Color.Black, 1);
     this.penDrawNode = new Pen(Color.Blue, 2);
     this.penDrawPoint = new Pen(Color.Black, 6);
     this.penDrawBeeLine = new Pen(Color.Black, 1);
     this.penDrawBeeLine.StartCap = LineCap.RoundAnchor;
     AdjustableArrowCap myArrow = new AdjustableArrowCap(4, 6);
     CustomLineCap customArrow = myArrow;
     this.penDrawLine.CustomEndCap = myArrow;
     this.penDrawLine.StartCap = LineCap.RoundAnchor;
     this.penDrawString = new Pen(Color.Red, 5);
     this.fontDrawString = new Font("����", 9f);
     this.drawObject = new DrawObject(this);
     drawObject.GetTableList();
     FormRefrash();
     AddToolTip(true);
 }
Esempio n. 42
0
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            // Clear background
            e.Graphics.Clear(SystemColors.Control);

            // Draw each part
            Point selection = (Point)this.anchorEdgeToXy[this.anchorEdge];

            double controlCenterX = (double)this.Width / 2.0;
            double controlCenterY = (double)this.Height / 2.0;

            Pen linePen = new Pen(SystemColors.WindowText, (((float)Width + (float)Height) / 2.0f) / 64.0f);
            AdjustableArrowCap cap = new AdjustableArrowCap((float)Width / 32.0f, (float)Height / 32.0f, true);
            linePen.CustomEndCap = cap;

            Point mousePoint = PointToClient(Control.MousePosition);
            int mouseAnchorX = (int)Math.Floor(((float)mousePoint.X * 3.0f) / (float)this.Width);
            int mouseAnchorY = (int)Math.Floor(((float)mousePoint.Y * 3.0f) / (float)this.Height);

            for (int y = 0; y < 3; ++y)
            {
                for (int x = 0; x < 3; ++x)
                {
                    AnchorEdge edge = this.xyToAnchorEdge[y][x];
                    Point offset = (Point)this.anchorEdgeToXy[edge];
                    Point vector = new Point(offset.X - selection.X, offset.Y - selection.Y);

                    int left = (this.Width * x) / 3;
                    int top = (this.Height * y) / 3;
                    int right = Math.Min(this.Width - 1, (this.Width * (x + 1)) / 3);
                    int bottom = Math.Min(this.Height - 1, (this.Height * (y + 1)) / 3);
                    int width = right - left;
                    int height = bottom - top;

                    if (vector.X == 0 && vector.Y == 0)
                    {
                        ButtonRenderer.DrawButton(e.Graphics, new Rectangle(left, top, width, height), PushButtonState.Pressed);
                        e.Graphics.DrawImage(this.centerImage, left + 3, top + 3, width - 6, height - 6);
                    }
                    else 
                    {
                        PushButtonState state;

                        if (drawHotPush && x == this.hotAnchorButton.X && y == this.hotAnchorButton.Y)
                        {
                            state = PushButtonState.Pressed;
                        }
                        else
                        {
                            state = PushButtonState.Normal;

                            if (!mouseDown && mouseAnchorX == x && mouseAnchorY == y)
                            {
                                state = PushButtonState.Hot;
                            }
                        }

                        ButtonRenderer.DrawButton(e.Graphics, new Rectangle(left, top, width, height), state);

                        if (vector.X <= 1 && vector.X >= -1 && vector.Y <= 1 && vector.Y >= -1)
                        {
                            double vectorMag = Math.Sqrt((double)((vector.X * vector.X) + (vector.Y * vector.Y)));
                            double normalX = (double)vector.X / vectorMag;
                            double normalY = (double)vector.Y / vectorMag;

                            Point center = new Point((left + right) / 2, (top + bottom) / 2);

                            Point start = new Point(center.X - (width / 4) * vector.X, center.Y - (height / 4) * vector.Y);
                            Point end = new Point(
                                start.X + (int)(((double)width / 2.0) * normalX),
                                start.Y + (int)(((double)height / 2.0) * normalY));

                            PixelOffsetMode oldPOM = e.Graphics.PixelOffsetMode;
                            e.Graphics.PixelOffsetMode = PixelOffsetMode.Half;
                            e.Graphics.DrawLine(linePen, start, end);
                            e.Graphics.PixelOffsetMode = oldPOM;
                        }
                    }
                }
            }

            linePen.Dispose();
            base.OnPaint(e);
        }
Esempio n. 43
0
 /// <summary>
 /// Serialization constructor
 /// </summary>
 /// <param name="info">The serialization info</param>
 /// <param name="context">The streaming context</param>
 public AdjustableArrowCapRef(SerializationInfo info, StreamingContext context)
 {
     var aac = _aac = new AdjustableArrowCap(info.GetSingle("Width"), info.GetSingle("Height"));
     aac.BaseCap = (LineCap)info.GetInt32("BaseCap");
     aac.BaseInset = info.GetSingle("BaseInset");
     aac.Filled = info.GetBoolean("Filled");
     aac.MiddleInset = info.GetSingle("MiddleInset");
     aac.StrokeJoin = (LineJoin)info.GetInt32("StrokeJoin");
     aac.WidthScale = info.GetSingle("WidthScale");
 }
Esempio n. 44
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            Graphics g = pe.Graphics;//работа с графикой GDI+
            g.Clear(Color.White);

            //выравнивание по центру
            StringFormat center = new StringFormat();//вся инфа о выравнивании
            center.Alignment = StringAlignment.Center; //ширина
            center.LineAlignment = StringAlignment.Center;//высота

            //вершины
            foreach(Vertex v in graf.VertexList)
            {
                g.DrawEllipse(new Pen(new SolidBrush(Color.LightGray), 2), v.x - 11, v.y - 11, 11 * 2, 11 * 2);
            }
            foreach (Vertex v in graf.VertexList)
            {
                g.DrawString(v.name.ToString(), new Font("Arial", 12), new SolidBrush(Color.Black), v.x+1, v.y+1, center);
            }

            foreach (Edge e in graf.EdgeList)//ребра со стрелочками
            {
                Pen p = new Pen(new SolidBrush(Color.LightBlue), 2);
                AdjustableArrowCap myCap = new AdjustableArrowCap(2, 2) { WidthScale = 2, BaseCap = LineCap.Square, Height = 5 };
                if (e.v1tov2) { p.CustomEndCap = myCap; }
                if (e.v2tov1) { p.CustomStartCap = myCap; }
                g.DrawLine(p, e.v1.x, e.v1.y, e.v2.x, e.v2.y);
            }

            //ребра
            if (FirstVertexForEdge != null)
            {
                g.FillEllipse(new SolidBrush(Color.FromArgb(128, 0, 255, 0)), FirstVertexForEdge.x - 11, FirstVertexForEdge.y - 11, 11 * 2, 11 * 2);
            }
            if (selectedVertex != null)
            {
                g.FillEllipse(new SolidBrush(Color.FromArgb(128, 0, 255, 0)), selectedVertex.x - 11, selectedVertex.y - 11, 11 * 2, 11 * 2);
            }
            if (selectedEdge != null)
            {
                Pen p = new Pen(new SolidBrush(Color.Green), 2);
                AdjustableArrowCap myCap = new AdjustableArrowCap(2, 2); // наконечник стрелки
                myCap.WidthScale = 2;
                myCap.BaseCap = LineCap.Square;
                myCap.Height = 3;
                if (selectedEdge.v1tov2) { p.CustomEndCap = myCap; }
                if (selectedEdge.v2tov1) { p.CustomStartCap = myCap; }
                g.DrawLine(p, selectedEdge.v1.x, selectedEdge.v1.y, selectedEdge.v2.x, selectedEdge.v2.y);
            }

            //стоимость
            foreach(Edge e in graf.EdgeList)
            {
                int edgeCenterX = (e.v1.x + e.v2.x) / 2;
                int edgeCenterY = (e.v1.y + e.v2.y) / 2;
                g.FillRectangle(new SolidBrush(Color.White), edgeCenterX - 10, edgeCenterY - 8, 20, 16);
            }
            foreach (Edge e in graf.EdgeList)
            {
                int edgeCenterX = (e.v1.x + e.v2.x) / 2;
                int edgeCenterY = (e.v1.y + e.v2.y) / 2;
                g.DrawString(e.cost.ToString(), new Font("Arial", 12), new SolidBrush(Color.Blue), edgeCenterX + 1, edgeCenterY + 1, center);
            }

            //Список ребер
            richTextBox1.Text = "Список ребер: \n";
            foreach (Edge e in graf.EdgeList)
            {
                richTextBox1.Text += e.v1.name.ToString() + " - " + e.v2.name.ToString() + "\n";
            }

            // Список суміжності
            richTextBox2.Text = "Список суміжності: \n";
            foreach (Vertex v in graf.VertexList)
            {
                richTextBox2.Text += v.name.ToString() + "->";
                foreach (Edge ee in graf.EdgeList)
                {
                    if (ee.v1 == v && ee.v1tov2 == true)
                    {
                        richTextBox2.Text += ee.v2.name.ToString() + "; ";
                    }
                    if (ee.v2 == v && ee.v2tov1 == true)
                    {
                        richTextBox2.Text += ee.v1.name.ToString() + "; ";
                    }
                }
                richTextBox2.Text += "\n";
            }

            // Таблица сумижности
            dataGridView1.Rows.Clear();
            dataGridView1.Columns.Clear();
            for (int i = 0; i < graf.VertexList.Count; i++)
            {
                dataGridView1.Columns.Add(new DataGridViewCheckBoxColumn());
                dataGridView1.Columns[i].HeaderText = graf.VertexList[i].name.ToString();
                dataGridView1.Columns[i].Name = graf.VertexList[i].name.ToString();
                dataGridView1.Columns[i].Width = 28;
            }
            for (int i = 0; i < graf.VertexList.Count; i++)
            {
                dataGridView1.Rows.Add();
                dataGridView1.Rows[i].HeaderCell.Value = graf.VertexList[i].name.ToString();
            }
            foreach (Edge ee in graf.EdgeList)
            {
                int index_v1 = 0;
                int index_v2 = 0;
                if (ee.v1tov2)
                {
                    index_v1 = 0;
                    index_v2 = 0;
                    foreach (Vertex v in graf.VertexList)
                    {
                        if (v == ee.v1) { break; }
                        index_v1++;
                    }
                    foreach (Vertex v in graf.VertexList)
                    {
                        if (v == ee.v2) { break; }
                        index_v2++;
                    }
                    dataGridView1.Rows[index_v1].Cells[index_v2].Value = CheckState.Checked;
                }
                if (ee.v2tov1)
                {
                    index_v1 = 0;
                    index_v2 = 0;
                    foreach (Vertex v in graf.VertexList)
                    {
                        if (v == ee.v1) { break; }
                        index_v1++;
                    }
                    foreach (Vertex v in graf.VertexList)
                    {
                        if (v == ee.v2) { break; }
                        index_v2++;
                    }
                    dataGridView1.Rows[index_v2].Cells[index_v1].Value = CheckState.Checked;
                }
            }
        }