Ejemplo n.º 1
0
        private void MainImage_PointerPressed(object sender, PointerPressedEventArgs e)
        {
            PointerPoint p = e.GetCurrentPoint(_mainImageControl);

            if (_pointerPos != p.Position)
            {
                return;
            }
            // _gridDrawer.SetCursor already called from OnMouseMove

            if (p.Properties.IsLeftButtonPressed)
            {
                // Get tempered note
                SomeInterval t = null;
                if (e.KeyModifiers.HasFlag(KeyModifiers.Alt))   // by cents
                {
                    float c = _gridDrawer.GetCursorCents();
                    t = new SomeInterval {
                        cents = c
                    };
                }
                else     // nearest rational
                {
                    _gridDrawer.UpdateCursorItem();
                    Rational r = _gridDrawer.GetCursorRational();
                    if (!r.IsDefault())
                    {
                        t = new SomeInterval {
                            rational = r
                        };
                    }
                }
                if (t != null)
                {
                    // Toggle selection
                    if (e.KeyModifiers.HasFlag(KeyModifiers.Control))
                    {
                        ToggleSelection(t);
                        //!!! invalidate image
                    }
                    // Play note
                    else
                    {
                        PlayNote(t);
                    }
                }
            }
            else if (p.Properties.IsMiddleButtonPressed)
            {
                _pointerPosDrag = _pointerPos;
            }
        }