Exemple #1
0
        private void DrawCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            var p = CoordHelper.TranslateFromMouse(CanvasWrapper.Config,
                                                   e.GetPosition(drawCanvas).X,
                                                   e.GetPosition(drawCanvas).Y);

            var xps = string.Format("{0:0.###}", p.ValueX);
            var yps = string.Format("{0:0.###}", p.ValueY);

            UpdateStatus("POINT: (" + xps + ", " + yps + ")");
        }
Exemple #2
0
        private void DrawCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            CanvasPoint p = CoordHelper.TranslateFromMouse(CanvasWrapper.Config, e.GetPosition(drawCanvas).X, e.GetPosition(drawCanvas).Y);

            if (activeMode == TOOL_MODE_POINT)
            {
                EventBus.Publish(new InputPointSelected(p.DotIndexLeft, p.DotIndexTop, p.ValueX, p.ValueY));
                CanvasWrapper.AddInputPoint(p.DotIndexLeft, p.DotIndexTop, p.ValueX, p.ValueY);
                demo.Points.Add(new Vector {
                    X = p.ValueX, Y = p.ValueY, Alternates = new CanvasPoint {
                        DotIndexLeft = p.DotIndexLeft, DotIndexTop = p.DotIndexTop
                    }
                });
                return;
            }

            if (activeMode == TOOL_MODE_LINE)
            {
                if (pointsSelected == 0)
                {
                    point1_xi = p.DotIndexLeft;
                    point1_yi = p.DotIndexTop;
                    pointsSelected++;
                }
                else if (pointsSelected == 1)
                {
                    pointsSelected++;
                    point2_xi = p.DotIndexLeft;
                    point2_yi = p.DotIndexTop;
                    CompleteLine();
                }
            }

            if (activeMode == TOOL_MODE_POLYGON)
            {
                if (pointsSelected == 0)
                {
                    point1_xi = p.DotIndexLeft;
                    point1_yi = p.DotIndexTop;
                    pointsSelected++;
                }
                else if (pointsSelected == 1)
                {
                    pointsSelected++;
                    point2_xi = p.DotIndexLeft;
                    point2_yi = p.DotIndexTop;
                    AddPolygonLine();
                }
                else if (pointsSelected >= 2)
                {
                    pointsSelected++;

                    // last end point becomes new start point
                    point1_xi = point2_xi;
                    point1_yi = point2_yi;
                    point2_xi = p.DotIndexLeft;
                    point2_yi = p.DotIndexTop;

                    AddPolygonLine();
                }
            }
        }