Ejemplo n.º 1
0
        void DrawCircle(XElement element, Graphics graphics)
        {
            int[] pos = SimulinkXmlParser.GetPosition(element);
            Pen   pen = di.GetPen(element);

            graphics.DrawEllipse(GetPen(element), pos[0], pos[1], pos[2] - pos[0], pos[3] - pos[1]);
        }
Ejemplo n.º 2
0
        void DrawTriangle(XElement element, Graphics graphics)
        {
            int[] pos = SimulinkXmlParser.GetPosition(element);
            Pen   pen = di.GetPen(element);

            Point[] p = new Point[] { new Point(pos[0], pos[1]), new Point(pos[0], pos[3]), new Point(pos[2], (pos[1] + pos[3]) / 2) };
            graphics.DrawPolygon(pen, p);
        }
Ejemplo n.º 3
0
 void DrawRect(XElement element, Graphics graphics)
 {
     try
     {
         int[] pos = SimulinkXmlParser.GetPosition(element);
         Pen   pen = di.GetPen(element);
         graphics.DrawRectangle(GetPen(element), pos[0], pos[1], pos[2] - pos[0], pos[3] - pos[1]);
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 4
0
        void DrawTransferFunc(XElement element, Graphics graphics)
        {
            try
            {
                int[]    pos  = SimulinkXmlParser.GetPosition(element);
                string[] snd  = new string[2];
                SizeF[]  size = new SizeF[2];
                Font     font = GetFont(element);
                float    w    = 0;

                for (int i = 0; i < 2; i++)
                {
                    string[] ss = ParseString(
                        element.GetAttributeLocal(SimulinkXmlParser.Fraction[i]));
                    string str = "";
                    for (int j = 0; j < ss.Length; j++)
                    {
                        if (j > 0)
                        {
                            str += " + ";
                        }
                        str += ss[j];
                        if (j < ss.Length - 1)
                        {
                            str += "s";
                        }
                    }
                    snd[i] = str;
                    SizeF siz = graphics.MeasureString(str, font);
                    if (w < siz.Width)
                    {
                        w = siz.Width;
                    }
                    size[i] = siz;
                }
                int cx  = (pos[0] + pos[2]) / 2;
                int cy  = (pos[1] + pos[3]) / 2;
                int w2  = (int)(w / 2);
                Pen pen = GetPen(element);
                graphics.DrawLine(pen, cx - w2, cy, cx + w2, cy);
                int[] yy    = new int[] { cy - (int)size[0].Height - 1, cy + 1 };
                Brush brush = GetForeBrush(element);
                for (int i = 0; i < 2; i++)
                {
                    float x = (float)cx - size[i].Width / 2;
                    graphics.DrawString(snd[i], font, brush, x, (float)yy[i]);
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 5
0
        void DrawMult(XElement element, Graphics graphics)
        {
            int[]  pos = SimulinkXmlParser.GetPosition(element);
            Pen    pen = di.GetPen(element);
            double dx  = (pos[2] - pos[0]);
            double dy  = (pos[3] - pos[1]);
            //int xl = (int)(dx * Math.Sqrt(0.5));
            int dxl = (int)(dx * Math.Sqrt(2) / 8);
            //int yl = (int)(dy * Math.Sqrt(0.5));
            int dyl = (int)(dy * Math.Sqrt(2) / 8);

            graphics.DrawLine(pen, pos[0] + dxl, pos[1] + dyl, pos[2] - dxl, pos[3] - dyl);
            graphics.DrawLine(pen, pos[0] + dxl, pos[3] - dyl, pos[2] - dxl, pos[1] + dyl);
        }
Ejemplo n.º 6
0
 int[] GetPosition(XElement element)
 {
     return(SimulinkXmlParser.GetPosition(element));
 }