Ejemplo n.º 1
0
        private void canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!IsSelectable)
            {
                return;
            }
            MainCanvas.CaptureMouse();              //Capture mouse to receive events even if the pointer is outside the control

            //Start dragging:
            _draggingState.StartDragging(CanvasScoreRenderer.ConvertPoint(e.GetPosition(MainCanvas)));

            //Check if element under cursor is staff element:
            FrameworkElement element = e.OriginalSource as FrameworkElement;

            if (element == null)
            {
                return;
            }
            if (!Renderer.OwnershipDictionary.ContainsKey(element))
            {
                return;
            }

            //Set selected element:
            Select(Renderer.OwnershipDictionary[element]);
        }
Ejemplo n.º 2
0
        private void MainCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (!IsSelectable)
            {
                return;
            }
            if (!_draggingState.IsDragging || _innerScore == null)
            {
                return;
            }

            Point currentPosition = e.GetPosition(MainCanvas);
            var   strategy        = DraggingStrategy.For(SelectedElement);

            if (strategy != null)
            {
                strategy.Drag(Renderer, SelectedElement, _draggingState, CanvasScoreRenderer.ConvertPoint(currentPosition));
            }

            if (InvalidatingMode == InvalidatingModes.RedrawAllScore)
            {
                RenderOnCanvas(_innerScore);
            }
        }