private void BlockItemDrag_MouseMove(object sender, MouseEventArgs e) { if (dragged != null) { Mouse.OverrideCursor = Cursors.None; } if (e.LeftButton == MouseButtonState.Pressed && dragged == null) { #if DEBUG Log.Info("Item drop."); #endif Mouse.AddMouseMoveHandler(this, Item_MouseMove); Mouse.AddMouseUpHandler(this, Item_MouseRelease); var p = e.GetPosition(this); drag.Margin = new Thickness(p.X - 24, p.Y - 24, 0, 0); var img = sender as Image; drag.Source = img.Source; Mouse.OverrideCursor = Cursors.No; drag.Visibility = Visibility.Visible; var item = img.Tag as Item; foreach (var v in data.Selected.Blocks) { v.Items.Remove(item); } dragged = data.Items.Data.Values.FirstOrDefault(s => s.Id.Equals(item.Id + "")); } }
/// <summary> /// Shows the FormatBar /// </summary> void ShowAdorner() { if (_adorner.Visibility == Visibility.Visible) { return; } VerifyAdornerLayer(); Control adorningEditor = _toolbar as Control; if (_adorner.Child == null) { _adorner.Child = adorningEditor; } adorningEditor.ApplyTemplate(); _toolbar.Update(); _adorner.Visibility = Visibility.Visible; PositionFormatBar(adorningEditor); _parentWindow = TreeHelper.FindParent <Window>(_adorner); if (_parentWindow != null) { Mouse.AddMouseMoveHandler(_parentWindow, OnPreviewMouseMoveParentWindow); } }
public static IObservable <MouseEventArgs> MouseMove(this DependencyObject that) { return(Observable.FromEvent <MouseEventArgs>( on => Mouse.AddMouseMoveHandler(that, (o, e) => on(e)), on => Mouse.RemoveMouseMoveHandler(that, (o, e) => on(e)) )); }
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); }
private void DoorExitArrowAdorner_Loaded(object sender, RoutedEventArgs e) { var parent = VisualTreeHelper.GetParent(doorView); while (!(parent is Window)) { parent = VisualTreeHelper.GetParent(parent); } Mouse.AddMouseMoveHandler(parent, (_, _) => InvalidateVisual()); }
public StandByFSBlinky(BlinkGrid blinkGrid) : base(blinkGrid) { var mw = Application.Current.MainWindow as MainWindow; Mouse.AddMouseMoveHandler(mw, MainWindowMouseMove); (mw.Flyouts.Items[0] as Flyout).IsOpenChanged += StandByFSBlinky_IsOpenChanged; dpt.Tick += dpt_Tick; dpt.Interval = new TimeSpan(0, 0, 0, 15); dpt.Start(); Player.Instance.PropertyChanged += Instance_PropertyChanged; }
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; }
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); }
private void ItemDrag_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed && dragged == null) { #if DEBUG Log.Info("Item drag."); #endif Mouse.AddMouseMoveHandler(this, Item_MouseMove); Mouse.AddMouseUpHandler(this, Item_MouseRelease); var p = e.GetPosition(this); drag.Margin = new Thickness(p.X - 24, p.Y - 24, 0, 0); var img = sender as Image; drag.Source = img.Source; Mouse.OverrideCursor = Cursors.No; drag.Visibility = Visibility.Visible; dragged = img.Tag as ItemData; } }
public virtual void AddHandler() { Mouse.AddMouseDownHandler(this.CurrentWindow.pictureBox, MouseDownHandler); Mouse.AddMouseUpHandler(this.CurrentWindow.pictureBox, MouseUpHandler); Mouse.AddMouseMoveHandler(this.CurrentWindow.pictureBox, MouseMoveHandler); }
public virtual void ConnectHandle() { Mouse.AddMouseDownHandler(this.CurrentWindow.Canvas, MouseDownHandle); Mouse.AddMouseUpHandler(this.CurrentWindow.Canvas, MouseUpHandle); Mouse.AddMouseMoveHandler(this.CurrentWindow.Canvas, MouseMoveHandler); }
/// <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; } }
/// <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 BindToMouse() { CaptureHost.CaptureMouse(); Mouse.AddMouseMoveHandler(clickSource, SendMouseMove); Mouse.AddMouseUpHandler(clickSource, SendMouseUp); }