Ejemplo n.º 1
0
        private void NormalPartOfUpdateMultPointGraphics(CGUserGraphicsLine pline)
        {
            if (NormalPartOfUpdateTwoPointGraphics(pline))
            {
                polygonEdgeSet.Remove(oldEdgeLineOfPolygon);
            }

            oldEdgeLineOfPolygon = pline;
            polygonEdgeSet.Add(pline);
        }
Ejemplo n.º 2
0
        private void MainWindow_RightMouseDown(object sender, MouseEventArgs e)
        {
            // note: the order of each event when double clicked
            //       down -> up -> down -> dbclick -> up

            if (buttonClicked == this.buttonDrawPolygon)
            {
                // log.write("mouse double click");

                if (polygonEdgeSet.Count == 0)
                {
                    return;
                }

                int dx = e.X - polygonEdgeSet[0].firstPoint.X;
                int dy = e.Y - polygonEdgeSet[0].firstPoint.Y;

                if (dx * dx + dy * dy > 3 * 3)
                {
                    CGUserGraphicsLine pline = new CGUserGraphicsLine(new Point(e.X, e.Y), polygonEdgeSet[0].firstPoint);
                    userCanvas.AddGraphics(pline);
                    polygonEdgeSet.Add(pline);
                }

                mouseState = CGMouseState.CGMouseStateUp;
                // log.write("canUpdateGraphics --> false");
                canUpdateGraphics = false;

                isUpdatingGraphicsWhenMouseUp = false;

                userCanvas.ClearStateOfSelectedGraphics();

                polygonEdgeSet.ForEach((l) => { userCanvas.RemoveGraphics(l); });

                CGUserGraphicsPolygon polygon = new CGUserGraphicsPolygon(polygonEdgeSet);
                userCanvas.AddGraphics(polygon);
                userCanvas.SetGraphicsSelected(polygon);

                ghs.DrawImage(userCanvas.bmp, this.ClientRectangle);
                polygonEdgeSet.Clear();
            }
            else if (buttonClicked == this.buttonDrawBezier)
            {
                if (polygonEdgeSet.Count <= 1)
                {
                    return;
                }

                if (oldSelectedCurve != null)
                {
                    userCanvas.RemoveGraphics(oldSelectedCurve);
                    oldSelectedCurve = null;
                }

                int dx = e.X - polygonEdgeSet[0].firstPoint.X;
                int dy = e.Y - polygonEdgeSet[0].firstPoint.Y;

                List <Point> downPointSet = new List <Point>();

                foreach (CGUserGraphicsLine l in polygonEdgeSet)
                {
                    downPointSet.Add(l.firstPoint);
                }

                if (dx * dx + dy * dy < 3 * 3)
                {
                    downPointSet.Add(polygonEdgeSet[0].firstPoint);
                }
                else
                {
                    downPointSet.Add(polygonEdgeSet[polygonEdgeSet.Count - 1].nextPoint);
                }

                mouseState = CGMouseState.CGMouseStateUp;
                // log.write("canUpdateGraphics --> false");
                canUpdateGraphics = false;

                isUpdatingGraphicsWhenMouseUp = false;

                userCanvas.ClearStateOfSelectedGraphics();

                polygonEdgeSet.ForEach((l) => { userCanvas.RemoveGraphics(l); });
                polygonEdgeSet.Clear();

                CGUserGraphicsBezier curve = new CGUserGraphicsBezier(downPointSet);

                userCanvas.AddGraphics(curve);
                userCanvas.SetGraphicsSelected(curve);

                ghs.DrawImage(userCanvas.bmp, this.ClientRectangle);

                downPointSet.Clear();
            }
            else if (buttonClicked == this.buttonDrawBStyleCurve)
            {
                if (polygonEdgeSet.Count <= 1)
                {
                    return;
                }

                if (oldSelectedCurve != null)
                {
                    userCanvas.RemoveGraphics(oldSelectedCurve);
                    oldSelectedCurve = null;
                }

                int dx = e.X - polygonEdgeSet[0].firstPoint.X;
                int dy = e.Y - polygonEdgeSet[0].firstPoint.Y;

                List <Point> downPointSet = new List <Point>();

                foreach (CGUserGraphicsLine l in polygonEdgeSet)
                {
                    downPointSet.Add(l.firstPoint);
                }

                if (dx * dx + dy * dy < 3 * 3)
                {
                    downPointSet.Add(polygonEdgeSet[0].firstPoint);
                }
                else
                {
                    downPointSet.Add(polygonEdgeSet[polygonEdgeSet.Count - 1].nextPoint);
                }

                mouseState = CGMouseState.CGMouseStateUp;
                // log.write("canUpdateGraphics --> false");
                canUpdateGraphics = false;

                isUpdatingGraphicsWhenMouseUp = false;

                userCanvas.ClearStateOfSelectedGraphics();

                polygonEdgeSet.ForEach((l) => { userCanvas.RemoveGraphics(l); });
                polygonEdgeSet.Clear();

                CGUserGraphicsBStyleCurve curve = new CGUserGraphicsBStyleCurve(downPointSet);

                userCanvas.AddGraphics(curve);
                userCanvas.SetGraphicsSelected(curve);

                ghs.DrawImage(userCanvas.bmp, this.ClientRectangle);

                downPointSet.Clear();
            }
            else if (buttonClicked == this.buttonRotation ||
                     buttonClicked == this.buttonZoomGraphics)
            {
                userCanvas.SetBasePoint(new Point(e.X, e.Y));

                ghs.DrawImage(userCanvas.bmp, this.ClientRectangle);
            }
        }