Пример #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}");
            }
        }
Пример #2
0
        /// <summary>
        /// Methid for apply color for shape
        /// </summary>
        /// <param name="obj"></param>
        private void ApplyColor(object obj)
        {
            ColorsWindow colorsWindow = (ColorsWindow)obj;

            colorsWindow.DialogResult = true;
            colorsWindow.Close();
        }
Пример #3
0
        //Painting
        private void DrawClick(object obj)
        {
            Point mousePoint = Mouse.GetPosition((IInputElement)obj);

            CurrentPolyline.Stroke = Brushes.Black;
            CurrentPolyline.Points.Add(mousePoint);
            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;
            }
        }