/// <summary> /// Raises the DragStart event. /// </summary> /// <param name="mousePt">Mouse point at time of event.</param> /// <param name="offset">Offset compared to target.</param> /// <param name="c">Control that is source of drag start.</param> protected virtual void OnDragStart(Point mousePt, Point offset, Control c) { // Convert point from client to screen coordinates mousePt = _target.OwningControl.PointToScreen(mousePt); DragStartEventCancelArgs ce = new DragStartEventCancelArgs(mousePt, offset, c); DragStart?.Invoke(this, ce); // If event is not cancelled then allow dragging _dragging = !ce.Cancel; }
private void OnDragStart(object sender, DragStartEventCancelArgs e) { _navigator.InternalDragStart(e, _page); }
private void OnDragStart(object sender, DragStartEventCancelArgs e) { Navigator.InternalDragStart(e, null); }
/// <summary> /// Raises the DragStart event. /// </summary> /// <param name="mousePt">Mouse point at time of event.</param> /// <param name="offset">Offset of mouse compared to element.</param> /// <param name="c">Control that starts the drag operation.</param> protected virtual void OnDragStart(Point mousePt, Point offset, Control c) { // Convert point from client to screen coordinates mousePt = _target.OwningControl.PointToScreen(mousePt); DragStartEventCancelArgs ce = new DragStartEventCancelArgs(mousePt, offset, c); if (DragStart != null) DragStart(this, ce); // If event is not cancelled then allow dragging _dragging = !ce.Cancel; }
internal void InternalDragStart(DragStartEventCancelArgs e, KryptonPage page) { if (DesignMode) e.Cancel = true; else { // Should not already be dragging, but if we are then ensure correct sequence of calls if (_pageDragging) { _pageDragging = false; if (DragPageNotify != null) DragPageNotify.PageDragQuit(this); } // Create a list of the pages being dragged if (page != null) _dragPages = new KryptonPage[] { page }; else { // Providing 'null' means we want all the pages List<KryptonPage> list = new List<KryptonPage>(); foreach (KryptonPage p in Pages) list.Add(p); _dragPages = list.ToArray(); } // Do any of the dragging pages have a flag set saying they can be dragged? bool allowPageDrag = false; foreach(KryptonPage p in _dragPages) if (p.AreFlagsSet(KryptonPageFlags.AllowPageDrag)) { allowPageDrag = true; break; } // Generate event allowing the DragPageNotify setting to be updated before the // actual drag processing occurs. You can even cancel the drag entirely. PageDragCancelEventArgs de = new PageDragCancelEventArgs(e.Point, e.Offset, e.Control, _dragPages); de.Cancel = (!AllowPageDrag || !allowPageDrag); OnBeforePageDrag(de); if (!de.Cancel) { // Update with any changes made by the event List<KryptonPage> list = new List<KryptonPage>(); foreach (KryptonPage p in de.Pages) list.Add(p); _dragPages = list.ToArray(); if (DragPageNotify != null) { // Give the notify interface a chance to reject the attempt to drag DragPageNotify.PageDragStart(this, this, de); _pageDragging = !de.Cancel; } } e.Cancel = de.Cancel; } }