Example #1
0
        /// <summary>
        /// Method for painting shape
        /// </summary>
        /// <param name="obj"></param>
        private void DrawClick(object obj)
        {
            try
            {
                Point mousePoint = Mouse.GetPosition((IInputElement)obj);
                CurrentPolyline.Stroke = Brushes.Black;
                CurrentPolyline.Points.Add(mousePoint);
                NewPointAdded?.Invoke();
                if (EndDrawing && CurrentPolyline.Points.Count >= 2)
                {
                    ColorsWindow colorWin = new ColorsWindow(this);
                    if (colorWin.ShowDialog() == true)
                    {
                        CurrentPolyline.Stroke = new SolidColorBrush(CurrentColor);
                    }
                    CurrentPolyline.Name = String.Format("Polyline_{0}", Polylines.Count + 1);
                    Polylines.Add(CurrentPolyline);
                    CurrentPolyline = new Polyline();
                    OnPropertyChanged("Polylines");
                    CountEdges = 0;
                    EndDrawing = false;

                    JustDrawn?.Invoke();
                }
                if (EndDrawing && CurrentPolyline.Points.Count < 2)
                {
                    throw new InvalidOperationException("Not enough points");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show($"Error: {e.Message}");
            }
        }
Example #2
0
 protected virtual void OnNewPointAdded()
 {
     NewPointAdded?.Invoke(this, EventArgs.Empty);
 }