コード例 #1
0
ファイル: Mirror.cs プロジェクト: hotab/OpticalBuilder
        public Mirror(string Name, SystemCoordinates Center, Angle Anglee, DoubleExtention Length)
        {
            angle       = Anglee;
            name        = Name;
            coordinates = Center;
            length      = Length;

            if (((DoubleExtention)angle != (DoubleExtention)90) && ((DoubleExtention)angle != (DoubleExtention)270))
            {
                DoubleExtention y = Center.X * angle.tg();
                DoubleExtention b = Center.Y - y;
                ToDraw           = new Line(angle.tg(), b); ToDraw.AngleForOnePointLines = angle;
                ToDraw.FirstEnd  = new SystemCoordinates((length / 2) * angle.cos() + Center.X, (length / 2) * angle.sin() + Center.Y);
                ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
            }
            else
            {
                ToDraw = new Line(Center.X);
                if ((DoubleExtention)angle == (DoubleExtention)90)
                {
                    ToDraw.FirstEnd  = new SystemCoordinates(Center.X, Center.Y + length / 2); ToDraw.AngleForOnePointLines = angle;
                    ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
                }
                if ((DoubleExtention)angle == (DoubleExtention)270)
                {
                    ToDraw.FirstEnd  = new SystemCoordinates(Center.X, Center.Y - length / 2); ToDraw.AngleForOnePointLines = angle;
                    ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
                }
            }
        }
コード例 #2
0
ファイル: Mirror.cs プロジェクト: hotab/OpticalBuilder
        public Mirror(string SaveStr)
        {
            string[] splitted = SaveStr.Split('^');
            if (splitted.Length != 7)
            {
                throw new OpticalBuilderLib.Exceptions.ErrorWhileReading();
            }
            try
            {
                string            Name   = splitted[1];
                SystemCoordinates Center = new SystemCoordinates(Convert.ToDouble(splitted[2]), Convert.ToDouble(splitted[3]));
                Angle             Anglee = Convert.ToDouble(splitted[4]);
                DoubleExtention   Length = Convert.ToDouble(splitted[5]);
                id          = Convert.ToInt32(splitted[6]);
                angle       = Anglee;
                name        = Name;
                coordinates = Center;
                length      = Length;
                if (((DoubleExtention)angle != (DoubleExtention)90) && ((DoubleExtention)angle != (DoubleExtention)270))
                {
                    DoubleExtention y = Center.X * angle.tg();
                    DoubleExtention b = Center.Y - y;
                    ToDraw = new Line(angle.tg(), b);
                }
                else
                {
                    ToDraw = new Line(Center.X);
                }
                if (((DoubleExtention)angle != (DoubleExtention)90) && ((DoubleExtention)angle != (DoubleExtention)270))
                {
                    DoubleExtention y = Center.X * angle.tg();
                    DoubleExtention b = Center.Y - y;
                    ToDraw           = new Line(angle.tg(), b);
                    ToDraw.FirstEnd  = new SystemCoordinates((length / 2) * angle.cos() + Center.X, (length / 2) * angle.sin() + Center.Y);
                    ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
                }
                else
                {
                    ToDraw = new Line(Center.X);
                    if ((DoubleExtention)angle == (DoubleExtention)90)
                    {
                        ToDraw.FirstEnd  = new SystemCoordinates(Center.X, Center.Y + length / 2);
                        ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
                    }
                    if ((DoubleExtention)angle == (DoubleExtention)270)
                    {
                        ToDraw.FirstEnd  = new SystemCoordinates(Center.X, Center.Y - length / 2);
                        ToDraw.SecondEnd = Center.BuildPointReflection(ToDraw.FirstEnd);
                    }
                }

                ToDraw.AngleForOnePointLines = angle;
            }
            catch
            {
                throw new OpticalBuilderLib.Exceptions.ErrorWhileReading();
            }
        }
コード例 #3
0
        public override void Draw(Point cursorCoordinates)
        {
            SystemCoordinates pp1  = CoordinateSystem.Instance.Converter(p1);
            SystemCoordinates curs = CoordinateSystem.Instance.Converter(cursorCoordinates);

            if (counter == 0)
            {
                OGL.DrawFilledCircle(new Pen(Color.Yellow), cursorCoordinates, 10);
            }
            if (counter == 1)
            {
                if (control_modifier == false)
                {
                    if (alt_modifier == true)
                    {
                        pp1 = pp1.BuildPointReflection(curs);
                    }
                    Line x = new Line(pp1,
                                      curs, false);
                    x.BuildAngle();
                    if (cursorCoordinates != p1)
                    {
                        MirrorDrawer.Draw(x.AngleForOnePointLines, pp1, curs);
                        OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 10);
                    }
                }
                else
                {
                    if (alt_modifier == true)
                    {
                        pp1 = pp1.BuildPointReflection(curs);
                    }
                    Line x = new Line(curs,
                                      pp1, false);
                    x.BuildAngle();
                    if (cursorCoordinates != p1)
                    {
                        MirrorDrawer.Draw(x.AngleForOnePointLines, curs, pp1);
                        OGL.DrawFilledCircle(new Pen(Color.Yellow), p1, 10);
                    }
                }
            }
            if (counter == 2)
            {
                MirrorDrawer.Draw(x.AngleForOnePointLines, x);
            }
        }