示例#1
0
        public AGMWallDual(int x, int y, int width, int height)
            : base()
        {
            Rectangle   = new Rectangle(x, y, width, height);
            objectID    = objIdInc++;
            logicIDTail = "";
            direction   = HVDirection.Horizontal;

            Initialize();
        }
示例#2
0
        public Switch(int x, int y, int width, int height)
            : base()
        {
            Rectangle = new Rectangle(x, y, width, height);
            int id = _objIdInc++;

            _switchID  = string.Format("SW{0}", id.ToString("D2"));
            _direction = HVDirection.Horizontal;
            Initialize();
        }
示例#3
0
        public override void Draw(Graphics g)
        {
            Pen   pen      = new Pen(Color, PenWidth);
            Brush brushout = new SolidBrush(Color.FromArgb(255, 150, 150, 150));
            Brush brushin  = new SolidBrush(Color.White);

            g.SmoothingMode = SmoothingMode.AntiAlias;
            Rectangle frect = new Rectangle(Rectangle.X, Rectangle.Y, Rectangle.Width, Rectangle.Height);

            g.DrawRectangle(pen, Rectangle);
            g.FillRectangle(brushout, frect);
            int blockWidth  = 0;
            int blockHeight = 0;
            int blockX_1    = 0;
            int blockY_1    = 0;
            int blockX_2    = 0;
            int blockY_2    = 0;

            if (Entry != null)
            {
                direction = (Entry == "Horizontal" ? HVDirection.Horizontal : HVDirection.Vertical);
            }

            switch (Direction)
            {
            case HVDirection.Horizontal:
            {
                blockWidth  = Rectangle.Width / 5;
                blockHeight = Rectangle.Height / 3;

                blockX_1 = Rectangle.X + Rectangle.Width / 10; blockY_1 = Rectangle.Y + Rectangle.Height / 3;
                blockX_2 = Rectangle.X + 7 * Rectangle.Width / 10; blockY_2 = Rectangle.Y + Rectangle.Height / 3;
            }
            break;

            case HVDirection.Vertical:
            {
                blockWidth  = Rectangle.Width / 3;
                blockHeight = Rectangle.Height / 5;

                blockX_1 = Rectangle.X + Rectangle.Width / 3; blockY_1 = Rectangle.Y + Rectangle.Height / 10;
                blockX_2 = Rectangle.X + Rectangle.Width / 3; blockY_2 = Rectangle.Y + 7 * Rectangle.Height / 10;
            }
            break;
            }
            Rectangle rect1 = new Rectangle(blockX_1, blockY_1, blockWidth, blockHeight);
            Rectangle rect2 = new Rectangle(blockX_2, blockY_2, blockWidth, blockHeight);

            g.DrawRectangle(pen, rect1);
            g.FillRectangle(brushin, rect1);
            g.DrawRectangle(pen, rect2);
            g.FillRectangle(brushin, rect2);
            pen.Dispose();
        }
示例#4
0
 public override void ClockWiseDirection()
 {
     base.ClockWiseDirection();
     if (this.direction == HVDirection.Horizontal)
     {
         direction = HVDirection.Vertical;
     }
     else if (direction == HVDirection.Vertical)
     {
         direction = HVDirection.Horizontal;
     }
 }
示例#5
0
 public override void AntiClockWiseDirection()
 {
     base.AntiClockWiseDirection();
     if (this._direction == HVDirection.Horizontal)
     {
         _direction = HVDirection.Vertical;
     }
     else if (_direction == HVDirection.Vertical)
     {
         _direction = HVDirection.Horizontal;
     }
 }
示例#6
0
        public override void MoveHandleTo(Point point, int handleNumber)
        {
            base.MoveHandleTo(point, handleNumber);

            if (this.Rectangle.Width > this.Rectangle.Height)
            {
                Direction = HVDirection.Horizontal;
            }
            else
            {
                Direction = HVDirection.Vertical;
            }
        }
示例#7
0
 public AGMChannelDual(int x, int y, int width, int height)
     : base()
 {
     Rectangle     = new Rectangle(x, y, width, height);
     _logicIDTail  = "";
     _objectID     = _objIdInc++;
     _tagIDBase    = 0;
     _flag         = _objIdInc++;
     _direction    = HVDirection.Horizontal;
     _entry        = EDirection.Left;
     _showProperty = false;
     Initialize();
 }
