Exemplo n.º 1
0
        public void DrawNode(Graphics g, WL.Node nd)
        {
            if (nd == null)
            {
                return;
            }

            SizeF sf = new SizeF((float)nd.Bounds.Width, (float)nd.Bounds.Height);

            RectangleF rect = new RectangleF(utilWiring.convertSystemPointToDrawingPoint(nd.Location), sf);
            string     text = nd.Text;

            pt.Media.SolidColorBrush newBrush = (pt.Media.SolidColorBrush)nd.Stroke;
            Color clr = System.Drawing.Color.FromArgb(newBrush.Color.A, newBrush.Color.R, newBrush.Color.G, newBrush.Color.B);

            if (newBrush.Color.R != 255 || newBrush.Color.G != 255 || newBrush.Color.B != 255)
            {
                Pen pen = new Pen(clr, (float)(0.3f));
                if (nd.Geometry is System.Windows.Media.RectangleGeometry)
                {
                    g.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
                }
            }

            pt.Media.SolidColorBrush newFill = (pt.Media.SolidColorBrush)nd.Fill;
            if (newFill.Color.R != 255 || newFill.Color.G != 255 || newFill.Color.B != 255)
            {
                Color clr1  = System.Drawing.Color.FromArgb(newFill.Color.A, newFill.Color.R, newFill.Color.G, newFill.Color.B);
                Brush brush = new SolidBrush(clr1);
                g.FillRectangle(brush, rect);
            }
            if (!string.IsNullOrEmpty(text))
            {
                Font ft1;

                if (nd.FontSize > 8f)
                {
                    ft1 = new Font("Arial", 8f, GraphicsUnit.Pixel);
                }
                else
                {
                    ft1 = new Font("Arial", 6f, GraphicsUnit.Pixel);
                }
                SizeF textSize = g.MeasureString(text, ft1);
                textSize.Height = textSize.Height * 0.7f;

                float x = 0, y = 0;

                pt.Media.SolidColorBrush textClr = (pt.Media.SolidColorBrush)nd.Foreground;
                Color clr2 = System.Drawing.Color.FromArgb(textClr.Color.A, textClr.Color.R, textClr.Color.G, textClr.Color.B);

                x = rect.X + (rect.Width - textSize.Width) / 2;
                y = rect.Y + (rect.Height - textSize.Height) / 2;

                g.DrawString(text, ft1, new SolidBrush(clr2), x, y);
            }
        }
Exemplo n.º 2
0
        private void DrawWiringLegend(ng.WiringNodeOut nodeOut)
        {
            string text0 = "";
            string text1 = "Transmission Line";
            string text2 = "Electrical power line";
            string text3 = "Ground wire";

            Point ptf1 = new Point(0, nodeOut.Size.Height + 90f);

            convertedPointF = utilWiring.convertSystemPointToDrawingPoint(ptf1);
            utilWiring.createTextNode_wiring(text0, convertedPointF, nodeOut);

            ptf1            = new Point(105, ptf1.Y + 15f);
            convertedPointF = utilWiring.convertSystemPointToDrawingPoint(ptf1);
            utilWiring.createTextNode_wiring(text1, convertedPointF, nodeOut);

            ptf1            = new Point(105, ptf1.Y + 30f);
            convertedPointF = utilWiring.convertSystemPointToDrawingPoint(ptf1);
            utilWiring.createTextNode_wiring(text2, convertedPointF, nodeOut);

            ptf1            = new Point(105, ptf1.Y + 30f);
            convertedPointF = utilWiring.convertSystemPointToDrawingPoint(ptf1);
            utilWiring.createTextNode_wiring(text3, convertedPointF, nodeOut);

            Point ptf2 = new Point(nodeOut.Location.X, nodeOut.Location.Y + nodeOut.Size.Height + 110f);
            Point ptf3 = new Point(ptf2.X + 100, ptf2.Y);

            drawing.PointF convertedPtf2 = new drawing.PointF();
            drawing.PointF convertedPtf3 = new drawing.PointF();
            convertedPtf2 = utilWiring.convertSystemPointToDrawingPoint(ptf2);
            convertedPtf3 = utilWiring.convertSystemPointToDrawingPoint(ptf3);
            ptArrayList.Add(new drawing.PointF[] { convertedPtf2, convertedPtf3 });

            ptf2          = new Point(ptf2.X, ptf2.Y + 30f);
            ptf3          = new Point(ptf2.X + 100, ptf2.Y);
            convertedPtf2 = utilWiring.convertSystemPointToDrawingPoint(ptf2);
            convertedPtf3 = utilWiring.convertSystemPointToDrawingPoint(ptf3);
            ptArrayList_power.Add(new drawing.PointF[] { convertedPtf2, convertedPtf3 });

            ptf2          = new Point(ptf2.X, ptf2.Y + 30f);
            ptf3          = new Point(ptf2.X + 100, ptf2.Y);
            convertedPtf2 = utilWiring.convertSystemPointToDrawingPoint(ptf2);
            convertedPtf3 = utilWiring.convertSystemPointToDrawingPoint(ptf3);
            ptArrayList_ground.Add(new drawing.PointF[] { convertedPtf2, convertedPtf3 });
        }