private void MainForm_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
                g.Clear(Color.White);
            else
            if (A == null) {
                g.Clear(Color.White);
                A = new Point(e.X, formHeight - e.Y);
                A.Paint(g, APen, formHeight);
            }
            else
            if (B == null)
            {
                B = new Point(e.X, formHeight - e.Y);
                B.Paint(g, BPen, formHeight);
                g.DrawLine(defaultLinePen, (int)A.X, formHeight - (int)A.Y, (int)B.X, formHeight - (int)B.Y);
            }
            else
            if(C == null)
            {
                C = new Point(e.X, formHeight - e.Y);
                C.Paint(g, CPen, formHeight);
                g.DrawLine(defaultLinePen, (int)C.X, formHeight - (int)C.Y, (int)B.X, formHeight - (int)B.Y);
                g.DrawLine(defaultLinePen, (int)A.X, formHeight - (int)A.Y, (int)C.X, formHeight - (int)C.Y);
            }
            else
            if (A_ == null)
            {
                A_ = new Point(e.X, formHeight - e.Y);
                A_.Paint(g, APen, formHeight);
            }
            else
            if (B_ == null)
            {
                B_ = new Point(e.X, formHeight - e.Y);
                B_.Paint(g, BPen, formHeight);
                g.DrawLine(defaultLinePen, (int)A_.X, formHeight - (int)A_.Y, (int)B_.X, formHeight - (int)B_.Y);
            }
            else
                if (C_ == null)
                {
                    C_ = new Point(e.X, formHeight - e.Y);
                    C_.Paint(g, CPen, formHeight);
                    g.DrawLine(defaultLinePen, (int)C_.X, formHeight - (int)C_.Y, (int)B_.X, formHeight - (int)B_.Y);
                    g.DrawLine(defaultLinePen, (int)A_.X, formHeight - (int)A_.Y, (int)C_.X, formHeight - (int)C_.Y);
                }
                else
                {
                    Triangle ABC = new Triangle(A, B, C);

                    Triangle ABC_ = new Triangle(A_, B_, C_);

                    ConversionOperator co = new ConversionOperator(ABC_, ABC, !CanRenamePoints.Checked, CanReflect.Checked);

                    ABC_.getTransformation(co.dx, co.dy, co.phi).Paint(g, new Pen(Color.LimeGreen, 3), new Pen(Color.Red, 3), formHeight);

                    A = null;
                    B = null;
                    C = null;
                    A_ = null;
                    B_ = null;
                    C_ = null;
                }
        }
示例#2
0
        private void MainForm_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                g.Clear(Color.White);
            }
            else
            if (A == null)
            {
                g.Clear(Color.White);
                A = new Point(e.X, formHeight - e.Y);
                A.Paint(g, APen, formHeight);
            }
            else
            if (B == null)
            {
                B = new Point(e.X, formHeight - e.Y);
                B.Paint(g, BPen, formHeight);
                g.DrawLine(defaultLinePen, (int)A.X, formHeight - (int)A.Y, (int)B.X, formHeight - (int)B.Y);
            }
            else
            if (C == null)
            {
                C = new Point(e.X, formHeight - e.Y);
                C.Paint(g, CPen, formHeight);
                g.DrawLine(defaultLinePen, (int)C.X, formHeight - (int)C.Y, (int)B.X, formHeight - (int)B.Y);
                g.DrawLine(defaultLinePen, (int)A.X, formHeight - (int)A.Y, (int)C.X, formHeight - (int)C.Y);
            }
            else
            if (A_ == null)
            {
                A_ = new Point(e.X, formHeight - e.Y);
                A_.Paint(g, APen, formHeight);
            }
            else
            if (B_ == null)
            {
                B_ = new Point(e.X, formHeight - e.Y);
                B_.Paint(g, BPen, formHeight);
                g.DrawLine(defaultLinePen, (int)A_.X, formHeight - (int)A_.Y, (int)B_.X, formHeight - (int)B_.Y);
            }
            else
            if (C_ == null)
            {
                C_ = new Point(e.X, formHeight - e.Y);
                C_.Paint(g, CPen, formHeight);
                g.DrawLine(defaultLinePen, (int)C_.X, formHeight - (int)C_.Y, (int)B_.X, formHeight - (int)B_.Y);
                g.DrawLine(defaultLinePen, (int)A_.X, formHeight - (int)A_.Y, (int)C_.X, formHeight - (int)C_.Y);
            }
            else
            {
                Triangle ABC = new Triangle(A, B, C);

                Triangle ABC_ = new Triangle(A_, B_, C_);

                ConversionOperator co = new ConversionOperator(ABC_, ABC, !CanRenamePoints.Checked, CanReflect.Checked);

                ABC_.getTransformation(co.dx, co.dy, co.phi).Paint(g, new Pen(Color.LimeGreen, 3), new Pen(Color.Red, 3), formHeight);

                A  = null;
                B  = null;
                C  = null;
                A_ = null;
                B_ = null;
                C_ = null;
            }
        }