public void FromString(string polygonString)
        {
            string[] str = polygonString.Split('|');

            string[] s = str[0].Split('#');

            for (int j = 0; j < s.Length; j++)
            {
                Polygon2DEditor polygonEditor = new Polygon2DEditor(this.FirstPolygon);

                polygonEditor.AddPoint(ConvertPoint2DFromString(s[j]));
            }

            s = str[1].Split('#');

            for (int j = 0; j < s.Length; j++)
            {
                Polygon2DEditor polygonEditor = new Polygon2DEditor(this.LastPolygon);

                polygonEditor.AddPoint(ConvertPoint2DFromString(s[j]));
            }
        }
Ejemplo n.º 2
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            Point2D point = new Point2D(e.X, e.Y - 30);

            if (StatusController.availablePartition != OnPart(point))
            {
                StatusController.availablePartition = OnPart(point);
                this.Invalidate();
                return;
            }

            if (StatusController.isZoomView)
            {
                if (e.Button == MouseButtons.Left)
                {
                    this.MoveTimer.Start();
                    if (OnPart(point) == Partition.Left)
                    {

                        PointF midPoint = new PointF(this.ClientSize.Width / 4, this.ClientSize.Height / 2);

                        if (e.X < midPoint.X)
                        {
                            StatusController.LeftZoom.Offset.X += (float)StatusController.LeftZoom.ratio;
                        }
                        else
                        {
                            StatusController.LeftZoom.Offset.X -= (float)StatusController.LeftZoom.ratio;
                        }
                        if (e.Y < midPoint.Y)
                        {
                            StatusController.LeftZoom.Offset.Y += (float)StatusController.LeftZoom.ratio;
                        }
                        else
                        {
                            StatusController.LeftZoom.Offset.Y -= (float)StatusController.LeftZoom.ratio;
                        }

                    }
                    else
                    {
                        PointF midPoint = new PointF(3 * this.ClientSize.Width / 4, this.ClientSize.Height / 2);

                        if (e.X < midPoint.X)
                        {
                            StatusController.RightZoom.Offset.X += (float)StatusController.RightZoom.ratio;
                        }
                        else
                        {
                            StatusController.RightZoom.Offset.X -= (float)StatusController.RightZoom.ratio;
                        }

                        if (e.Y < midPoint.Y)
                        {
                            StatusController.RightZoom.Offset.Y += (float)StatusController.RightZoom.ratio;
                        }
                        else
                        {
                            StatusController.RightZoom.Offset.Y -= (float)StatusController.RightZoom.ratio;
                        }
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    this.MoveTimer.Stop();
                    StatusController.LeftZoom.ratio = 1.0;
                    StatusController.LeftZoom.Offset = new PointF(0.0F, -30.0F);

                    StatusController.RightZoom.ratio = 1.0;
                    StatusController.RightZoom.Offset = new PointF(0.0F, -30.0F);
                }
                this.Invalidate();
                return;
            }

            Polygon2DAdorner polygonAdorner = null;

            if (OnPart(point) == Partition.Left)
            {
                polygonAdorner = this.LeftPolygon;
            }
            else
            {
                point.X -= this.ClientSize.Width / 2;
                polygonAdorner = this.RightPolygon;
            }

            if (e.Button == MouseButtons.Left)
            {

                int i = polygonAdorner.HitTest(point);

                if (i == -1 && StatusController.canAddPoint)
                {
                    if (StatusController.availablePartition == Partition.Left)
                    {
                        Polygon2DEditor pe = new Polygon2DEditor(FirstPolygon);

                        pe.AddPoint(point);

                        StatusController.canRestart = false;
                    }
                    else
                    {
                        Polygon2DEditor pe = new Polygon2DEditor(this.SecondPolygon);

                        pe.AddPoint(new Point2D(point));

                        StatusController.canRestart = false;
                    }
                }

                else
                {
                    StatusController.CatchPoint = i;
                }
            }
            else
            {
                int i = polygonAdorner.HitTest(point);

                if (i != -1)
                {
                    if (StatusController.availablePartition == Partition.Left)
                    {
                        Polygon2DEditor pe = new Polygon2DEditor(this.FirstPolygon);

                        pe.RemovePoint(i);

                        StatusController.canRestart = false;
                    }
                    else
                    {
                        Polygon2DEditor pe = new Polygon2DEditor(this.SecondPolygon);

                        pe.RemovePoint(i);

                        StatusController.canRestart = false;
                    }
                }
            }
            this.Invalidate();
        }
Ejemplo n.º 3
0
        private Polygon2D BuildPolygon()
        {
            Polygon2D polygon = new Polygon2D();
            Polygon2DEditor polygonEditor = new Polygon2DEditor(polygon);
            int j = 0;

            for (int i = 0; i < this.indices.Length; i++)
            {
                this.points[j].Y = this.Reverse - this.points[j].Y + XWFParser.Margin;
                polygonEditor.AddPoint(this.points[j]);
                j = this.indices[j];
            }

            return polygon;
        }