Beispiel #1
0
        private void AdornerRectangle_OnPreviewMouseMove(object sender, MouseEventArgs e)
        {
            if (_istextboxEditing)
            {
                return;
            }

            if (IsDrawing && e.LeftButton == MouseButtonState.Pressed)
            {
                AdornerRectangle.CaptureMouse();

                Point mousePoint = new Point(Mouse.GetPosition(AdornerRectangle).X, Mouse.GetPosition(AdornerRectangle).Y);

                if (_selectedElement != null)
                {
                    MoveElement(_selectedElement, mousePoint);
                    return;
                }

                if (rectbtn.IsChecked.HasValue && rectbtn.IsChecked.Value)
                {
                    DrawRect(mousePoint);
                }

                if (criclebtn.IsChecked.HasValue && criclebtn.IsChecked.Value)
                {
                    DrawEllipse(mousePoint);
                }

                if (penbtn.IsChecked.HasValue && penbtn.IsChecked.Value)
                {
                    DrawPath(mousePoint);
                }
            }
        }
Beispiel #2
0
        private void AdornerRectangle_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            AdornerRectangle.Focus();
            if (IsDrawing)
            {
                Point mousePoint = e.GetPosition(AdornerRectangle);

                //_selectedElement = AdornerRectangle.Children.Cast<UIElement>().FirstOrDefault(x =>
                //     x.TransformToVisual(AdornerRectangle)
                //        .TransformBounds(new Rect(x.RenderSize)).Contains(mousePoint));

                if (_selectedElement != null)
                {
                    return;
                }

                if (rectbtn.IsChecked.HasValue && rectbtn.IsChecked.Value)
                {
                    InitRect();
                }
                else if (criclebtn.IsChecked.HasValue && criclebtn.IsChecked.Value)
                {
                    InitCricle();
                }
                else if (penbtn.IsChecked.HasValue && penbtn.IsChecked.Value)
                {
                    InitPen();
                }
                else if (textbtn.IsChecked.HasValue && textbtn.IsChecked.Value)
                {
                    InitTextbox(mousePoint);
                }
            }
        }
Beispiel #3
0
 private void AdornerRectangle_OnPreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     _selectedElement = null;
     drawingRect      = null;
     drawingEllipse   = null;
     drawingPolyline  = null;
     UpdateUndoBtnEnable();
     AdornerRectangle.ReleaseMouseCapture();
 }