public void MouseDown(Vector2 position)
        {
            MouseDownPosition = position;
            MouseClickDown();

            if (IsPressed("d"))
            {
                DeleteAt?.Invoke(this, position);
                KeyPressed = null;
            }
            else if (IsPressed("c"))
            {
                CreateAt?.Invoke(this, position);
            }
            else if (IsPressed("p"))
            {
                AddPoint?.Invoke(this, position);
            }
            else
            {
                SelectAt?.Invoke(this, position);
            }

            LastMousePosition = position;
        }
Пример #2
0
 private void OnPlusButtonClicked(AttributeRow row)
 {
     if (Input.GetKey(KeyCode.LeftShift))
     {
         AddMultiplePoints?.Invoke(row.Attribute);
     }
     else
     {
         AddPoint?.Invoke(row.Attribute);
     }
 }
Пример #3
0
        public TrackViewer(GCodeCollector code)
        {
            InitializeComponent();
            Code = code;

            zoomSlider.ValueChanged                  += OnSliderValueChanged;
            scrollViewer.ScrollChanged               += OnScrollViewerScrollChanged;
            scrollViewer.MouseMove                   += Vaszon_MouseMove;
            scrollViewer.PreviewMouseRightButtonUp   += OnMouseRightButtonUp;
            scrollViewer.PreviewMouseRightButtonDown += OnMouseRightButtonDown;
            scrollViewer.PreviewMouseWheel           += OnPreviewMouseWheel;


            RemoveBtn.Click += (s, e) =>
            {
                RemovePoint?.Invoke(_p - 1);
                SetPosition(_p);
            };

            Vaszon.MouseUp += (s, e) =>
            {
                if (!Keyboard.IsKeyDown(Key.LeftCtrl))
                {
                    return;
                }
                System.Windows.Point currentPosition = e.GetPosition(Vaszon);

                currentPosition.X -= ShiftView.X;
                currentPosition.Y -= ShiftView.Y;

                AddPoint?.Invoke(_p, currentPosition);

                var line = Vaszon.Children[Vaszon.Children.Count - 2] as Line;

                SetPosition(_p + 1);
            };

            jelolo                 = new Ellipse();
            jelolo.Fill            = Brushes.Yellow;
            jelolo.Stroke          = Brushes.Black;
            jelolo.Width           = 1;
            jelolo.Height          = 1;
            jelolo.StrokeThickness = 0.2;
            jelolo.MouseEnter     += (s, e) => { Mouse.OverrideCursor = Cursors.Hand; };
            jelolo.MouseLeave     += (s, e) => { Mouse.OverrideCursor = null; };

            jelolo.MouseDown += (s, e) =>
            {
                mozog = true;
                jelolo.CaptureMouse();
            };
            jelolo.MouseUp += (s, e) =>
            {
                mozog = false;
                jelolo.ReleaseMouseCapture();
            };
            jelolo.MouseMove += (s, e) =>
            {
                if (!mozog)
                {
                    return;
                }
                System.Windows.Point currentPosition = e.GetPosition(Vaszon);



                Canvas.SetLeft(jelolo, currentPosition.X - jelolo.Width / 2);
                Canvas.SetTop(jelolo, currentPosition.Y - jelolo.Height / 2);

                var line = Vaszon.Children[Vaszon.Children.Count - 2] as Line;

                line.X2 = currentPosition.X;
                line.Y2 = currentPosition.Y;

                var l = line.DataContext as GCodeLine;
                currentPosition.X -= ShiftView.X;
                currentPosition.Y -= ShiftView.Y;
                l.x = currentPosition.X;
                l.y = currentPosition.Y;
            };
        }