示例#1
0
        protected override void DrawSlot(Control ctrl, Point p, SlotPosition position, SlotDirection direction)
        {
            Graphics g = ctrl.CreateGraphics();
            //UI ui = new UI();
            SolidBrush brush = new SolidBrush(UI.SLOT_COLOR);
            Pen        pen   = new Pen(brush, 0.5f);

            Point pN = new Point(0, 0);
            Point pS = new Point(0, 0);
            Point pW = new Point(0, 0);
            Point pE = new Point(0, 0);

            Point[] points = new Point[3];

            // this is the only situation possible for the tee
            if (position.Equals(SlotPosition.Right))
            {
                if (direction == SlotDirection.Out)
                {
                    pE = new Point(p.X - 1, p.Y);
                    pS = new Point(pE.X - 3, pE.Y + 3);
                    pW = new Point(pE.X - 11, pE.Y);
                    pN = new Point(pE.X - 3, pE.Y - 3);

                    points[0] = pN;
                    points[1] = pE;
                    points[2] = pS;
                    g.DrawLine(pen, pW, pE);
                }
            }
            else if (position.Equals(SlotPosition.Left))
            {
                if (direction == SlotDirection.In)
                {
                    pW = p;
                    pS = p;
                    pN = p;
                    pE = new Point(p.X + 5, p.Y);

                    points[0] = pN;
                    points[1] = pE;
                    points[2] = pS;
                    g.DrawLine(pen, pW, pE);
                }
            }
            g.FillPolygon(brush, points);

            g.Dispose();
            brush.Dispose();
            pen.Dispose();
        }
示例#2
0
        protected virtual void DrawSlot(Control ctrl, Point p, SlotPosition position, SlotDirection direction)
        {
            Graphics   g     = ctrl.CreateGraphics();
            UI         ui    = new UI();
            SolidBrush brush = new SolidBrush(ui.SLOT_COLOR);
            Pen        pen   = new Pen(brush, 0.5f);

            Point pN = new Point(0, 0);
            Point pS = new Point(0, 0);
            Point pW = new Point(0, 0);
            Point pE = new Point(0, 0);

            Point[] points = new Point[3];

            if (position.Equals(SlotPosition.Up))
            {
                if (direction == SlotDirection.In)
                {
                    pN = p;
                    pS = new Point(p.X, p.Y + 5);
                    pW = new Point(p.X - 3, p.Y + 2);
                    pE = new Point(p.X + 3, p.Y + 2);

                    points[0] = pW;
                    points[1] = pE;
                    points[2] = pS;
                    g.DrawLine(pen, pN, pS);
                }
                else if (direction == SlotDirection.Out)
                {
                    pN = new Point(p.X, p.Y + 1);
                    pS = new Point(p.X, p.Y + 5);
                    pW = new Point(p.X - 4, p.Y + 4);
                    pE = new Point(p.X + 4, p.Y + 4);

                    points[0] = pW;
                    points[1] = pE;
                    points[2] = pN;
                    g.DrawLine(pen, pN, pS);
                }
            }
            else if (position.Equals(SlotPosition.Left))
            {
                if (direction == SlotDirection.In)
                {
                    pW = p;
                    pS = new Point(p.X + 2, p.Y + 3);
                    pN = new Point(p.X + 2, p.Y - 3);
                    pE = new Point(p.X + 5, p.Y);

                    points[0] = pN;
                    points[1] = pE;
                    points[2] = pS;
                    g.DrawLine(pen, pW, pE);
                }
                else if (direction == SlotDirection.Out)
                {
                    pW = new Point(p.X + 1, p.Y);
                    pS = new Point(p.X + 4, p.Y + 3);
                    pN = new Point(p.X + 4, p.Y - 3);
                    pE = new Point(p.X + 5, p.Y);

                    points[0] = pN;
                    points[1] = pS;
                    points[2] = pW;
                    g.DrawLine(pen, pW, pE);
                }
            }
            else if (position.Equals(SlotPosition.Right))
            {
                if (direction == SlotDirection.Out)
                {
                    pE = new Point(p.X - 1, p.Y);
                    pS = new Point(pE.X - 3, pE.Y + 3);
                    pW = new Point(pE.X - 5, pE.Y);
                    pN = new Point(pE.X - 3, pE.Y - 3);

                    points[0] = pN;
                    points[1] = pE;
                    points[2] = pS;
                    g.DrawLine(pen, pW, pE);
                }
                else if (direction == SlotDirection.In)
                {
                    pE = new Point(p.X - 1, p.Y);
                    pS = new Point(pE.X - 3, pE.Y + 3);
                    pW = new Point(pE.X - 6, pE.Y);
                    pN = new Point(pE.X - 3, pE.Y - 3);

                    points[0] = pN;
                    points[1] = pS;
                    points[2] = pW;
                    g.DrawLine(pen, pW, pE);
                }
            }
            else if (position.Equals(SlotPosition.Down))
            {
                if (direction == SlotDirection.Out)
                {
                    pS = new Point(p.X, p.Y - 1);
                    pN = new Point(pS.X, pS.Y - 5);
                    pW = new Point(pS.X - 3, pS.Y - 3);
                    pE = new Point(pS.X + 3, pS.Y - 3);

                    points[0] = pW;
                    points[1] = pE;
                    points[2] = pS;
                    g.DrawLine(pen, pN, pS);
                }
                else if (direction == SlotDirection.In)
                {
                    pS = new Point(p.X, p.Y - 1);
                    pN = new Point(pS.X, pS.Y - 6);
                    pW = new Point(pS.X - 3, pS.Y - 2);
                    pE = new Point(pS.X + 3, pS.Y - 2);

                    points[0] = pW;
                    points[1] = pE;
                    points[2] = pN;
                    g.DrawLine(pen, pN, pS);
                }
            }
            g.FillPolygon(brush, points);
        }