Ejemplo n.º 1
0
 public static IObservable <MouseButtonEventArgs> MouseDown(this DependencyObject that)
 {
     return(Observable.FromEvent <MouseButtonEventArgs>(
                on => Mouse.AddMouseDownHandler(that, (o, e) => on(e)),
                on => Mouse.RemoveMouseDownHandler(that, (o, e) => on(e))
                ));
 }
Ejemplo n.º 2
0
        public InputDeviceHelper(DependencyObject context)
        {
            if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA)
            {
                throw new InvalidOperationException("The calling thread must be STA!");
            }

            Dispatcher = Dispatcher.CurrentDispatcher;

            var keys = Enum.GetValues(typeof(Key)).Cast <Key>().ToArray();

            _kbState = new Dictionary <Key, bool>(keys.Length);
            foreach (var key in keys)
            {
                _kbState[key] = false;
            }

            var mouseButtons = Enum.GetValues(typeof(MouseButton)).Cast <MouseButton>().ToArray();

            _mbState = new Dictionary <MouseButton, bool>(mouseButtons.Length);
            foreach (var button in mouseButtons)
            {
                _mbState[button] = false;
            }

            Keyboard.AddKeyUpHandler(context, OnKeyStateChanged);
            Keyboard.AddKeyDownHandler(context, OnKeyStateChanged);
            Keyboard.AddLostKeyboardFocusHandler(context, OnKeyboardFocusChanged);
            Mouse.AddMouseUpHandler(context, OnMouseButtonStateChanged);
            Mouse.AddMouseDownHandler(context, OnMouseButtonStateChanged);
        }
Ejemplo n.º 3
0
        protected override void OnPlotterAttached(Plotter plotter)
        {
            base.OnPlotterAttached(plotter);

            Mouse.AddMouseDownHandler(Parent, OnMouseDown);
            Mouse.AddMouseMoveHandler(Parent, OnMouseMove);
            Mouse.AddMouseUpHandler(Parent, OnMouseUp);
            Mouse.AddMouseWheelHandler(Parent, OnMouseWheel);
        }
Ejemplo n.º 4
0
        public void SetToolType(DrawToolType type)
        {
            Mouse.RemoveMouseDownHandler(this.DrawCanvas, this.polylineToolMouseDown);
            Mouse.RemoveMouseUpHandler(this, this.polylineToolMouseUp);
            Mouse.RemoveMouseMoveHandler(this, this.polylineToolMouseMove);
            this.DrawCanvas.Cursor = null;
            this.lastShape         = null;
            this.ToolType          = type;

            Mouse.AddMouseDownHandler(this.DrawCanvas, this.polylineToolMouseDown);
            Mouse.AddMouseUpHandler(this, this.polylineToolMouseUp);
            Mouse.AddMouseMoveHandler(this, this.polylineToolMouseMove);
            this.DrawCanvas.Cursor = Cursors.Cross;
        }
Ejemplo n.º 5
0
        protected override void OnViewportChanged()
        {
            base.OnViewportChanged();

            //Mouse.AddPreviewMouseDownHandler(Parent, (MouseButtonEventHandler)OnMouseDown);
            //Mouse.AddPreviewMouseMoveHandler(Parent, (MouseEventHandler)OnMouseMove);
            //Mouse.AddPreviewMouseUpHandler(Parent, (MouseButtonEventHandler)OnMouseUp);

            Mouse.AddMouseDownHandler(Parent, OnMouseDown);
            Mouse.AddMouseMoveHandler(Parent, OnMouseMove);
            Mouse.AddMouseUpHandler(Parent, OnMouseUp);

            Mouse.AddMouseWheelHandler(Parent, OnMouseWheel);
        }
Ejemplo n.º 6
0
 public virtual void AddHandler()
 {
     Mouse.AddMouseDownHandler(this.CurrentWindow.pictureBox, MouseDownHandler);
     Mouse.AddMouseUpHandler(this.CurrentWindow.pictureBox, MouseUpHandler);
     Mouse.AddMouseMoveHandler(this.CurrentWindow.pictureBox, MouseMoveHandler);
 }