示例#8
0
        public override void Draw(Graphics g)
        {
            Pen pen = new Pen(Color, PenWidth);

            Brush brushout = null;

            if (_tagIDBase == 0)
            {
                brushout = new SolidBrush(Color.FromArgb(255, 0, 255, 255));
            }
            else
            {
                brushout = new SolidBrush(Color.FromArgb(255, 0, 255, 0));
            }

            Brush brushin = new SolidBrush(Color.White);

            g.SmoothingMode = SmoothingMode.AntiAlias;

            Rectangle frect = new Rectangle(Rectangle.X, Rectangle.Y, Rectangle.Width, Rectangle.Height);

            g.FillRectangle(brushout, frect);    //填充区域

            if (Angle != null)
            {
                _direction = (Angle == "Horizontal" ? HVDirection.Horizontal : HVDirection.Vertical);
            }

            //宽度大于高度,箭头横向
            if (Rectangle.Width > Rectangle.Height)
            {
                _direction = HVDirection.Horizontal;
            }
            //宽度小于高度,箭头竖向
            if (Rectangle.Width < Rectangle.Height)
            {
                _direction = HVDirection.Vertical;
            }

            switch (_direction)
            {
            case HVDirection.Horizontal:
            {
                p11.X = Rectangle.X + Rectangle.Width / 2; p11.Y = Rectangle.Y + Rectangle.Height / 2;
                p12.X = Rectangle.X + Rectangle.Width / 4; p12.Y = Rectangle.Y + Rectangle.Height / 6;
                p13.X = Rectangle.X + Rectangle.Width / 4; p13.Y = Rectangle.Y + 2 * Rectangle.Height / 6;
                p14.X = Rectangle.X; p14.Y = Rectangle.Y + 2 * Rectangle.Height / 6;
                p15.X = Rectangle.X; p15.Y = Rectangle.Y + 4 * Rectangle.Height / 6;
                p16.X = Rectangle.X + Rectangle.Width / 4; p16.Y = Rectangle.Y + 4 * Rectangle.Height / 6;
                p17.X = Rectangle.X + Rectangle.Width / 4; p17.Y = Rectangle.Y + 5 * Rectangle.Height / 6;

                p21.X = Rectangle.X + Rectangle.Width / 2; p21.Y = Rectangle.Y + Rectangle.Height / 2;
                p22.X = Rectangle.X + 3 * Rectangle.Width / 4; p22.Y = Rectangle.Y + Rectangle.Height / 6;
                p23.X = Rectangle.X + 3 * Rectangle.Width / 4; p23.Y = Rectangle.Y + 2 * Rectangle.Height / 6;
                p24.X = Rectangle.X + Rectangle.Width; p24.Y = Rectangle.Y + 2 * Rectangle.Height / 6;
                p25.X = Rectangle.X + Rectangle.Width; p25.Y = Rectangle.Y + 4 * Rectangle.Height / 6;
                p26.X = Rectangle.X + 3 * Rectangle.Width / 4; p26.Y = Rectangle.Y + 4 * Rectangle.Height / 6;
                p27.X = Rectangle.X + 3 * Rectangle.Width / 4; p27.Y = Rectangle.Y + 5 * Rectangle.Height / 6;
            }
            break;

            case HVDirection.Vertical:
            {
                p11.X = Rectangle.X + Rectangle.Width / 2; p11.Y = Rectangle.Y + Rectangle.Height / 2;
                p12.X = Rectangle.X + Rectangle.Width / 6; p12.Y = Rectangle.Y + Rectangle.Height / 4;
                p13.X = Rectangle.X + 2 * Rectangle.Width / 6; p13.Y = Rectangle.Y + Rectangle.Height / 4;
                p14.X = Rectangle.X + 2 * Rectangle.Width / 6; p14.Y = Rectangle.Y;
                p15.X = Rectangle.X + 4 * Rectangle.Width / 6; p15.Y = Rectangle.Y;
                p16.X = Rectangle.X + 4 * Rectangle.Width / 6; p16.Y = Rectangle.Y + Rectangle.Height / 4;
                p17.X = Rectangle.X + 5 * Rectangle.Width / 6; p17.Y = Rectangle.Y + Rectangle.Height / 4;

                p21.X = Rectangle.X + Rectangle.Width / 2; p21.Y = Rectangle.Y + Rectangle.Height / 2;
                p22.X = Rectangle.X + 1 * Rectangle.Width / 6; p22.Y = Rectangle.Y + 3 * Rectangle.Height / 4;
                p23.X = Rectangle.X + 2 * Rectangle.Width / 6; p23.Y = Rectangle.Y + 3 * Rectangle.Height / 4;
                p24.X = Rectangle.X + 2 * Rectangle.Width / 6; p24.Y = Rectangle.Y + Rectangle.Height;
                p25.X = Rectangle.X + 4 * Rectangle.Width / 6; p25.Y = Rectangle.Y + Rectangle.Height;
                p26.X = Rectangle.X + 4 * Rectangle.Width / 6; p26.Y = Rectangle.Y + 3 * Rectangle.Height / 4;
                p27.X = Rectangle.X + 5 * Rectangle.Width / 6; p27.Y = Rectangle.Y + 3 * Rectangle.Height / 4;
            }
            break;
            }

            //画箭头
            GraphicsPath path = new GraphicsPath();

            path.StartFigure();
            path.AddLine(p11, p12);
            path.AddLine(p12, p13);
            path.AddLine(p13, p14);
            path.AddLine(p14, p15);
            path.AddLine(p15, p16);
            path.AddLine(p16, p17);
            path.AddLine(p17, p11);

            g.FillPath(brushin, path);
            g.DrawPath(pen, path);

            path = new GraphicsPath();

            path.StartFigure();
            path.AddLine(p21, p22);
            path.AddLine(p22, p23);
            path.AddLine(p23, p24);
            path.AddLine(p24, p25);
            path.AddLine(p25, p26);
            path.AddLine(p26, p27);
            path.AddLine(p27, p21);

            g.FillPath(brushin, path);
            g.DrawPath(pen, path);

            g.DrawRectangle(pen, Rectangle);       //画外框

            Brush        brushin0 = new SolidBrush(Color.Red);
            StringFormat style    = new StringFormat();

            style.Alignment = StringAlignment.Center;
            if (_showProperty)
            {
                g.DrawString(
                    _logicIDTail,
                    new Font("宋体", 9, FontStyle.Regular),
                    brushin0,
                    Rectangle, style);
            }
            pen.Dispose();
        }