Esempio n. 1
0
        private void MainFormPctrbxScreen_MouseMove(Object sender, MouseEventArgs e)
        {
            Point mouseLocation = e.Location;

            MainFormSttsstpLblMouseX.Text = mouseLocation.X.ToString().PadLeft(3);
            MainFormSttsstpLblMouseY.Text = mouseLocation.Y.ToString().PadLeft(3);

            code.AddSoftPoint(e.Location);

            #region Snap
            if (myCursor.IsSnapped)
            {
                myCursor.ContinueSnap(ControlPointToScreen(e.Location, MainFromPctrbxScreen));
            }
            else
            {
                if (e.Button == MouseButtons.None)
                {
                    Int32 figCount = code.GetFiguresCount();
                    if (figCount != 0)
                    {
                        PointF vetrex = code.FindNearestVertex(e.Location);
                        //Привязка считается в отображаемых пикселях
                        ConvertRealCoordToPx(vetrex, out Point vetrexPx);
                        Single distance = MyFigure.FindLength(vetrexPx, e.Location);
                        if (distance < snapDistancePx)
                        {
                            Int32 x     = (Int32)Math.Round(vetrex.X);
                            Int32 y     = (Int32)Math.Round(vetrex.Y);
                            Point point = ControlPointToScreen(new Point(x, y), MainFromPctrbxScreen);
                            myCursor.DoSnap(point);
                            //У кода - координаты реальные.
                            code.AddSnapPoint(new Point(x, y));
                        }
                    }
                }
            }
            #endregion
        }
 public static String GetDescription(MyFigure _myFigure)
 {
     //???Всё-таки мне пригодился конвертер. Смотрится не очень. Стоит ли внедрить
     //FiguresEnum в MyFigure?
     if (_myFigure is MyCircle)
     {
         return(Figure.Circle.GetDescription());
     }
     else
     if (_myFigure is MyRectangle)
     {
         return(Figure.Rectangle.GetDescription());
     }
     else if (_myFigure is MyCut)
     {
         return(Figure.Cut.GetDescription());
     }
     else
     {
         throw new Exception($"Для фигуры {_myFigure} не реализовано описание");
     }
 }
Esempio n. 3
0
 public ListBoxFigure(MyFigure _object)
 {
     Id            = _object.Id;
     DisplayMember = $"[{_object.X},{_object.Y}]".PadRight(10) + _object.GetDescription();
 }