Ejemplo n.º 7
0
 public virtual void ConnectHandle()
 {
     Mouse.AddMouseDownHandler(this.CurrentWindow.Canvas, MouseDownHandle);
     Mouse.AddMouseUpHandler(this.CurrentWindow.Canvas, MouseUpHandle);
     Mouse.AddMouseMoveHandler(this.CurrentWindow.Canvas, MouseMoveHandler);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Отвязка и привязка событий к мыше и клавиатуре в зависимости от выбранного типа интрумента
        /// </summary>
        public void SetToolType(DrawToolType type)
        {
            switch (this.ToolType)
            {
            case DrawToolType.Pointer:
                Mouse.RemoveMouseDownHandler(this.window, this.toolMouseDown);
                Mouse.RemoveMouseUpHandler(this.window, this.toolMouseUp);
                Mouse.RemoveMouseMoveHandler(this.window, this.toolMouseMove);
                Keyboard.RemoveKeyDownHandler(this.window, this.toolKeyDown);
                Keyboard.RemoveKeyUpHandler(this.window, this.toolKeyUp);
                Mouse.RemoveMouseDownHandler(this.dotsControl, this.dotsControl_MouseDown);
                Mouse.RemoveMouseUpHandler(this.dotsControl, this.dotsControl_MouseUp);
                Mouse.RemoveMouseMoveHandler(this.dotsControl, this.dotsControl_MouseMove);
                this.selectShapes(null);
                break;

            case DrawToolType.Polyline:
                Mouse.RemoveMouseDownHandler(this.canvas, this.polylineToolMouseDown);
                Mouse.RemoveMouseUpHandler(this.window, this.polylineToolMouseUp);
                Mouse.RemoveMouseMoveHandler(this.window, this.polylineToolMouseMove);
                this.canvas.Cursor = null;
                this.lastShape     = null;
                break;

            case DrawToolType.Rectangle:
                Mouse.RemoveMouseDownHandler(this.canvas, this.rectangleToolMouseDown);
                Mouse.RemoveMouseUpHandler(this.window, this.rectangleToolMouseMouseUp);
                Mouse.RemoveMouseMoveHandler(this.window, this.rectangleToolMouseMove);
                this.canvas.Cursor = null;
                this.lastShape     = null;
                break;

            case DrawToolType.Delete:
                Mouse.RemoveMouseDownHandler(this.canvas, this.deleteToolMouseDown);
                Mouse.RemoveMouseMoveHandler(this.window, this.deleteToolMouseMove);
                if (this.lastShape != null)
                {
                    this.lastShape.SetDeletingStyle(false);
                    this.lastShape = null;
                }
                break;
            }

            this.ToolType = type;

            switch (this.ToolType)
            {
            case DrawToolType.Pointer:
                Mouse.AddMouseDownHandler(this.dotsControl, this.dotsControl_MouseDown);
                Mouse.AddMouseUpHandler(this.dotsControl, this.dotsControl_MouseUp);
                Mouse.AddMouseDownHandler(this.window, this.toolMouseDown);
                Mouse.AddMouseUpHandler(this.window, this.toolMouseUp);
                Mouse.AddMouseMoveHandler(this.window, this.toolMouseMove);
                Mouse.AddMouseMoveHandler(this.dotsControl, this.dotsControl_MouseMove);
                Keyboard.AddKeyDownHandler(this.window, this.toolKeyDown);
                Keyboard.AddKeyUpHandler(this.window, this.toolKeyUp);
                break;

            case DrawToolType.Polyline:
                Mouse.AddMouseDownHandler(this.canvas, this.polylineToolMouseDown);
                Mouse.AddMouseUpHandler(this.window, this.polylineToolMouseUp);
                Mouse.AddMouseMoveHandler(this.window, this.polylineToolMouseMove);
                this.canvas.Cursor = Cursors.Cross;
                break;

            case DrawToolType.Rectangle:
                Mouse.AddMouseDownHandler(this.canvas, this.rectangleToolMouseDown);
                Mouse.AddMouseUpHandler(this.window, this.rectangleToolMouseMouseUp);
                Mouse.AddMouseMoveHandler(this.window, this.rectangleToolMouseMove);
                this.canvas.Cursor = Cursors.Cross;
                break;

            case DrawToolType.Delete:
                Mouse.AddMouseDownHandler(this.canvas, this.deleteToolMouseDown);
                Mouse.AddMouseMoveHandler(this.window, this.deleteToolMouseMove);
                break;
            }
        }
Ejemplo n.º 9
0
 private void AboutView_Loaded(object sender, RoutedEventArgs e)
 {
     Mouse.Capture(this, CaptureMode.SubTree);
     Mouse.AddMouseDownHandler(this, this.MouseButtonEventHandler);
 }
Ejemplo n.º 10
0
 /// <summary> Starts the listening of mouse events.
 /// </summary>
 public void StartMouseListening()
 {
     Mouse.AddMouseDownHandler(_renderer, _controller.MouseDownHandler);
     Mouse.AddMouseUpHandler(_renderer, _controller.MouseUpHandler);
     Mouse.AddMouseMoveHandler(_renderer, _controller.MouseMoveHandler);
 }
 private void ListBoxItemTemplateTextBlock_Loaded(object sender, RoutedEventArgs e)
 {
     Mouse.AddMouseDownHandler((TextBlock)sender, this.SuggestionsListBoxItem_MouseDownHandler, true);
 }
Ejemplo n.º 12
0
 private void _DebugHook()
 {
     Mouse.AddMouseDownHandler(this, _DebugHandleMouseDown);
 }
Ejemplo n.º 13
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     Mouse.AddMouseDownHandler(App.Current.MainWindow, UserControl_MouseDown);
 }
Ejemplo n.º 14
0
 public MainWindow()
 {
     InitializeComponent();
     MouseTouchDevice.RegisterEvents(Surface);
     Mouse.AddMouseDownHandler(this, OnMouseDown);
 }