Ejemplo n.º 1
0
 // Methods
 public PolyOperation(MouseArea mc)
 {
     this.mouseAreaControl = null;
     this.win32 = null;
     this.reversePath = new GraphicsPath();
     this.graph = null;
     this.operate = PolyOperate.Draw;
     this.points = new PointF[0];
     this.moveindex = -1;
     this.startpoint = PointF.Empty;
     this.prePoint = PointF.Empty;
     this.nextPoint = PointF.Empty;
     this.insertindex = -1;
     this.tooltips = new Hashtable(0x10);
     this.oldpoints = string.Empty;
     this.mousedown = false;
     this.AreaPoints=new ArrayList();
     this.mouseAreaControl = mc;
     this.win32 = mc.win32;
     this.mouseAreaControl.PicturePanel.GraphChanged += new EventHandler(this.ChangeGraph);
     this.mouseAreaControl.SVGDocument.SelectCollection.OnCollectionChangedEvent += new OnCollectionChangedEventHandler(this.ChangeSelect);
     this.mouseAreaControl.DefaultCursor = SpecialCursors.bezierCursor;
 }
Ejemplo n.º 2
0
        public void OnMouseMove(MouseEventArgs e)
        {
            if (this.graph == null )
            {
                this.Operate = PolyOperate.Draw;
                return;
            }
            if (((SvgElement) this.graph).ParentNode == null)
            {
                this.Operate = PolyOperate.Draw;
                return;
            }
            if ((Control.ModifierKeys & Keys.Control) == Keys.Control || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom15))
            {
                addBegin =false;
                addEnd =false;
            }
            if (isKeydown((int)ItopVector.Core.Win32.Enum.VirtualKeys.VK_B) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom13))
            {
                addBegin =true;
                addEnd =false;
            }
            else if (isKeydown((int)ItopVector.Core.Win32.Enum.VirtualKeys.VK_E) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom12))
            {
                addEnd =true;
                addBegin=false;
            }
            if(addEnd || addBegin)
            {
                this.Operate = PolyOperate.Draw;
                return;
            }
            if (e.Button == MouseButtons.None)
            {
                this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
                this.win32.W32SetROP2(7);
                this.win32.W32PolyDraw(this.reversePath);
                this.reversePath.Reset();
                this.win32.ReleaseDC();
                int num4;
                PointF[] tfArray1 = (PointF[]) this.points.Clone();
                int num1 = 0;
                this.insertindex = num4 = -1;
                this.moveindex = num4;
                GraphicsPath path1 = new GraphicsPath();
                Pen pen1 = new Pen(Color.Beige, 4f);
                PointF[] tfArray3 = tfArray1;
                for (int num5 = 0; num5 < tfArray3.Length; num5++)
                {
                    PointF tf1 = tfArray3[num5];
                    RectangleF ef1 = new RectangleF(tf1.X - 2f, tf1.Y - 2f, 4f, 4f);
                    if (ef1.Contains((PointF) new Point(e.X, e.Y)))
                    {
                        this.moveindex = num1;
                        if ((Control.ModifierKeys & Keys.Control) == Keys.Control || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14))
                        {
                            if (((Control.ModifierKeys & Keys.Alt) == Keys.Alt || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11)) && this.graph is Polyline && num5 > 0 && num5 < tfArray3.Length-1 && (this.mouseAreaControl.CurrentOperation != ToolOperation.Custom14))
                            {
            //								PointF[] tfs=new PointF[num5];
            //								for(int i=0;i<num5;i++)
            //								{
            //									tfs[i] = tfArray1[i];
            //								}
            //								((Polyline) this.graph).Points = tfs;
                                this.Operate = PolyOperate.Break;
                                return;
                            }
                            else
                            {
                                this.Operate = PolyOperate.Del;
                                return;
                            }
                        }
                        this.Operate = PolyOperate.MovePoint;
                        return;

                    }
                    if ((num1 - 1) >= 0)
                    {
                        path1.Reset();
                        PointF tf2 = tfArray1[num1 - 1];
                        path1.AddLine(tf2, tf1);
                        if (path1.IsOutlineVisible(new PointF((float) e.X, (float) e.Y), pen1))
                        {
                            if (((Control.ModifierKeys & Keys.Control) == Keys.Control) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom15))

                            {
                                this.Operate = PolyOperate.Add;
                            }
                            else
                            {
                                this.Operate = PolyOperate.MovePath;
                            }
                            this.insertindex = num1;
                            return;
                        }
                    }
                    if (((num1 == (tfArray1.Length - 1)) && (this.mouseAreaControl.CurrentOperation == ToolOperation.Polygon)) && (tfArray1.Length >= 3))
                    {
                        path1.Reset();
                        PointF tf3 = tfArray1[0];
                        path1.AddLine(tf3, tf1);
                        if (path1.IsOutlineVisible(new PointF((float) e.X, (float) e.Y), pen1))
                        {
                            if (((Control.ModifierKeys & Keys.Control) == Keys.Control) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11)
                                || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom12) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom13) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14))
                            {
                                this.Operate = PolyOperate.MovePath;
                            }
                            else
                            {
                                this.Operate = PolyOperate.Add;
                            }
                            this.insertindex = num1;
                            return;
                        }
                    }
                    num1++;
                }
                if (((Control.ModifierKeys & Keys.Control) == Keys.Control) || (this.mouseAreaControl.CurrentOperation == ToolOperation.ShapeTransform) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11)
                    || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom12) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom13) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom15))
                {
                    this.Operate = PolyOperate.MovePoint;
                }
                else
                {
                    this.Operate = PolyOperate.Draw;
                }

                if( this.operate==PolyOperate.Draw)
                {
                    PointF pf1 =new PointF(e.X,e.Y);

                    PointF pf2 = this.points[points.Length -1];

                    PointF pf3 = pf1;
                    if(this.graph is Polygon)
                    {
                        pf3=points[0];
                    }

                    PointF[] array1=new PointF[3]{pf2,pf1,pf3};

                    this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
                    this.win32.W32SetROP2(7);
                    this.reversePath.Reset();
                    this.reversePath.AddLines(array1);
                    this.win32.W32PolyDraw(this.reversePath);
                    this.win32.ReleaseDC();
                }
            }
            if ((e.Button != MouseButtons.Left) || !this.mousedown)
            {
                return;
            }
            this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
            this.win32.W32SetROP2(7);
            this.win32.W32PolyDraw(this.reversePath);
            this.reversePath.Reset();
            PointF tf4 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float) e.X, (float) e.Y));
            SizeF ef2 = this.mouseAreaControl.PicturePanel.GridSize;
            float single1 = ef2.Height;
            float single2 = ef2.Width;
            if (this.mouseAreaControl.PicturePanel.SnapToGrid)
            {
                int num2 = (int) ((tf4.X + (single2 / 2f)) / single2);
                int num3 = (int) ((tf4.Y + (single1 / 2f)) / single1);
                tf4 = (PointF) new Point((int) (num2 * single2), (int) (num3 * single1));
            }
            tf4 = this.mouseAreaControl.PicturePanel.PointToSystem(tf4);
            //tf4 = this.mouseAreaControl.PicturePanel.PointToView(tf4);//05-16 �޸�
            switch (this.operate)
            {
                case PolyOperate.MovePath:
                {
                    PointF[] tfArray2 = (PointF[]) this.points.Clone();
                    Matrix matrix1 = new Matrix();
                    PointF tf5 = this.mouseAreaControl.PicturePanel.PointToSystem(this.startpoint);
                    matrix1.Translate(tf4.X - tf5.X, tf4.Y - tf5.Y);
                    matrix1.TransformPoints(tfArray2);
                    if ((tfArray2.Length < 3) || !(this.graph is Polygon))
                    {
                        this.reversePath.AddLines(tfArray2);
                        break;
                    }
                    this.reversePath.AddPolygon(tfArray2);
                    break;
                }
                case PolyOperate.MovePoint:
                {
                    if ((this.moveindex >= 0) && (this.moveindex < this.points.Length))
                    {
                        if (!this.prePoint.IsEmpty)
                        {
                            this.reversePath.AddLine(this.prePoint, tf4);
                        }
                        if (!this.nextPoint.IsEmpty)
                        {
                            this.reversePath.AddLine(tf4, this.nextPoint);
                        }
                        this.reversePath.AddRectangle(new RectangleF(tf4.X - 2f, tf4.Y - 2f, 4f, 4f));
                    }
                    goto Label_04D2;
                }
                default:
                {
                    goto Label_04D2;
                }
            }
            Label_04D2:
            this.win32.W32PolyDraw(this.reversePath);
            this.win32.ReleaseDC();
        }