public override void Draw(Graphics g, VisualGraph drawArea)
        {
            Pen pen = new Pen(Color, PenWidth);

            g.DrawEllipse(pen, DrawRectangle.GetNormalizedRectangle(ShapeRect));
            pen.Dispose();
        }
Example #2
0
        public void Clone(VisualGraph drawArea)
        {
            int   n = tempList.Count;
            Point point;

            for (int i = 0; i < n; i++)
            {
                DrawObject o = (DrawObject)tempList[i];
                point = new Point(o.ShapeRect.X + 10, o.ShapeRect.Y + 10);
                switch (o.ObjectType)
                {
                case Global.DrawType.DrawEllipse:
                    DrawEllipse dp = new DrawEllipse(point, drawArea);
                    dp.Selected = false;
                    objList.Add(dp);
                    break;

                case Global.DrawType.DrawLine:
                    DrawLine dl = new DrawLine(point, drawArea);
                    dl.Selected   = false;
                    dl.StartPoint = point;
                    dl.EndPoint   = new Point(point.X + o.ShapeRect.Width,
                                              point.Y + o.ShapeRect.Height);
                    dl.Width    = o.ShapeRect.Width;
                    dl.Height   = o.ShapeRect.Height;
                    dl.PenWidth = o.PenWidth;
                    dl.Color    = o.Color;
                    objList.Add(dl);
                    break;

                case Global.DrawType.DrawRectangle:
                    DrawRectangle dr = new DrawRectangle(point, drawArea);
                    dr.Selected = false;
                    objList.Add(dr);
                    break;

                case Global.DrawType.DrawText:
                    DrawText dt = new DrawText(point, drawArea);
                    dt.Selected = false;
                    objList.Add(dt);
                    break;

                case Global.DrawType.DrawPic:
                    DrawPic   oldpic = (DrawPic)o;
                    DrawPic   dpic   = new DrawPic(point, drawArea);
                    Rectangle ret    = new Rectangle(point.X, point.Y, oldpic.ShapeRect.Width,
                                                     oldpic.ShapeRect.Height);
                    dpic.ShapeRect = ret;
                    dpic.TheImage  = oldpic.TheImage;
                    dpic.Selected  = false;
                    objList.Add(dpic);
                    break;
                }
            }
            drawArea.ActivedObjType = Global.DrawType.POINTER;
        }
Example #3
0
        //将所选工具加入到页面容器中
        private void VisualGraph_DragDrop(object sender, DragEventArgs e)
        {
            Point point = new Point(e.X, e.Y);

            point = this.PointToClient(point);
            switch (activedObjType)
            {
            case Global.DrawType.DrawText:
                DrawText text = new DrawText(point, this);
                objList.UnselectAll();
                objList.AddObject(text);
                text.Selected = true;
                break;

            case Global.DrawType.DrawRectangle:
                DrawRectangle rect = new DrawRectangle(point, this);
                objList.UnselectAll();
                objList.AddObject(rect);
                rect.Selected = true;
                break;

            case Global.DrawType.DrawEllipse:
                DrawEllipse elip = new DrawEllipse(point, this);
                objList.UnselectAll();
                objList.AddObject(elip);
                elip.Selected = true;
                break;

            case Global.DrawType.DrawLine:
                DrawLine line = new DrawLine(point, this);
                objList.UnselectAll();
                objList.AddObject(line);
                line.Selected = true;
                break;

            case Global.DrawType.DrawPic:
                DrawPic pic = new DrawPic(point, this);
                objList.UnselectAll();
                objList.AddObject(pic);
                pic.Selected = true;
                break;
            }
            activedObjType = Global.DrawType.POINTER;
            this.Refresh();
        }
Example #4
0
        public override void Draw(Graphics g, VisualGraph drawArea)
        {
            SolidBrush drawBrush = new SolidBrush(Color.Black);
            Pen        fontPen   = new Pen(Color, PenWidth);

            if (_stringFormat == null)
            {
                _stringFormat               = new StringFormat();
                _stringFormat.Alignment     = StringAlignment.Center;
                _stringFormat.LineAlignment = StringAlignment.Center;
            }
            Font drawFont = new Font("Arial", 12);

            g.DrawString(CurText, drawFont, drawBrush, ShapeRect, _stringFormat);
            if (_Show)
            {
                g.DrawRectangle(fontPen, DrawRectangle.GetNormalizedRectangle(ShapeRect));
            }
            drawFont.Dispose();
            drawBrush.Dispose();
            fontPen.Dispose();
        }
 public override void Normalize()
 {
     ShapeRect = DrawRectangle.GetNormalizedRectangle(ShapeRect);
 }