예제 #1
0
        /// <summary>
        /// Event raised when the user presses down the left mouse-button.
        /// </summary>
        private void Control_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //If we already are doing an operation, don't start another
            if (currentMouseOperation != MouseOperation.None)
            {
                return;
            }

            bool doMouseMovePrep = false;

            if (e.ChangedButton == MouseButton.Middle)
            {
                prePanTimerangeStart = TimeRangeStart;
                prePanTimerangeEnd   = TimeRangeEnd;
                if (Keyboard.IsKeyDown(Key.LeftCtrl))
                {
                    //System.Diagnostics.Debug.WriteLine("Resize");
                    currentMouseOperation = MouseOperation.Resize;
                }
                else
                {
                    currentMouseOperation = MouseOperation.Pan;
                    //System.Diagnostics.Debug.WriteLine("Pan");
                }
                doMouseMovePrep = true;
            }
            else if (e.ChangedButton == MouseButton.Left)
            {
                //
                //  Clear selection immediately when starting drag selection.
                //
                listBox.SelectedItems.Clear();

                isLeftMouseButtonDownOnCanvas = true;
                origMouseDownPoint            = e.GetPosition(GridContainer);

                currentMouseOperation = MouseOperation.Select;
                doMouseMovePrep       = true;
            }

            if (doMouseMovePrep)
            {
                origMouseDownPoint = e.GetPosition(GridContainer);
                GridContainer.CaptureMouse();
                listBox.Focus();
                Keyboard.Focus(listBox);
                e.Handled = true;
            }
        }