Beispiel #1
0
        private void AddIntersectAction(object sender, MouseEventArgs e)
        {
            if (selectedSeg1 == null)
            {
                double mouseX = cs1.VisualToRealX(e.X);
                double mouseY = cs1.VisualToRealY(e.Y);
                clickPoint = new RealPoint(mouseX, mouseY);

                selectedSeg1 = (RealSegment)SelectFigure(clickPoint);
                if (selectedSeg1 != null)
                {
                    selectedSeg1.SetBackLight();
                }
                this.Text = "select first segment";
            }

            else
            {
                double mouseX = cs1.VisualToRealX(e.X);
                double mouseY = cs1.VisualToRealY(e.Y);
                clickPoint = new RealPoint(mouseX, mouseY);

                this.Text    = "select second segment";
                selectedSeg2 = (RealSegment)SelectFigure(clickPoint);
                if (selectedSeg2 != null)
                {
                    selectedSeg1.UnSetBackLight();
                    RealIntersect intersectPoint = new RealIntersect(selectedSeg1, selectedSeg2);
                    realFigureList.Add(intersectPoint);
                    selectedSeg1 = null;
                    selectedSeg2 = null;
                }
            }
        }
Beispiel #2
0
        private void MiddlePointAction(object sender, MouseEventArgs e)
        {
            double mouseX = cs1.VisualToRealX(e.X);
            double mouseY = cs1.VisualToRealY(e.Y);

            clickPoint   = new RealPoint(mouseX, mouseY);
            selectedSeg1 = SelectFigure(clickPoint) as RealSegment;
            if (selectedSeg1 != null)
            {
                selectedSeg1.SetBackLight();
                RealPoint middlePoint = new RealPoint(
                    (selectedSeg1.firstPoint.x + selectedSeg1.secondPoint.x) / 2,
                    (selectedSeg1.firstPoint.y + selectedSeg1.secondPoint.y) / 2);
                realFigureList.Add(middlePoint);
            }
            this.Text = "MiddlePointAction select first segment";
        }