//TODO Styles DragIndicator private void OnMouseMove_BeginReorder(Point mousePosition) { DataGridColumnHeader dragIndicator = new DataGridColumnHeader { OwningColumn = OwningColumn, IsEnabled = false, Content = Content, ContentTemplate = ContentTemplate }; dragIndicator.PseudoClasses.Add(":dragIndicator"); IControl dropLocationIndicator = OwningGrid.DropLocationIndicatorTemplate?.Build(); //dropLocationIndicator.SetStyleWithType(OwningGrid.DropLocationIndicatorStyle); //if (OwningColumn.DragIndicatorStyle != null) //{ // dragIndicator.SetStyleWithType(OwningColumn.DragIndicatorStyle); //} //else if (OwningGrid.DragIndicatorStyle != null) //{ // dragIndicator.SetStyleWithType(OwningGrid.DragIndicatorStyle); //} // If the user didn't style the dropLocationIndicator's Height, default to the column header's height if (dropLocationIndicator != null && double.IsNaN(dropLocationIndicator.Height) && dropLocationIndicator is Control element) { element.Height = Bounds.Height; } // pass the caret's data template to the user for modification DataGridColumnReorderingEventArgs columnReorderingEventArgs = new DataGridColumnReorderingEventArgs(OwningColumn) { DropLocationIndicator = dropLocationIndicator, DragIndicator = dragIndicator }; OwningGrid.OnColumnReordering(columnReorderingEventArgs); if (columnReorderingEventArgs.Cancel) { return; } // The user didn't cancel, so prepare for the reorder _dragColumn = OwningColumn; _dragMode = DragMode.Reorder; _dragStart = mousePosition; // Display the reordering thumb OwningGrid.ColumnHeaders.DragColumn = OwningColumn; OwningGrid.ColumnHeaders.DragIndicator = columnReorderingEventArgs.DragIndicator; OwningGrid.ColumnHeaders.DropLocationIndicator = columnReorderingEventArgs.DropLocationIndicator; // If the user didn't style the dragIndicator's Width, default it to the column header's width if (double.IsNaN(dragIndicator.Width)) { dragIndicator.Width = Bounds.Width; } }
internal void OnMouseMove(ref bool handled, Point mousePosition, Point mousePositionHeaders) { if (handled || this.OwningGrid == null || this.OwningGrid.ColumnHeaders == null) { return; } Debug.Assert(this.OwningGrid.Parent is UIElement); double distanceFromLeft = mousePosition.X; double distanceFromRight = this.ActualWidth - distanceFromLeft; OnMouseMove_Resize(ref handled, mousePositionHeaders); OnMouseMove_Reorder(ref handled, mousePosition, mousePositionHeaders, distanceFromLeft, distanceFromRight); // if we still haven't done anything about moving the mouse while // the button is down, we remember that we're dragging, but we don't // claim to have actually handled the event if (_dragMode == DragMode.MouseDown) { _dragMode = DragMode.Drag; } if (_dragMode == DragMode.Drag) { DragDeltaEventArgs dragDeltaEventArgs = new DragDeltaEventArgs(mousePositionHeaders.X - _lastMousePositionHeaders.Value.X, mousePositionHeaders.Y - _lastMousePositionHeaders.Value.Y); this.OwningGrid.OnColumnHeaderDragDelta(dragDeltaEventArgs); } _lastMousePositionHeaders = mousePositionHeaders; SetDragCursor(mousePosition); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); switch (dragMode) { case DragMode.None: return; case DragMode.MouseDownRight: dragMode = DragMode.None; Invalidate(); break; case DragMode.MouseDown: // Window Select dragMode = DragMode.SelectWin; dragStop = fromScreen(new Vector(e.Location.X, e.Location.Y)); showCaret = true; Invalidate(); break; case DragMode.SelectWin: dragStop = fromScreen(new Vector(e.Location.X, e.Location.Y)); Invalidate(); break; } }
protected override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); Vector3 point = new Vector3(0, 0, 0); Glu.UnProject(new Vector3(e.X, e.Y, 0.0f), ref point); Vector2 point2 = new Vector2(point.X, point.Y); if (e.Button == MouseButton.Left) { if (Vector2.Distance(start, point2) < selectionRadius) { dragMode = DragMode.Start; start = point2; } else if (Vector2.Distance(end, point2) < selectionRadius) { dragMode = DragMode.End; end = point2; } } else if (e.Button == MouseButton.Right) { pathSet = false; OnResize(); } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (ArchiveMaintainer == null || ArchiveMaintainer.LoadingInitialData) { return; } // Do the same thing for everything here for consistency DataTimeRange everything = CurrentArchiveRange; if (MouseDragging == DragMode.New && e.X == MouseDragStart) { LongPoint virtualclicked = LongPoint.DeTranslateFromScreen(new LongPoint(e.Location), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)); long proposedoffset = ArchiveMaintainer.GraphNow.Ticks - (virtualclicked.X + (GraphWidth.Ticks / 2)); GraphOffset = TimeSpan.FromTicks(proposedoffset > 0 ? proposedoffset : 0); } TimerScroll = ScrollMode.None; Scroller.Stop(); AutoScaleGraph(); GridSpacing = BodgeSpacing(GraphWidth); RefreshXRange(false); MouseDragging = DragMode.None; MouseResizing = ResizeMode.None; }
//TODO DragEvents //TODO MouseCapture internal void OnMouseLeftButtonUp(ref bool handled, PointerEventArgs args, Point mousePosition, Point mousePositionHeaders) { IsPressed = false; if (OwningGrid != null && OwningGrid.ColumnHeaders != null) { if (_dragMode == DragMode.MouseDown) { OnMouseLeftButtonUp_Click(args.KeyModifiers, ref handled); } else if (_dragMode == DragMode.Reorder) { // Find header we're hovering over int targetIndex = GetReorderingTargetDisplayIndex(mousePositionHeaders); if (((!OwningColumn.IsFrozen && targetIndex >= OwningGrid.FrozenColumnCount) || (OwningColumn.IsFrozen && targetIndex < OwningGrid.FrozenColumnCount))) { OwningColumn.DisplayIndex = targetIndex; DataGridColumnEventArgs ea = new DataGridColumnEventArgs(OwningColumn); OwningGrid.OnColumnReordered(ea); } } SetDragCursor(mousePosition); // Variables that track drag mode states get reset in DataGridColumnHeader_LostMouseCapture args.Pointer.Capture(null); OnLostMouseCapture(); _dragMode = DragMode.None; handled = true; } }
public void endDrag() { if (dragMode == DragMode.none) return; dragMode = DragMode.none; editableObject.draged = false; }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); Rectangle seq = new Rectangle(); getSequencerGeometry(ref seq); if (seq.Contains(e.Location)) { dragMode = DragMode.Holding; dragcol = (e.Location.X - seq.X) * _columns / seq.Width; if (dragcol < 0) { dragcol = 0; } if (dragcol >= _columns) { dragcol = _columns - 1; } dragrow = (e.Location.Y - seq.Y) * _rows / seq.Height; if (dragrow < 0) { dragrow = 0; } if (dragrow >= _rows) { dragrow = _rows - 1; } dragrow = _rows - 1 - dragrow; Invalidate(); } else { forwardOnMouseDown(e); } }
//TODO DragEvents internal void OnMouseMove(ref bool handled, Point mousePosition, Point mousePositionHeaders) { if (handled || OwningGrid == null || OwningGrid.ColumnHeaders == null) { return; } Debug.Assert(OwningGrid.Parent is InputElement); double distanceFromLeft = mousePosition.X; double distanceFromRight = Bounds.Width - distanceFromLeft; OnMouseMove_Resize(ref handled, mousePositionHeaders); OnMouseMove_Reorder(ref handled, mousePosition, mousePositionHeaders, distanceFromLeft, distanceFromRight); // if we still haven't done anything about moving the mouse while // the button is down, we remember that we're dragging, but we don't // claim to have actually handled the event if (_dragMode == DragMode.MouseDown) { _dragMode = DragMode.Drag; } _lastMousePositionHeaders = mousePositionHeaders; SetDragCursor(mousePosition); }
protected override void OnMouseUp(MouseEventArgs e) { if (m_dragActive == DragMode.dmWindowZoom) { ControlPaint.DrawReversibleFrame(m_dragWindowRectangle, Color.Black, FrameStyle.Dashed); Rectangle r = RectangleToClient(m_dragWindowRectangle); float x1 = absx(r.Left); float y1 = absx(r.Top); float w = absx(r.Right) - absx(r.Left); float h = absy(r.Bottom) - absy(r.Top); Fit = false; if (Square) { DisplayScale = Math.Min((float)this.Width / w, (float)this.Height / h); } else { DisplayScaleXY = new PointF((float)this.Width / w, (float)this.Height / h); } PointF asPos = abs2scr(new PointF(x1, y1)); AutoScrollPosition = new Point((int)asPos.X, (int)asPos.Y); m_dragWindowRectangle = new Rectangle(); } if (m_dragActive == DragMode.dmDragHandle) { if (m_dragOa != null && e_ArtworkChanged != null) { e_ArtworkChanged(m_dragOa); } } m_dragActive = DragMode.dmNone; base.OnMouseUp(e); }
/** * <summary>Snaps the object to a track at a given position along it</summary> * <param name="newTrack">The new DragTrack to snap to</param> * <param name="positionAlong">How far along the track, as a decimal of its length, to snap to</param> */ public void SnapToTrack(DragTrack newTrack, float positionAlong) { if (newTrack == null) { return; } if (track && newTrack != track) { track.OnDisconnect(this); } dragMode = DragMode.LockToTrack; if (IsAutoMoving()) { activeAutoMove.Stop(track, this, true); activeAutoMove = null; } track = newTrack; track.SetPositionAlong(positionAlong, this); if (_rigidbody) { _rigidbody.velocity = Vector3.zero; _rigidbody.angularVelocity = Vector3.zero; } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (ArchiveMaintainer == null || ArchiveMaintainer.LoadingInitialData) { return; } DataTimeRange everything = CurrentArchiveRange; long selectedleft = LongPoint.TranslateToScreen(new LongPoint(GraphLeft.Ticks, 1), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)).X; long selectedright = LongPoint.TranslateToScreen(new LongPoint(GraphRight.Ticks, 1), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)).X; if (e.Location.X > selectedleft - 3 && e.Location.X < selectedleft + 3) { MouseResizing = ResizeMode.Left; } else if (e.Location.X > selectedright - 3 && e.Location.X < selectedright + 3) { MouseResizing = ResizeMode.Right; } else if (e.Location.X > selectedleft - 3 && e.Location.X < selectedright + 3) { MouseDragging = DragMode.Existing; } else { MouseDragStart = e.X; MouseDragging = DragMode.New; } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if ((e.Button == MouseButtons.Left) || (e.Button == MouseButtons.Right)) { if (dragMode != DragMode.None) { abortDrag(); return; } Vector mp = fromScreen(new Vector(e.Location.X, e.Location.Y)); if (selection.items > 0) { selection.unselect(); Invalidate(); } if (e.Button == MouseButtons.Left) { dragMode = DragMode.MouseDown; } else { dragMode = DragMode.MouseDownRight; } dragStart = mp; } }
private void StartDrag(SAMTime gameTime, InputState istate) { for (int i = 0; i < _nodes.Length; i++) { if (_nodes[i].DrawingBoundingRect.Contains(istate.GamePointerPositionOnMap)) { isDragging = true; isActiveDragging = false; mouseStartPos = istate.GamePointerPositionOnMap.X; offsetStart = _nodes[i].NodePos.X; dragAnchor = i; dragMode = DragMode.Node; dragStartTime = gameTime.TotalElapsedSeconds; return; } } isDragging = true; mouseStartPos = istate.GamePointerPositionOnMap.X; offsetStart = _nodes[0].Position.X; dragAnchor = -1; dragMode = DragMode.Global; dragStartTime = gameTime.TotalElapsedSeconds; }
private Point SetCursorForPosition(Point position) { DragMode dragMode = CalculateDragMode(position); CoreCursorType cursorType; if (dragMode == DragMode.Full) { cursorType = CoreCursorType.Hand; } else if (dragMode == DragMode.TopLeft || dragMode == DragMode.BottomRight) { cursorType = CoreCursorType.SizeNorthwestSoutheast; } else if (dragMode == DragMode.TopRight || dragMode == DragMode.BottomLeft) { cursorType = CoreCursorType.SizeNortheastSouthwest; } else if (dragMode == DragMode.Top || dragMode == DragMode.Bottom) { cursorType = CoreCursorType.SizeNorthSouth; } else if (dragMode == DragMode.Left || dragMode == DragMode.Right) { cursorType = CoreCursorType.SizeWestEast; } else { cursorType = CoreCursorType.Arrow; } FrameworkElementExtensions.SetCursor(this, new CoreCursor(cursorType, (uint)cursorType)); return(position); }
private bool HandleMouseDown() { bool left = Event.current.button == 0; bool right = Event.current.button == 1; if (!left && !right) { return(false); } if (MouseRect.Contains(Event.current.mousePosition)) { var mousePos = Event.current.mousePosition - new Vector2(0, 16); var newNodes = new List <GraphNode>(); newNodes.AddRange(AllNodes .Where(node => node.PhysicalRect.Contains(mousePos)) .OrderByDescending(node => node.Id)); if (!newNodes.Any()) { DeselectNodes(SelectedNodes); GUI.FocusControl(string.Empty); } else if (!(CurrentMouseMode is ConnectMode)) { if (!SelectedNodes.Contains(newNodes.First())) { if (!CtrlPressed) { DeselectNodes(SelectedNodes); } SelectNodes(newNodes.First()); } if (left) { NextMouseMode = new DragMode(this); } if (right) { newNodes.First().HandleRightClick(); } Event.current.Use(); return(true); } if (CurrentMouseMode is NormalMode && left) { NextMouseMode = new SelectMode(this); Event.current.Use(); return(true); } } return(false); }
void OnMouseUp(object sender, MouseEventArgs mouseEventArgs) { _graph.PanningIsEnabled = true; _dragMode = DragMode.None; _dragStart = null; _hypotheticalDragMode = DragMode.None; _graph.Control.Cursor = Cursors.Default; }
public void CropUpProcess() { PreviewRect.Opacity = 0.0; Mode = DragMode.Wait; this.Cursor = null; Croptmr.Stop(); }
public override void OnInspectorGUI() { if (GUILayout.Button("Import...")) { EditorUtility.SetDirty(positionData); Undo.RecordObject(positionData, "Load Positions"); positionData.Import(); } GUI.enabled = false; EditorGUILayout.TextField("Path", positionData.path); GUI.enabled = true; using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("Reload", EditorStyles.miniButtonLeft)) { EditorUtility.SetDirty(positionData); Undo.RecordObject(positionData, "Load Positions"); positionData.Load(); } if (GUILayout.Button("Save", EditorStyles.miniButtonMid)) { positionData.Save(); } if (GUILayout.Button("Export...", EditorStyles.miniButtonRight)) { positionData.Export(); } } dragMode = (DragMode)EditorGUILayout.EnumPopup("Drag Mode", dragMode); EditorGUILayout.Space(); if (selectedNodeIndex != -1) { EditorGUILayout.LabelField(String.Format("Node Info [{0}]", selectedNodeIndex), EditorStyles.boldLabel); EditorGUI.indentLevel++; bool selectedIsFinishLine = selectedNodeIndex == positionData.finishLineIndex; GUI.enabled = !selectedIsFinishLine; bool setFinishLine = EditorGUILayout.Toggle("Start/Finish Line", selectedIsFinishLine); if (setFinishLine != selectedIsFinishLine) { EditorUtility.SetDirty(positionData); Undo.RecordObject(positionData, "Change Start/Finish Line"); positionData.finishLineIndex = selectedNodeIndex; } EditorGUI.indentLevel--; GUI.enabled = true; } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (dragMode == DragMode.Dial) { GraphicsUtil.TextPosition titlePos = new GraphicsUtil.TextPosition(); GraphicsUtil.TextPosition valuePos = new GraphicsUtil.TextPosition(); VectorRect bar = new VectorRect(); VectorRect handle = new VectorRect(); Vector vlow = Vector.Zero; Vector vhigh = Vector.Zero; getPositions(ref titlePos, ref valuePos, ref bar, ref handle, ref vlow, ref vhigh); // Hit in Dial Region double n = 0; if (_slideDirection == SlideDirection.Horizontal) { n = (e.X - vlow.x) / (vhigh.x - vlow.x); } else { n = (e.Y - vlow.y) / (vhigh.y - vlow.y); } if (n < 0) { n = 0; } if (n > 1.0) { n = 1; } if (logScale) { if ((_minVal <= 0) || (_maxVal <= 0) || (_minVal == _maxVal)) { _val = _minVal; } else { _val = Math.Exp(n * (Math.Log(_maxVal) - Math.Log(_minVal)) + Math.Log(_minVal)); } } else { _val = n * (_maxVal - _minVal) + _minVal; } newValue(); Invalidate(); dragMode = DragMode.Idle; } else { forwardOnMouseUp(e); } }
public EditorClip(EditorTrack tr, IClip c) { this.track = tr; this.clip = c; rect = Rect.zero; dragMode = DragMode.None; e = Event.current; clipMode = ClipMode.None; }
public void SetVisible(bool visible) { GetComponentInChildren <Renderer>().enabled = visible; GetComponentInChildren <Collider>().enabled = visible; _dragging = false; _mode = DragMode.None; _material.color = _changed ? changedColor : inactiveColor; }
private void OnMouseMove_BeginReorder(Point mousePosition) { DataGridColumnHeader dragIndicator = new DataGridColumnHeader(); dragIndicator.OwningColumn = this.OwningColumn; dragIndicator.IsEnabled = false; dragIndicator.Content = this.Content; dragIndicator.ContentTemplate = this.ContentTemplate; Control dropLocationIndicator = new ContentControl(); dropLocationIndicator.SetStyleWithType(this.OwningGrid.DropLocationIndicatorStyle); if (this.OwningColumn.DragIndicatorStyle != null) { dragIndicator.SetStyleWithType(this.OwningColumn.DragIndicatorStyle); } else if (this.OwningGrid.DragIndicatorStyle != null) { dragIndicator.SetStyleWithType(this.OwningGrid.DragIndicatorStyle); } // If the user didn't style the dragIndicator's Width, default it to the column header's width if (double.IsNaN(dragIndicator.Width)) { dragIndicator.Width = this.ActualWidth; } // If the user didn't style the dropLocationIndicator's Height, default to the column header's height if (double.IsNaN(dropLocationIndicator.Height)) { dropLocationIndicator.Height = this.ActualHeight; } // pass the caret's data template to the user for modification DataGridColumnReorderingEventArgs columnReorderingEventArgs = new DataGridColumnReorderingEventArgs(this.OwningColumn) { DropLocationIndicator = dropLocationIndicator, DragIndicator = dragIndicator }; this.OwningGrid.OnColumnReordering(columnReorderingEventArgs); if (columnReorderingEventArgs.Cancel) { return; } // The user didn't cancel, so prepare for the reorder _dragColumn = this.OwningColumn; _dragMode = DragMode.Reorder; _dragStart = mousePosition; // Display the reordering thumb this.OwningGrid.ColumnHeaders.DragColumn = this.OwningColumn; this.OwningGrid.ColumnHeaders.DragIndicator = columnReorderingEventArgs.DragIndicator; this.OwningGrid.ColumnHeaders.DropLocationIndicator = columnReorderingEventArgs.DropLocationIndicator; }
protected void onMouseUp(object sender, MouseEventArgs ev) { if (ev.Button != MouseButtons.Left) { return; } dragMode = DragMode.None; }
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) { base.OnMouseLeftButtonUp(e); isDown = false; mode = DragMode.None; this.ReleaseMouseCapture(); }
internal DragItem(object relativeObj, DockMode dockMode, DragMode dragMode, Point clickPos, Rect clickRect, Size size) { _relativeObj = relativeObj; _dockMode = dockMode; _dragMode = dragMode; _clickPos = clickPos; _clickRect = clickRect; _size = size; }
void CheckForDragMode(Vector3 mousePos) { if (Vector3.Distance(_mouseDownPos, mousePos) > DRAG_MODE_DISTANCE) { var diff = mousePos - _mouseDownPos; _dragMode = Mathf.Abs(diff.x) > Mathf.Abs(diff.y) ? DragMode.Horiz : DragMode.Vert; MAIN.uiCont.HideDragHelper(); } }
/// <inheritdoc /> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; if (BgColor != null) { hashCode = hashCode * 59 + BgColor.GetHashCode(); } if (Camera != null) { hashCode = hashCode * 59 + Camera.GetHashCode(); } if (Domain != null) { hashCode = hashCode * 59 + Domain.GetHashCode(); } if (AspectMode != null) { hashCode = hashCode * 59 + AspectMode.GetHashCode(); } if (AspectRatio != null) { hashCode = hashCode * 59 + AspectRatio.GetHashCode(); } if (XAxis != null) { hashCode = hashCode * 59 + XAxis.GetHashCode(); } if (YAxis != null) { hashCode = hashCode * 59 + YAxis.GetHashCode(); } if (ZAxis != null) { hashCode = hashCode * 59 + ZAxis.GetHashCode(); } if (DragMode != null) { hashCode = hashCode * 59 + DragMode.GetHashCode(); } if (HoverMode != null) { hashCode = hashCode * 59 + HoverMode.GetHashCode(); } if (UiRevision != null) { hashCode = hashCode * 59 + UiRevision.GetHashCode(); } if (Annotations != null) { hashCode = hashCode * 59 + Annotations.GetHashCode(); } return(hashCode); } }
protected override void MouseUp(GUIMouseButtonEventArgs args) { base.MouseUp(args); DragOffsetTopLeft = DragOffsetBottomRight = Vector2.Zero; CurrentDrag = DragMode.None; // If this is done in MouseDown, Godot won't fire MouseUp as you need focus to receive MouseUps. UserInterfaceManager.Focused?.ReleaseFocus(); }
public void endDrag() { if (dragMode == DragMode.none) return; dragedRigidbody = null; nowDrag.connectedBody = null; dragMode = DragMode.none; editableObject.draged = false; editableObject = null; }
protected override void OnMouseUp(MouseEventArgs e) { if (dragMode == DragMode.Workspace && e.Button == MouseButtons.Left) { Cursor = Cursors.Default; dragMode = DragMode.Idle; Capture = false; Invalidate(); } }
/// <summary> /// Handle "mouse up" event for end of resize/move. /// </summary> private void doMouseUpRM() { // Have been resizing or moving? Indicate it's now done. if (dragMode != DragMode.None) { DoMoveResizeFinished(); } // Resize by dragging border ends dragMode = DragMode.None; }
public static Vector3 getFlatCrossPoint(Vector3 pFlatPos, Ray pRay, DragMode pMode) { switch (pMode) { case DragMode.XY: return getZFlatCrossPoint(pFlatPos, pRay); break; case DragMode.XZ: return getYFlatCrossPoint(pFlatPos, pRay); break; } Debug.LogError("getFlatCrossPoint"); return pFlatPos; }
void OnMouseMove(object sender, MouseEventArgs args) { switch (_dragMode) { case DragMode.None: var hit = HitTest(_graph.Window, args.Location); switch (hit) { case HitKind.None: _graph.Control.Cursor = Cursors.Default; _dragMode = DragMode.None; _hypotheticalDragMode = DragMode.None; _dragStart = null; break; case HitKind.LeftEdge: _graph.Control.Cursor = Cursors.SizeWE; _hypotheticalDragMode = DragMode.ResizeLeft; break; case HitKind.RightEdge: _graph.Control.Cursor = Cursors.SizeWE; _hypotheticalDragMode = DragMode.ResizeRight; break; case HitKind.Center: _graph.Control.Cursor = Hand; _hypotheticalDragMode = DragMode.Center; break; } break; case DragMode.ResizeLeft: ResizeLeft(_graph.Window, _dragStart.Value, args.Location); _dragStart = args.Location; _graph.Draw(); break; case DragMode.ResizeRight: ResizeRight(_graph.Window, _dragStart.Value, args.Location); _dragStart = args.Location; _graph.Draw(); break; case DragMode.Center: Drag(_graph.Window, _dragStart.Value, args.Location); _dragStart = args.Location; _graph.Draw(); break; default: throw new ArgumentOutOfRangeException(); } }
Vector3 getScale(Vector2 pPosChange,DragMode pDragMode) { pPosChange *= scaleValue; //switch (dragMode) //{ // case DragMode.XY: // return new Vector3(getScale(pPosChange.x), getScale(pPosChange.y), 1f); // case DragMode.XZ: // return new Vector3(getScale(pPosChange.x), 1f, getScale(pPosChange.y)); //} switch (dragMode) { case DragMode.XY: return new Vector3((pPosChange.x), (pPosChange.y), 0f); case DragMode.XZ: return new Vector3((pPosChange.x), 0f, (pPosChange.y)); } Debug.LogError("dragMode error"); return Vector3.one; }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (ArchiveMaintainer == null || ArchiveMaintainer.LoadingInitialData) return; // Do the same thing for everything here for consistency DataTimeRange everything = CurrentArchiveRange; if (MouseDragging == DragMode.New && e.X == MouseDragStart) { LongPoint virtualclicked = LongPoint.DeTranslateFromScreen(new LongPoint(e.Location), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)); long proposedoffset = ArchiveMaintainer.GraphNow.Ticks - (virtualclicked.X + (GraphWidth.Ticks / 2)); GraphOffset = TimeSpan.FromTicks(proposedoffset > 0 ? proposedoffset : 0); } TimerScroll = ScrollMode.None; Scroller.Stop(); AutoScaleGraph(); GridSpacing = BodgeSpacing(GraphWidth); RefreshXRange(false); MouseDragging = DragMode.None; MouseResizing = ResizeMode.None; }
internal void OnMouseMove(ref bool handled, Point mousePosition, Point mousePositionGridParent) { if (handled) { return; } Debug.Assert(this.OwningGrid.Parent is UIElement); // various useful positions Point mousePositionHeaders = this.Translate(this.OwningGrid.ColumnHeaders, mousePosition); Point mousePositionGrid = this.Translate(this.OwningGrid, mousePosition); double distanceFromLeft = mousePosition.X; double distanceFromRight = this.ActualWidth - distanceFromLeft; OnMouseMove_Resize(ref handled, mousePositionGrid); OnMouseMove_Reorder(ref handled, mousePosition, mousePositionHeaders, mousePositionGrid, mousePositionGridParent, distanceFromLeft, distanceFromRight); // if we still haven't done anything about moving the mouse while // the button is down, we remember that we're dragging, but we don't // claim to have actually handled the event if (_dragMode == DragMode.MouseDown) { _dragMode = DragMode.Drag; } if (_dragMode == DragMode.Drag) { DragDeltaEventArgs dragDeltaEventArgs = new DragDeltaEventArgs(mousePositionGrid.X - _lastMousePositionGrid.Value.X, mousePositionGrid.Y - _lastMousePositionGrid.Value.Y); this.OwningGrid.OnColumnHeaderDragDelta(dragDeltaEventArgs); } _lastMousePositionGrid = mousePositionGrid; SetDragCursor(mousePosition); }
private void DataGridColumnHeader_LostMouseCapture(object sender, MouseEventArgs e) { // When we stop interacting with the column headers, we need to reset the drag mode // and close any popups if they are open. _dragMode = DragMode.None; _dragColumn = null; _dragStart = null; _lastMousePositionGrid = null; if (_reorderingThumb != null) { _reorderingThumb.IsOpen = false; } if (this.OwningGrid != null) { this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false; } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (ArchiveMaintainer == null || ArchiveMaintainer.LoadingInitialData) return; DataTimeRange everything = CurrentArchiveRange; long selectedleft = LongPoint.TranslateToScreen(new LongPoint(GraphLeft.Ticks, 1), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)).X; long selectedright = LongPoint.TranslateToScreen(new LongPoint(GraphRight.Ticks, 1), everything, DataRange.UnitRange, new LongRectangle(ScrollViewRectangle)).X; if (e.Location.X > selectedleft - 3 && e.Location.X < selectedleft + 3) { MouseResizing = ResizeMode.Left; } else if (e.Location.X > selectedright - 3 && e.Location.X < selectedright + 3) { MouseResizing = ResizeMode.Right; } else if (e.Location.X > selectedleft - 3 && e.Location.X < selectedright + 3) { MouseDragging = DragMode.Existing; } else { MouseDragStart = e.X; MouseDragging = DragMode.New; } }
/// <summary> Event handler for pressing the mouse button. A double click with the left mouse button results in /// zooming in the map. A double click with the right mouse button results in zooming out the map. Pressing the /// left button and the shift key, the zooming rectangle is shown on the map. </summary> /// <param name="sender"> Sender of the MouseDown event. </param> /// <param name="e"> Event parameters. </param> private void source_MouseDown(object sender, MouseButtonEventArgs e) { if (!IsActive) return; mapView.Focus(); // NEW: Skip MouseDragMode == None if (MouseDragMode == DragMode.None) { e.Handled = true; return; } if (ZoomOnDoubleClick && e.ClickCount == 2) { Point p = MapView.CanvasToPtvMercator(MapView.GeoCanvas, e.GetPosition(MapView.GeoCanvas)); if (e.RightButton == MouseButtonState.Pressed) { MapView.ZoomAround(p, MapView.FinalZoom + -1, Map.UseAnimation); e.Handled = true; return; } if (e.LeftButton == MouseButtonState.Pressed) { MapView.ZoomAround(p, MapView.FinalZoom + 1, Map.UseAnimation); e.Handled = true; return; } } // Save starting point, used later when determining how much to scroll. this.ScreenStartPoint = e.GetPosition(mapView); this.WorldStartPoint = mapView.CanvasToPtvMercator(mapView, e.GetPosition(mapView)); // NEW: check for MouseDragMode if (e.LeftButton == MouseButtonState.Pressed && (MouseDragMode == DragMode.Select || MouseDragMode == DragMode.SelectOnShift && (Keyboard.Modifiers & ModifierKeys.Shift) > 0)) // was && (Keyboard.Modifiers & ModifierKeys.Shift) > 0)) { mapView.Cursor = Cursors.Arrow; if (dragRectangle != null) mapView.ForePaneCanvas.Children.Remove(dragRectangle); dragRectangle = new Rectangle(); dragRectangle.IsHitTestVisible = false; dragRectangle.Fill = new SolidColorBrush(Color.FromArgb(0x3e, 0x11, 0x57, 0xdc)); dragRectangle.Stroke = new SolidColorBrush(Color.FromArgb(0x55, 0x07, 0x81, 0xf7)); dragRectangle.StrokeDashArray = new DoubleCollection(new double[] { 20, 8 }); dragRectangle.StrokeEndLineCap = PenLineCap.Round; dragRectangle.StrokeDashCap = PenLineCap.Round; dragRectangle.StrokeThickness = 1.5; dragRectangle.RadiusX = 8; dragRectangle.RadiusY = 8; Canvas.SetZIndex(dragRectangle, 266); Canvas.SetLeft(dragRectangle, ScreenStartPoint.X); Canvas.SetTop(dragRectangle, ScreenStartPoint.Y); mapView.ForePaneCanvas.Children.Add(dragRectangle); dragMode = DragMode.Select; mapView.CaptureMouse(); } else if (e.LeftButton == MouseButtonState.Pressed && mapView.CaptureMouse()) { mapView.Cursor = Cursors.Hand; dragMode = DragMode.Pan; wasPanned = false; } }
protected void onMouseUp(object sender, MouseEventArgs ev) { if (ev.Button != MouseButtons.Left) return; dragMode = DragMode.None; }
private void OnStartScale(RectangleTool.ToolCoord pivotCoord, RectangleTool.ToolCoord pickedCoord, Vector2 mousePos, DragMode dragMode, bool rippleTime) { Bounds selectionBounds = this.selectionBounds; this.m_DragMode = dragMode; this.m_Pivot = base.ToolCoordToPosition(pivotCoord, selectionBounds); this.m_Previous = base.ToolCoordToPosition(pickedCoord, selectionBounds); this.m_MouseOffset = mousePos - this.m_Previous; this.m_RippleTime = rippleTime; this.m_RippleTimeStart = selectionBounds.min.x; this.m_RippleTimeEnd = selectionBounds.max.x; this.m_CurveEditor.StartLiveEdit(); }
internal void OnMouseLeftButtonDown(ref bool handled, Point mousePosition) { this.IsPressed = true; if (this.OwningGrid != null) { this.CaptureMouse(); _dragMode = DragMode.MouseDown; _frozenColumnsWidth = this.OwningGrid.ColumnsInternal.GetVisibleFrozenEdgedColumnsWidth(); _lastMousePositionGrid = this.Translate(this.OwningGrid, mousePosition); double distanceFromLeft = mousePosition.X; double distanceFromRight = this.ActualWidth - distanceFromLeft; DataGridColumn currentColumn = this.OwningColumn; DataGridColumn previousColumn = null; if (!(this.OwningColumn is DataGridFillerColumn)) { previousColumn = this.OwningGrid.ColumnsInternal.GetPreviousVisibleNonFillerColumn(currentColumn); } if (_dragMode == DragMode.MouseDown && _dragColumn == null && (distanceFromRight <= DATAGRIDCOLUMNHEADER_resizeRegionWidth)) { handled = TrySetResizeColumn(currentColumn); } else if (_dragMode == DragMode.MouseDown && _dragColumn == null && distanceFromLeft <= DATAGRIDCOLUMNHEADER_resizeRegionWidth && previousColumn != null) { handled = TrySetResizeColumn(previousColumn); } if (_dragMode == DragMode.Resize && _dragColumn != null) { _dragStart = _lastMousePositionGrid; _originalWidth = _dragColumn.ActualWidth; _originalHorizontalOffset = this.OwningGrid.HorizontalOffset; _lastResizeWidth = _originalWidth; handled = true; } } }
protected void onMouseDown(object sender, MouseEventArgs ev) { if (ev.Button != MouseButtons.Left) return; dragMode = GetDragMode(ev, Size); screenStartMouse = Control.MousePosition; documentStartBox = new Rectangle(documentLeft, documentTop, documentWidth, documentHeight); }
private void OnMouseMove_BeginReorder(Point mousePosition, Point mousePositionGridParent) { DataGridColumnHeader dragIndicator = new DataGridColumnHeader(); dragIndicator.OwningColumn = this.OwningColumn; dragIndicator.IsEnabled = false; dragIndicator.Content = this.Content; dragIndicator.ContentTemplate = this.ContentTemplate; if (this.OwningColumn.DragIndicatorStyle != null) { dragIndicator.SetStyleWithType(this.OwningColumn.DragIndicatorStyle); } else if (this.OwningGrid.DragIndicatorStyle != null) { dragIndicator.SetStyleWithType(this.OwningGrid.DragIndicatorStyle); } // If the user didn't style the dragIndicator's Width, default it to the column header's width if (double.IsNaN(dragIndicator.Width)) { dragIndicator.Width = this.ActualWidth; } // If the user didn't style the dropLocationIndicator's Height, default to the column header's height if (double.IsNaN(this.OwningGrid.ColumnDropLocationIndicator.Height)) { this._autoSizeDropLocationIndicatorHeight = true; this.OwningGrid.ColumnDropLocationIndicator.Height = this.ActualHeight; } // pass the caret's data template to the user for modification DataGridColumnReorderingEventArgs columnReorderingEventArgs = new DataGridColumnReorderingEventArgs(this.OwningColumn) { DropLocationIndicator = this.OwningGrid.ColumnDropLocationIndicator, DragIndicator = dragIndicator }; this.OwningGrid.OnColumnReordering(columnReorderingEventArgs); if (columnReorderingEventArgs.Cancel) { return; } // The user didn't cancel, so prepare for the reorder _dragColumn = this.OwningColumn; _dragMode = DragMode.Reorder; _dragStartParent = mousePositionGridParent; // the mouse position relative to the ColumnHeader needs to be scaled to be in the same // dimensions as the DataGrid, so that it doesn't get out of sync later on _dragStart = this.OwningGrid.RenderTransform.Transform(mousePosition); // Display the reordering thumb if (_reorderingThumb == null) { _reorderingThumb = new Popup(); } _reorderingThumb.Child = columnReorderingEventArgs.DragIndicator; _reorderingThumb.IsOpen = true; // use the data template to populate the caret if (columnReorderingEventArgs.DropLocationIndicator != null) { System.Windows.Controls.Control child = columnReorderingEventArgs.DropLocationIndicator; this.OwningGrid.ColumnDropLocationIndicatorPopup.Child = child; this.OwningGrid.ColumnDropLocationIndicatorPopup.Height = child.ActualHeight; this.OwningGrid.ColumnDropLocationIndicatorPopup.Width = child.ActualWidth; this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false; } }
/// <summary> /// Resets the static DataGridColumnHeader properties when a header loses mouse capture /// </summary> private void OnLostMouseCapture() { // When we stop interacting with the column headers, we need to reset the drag mode // and close any popups if they are open. if (DataGridColumnHeader._dragColumn != null && DataGridColumnHeader._dragColumn.HeaderCell != null) { DataGridColumnHeader._dragColumn.HeaderCell.Cursor = DataGridColumnHeader._originalCursor; } _dragMode = DragMode.None; _dragColumn = null; _dragStart = null; _lastMousePositionGrid = null; if (_reorderingThumb != null) { _reorderingThumb.IsOpen = false; } if (this.OwningGrid != null) { this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false; } }
private static bool TrySetResizeColumn(DataGridColumn column) { // If datagrid.CanUserResizeColumns == false, then the column can still override it if (column.ActualCanUserResize) { _dragColumn = column; _dragMode = DragMode.Resize; return true; } return false; }
void RoomDlg_MouseDown(object sender, MouseEventArgs e) { Point click = new Point(e.X, e.Y); Vec2i pos = new Vec2i(e.X, e.Y); mMousePos = pos; if (mMode == ViewMode.Objects) { bool dragDepthFound = false; foreach (ObjectInstance obj in mRoom.Objects) { if (obj.Layer != 1) continue; Vec2i depthcenter = new Vec2i(obj.Position.x, obj.Depth * mData.WalkGridSize/2 - mData.WalkGridSize / 4); if ((depthcenter - pos - mRoom.ScrollOffset).length() <= 5) { mDragObject = obj; mDragOffset = depthcenter - pos; mDragDepth = true; dragDepthFound = true; break; } } if (!dragDepthFound) { mDragDepth = false; bool dragSecond = e.Button == MouseButtons.Middle; mDragObject = getObjectAt(pos + mRoom.ScrollOffset, dragSecond); mControl.SelectedObject = mDragObject; if (mDragObject != null) { mDragOffset = mDragObject.getPosition() - pos; } } if (e.Button == MouseButtons.Right) { if (mDragObject != null) { if (mDragObject.GetType() == typeof(ObjectInstance)) menuObject.Items[2].Text = "Show in Object window"; else menuObject.Items[2].Text = "Show in Character window"; menuObject.Show(this, click); } else menuRemoveBackground.Show(this, click); } } else if (mMode == ViewMode.Walkmap) { if (e.Button == MouseButtons.Right) { Vec2i cp = clickToWalkmap(e.X, e.Y); ToolStripMenuItem it = menuWalkmap.Items[9] as ToolStripMenuItem; if (mRoom.Walkmap[cp.x, cp.y].hasScript) { it.Enabled = true; } else it.Enabled = false; menuWalkmap.Show(this, click); return; } modifyWalkmap(pos.x, pos.y); mDragDepth = true; } else if (mMode == ViewMode.Deepmap) { int depth = (e.Y+mData.WalkGridSize/2+mRoom.ScrollOffset.y) / mData.WalkGridSize; if (depth == mRoom.Depthmap.x) mDragDepth = true; if (depth == mRoom.Depthmap.y) mDragDepthBottom = true; } else if (mMode == ViewMode.Inventory) { if (mRoom.HasInventory) { if (e.Button == MouseButtons.Right) { menuInventory.Show(this, click); } int sizex = mRoom.InvSize.x * ((int)(50 * mRoom.InvScale.x) + mRoom.InvSpacing) + 30; int sizey = mRoom.InvSize.y * ((int)(50 * mRoom.InvScale.y) + mRoom.InvSpacing) + 5; int ydown = -mRoom.ScrollOffset.y + mRoom.InvPos.y + sizey; int xmiddle = -mRoom.ScrollOffset.x + mRoom.InvPos.x + sizex / 2; int ymiddle = -mRoom.ScrollOffset.y + mRoom.InvPos.y + sizey / 2; int xright = -mRoom.ScrollOffset.x + mRoom.InvPos.x + sizex; int xleft = -mRoom.ScrollOffset.x + mRoom.InvPos.x; int yup = -mRoom.ScrollOffset.y + mRoom.InvPos.y; //bottom if (e.X >= xmiddle - 15 && e.X <= xmiddle + 15) { if (e.Y <= ydown + 3 && e.Y >= ydown - 5 - 3) { mDragMode = DragMode.DragBottom; mDragOffset.y = e.Y - ydown; } else mDragMode = DragMode.DragNone; } //right else if (e.Y >= ymiddle - 15 && e.Y <= ymiddle + 15) { if (e.X <= xright + 3 && e.X >= xright - 5 - 3) { mDragMode = DragMode.DragRight; mDragOffset.x = e.X - xright; } else mDragMode = DragMode.DragNone; } //corner else if (e.X >= xright - 11 - 3 && e.X <= xright + 3) { if (e.Y >= ydown - 11 - 3 && e.Y <= ydown + 3) mDragMode = DragMode.DragCorner; else mDragMode = DragMode.DragNone; } else mDragMode = DragMode.DragNone; //elsewhere on inventory if (mDragMode == DragMode.DragNone && e.X >= xleft && e.X <= xright) { if (e.Y >= yup && e.Y <= ydown) { mDragMode = DragMode.DragPosition; mDragOffset = new Vec2i(e.X, e.Y) - mRoom.InvPos; } } } else { if (e.Button == MouseButtons.Right) { return; } mRoom.InvPos = new Vec2i(e.X + mRoom.ScrollOffset.x, e.Y + mRoom.ScrollOffset.y); mRoom.InvScale = new Vec2f(1.0f, 1.0f); mRoom.HasInventory = true; mDragMode = DragMode.DragCorner; this.Cursor = Cursors.SizeNWSE; } } else if (mMode == ViewMode.Specialfx) { Vec2i clickpos = pos; clickpos += mRoom.ScrollOffset; for (int shapeidx = 0; shapeidx < mRoom.FXShapes.Count; ++shapeidx) { FxShape shape = (FxShape)mRoom.FXShapes[shapeidx]; if (!shape.Active) continue; Vec2i center = new Vec2i(); for (int i = 0; i < shape.Positions.Length; ++i) { if ((shape.Positions[i] - clickpos).length() <= 4) { mDragMode = DragMode.DragCorner; mDraggingShape = shape; mShapeIndex = i; mDragOffset = clickpos - center; return; } center += shape.Positions[i]; } center /= shape.Positions.Length; if ((center - clickpos).length() <= 10) { mDragMode = DragMode.DragPosition; mDraggingShape = shape; mDragOffset = pos; break; } Vec2i depthcenter = new Vec2i(center.x, (int)((shape.Depth + 0.5f) * mData.WalkGridSize - mData.WalkGridSize / 2)); if ((depthcenter - clickpos).length() <= 5) { mDragMode = DragMode.DragBottom; mDraggingShape = shape; mDragOffset = depthcenter - pos; return; } } } }
private void OnEndScale() { this.m_CurveEditor.EndLiveEdit(); this.m_DragMode = DragMode.None; GUI.changed = true; }
void RoomDlg_MouseUp(object sender, MouseEventArgs e) { mDragObject = null; mDragDepth = false; if (mMode == ViewMode.Deepmap) mDragDepthBottom = false; if (mMode == ViewMode.Inventory) { mDragMode = DragMode.DragNone; this.Cursor = Cursors.Default; } if (mMode == ViewMode.Specialfx) { mDragMode = DragMode.DragNone; } }
void OnDragObject(GameObject pObject,DragMode pMode) { if (dragMode != DragMode.none) return; var lNowDrag = pMode == DragMode.XY ? jointXyDrag : jointXzDrag; if (!lNowDrag) return; var lEditableObject = zzEditableObjectContainer.findRoot(pObject); if (!lEditableObject) return; editableObject = lEditableObject; lEditableObject.draged = true; dragMode = pMode; nowDrag = lNowDrag; dragedRigidbody = lEditableObject.rigidbody; var lDragedTransform = lEditableObject.transform; var lDragWorldPos = zzRigidbodyDrag.getZFlatCrossPoint(lDragedTransform.position, zzObjectPicker.getMainCameraRay()); //getFlatCrossPoint(lDragedTransform.position, getCameraRay(), dragMode); originalPosition = lDragWorldPos; nowDrag.transform.position = lDragWorldPos; nowDrag.connectedBody = dragedRigidbody; }
/// <summary> Event handler for releasing the mouse button. The map is zoomed to the selected section. </summary> /// <param name="sender"> Sender of the MouseUp event. </param> /// <param name="e"> Event parameters. </param> private void source_MouseUp(object sender, MouseButtonEventArgs e) { if (!IsActive) return; if (mapView.IsMouseCaptured) { // we're done. reset the cursor and release the mouse pointer mapView.Cursor = Cursors.Arrow; mapView.ReleaseMouseCapture(); } if (dragMode == DragMode.Select) { mapView.ForePaneCanvas.Children.Remove(dragRectangle); dragRectangle = null; dragMode = DragMode.None; var physicalPoint = e.GetPosition(mapView); double minx = physicalPoint.X < ScreenStartPoint.X ? physicalPoint.X : ScreenStartPoint.X; double miny = physicalPoint.Y < ScreenStartPoint.Y ? physicalPoint.Y : ScreenStartPoint.Y; double maxx = physicalPoint.X > ScreenStartPoint.X ? physicalPoint.X : ScreenStartPoint.X; double maxy = physicalPoint.Y > ScreenStartPoint.Y ? physicalPoint.Y : ScreenStartPoint.Y; if (Math.Abs(maxx - minx) < 32 && Math.Abs(maxy - miny) < 32) return; Point p1 = mapView.TranslatePoint(new Point(minx, miny), mapView.GeoCanvas); Point p2 = mapView.TranslatePoint(new Point(maxx, maxy), mapView.GeoCanvas); mapView.SetEnvelope(new MapRectangle( (p1.X / MapView.ZoomAdjust * MapView.LogicalSize / MapView.ReferenceSize) - 1.0 / MapView.ZoomAdjust * MapView.LogicalSize / 2, (p2.X / MapView.ZoomAdjust * MapView.LogicalSize / MapView.ReferenceSize) - 1.0 / MapView.ZoomAdjust * MapView.LogicalSize / 2, -(p2.Y / MapView.ZoomAdjust * MapView.LogicalSize / MapView.ReferenceSize) + 1.0 / MapView.ZoomAdjust * MapView.LogicalSize / 2, -(p1.Y / MapView.ZoomAdjust * MapView.LogicalSize / MapView.ReferenceSize) + 1.0 / MapView.ZoomAdjust * MapView.LogicalSize / 2), Map.UseAnimation); e.Handled = true; } if (wasPanned) { wasPanned = false; e.Handled = true; } }
protected override void OnMouseUp(MouseEventArgs e) { if (mDragMode == DragMode.SelectRange) { int area = mSelectRect.Width * mSelectRect.Height; if (area > 10) { float minX = GetValueX(mSelectRect.Left); float maxX = GetValueX(mSelectRect.Right); float minY = GetValueY(mSelectRect.Top); float maxY = GetValueY(mSelectRect.Bottom); SetZoom(minX, minY, maxX, maxY); } } mDragMode = DragMode.None; base.OnMouseUp(e); }
private void OnMouseMove_Reorder(ref bool handled, Point mousePosition, Point mousePositionHeaders, Point mousePositionGrid, Point mousePositionGridParent, double distanceFromLeft, double distanceFromRight) { if (handled) { return; } #region handle entry into reorder mode if (_dragMode == DragMode.MouseDown && _dragColumn == null && (distanceFromRight > DATAGRIDCOLUMNHEADER_resizeRegionWidth && distanceFromLeft > DATAGRIDCOLUMNHEADER_resizeRegionWidth)) { DragStartedEventArgs dragStartedEventArgs = new DragStartedEventArgs(mousePositionGrid.X - _lastMousePositionGrid.Value.X, mousePositionGrid.Y - _lastMousePositionGrid.Value.Y); this.OwningGrid.OnColumnHeaderDragStarted(dragStartedEventArgs); handled = CanReorderColumn(this.OwningColumn); if (handled) { DataGridColumnHeader dragIndicator = new DataGridColumnHeader(); dragIndicator.OwningColumn = this.OwningColumn; dragIndicator.IsEnabled = false; dragIndicator.Content = this.Content; dragIndicator.ContentTemplate = this.ContentTemplate; if (this.OwningGrid.DragIndicatorStyle != null) { dragIndicator.Style = this.OwningGrid.DragIndicatorStyle; } // If the user didn't style the dragIndicator's Width, default it to the column header's width if (double.IsNaN(dragIndicator.Width)) { dragIndicator.Width = this.ActualWidth; } // If the user didn't style the dropLocationIndicator's Height, default to the column header's height // if (double.IsNaN(this.OwningGrid.ColumnDropLocationIndicator.Height)) { this.OwningGrid.ColumnDropLocationIndicator.Height = this.ActualHeight; } // pass the caret's data template to the user for modification DataGridColumnReorderingEventArgs columnReorderingEventArgs = new DataGridColumnReorderingEventArgs(this.OwningColumn) { DropLocationIndicator = this.OwningGrid.ColumnDropLocationIndicator, DragIndicator = dragIndicator }; this.OwningGrid.OnColumnReordering(columnReorderingEventArgs); if (columnReorderingEventArgs.Cancel) { return; } // The user didn't cancel, so prepare for the reorder _dragColumn = this.OwningColumn; _dragMode = DragMode.Reorder; _dragStartParent = mousePositionGridParent; // the mouse position relative to the ColumnHeader needs to be scaled to be in the same // dimensions as the DataGrid, so that it doesn't get out of sync later on _dragStart = this.OwningGrid.RenderTransform.Transform(mousePosition); // Display the reordering thumb if (_reorderingThumb == null) { _reorderingThumb = new Popup(); } _reorderingThumb.Child = columnReorderingEventArgs.DragIndicator; _reorderingThumb.IsOpen = true; // use the data template to populate the caret if (columnReorderingEventArgs.DropLocationIndicator != null) { Control child = columnReorderingEventArgs.DropLocationIndicator; this.OwningGrid.ColumnDropLocationIndicatorPopup.Child = child; this.OwningGrid.ColumnDropLocationIndicatorPopup.Height = child.ActualHeight; this.OwningGrid.ColumnDropLocationIndicatorPopup.Width = child.ActualWidth; this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false; } } } #endregion #region handle reorder mode (eg, positioning of the popup) if (_dragMode == DragMode.Reorder && _reorderingThumb != null) { DragDeltaEventArgs dragDeltaEventArgs = new DragDeltaEventArgs(mousePositionGrid.X - _lastMousePositionGrid.Value.X, mousePositionGrid.Y - _lastMousePositionGrid.Value.Y); this.OwningGrid.OnColumnHeaderDragDelta(dragDeltaEventArgs); _reorderingThumb.HorizontalOffset = mousePositionGridParent.X - _dragStart.Value.X; _reorderingThumb.VerticalOffset = _dragStartParent.Value.Y - _dragStart.Value.Y; // the mouse position relative to the ColumnHeadersPresenter can be scaled differently than // the same position relative to the DataGrid, so apply the grid's RenderTransform Point scaledMousePositionHeaders = this.OwningGrid.RenderTransform.Transform(mousePositionHeaders); // prepare some variables for clipping/hiding double dgX = mousePositionGridParent.X - scaledMousePositionHeaders.X; double dgY = mousePositionGridParent.Y - scaledMousePositionHeaders.Y; double dgW = this.OwningGrid.CellsWidth; double dgH = this.OwningGrid.CellsHeight + this.OwningGrid.ColumnHeaders.ActualHeight; // we need to transform the size of the clipping rectangle if the datagrid has a rendertransform set Point clipSize = new Point(dgW, dgH); clipSize = this.OwningGrid.RenderTransform.Transform(clipSize); // clip the thumb to the column headers region _reorderingThumb.Child.Clip = new RectangleGeometry { Rect = new Rect( dgX - _reorderingThumb.HorizontalOffset, dgY - _reorderingThumb.VerticalOffset, clipSize.X, clipSize.Y ) }; // if the datagrid has a scale transform, apply the inverse to the popup's clipping rectangle ScaleTransform scaleTransform = null; ScaleTransform gridScaleTransform = _reorderingThumb.Child.RenderTransform as ScaleTransform; if (gridScaleTransform != null && gridScaleTransform.ScaleY != 0.0 && gridScaleTransform.ScaleX != 0.0) { scaleTransform = new ScaleTransform(); scaleTransform.ScaleX = 1.0 / gridScaleTransform.ScaleX; scaleTransform.ScaleY = 1.0 / gridScaleTransform.ScaleY; } if (scaleTransform != null) { _reorderingThumb.Child.Clip.Transform = scaleTransform; } // Find header we're hovering over DataGridColumn targetColumn = this.GetReorderingTargetColumn(mousePosition, true /* ignoreVertical */, true /* clipToVisible */); if (this.OwningGrid.ColumnDropLocationIndicator != null) { if (targetColumn == this.OwningGrid.ColumnsInternal.FillerColumn) { // change target column to last column but position caret at the end targetColumn = this.OwningGrid.ColumnsInternal.LastVisibleColumn; Point targetPosition = this.OwningGrid.RenderTransform.Transform(this.Translate(targetColumn.HeaderCell, mousePosition)); this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = true; this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset = mousePositionGridParent.X - targetPosition.X + targetColumn.HeaderCell.ActualWidth; this.OwningGrid.ColumnDropLocationIndicatorPopup.VerticalOffset = mousePositionGridParent.Y - targetPosition.Y; } else if (targetColumn != null) { // try to position caret Point targetPosition = this.OwningGrid.RenderTransform.Transform(this.Translate(targetColumn.HeaderCell, mousePosition)); this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = true; this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset = mousePositionGridParent.X - targetPosition.X; this.OwningGrid.ColumnDropLocationIndicatorPopup.VerticalOffset = mousePositionGridParent.Y - targetPosition.Y; } else { this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false; } // hide the caret if it's off the grid -- this is not the same as clipping if (this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset < dgX || dgX + clipSize.X < this.OwningGrid.ColumnDropLocationIndicatorPopup.HorizontalOffset) { this.OwningGrid.ColumnDropLocationIndicatorPopup.IsOpen = false; } } handled = true; } #endregion }
protected override void OnMouseDown(MouseEventArgs e) { if (mGraphRect.Contains(new Point(e.X, e.Y))) { mMouseDownX = e.X; mMouseDownY = e.Y; if (e.Button == System.Windows.Forms.MouseButtons.Left) { mSelectRect = new Rectangle(e.X, e.Y, 0, 0); mDragMode = DragMode.SelectRange; } else if (e.Button == System.Windows.Forms.MouseButtons.Right) { mDragMode = DragMode.GraphDrag; } } base.OnMouseDown(e); }
void OnMouseDown(object sender, MouseEventArgs args) { if (args.Button == MouseButtons.Left) { _dragMode = _hypotheticalDragMode; _dragStart = args.Location; if (_dragMode != DragMode.None) { _graph.PanningIsEnabled = false; } if (_dragMode == DragMode.Center) { _graph.Control.Cursor = HandDrag; } } }
void OnDragObject(GameObject pObject, DragMode pMode) { if (dragMode != DragMode.none) return; var lEditableObject = zzEditableObjectContainer.findRoot(pObject); if (!lEditableObject) return; editableObject = lEditableObject; lEditableObject.draged = true; dragMode = pMode; //放缩的尺寸基于原始的放缩值 var lObjectScale = lEditableObject.transform.localScale; switch (dragMode) { case DragMode.XY: scaleValue = Mathf.Sqrt(lObjectScale.x * lObjectScale.x + lObjectScale.y * lObjectScale.y) * 0.01f; break; case DragMode.XZ: scaleValue = Mathf.Sqrt(lObjectScale.x * lObjectScale.x + lObjectScale.z * lObjectScale.z) * 0.01f; break; } lastMousePosition = getMousePosition(); }
private void OnStartMove(Vector2 position, DragMode dragMode, bool rippleTime) { Bounds selectionBounds = this.selectionBounds; this.m_DragMode = dragMode; this.m_Previous = position; this.m_RippleTime = rippleTime; this.m_RippleTimeStart = selectionBounds.min.x; this.m_RippleTimeEnd = selectionBounds.max.x; this.m_CurveEditor.StartLiveEdit(); }
internal void OnMouseLeftButtonUp(ref bool handled, Point mousePosition) { this.IsPressed = false; if (_dragMode == DragMode.MouseDown) { OnMouseLeftButtonUp_Click(ref handled); } else if (_dragMode == DragMode.Reorder) { // Find header we're hovering over int? targetIndex = this.GetReorderingTargetDisplayIndex(mousePosition, true /* ignoreVertical */, true /* clipToVisible */); if (targetIndex.HasValue && ((!this.OwningColumn.IsFrozen && targetIndex.Value >= this.OwningGrid.FrozenColumnCount) || (this.OwningColumn.IsFrozen && targetIndex.Value < this.OwningGrid.FrozenColumnCount))) { this.OwningColumn.DisplayIndex = targetIndex.Value; DataGridColumnEventArgs ea = new DataGridColumnEventArgs(this.OwningColumn); this.OwningGrid.OnColumnReordered(ea); } DragCompletedEventArgs dragCompletedEventArgs = new DragCompletedEventArgs(mousePosition.X - _dragStart.Value.X, mousePosition.Y - _dragStart.Value.Y, false); this.OwningGrid.OnColumnHeaderDragCompleted(dragCompletedEventArgs); // If we autosized the indicator's height, set it back to NaN if (this._autoSizeDropLocationIndicatorHeight) { this._autoSizeDropLocationIndicatorHeight = false; this.OwningGrid.ColumnDropLocationIndicator.Height = double.NaN; } } else if (_dragMode == DragMode.Drag) { DragCompletedEventArgs dragCompletedEventArgs = new DragCompletedEventArgs(0, 0, false); this.OwningGrid.OnColumnHeaderDragCompleted(dragCompletedEventArgs); } SetDragCursor(mousePosition); // Variables that track drag mode states get reset in DataGridColumnHeader_LostMouseCapture ReleaseMouseCapture(); DataGridColumnHeader._dragMode = DragMode.None; handled = true; }