private bool ProcessTrackMessage(TrackMousePositionMessage trackMessage) { this.Location = trackMessage.Location; if (HasMoved(this.Location)) { _contextMenuEnabled = false; } if (this.CaptureHandler != null) { if (ConstrainToTile(this.CaptureHandler) && !this.TileClientRectangle.Contains(this.Location)) { SetCursorToken(null); return(true); } if (this.CaptureHandler.Track(this)) { SetCursorToken(); return(true); } } if (!_tile.Enabled) { return(true); } IMouseButtonHandler handler = FindHandlingGraphic(TrackHandler); SetCursorToken(handler); return(handler != null); }
public bool Track(IMouseInformation mouseInformation) { bool result = false; if (_capturedHandler != null) { return(_capturedHandler.Track(mouseInformation)); } foreach (IGraphic graphic in EnumerateChildGraphics(true)) { if (!graphic.Visible) { continue; } IMouseButtonHandler handler = graphic as IMouseButtonHandler; if (handler != null) { result = handler.Track(mouseInformation); if (result) { break; } } } return(result); }
/// <summary> /// Called by the framework when the mouse button is released. /// </summary> /// <remarks> /// <para> /// The <see cref="ControlGraphic"/> implementation calls <see cref="IMouseButtonHandler.Stop"/> on /// the current handler, <see cref="Stop"/>, or any child graphics implementing <see cref="IMouseButtonHandler"/>, /// in decreasing order of priority. /// </para> /// </remarks> /// <param name="mouseInformation">The mouse input information.</param> /// <returns>True if the framework should <b>not</b> release capture; False otherwise.</returns> bool IMouseButtonHandler.Stop(IMouseInformation mouseInformation) { bool result; if (_capturedHandler != null) { result = _capturedHandler.Stop(mouseInformation); if (!result) { _capturedHandler = null; return(result); } } try { result = this.Stop(mouseInformation); } finally { _isTracking = false; _lastTrackedPosition = PointF.Empty; } return(result); }
public void Cancel() { if (_capturedHandler != null) { _capturedHandler.Cancel(); _capturedHandler = null; } }
/// <summary> /// Called by the framework each time a mouse button is pressed. /// </summary> /// <remarks> /// <para> /// As a general rule, if the <see cref="IMouseButtonHandler"/> object did anything as a result of this call, it must /// return true. If false is returned, <see cref="IMouseButtonHandler.Start"/> is called on other <see cref="IMouseButtonHandler"/>s /// until one returns true. /// </para> /// <para> /// The <see cref="ControlGraphic"/> implementation finds a handler by trying <see cref="Start"/>, /// and any child graphics implementing <see cref="IMouseButtonHandler"/>, in decreasing order of priority. /// </para> /// </remarks> /// <param name="mouseInformation">The mouse input information.</param> /// <returns>True if the <see cref="ControlGraphic"/> did something as a result of the call and hence would like to receive capture; False otherwise.</returns> bool IMouseButtonHandler.Start(IMouseInformation mouseInformation) { bool result = false; if (_capturedHandler != null) { result = _capturedHandler.Start(mouseInformation); if (result) { return(true); } } if (Enabled) { CoordinateSystem = CoordinateSystem.Destination; try { if (HitTest(mouseInformation.Location)) { _lastTrackedPosition = mouseInformation.Location; _isTracking = true; } result = Start(mouseInformation); _isTracking = _isTracking && result; } finally { ResetCoordinateSystem(); } } _capturedHandler = null; if (!result) { foreach (IGraphic graphic in EnumerateChildGraphics(true)) { if (!graphic.Visible) { continue; } IMouseButtonHandler handler = graphic as IMouseButtonHandler; if (handler != null) { result = handler.Start(mouseInformation); if (result) { _capturedHandler = handler; break; } } } } return(result); }
private void OnCaptureChanging(object sender, ItemEventArgs <IMouseButtonHandler> e) { if (_currentMouseButtonHandler == e.Item) { return; } _currentMouseButtonHandler = e.Item; this.Capture = (_currentMouseButtonHandler != null); }
private bool StopHandler(IMouseButtonHandler handler) { bool handled = handler.Stop(this); if (!handled) { _startCount = 0; } return(handled); }
private void SetCursorToken(IMouseButtonHandler handler, Point location) { if (handler is ICursorTokenProvider) { this.CursorToken = (handler as ICursorTokenProvider).GetCursorToken(location); } else { this.CursorToken = null; } }
private bool TrackHandler(IMouseButtonHandler handler) { if (!_tile.Selected && SuppressOnTileActivate(handler)) { return(false); } if (ConstrainToTile(handler) && !this.TileClientRectangle.Contains(this.Location)) { return(false); } return(handler.Track(this)); }
private bool CanStartNewHandler(IMouseButtonHandler handler) { if (_clickCount < 2) { return(true); } else if (CanStartOnDoubleClick(handler)) { return(true); } else { return(false); } }
public bool Stop(IMouseInformation mouseInformation) { bool result = false; if (_capturedHandler != null) { result = _capturedHandler.Stop(mouseInformation); if (!result) { _capturedHandler = null; return(false); } } return(result); }
/// <summary> /// Called by the framework when the mouse has moved. /// </summary> /// <remarks> /// <para> /// A button does not necessarily have to be down for this message to be called. The framework can /// call it any time the mouse moves. /// </para> /// <para> /// The <see cref="ControlGraphic"/> implementation calls <see cref="IMouseButtonHandler.Track"/> on /// the current handler, <see cref="Track"/>, or any child graphics implementing <see cref="IMouseButtonHandler"/>, /// in decreasing order of priority. /// </para> /// </remarks> /// <param name="mouseInformation">The mouse input information.</param> /// <returns>True if the message was handled; False otherwise.</returns> bool IMouseButtonHandler.Track(IMouseInformation mouseInformation) { bool result = false; if (_capturedHandler != null) { return(_capturedHandler.Track(mouseInformation)); } if (Enabled) { try { result = Track(mouseInformation); } finally { if (_isTracking) { _lastTrackedPosition = mouseInformation.Location; } } } if (!result) { foreach (IGraphic graphic in EnumerateChildGraphics(true)) { if (!graphic.Visible) { continue; } IMouseButtonHandler handler = graphic as IMouseButtonHandler; if (handler != null) { result = handler.Track(mouseInformation); if (result) { break; } } } } return(result); }
private void SetCapture(IMouseButtonHandler handler) { Trace.WriteLine(String.Format("Setting capture: {0}", handler.GetType().FullName)); this.CaptureHandler = handler; if (SuppressContextMenu(this.CaptureHandler)) { _contextMenuEnabled = false; } SetCursorToken(); //tools can't have context menus if (handler is IGraphic) { this.ContextMenuProvider = handler as IContextMenuProvider; } }
/// <summary> /// Called by the framework to let <see cref="IMouseButtonHandler"/> perform any necessary cleanup /// when capture is going to be forcibly released. /// </summary> /// <remarks> /// <para> /// The <see cref="ControlGraphic"/> implementation calls <see cref="IMouseButtonHandler.Cancel"/> on /// the current handler or <see cref="Cancel"/> in decreasing order of priority. /// </para> /// </remarks> void IMouseButtonHandler.Cancel() { if (_capturedHandler != null) { _capturedHandler.Cancel(); _capturedHandler = null; } try { this.Cancel(); } finally { _isTracking = false; _lastTrackedPosition = PointF.Empty; } }
private bool StartHandler(IMouseButtonHandler handler) { if (_selectedOnThisClick && SuppressOnTileActivate(handler)) { return(false); } if (_clickCount > 1 && IgnoreDoubleClicks(handler)) { return(false); } bool start = handler.Start(this); if (start) { ++_startCount; } return(start); }
private static bool ConstrainToTile(IMouseButtonHandler handler) { return (handler.Behaviour & MouseButtonHandlerBehaviour.ConstrainToTile) == MouseButtonHandlerBehaviour.ConstrainToTile; }
private static bool CancelStartOnDoubleClick(IMouseButtonHandler handler) { return (handler.Behaviour & MouseButtonHandlerBehaviour.CancelStartOnDoubleClick) == MouseButtonHandlerBehaviour.CancelStartOnDoubleClick; }
private static bool SuppressContextMenu(IMouseButtonHandler handler) { return (handler.Behaviour & MouseButtonHandlerBehaviour.SuppressContextMenu) == MouseButtonHandlerBehaviour.SuppressContextMenu; }
private bool TrackHandler(IMouseButtonHandler handler) { if (!_tile.Selected && SuppressOnTileActivate(handler)) return false; if (ConstrainToTile(handler) && !this.TileClientRectangle.Contains(this.Location)) return false; return handler.Track(this); }
private static bool SuppressOnTileActivate(IMouseButtonHandler handler) { return((handler.Behaviour & MouseButtonHandlerBehaviour.SuppressOnTileActivate) == MouseButtonHandlerBehaviour.SuppressOnTileActivate); }
private void SetCursorToken(IMouseButtonHandler handler) { SetCursorToken(handler, Location); }
private bool CanStartNewHandler(IMouseButtonHandler handler) { if (_clickCount < 2) return true; else if (CanStartOnDoubleClick(handler)) return true; else return false; }
private void OnCaptureChanging(object sender, ItemEventArgs<IMouseButtonHandler> e) { if (_currentMouseButtonHandler == e.Item) return; _currentMouseButtonHandler = e.Item; this.Capture = (_currentMouseButtonHandler != null); }
public bool Start(IMouseInformation mouseInformation) { bool result = false; if (_capturedHandler != null) { result = _capturedHandler.Start(mouseInformation); if (result) return true; } _capturedHandler = null; foreach (IGraphic graphic in EnumerateChildGraphics(true)) { if (!graphic.Visible) continue; IMouseButtonHandler handler = graphic as IMouseButtonHandler; if (handler != null) { result = handler.Start(mouseInformation); if (result) { _capturedHandler = handler; break; } } } return result; }
private static bool IgnoreDoubleClicks(IMouseButtonHandler handler) { return((handler.Behaviour & MouseButtonHandlerBehaviour.IgnoreDoubleClicks) == MouseButtonHandlerBehaviour.IgnoreDoubleClicks); }
private static bool CanStartOnDoubleClick(IMouseButtonHandler handler) { return(false == CancelStartOnDoubleClick(handler)); }
private static bool CancelStartOnDoubleClick(IMouseButtonHandler handler) { return((handler.Behaviour & MouseButtonHandlerBehaviour.CancelStartOnDoubleClick) == MouseButtonHandlerBehaviour.CancelStartOnDoubleClick); }
private static bool SuppressContextMenu(IMouseButtonHandler handler) { return((handler.Behaviour & MouseButtonHandlerBehaviour.SuppressContextMenu) == MouseButtonHandlerBehaviour.SuppressContextMenu); }
private static bool ConstrainToTile(IMouseButtonHandler handler) { return((handler.Behaviour & MouseButtonHandlerBehaviour.ConstrainToTile) == MouseButtonHandlerBehaviour.ConstrainToTile); }
private static bool SuppressOnTileActivate(IMouseButtonHandler handler) { return (handler.Behaviour & MouseButtonHandlerBehaviour.SuppressOnTileActivate) == MouseButtonHandlerBehaviour.SuppressOnTileActivate; }
public bool Stop(IMouseInformation mouseInformation) { bool result = false; if (_capturedHandler != null) { result = _capturedHandler.Stop(mouseInformation); if (!result) { _capturedHandler = null; return false; } } return result; }
private void SetCapture(IMouseButtonHandler handler) { Trace.WriteLine(String.Format("Setting capture: {0}", handler.GetType().FullName)); this.CaptureHandler = handler; if (SuppressContextMenu(this.CaptureHandler)) _contextMenuEnabled = false; SetCursorToken(); //tools can't have context menus if (handler is IGraphic) this.ContextMenuProvider = handler as IContextMenuProvider; }
private static bool CanStartOnDoubleClick(IMouseButtonHandler handler) { return false == CancelStartOnDoubleClick(handler); }
private bool StartHandler(IMouseButtonHandler handler) { if (_selectedOnThisClick && SuppressOnTileActivate(handler)) return false; if (_clickCount > 1 && IgnoreDoubleClicks(handler)) return false; bool start = handler.Start(this); if (start) ++_startCount; return start; }
private static bool IgnoreDoubleClicks(IMouseButtonHandler handler) { return (handler.Behaviour & MouseButtonHandlerBehaviour.IgnoreDoubleClicks) == MouseButtonHandlerBehaviour.IgnoreDoubleClicks; }
private bool StopHandler(IMouseButtonHandler handler) { bool handled = handler.Stop(this); if (!handled) _startCount = 0; return handled; }