Esempio n. 1
0
        private void canvas_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (_primitivePoints != null)
            {
                _primitivePoints.Add(e.Location);
                _primitiveDrawer.Draw(_canvasGraphics, _drawingPen, _primitivePoints, _canvas);
            }

            var pointLocationFinder  = PointLocationFinder.GetInstance();
            var pointPositionMessage = _primitive switch
            {
                Polygon polygon when(button9.Focused || button10.Focused)
                => pointLocationFinder.GetPointPosition(polygon, e.Location).ToString(),
                Edge edge when button11.Focused
                => pointLocationFinder.GetPointDirection(edge, e.Location).ToString(),
                _ => null
            };

            if (!string.IsNullOrWhiteSpace(pointPositionMessage))
            {
                MessageBox.Show(pointPositionMessage);
            }
        }