예제 #1
0
파일: ObjList.cs 프로젝트: sjyfok/cpp
        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;
        }
예제 #2
0
파일: VisualGraph.cs 프로젝트: sjyfok/cpp
        //将所选工具加入到页面容器中
        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();
        }