Esempio n. 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;
                }
            }
        }
Esempio n. 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";
        }
Esempio n. 3
0
        private void AddLineAction(object sender, MouseEventArgs e)
        {
            double x;
            double y;

            if (RoundingButton.Checked)
            {
                x = Math.Round(cs1.VisualToRealX(e.X));
                y = Math.Round(cs1.VisualToRealY(e.Y));
            }
            else
            {
                x = cs1.VisualToRealX(e.X);
                y = cs1.VisualToRealY(e.Y);
            }

            if (creatingLine)
            {
                if (RoundingButton.Checked)
                {
                    selectedPoint.x = Math.Round(selectedPoint.x);
                    selectedPoint.y = Math.Round(selectedPoint.y);
                }
                selectedPoint = null;
                creatingLine  = false;
            }
            else
            {
                firstPoint = new RealPoint(x, y);
                realFigureList.Add(firstPoint);
                secondPoint = new RealPoint(x, y);
                realFigureList.Add(secondPoint);
                RealSegment rs = new RealSegment(firstPoint, secondPoint);
                realFigureList.Add(rs);
                selectedPoint = secondPoint;
                creatingLine  = true;
            }
        }
Esempio n. 4
0
 public RealIntersect(RealSegment ab, RealSegment cd)
 {
     this.ab        = ab;
     this.cd        = cd;
     intersectPoint = new RealPoint(0, 0);
 }