public override void OnMouseDown(MouseActionEventArgs e) { var scene = Folding.SceneHandler(); if (HitCount == 0) { Focused = scene.Focused; #if TraceMouse Trace.WriteLine(string.Format("GraphSceneMouseFolding OnMouseDown Focused: {0}", Focused)); #endif } base.OnMouseDown(e); if (Focused != null && Focused != scene.Focused) { #if TraceMouse Trace.WriteLine(string.Format("GraphSceneMouseFolding OnMouseDown HitCount=0, was: {0}", HitCount)); #endif HitCount = 0; } #if TraceMouse Trace.WriteLine(string.Format("GraphSceneMouseFolding OnMouseDown HitCount {0}", HitCount)); #endif Resolved = HitCount > 0; }
protected void BaseMouseDown(MouseActionEventArgs e) { base.OnMouseDown(e); if (DragBoxFromMouseDown == Rectangle.Zero) { DragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width / 2), e.Y - (dragSize.Height / 2)), dragSize); } LastMousePos = e.Location; if (Behaviour == DragBehaviour.DoubleClick) { var hit = CheckDoubleClickHit(e.X, e.Y); if (e.Clicks > 1 && hit) { HitCount++; } else { HitCount = 0; } } LastMouseTime = Environment.TickCount; }
public void OnMouseAction(MouseActionEventArgs mouse) { switch (mouse.Button) { case MouseButton.Left: switch (mouse.Action) { case MouseAction.Released: Point targetPosition = ((mouse.Position.ToVector2() + Camera * Zoom) / Zoom / 32).ToPoint(); if (Map.Bounds.Contains(targetPosition)) { Tile target = Map.Tiles[targetPosition.X, targetPosition.Y]; foreach (Creature creature in Map.Creatures) { creature.WalkTo(target); } } break; } break; case MouseButton.Middle: switch (mouse.Action) { case MouseAction.Released: Zoom = 1.0f; break; } break; } }
private void OnMouseAction(object sender, MouseActionEventArgs mouse) { UIElement interceptor = null; foreach (UIElement child in Children) { if ((interceptor = child.OnMouseAction(mouse)) != null) { if (mouse.Button == MouseButton.Left && mouse.Action == MouseAction.Pressed) { if (!child.IsAlwaysAtBottom) { Children.Remove(child); InsertToTop(child); } if (interceptor.TakesFocusOnMouseAction) { KeyboardFocus = interceptor; } } break; } } }
public override void OnMouseMove(MouseActionEventArgs e) { if (MouseMove != null) { MouseMove(this, e); } }
/// <summary> /// Get the source object type or role after the /// base class sets the source shape /// </summary> /// <param name="e">MouseActionEventArgs</param> protected override void OnClicked(MouseActionEventArgs e) { base.OnClicked(e); if (mySourceObjectType == null && mySourceRole == null) { RoleBase roleBase = myLastMouseDownRole; if (roleBase != null) { Role role = roleBase.Role; mySourceRole = roleBase; FactTypeShape factShape; if (null != role.RolePlayer && null != (factShape = MouseDownHitShape as FactTypeShape)) { bool haveConnectorForRole = false; foreach (RolePlayerLink connector in MultiShapeUtility.GetEffectiveAttachedLinkShapesFrom <RolePlayerLink>(factShape)) { if (connector.AssociatedRolePlayerLink.PlayedRole == role) { haveConnectorForRole = true; break; } } mySourceRoleMissingConnector = !haveConnectorForRole; } } else { mySourceObjectType = ObjectTypeFromShape(MouseDownHitShape); } } }
public override void OnMouseDown(MouseActionEventArgs e) { base.OnMouseDown(e); Resolved = false; canStart = TestSceneHit(e.Location); Exclusive = false; }
/// <summary> /// sets controls ScrollPosition according to mouse position /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void OnMouseMove(MouseActionEventArgs e) { base.OnMouseMove(e); if (Resolved) { var scrollTarget = this.Viewport(); if (scrollTarget != null) { var oldScroll = scrollTarget.ClipOrigin; var dx = e.X - LastMousePos.X; var dy = e.Y - LastMousePos.Y; var scrollPosition = new Point( Math.Max(oldScroll.X - dx, 0), Math.Max(oldScroll.Y - dy, 0) ); this.LastMousePos = new Point(e.X, e.Y); if (oldScroll != scrollPosition) { scrollTarget.ClipOrigin = scrollPosition; scrollTarget.Refresh(); } } } }
public void OnMouseAction(MouseActionEventArgs mouse) { switch (mouse.Action) { case MouseAction.Released: if (Map.ActiveMode == ShipDesignerMap.Mode.Build) { switch (mouse.Button) { case MouseButton.Left: Ship.AddModule(SelectedModule, GridPosition, Map.ModuleRotation); break; case MouseButton.Right: Ship.RemoveModule(GridPosition); break; case MouseButton.Middle: BattleModule module = Ship.GetModuleAt(GridPosition); if (module != null) { SelectedModule = module.Data; } Map.ModuleRotation++; break; } } break; } }
/// <summary> /// Handle the click by emulating a drag/drop operation /// </summary> protected override void OnClicked(MouseActionEventArgs e) { ElementGroupPrototype prototype; DiagramClientView clientView; Diagram diagram; DiagramView activeDiagramView; IToolboxService toolbox; if (null != (prototype = this.myPrototype) && null != (clientView = e.DiagramClientView) && null != (diagram = clientView.Diagram) && null != (activeDiagramView = diagram.ActiveDiagramView) && null != (toolbox = activeDiagramView.Toolbox)) { IDataObject dataObject = new DataObject(typeof(ElementGroupPrototype).FullName, prototype); Point p = clientView.PointToScreen(clientView.WorldToDevice(e.CurrentMousePosition)); clientView.OnDragDropCommon(new DragEventArgs(dataObject, 0, p.X, p.Y, DragDropEffects.Move | DragDropEffects.Copy | DragDropEffects.Scroll, DragDropEffects.None), true, base.MouseDownHitShape); toolbox.SelectedToolboxItemUsed(); } #if VISUALSTUDIO_10_0 // Make sure we deactivate on click if (IsActive) { Cancel(e.DiagramClientView); } #endif // VISUALSTUDIO_10_0 }
public void OnMouseDown(MouseActionEventArgs e) { Resolved = false; if (UserEventsDisabled) { return; } foreach (var mouseAction in MouseActions) { if (mouseAction.Enabled) { mouseAction.OnMouseDown(e); Resolved = mouseAction.Resolved || Resolved; if (mouseAction.Exclusive) { break; } //if (mouseAction is IDragDropAction && // !( (IDragDropAction)mouseAction ).Dragging) { // break; //} } } Perform(); }
public override void OnMouseUp(MouseActionEventArgs e) { if (NewItem != null) { var shape = Scene.ItemShape(NewItem); var newSize = shape.Size; if (newSize.Height < 10 || newSize.Width < 10) { Scene.Remove(NewItem); newCounter--; Scene.Focused = default(TItem); if (Last != null) { Scene.Requests.Add(new LayoutCommand <TItem> (Last, LayoutActionType.Perform)); } Scene.Requests.Add(new Command <TItem>(NewItem)); } else { Scene.Graph.OnGraphChange(NewItem, GraphEventType.Add); } } NewItem = default(TItem); base.OnMouseUp(e); }
protected override void OnMouseMoveResolved(MouseActionEventArgs e) { if ((Edge != null) && (resizing)) { ShowGrips = true; var rect = Camera.ToSource( Rectangle.FromLTRB(MouseDownPos.X, MouseDownPos.Y, LastMousePos.X, LastMousePos.Y)); Scene.Requests.Add(new ResizeCommand <TItem>(Edge, Scene.ItemShape, rect)); foreach (var twigEdge in Scene.Graph.Twig(Edge)) { Scene.Requests.Add(new LayoutCommand <TItem>(twigEdge, LayoutActionType.Justify)); } // saving current mouse position to be used for next dragging this.LastMousePos = e.Location; IsTargetHit(this.LastMousePos); } else { Resolved = false; } }
public override void OnMouseMove(MouseActionEventArgs e) { base.OnMouseMove(e); Resolved = Resolved && Source != null; if (Resolved && (e.Button != MouseActionButtons.Left)) { EndAction(); } if (Resolved && !Dragging) { Dragging = true; InprocDragDrop.Dragging = true; InprocDragDrop.Data = new GraphCursor <IVisual, IVisualEdge>(Scene.Graph, Source); try { var startData = new DragStartData( DragDropViz.TransferDataOfVisual(Scene.Graph, Source), DragDropAction.All, GetDragImageBackend(Scene.Graph, Source), e.Location.X, e.Location.Y); DragDropHandler.DragStart(startData); } catch {} finally { EndAction(); } } }
public virtual void MouseMove(MouseActionEventArgs e) { if (EnabledEvents.HasFlag(WidgetEvent.DragStarted)) { return; } if (e.Button != MouseActionButtons.Left) { return; } if (DragDropInfo.DragRect.IsEmpty) { SetupDragRect(e); } if (DragDropInfo.DragRect.Contains(e.Location)) { return; } var dragData = GetDragStartData(); if (dragData != null) { DragStart(dragData); } DragDropInfo.DragRect = Rectangle.Zero; }
/// <summary> /// sets initial dragging rectangle /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override void OnMouseDown(MouseActionEventArgs e) { base.OnMouseDown(e); MouseDownPos = e.Location; if (e.Button == MouseActionButtons.Left) { resizing = false; hitAnchor = Anchor.None; CursorHandler.SaveCursor(); moving = HitTest(e.Location); if (hitAnchor != Anchor.None && ResizingEnabled) { var anchor = AdjacentAnchor(hitAnchor); resizing = anchor != Anchor.None; this.Resolved = resizing; if (Resolved) { moving = false; this.LastMousePos = e.Location; this.MouseDownPos = Camera.FromSource(this.Shape[anchor]); } } else { Resolved = (this.Shape != null) && moving; } } }
public override void OnMouseMove(MouseActionEventArgs e) { if (Scene == null) { return; } Exclusive = false; var before = Scene.Hovered; Current = HitTest(e.Location); if (Current != null && Scene.Selected.Contains(Current) && (e.Button == MouseActionButtons.None || e.IsTouchEvent)) { if (Scene.Focused != null && !Current.Equals(Scene.Focused)) { Scene.Requests.Add( new StateChangeCommand <TItem>(Scene.Focused, new Pair <UiState>(UiState.None, UiState.Focus)) ); } Scene.Focused = Current; Scene.Hovered = default(TItem); } else { Scene.Hovered = Current; } if (!object.ReferenceEquals(before, Current)) { if (before != null) { Scene.Requests.Add( new StateChangeCommand <TItem>(before, new Pair <UiState>(UiState.Hovered, UiState.None))); } if (Current != null) { Scene.Requests.Add( new StateChangeCommand <TItem>(Current, new Pair <UiState>(UiState.None, UiState.Hovered)) ); } } //if (before != null && !before.Equals(Current)) // Scene.Requests.Add( // new StateChangeCommand<TItem>(before, // new Pair<UiState>(UiState.Hovered, UiState.None))); //if (Current != null && !Current.Equals(before) && !sameFocus) // Scene.Requests.Add( // new StateChangeCommand<TItem>(Current, // new Pair<UiState>(UiState.None, UiState.Hovered)) // ); Resolved = false; }
public override void OnMouseMove(MouseActionEventArgs e) { Exclusive = false; if (Scene == null) { return; } if (Current == null) { return; } base.BaseMouseMove(e); Resolved = Resolved && (Scene.Focused != null); if (Resolved) { OnMouseMoveResolved(e); } if (e.Button != MouseActionButtons.Left) { EndAction(); Resolved = false; return; } Dragging = !Resolved; }
/// <summary> /// Get the source object type or role after the /// base class sets the source shape /// </summary> /// <param name="e">MouseActionEventArgs</param> protected override void OnClicked(MouseActionEventArgs e) { base.OnClicked(e); if (mySourceElement == null) { mySourceElement = ElementFromShape <ORMModelElement>(MouseDownHitShape); } }
/// <summary> /// Allow dragging of the subtype onto the supertype /// </summary> protected override void OnDraggingBegun(MouseActionEventArgs e) { if (mySourceObjectType == null) { mySourceObjectType = ObjectTypeFromShape(MouseDownHitShape); } base.OnDraggingBegun(e); }
/// <summary> /// Allow dragging the source element onto the target /// </summary> protected override void OnDraggingBegun(MouseActionEventArgs e) { if (mySourceElement == null) { mySourceElement = ElementFromShape <ORMModelElement>(MouseDownHitShape); } base.OnDraggingBegun(e); } /// <summary>
/// <summary> /// Get the source object type or role after the /// base class sets the source shape /// </summary> /// <param name="e">MouseActionEventArgs</param> protected override void OnClicked(MouseActionEventArgs e) { base.OnClicked(e); if (mySourceObjectType == null) { mySourceObjectType = ObjectTypeFromShape(MouseDownHitShape); } }
public override void OnMouseDown(MouseActionEventArgs e) { base.OnMouseDown(e); if (MouseDown != null) { MouseDown(e); } }
public override void OnMouseUp(MouseActionEventArgs e) { base.OnMouseUp(e); if (MouseUp != null) { MouseUp(this, e); } }
public override void OnMouseDown(MouseActionEventArgs e) { var item = Hit(e); if (MoveIfItemHit || item == null) { base.OnMouseDown(e); } }
public override void OnMouseMove(MouseActionEventArgs e) { if (DragLeft) { Dropping = false; DragLeft = false; } base.OnMouseMove(e); }
public override void OnMouseUp(MouseActionEventArgs e) { canStart = false; base.OnMouseUp(e); Exclusive = false; var oldShape = this.Shape; this.Shape = ShapeFactory.Shape(ShapeDataType, Point.Zero, Size.Zero, false); SelectionRenderer.InvalidateShapeOutline(oldShape, ShapeFactory.Shape(ShapeDataType, Point.Zero, Size.Zero, false)); }
protected override void OnMouseMoveResolved(MouseActionEventArgs e) { if (NewItem == null) { AddItem(); this.MouseDownPos = e.Location; } base.OnMouseMoveResolved(e); }
public override UIElement OnMouseAction(MouseActionEventArgs mouse) { UIElement intercept = base.OnMouseAction(mouse); if (intercept == this && mouse.Action == MouseAction.Released && mouse.Button == MouseButton.Left && OnClick != null) { OnClick(this, EventArgs.Empty); } return(intercept); }
public void MoveNode1(Rectangle bounds) { NeutralPosition(); var startposition = Factory.Nodes[1].Shape[Anchor.LeftTop] + new Size(10, 0); var position = camera.FromSource(startposition); var e = new MouseActionEventArgs( MouseActionButtons.Left, ModifierKeys.None, 0, position.X, position.Y, 0); Display.ActionDispatcher.OnMouseDown(e); DoEvents(); Assert.AreSame(Scene.Focused, Factory.Nodes[1]); Display.ActionDispatcher.OnMouseUp(e); Display.ActionDispatcher.OnMouseDown(e); DoEvents(); var v = new Vector(); // diagonal movement: v.Start = startposition; v.End = new Point(bounds.Right, bounds.Bottom); MoveAlongLine(v); // horizontal movement: v.Start = v.End; v.End = new Point(bounds.Right, startposition.Y); MoveAlongLine(v); // vertical movement: v.Start = v.End; v.End = new Point(startposition.X, bounds.Bottom); MoveAlongLine(v); v.Start = v.End; v.End = new Point(bounds.Width / 2, bounds.Bottom); MoveAlongLine(v); v.Start = v.End; v.End = new Point(bounds.Width / 2, Factory.distance.Height); MoveAlongLine(v); v.Start = v.End; v.End = startposition; MoveAlongLine(v); position = camera.FromSource(v.End); e = new MouseActionEventArgs( MouseActionButtons.Left, ModifierKeys.None, 0, position.X, position.Y, 0); Display.ActionDispatcher.OnMouseUp(e); }
/// <summary> /// Add a source shape or commit/cancel the action by forwarding the /// click to the base class, or modify the current role sequence by handling /// the click locally. /// </summary> /// <param name="e">MouseActionEventArgs</param> protected override void OnClicked(MouseActionEventArgs e) { switch (myPendingOnClickedAction) { case OnClickedAction.Commit: myPendingOnClickedAction = OnClickedAction.Normal; // Letting the click through to the base ConnectAction // at this point (a constraint is selected and a role has been // double-clicked) will force the connect action to finish. base.OnClicked(e); return; case OnClickedAction.CheckForCommit: myPendingOnClickedAction = OnClickedAction.Normal; break; } DiagramMouseEventArgs args = CurrentDiagramArgs as DiagramMouseEventArgs; if (args != null) { DiagramItem item = args.DiagramHitTestInfo.HitDiagramItem; ModelElement currentElement = null; bool isSupertypeRole = false; ORMDiagram ormDiagram; foreach (ModelElement elem in item.RepresentedElements) { currentElement = elem; SubtypeLink subtypeLink = currentElement as SubtypeLink; if (subtypeLink != null) { isSupertypeRole = true; currentElement = subtypeLink.AssociatedSubtypeFact.SupertypeRole; } break; } ExternalConstraintShape constraintShape; Role role; if (null != (constraintShape = currentElement as ExternalConstraintShape)) { if (mySourceShape == null) { // Let the click through to the base to officially begin the drag action base.OnClicked(e); mySourceShape = constraintShape; IConstraint activeConstraint = constraintShape.AssociatedConstraint; myActiveConstraint = activeConstraint; switch (activeConstraint.ConstraintType) { case ConstraintType.DisjunctiveMandatory: // This setting is refined later myAllowSubtypeConnection = true; break; case ConstraintType.Exclusion: ExclusionConstraint exclusion = (ExclusionConstraint)activeConstraint; // If the exclusion constraint is currently attached to any fact types // that are not subtype facts, then we cannot allow a subtype connection. LinkedElementCollection<FactType> exclusionFactTypes = exclusion.FactTypeCollection; myAllowSubtypeConnection = (exclusionFactTypes.Count == 0) ? true : exclusionFactTypes[0] is SubtypeFact; break; default: myAllowSubtypeConnection = false; break; } if (null != (ormDiagram = mySourceShape.Diagram as ORMDiagram)) { ormDiagram.StickyObject = constraintShape; } } } else if (null != (role = currentElement as Role)) { // Add or remove the role IList<Role> roles = SelectedRoleCollection; int roleIndex = roles.IndexOf(role); bool forceRedraw = false; int redrawIndexBound = -1; ExternalConstraintShape sourceShape = mySourceShape; if (roleIndex >= 0) { // Only remove a role when the control key is down. Otherwise, // there is no way to double-click on a previously selected // role without turning it off, and this is a natural gesture. // Add shift key as well for discoverability. if (0 != (0xff00 & GetKeyState(Keys.ControlKey)) || 0 != (0xff00 & GetKeyState(Keys.ShiftKey))) { forceRedraw = true; roles.RemoveAt(roleIndex); redrawIndexBound = roles.Count; if (roles.Count == 0 && mySubtypeConnection && InitialRoles.Count == 0) { mySubtypeConnection = false; } } } else { bool allowAdd = false; if (mySubtypeConnection) { allowAdd = isSupertypeRole; } else if (isSupertypeRole) { if (roles.Count == 0 && InitialRoles.Count == 0 && myAllowSubtypeConnection) { mySubtypeConnection = true; allowAdd = true; } } else { allowAdd = true; } if (allowAdd) { forceRedraw = true; roles.Add(role); } else { sourceShape = null; } } if (sourceShape != null) { myPendingOnClickedAction = OnClickedAction.CheckForCommit; } if (forceRedraw) { // Force the shape types to redraw RedrawOwningFactType(role); // Force anything with a later index to redraw as well. // These roles may be on different fact types than the // original. for (int i = roleIndex; i < redrawIndexBound; ++i) { RedrawOwningFactType(roles[i]); } } } else if (mySourceShape != null && null != (ormDiagram = currentElement as ORMDiagram)) { #if VISUALSTUDIO_10_0 if (IsActive) { Cancel(e.DiagramClientView); } #else base.OnClicked(e); // Let through to allow a cancel #endif } } }
/// <summary> /// Add a source shape or commit/cancel the action by forwarding the /// click to the base class, or modify the current role sequence by handling /// the click locally. /// </summary> /// <param name="e">MouseActionEventArgs</param> protected override void OnClicked(MouseActionEventArgs e) { switch (myPendingOnClickedAction) { case OnClickedAction.Commit: myPendingOnClickedAction = OnClickedAction.Normal; // Letting the click through to the base ConnectAction // at this point (a constraint is selected and a role has been // double-clicked) will force the connect action to finish. base.OnClicked(e); return; case OnClickedAction.CheckForCommit: myPendingOnClickedAction = OnClickedAction.Normal; break; } DiagramMouseEventArgs args = CurrentDiagramArgs as DiagramMouseEventArgs; if (args != null) { DiagramItem item = args.DiagramHitTestInfo.HitDiagramItem; ModelElement currentElement = null; foreach (ModelElement elem in item.RepresentedElements) { currentElement = elem; break; } UniquenessConstraint internalUniquenessConstraint; RoleBase roleBase; if (null != (internalUniquenessConstraint = currentElement as UniquenessConstraint) && internalUniquenessConstraint.IsInternal) { if (mySourceShape == null) { // Let the click through to the base to officially begin the drag action base.OnClicked(e); mySourceShape = item.Shape as FactTypeShape; myIUC = internalUniquenessConstraint; } } else if (mySourceShape != null) { if (null != (roleBase = currentElement as RoleBase)) { Role role = roleBase.Role; if (role.FactType == mySourceShape.AssociatedFactType) { // Add or remove the role IList<Role> roles = SelectedRoleCollection; int roleIndex = roles.IndexOf(role); bool forceRedraw = false; if (roleIndex >= 0) { // Only remove a role when the control key is down. Otherwise, // there is no way to double-click on a previously selected // role without turning it off, and this is a natural gesture. // Add shift key as well for discoverability. if (0 != (0xff00 & GetKeyState(Keys.ControlKey)) || 0 != (0xff00 & GetKeyState(Keys.ShiftKey))) { forceRedraw = true; roles.RemoveAt(roleIndex); } } else { forceRedraw = true; roles.Add(role); } if (mySourceShape != null) { myPendingOnClickedAction = OnClickedAction.CheckForCommit; } if (forceRedraw) { // Force the shape to redraw Debug.Assert(mySourceShape != null); //source shape should have been set mySourceShape.Invalidate(true); } } } else if (currentElement is ORMDiagram) { base.OnClicked(e); // Let through to allow a cancel } } } }
/// <summary> /// Hack override to handle MSBUG where the transaction triggered /// by the mouse action is committed after the mouse action is deactivated. /// We don't want this because we end up tossing our state prematurely and /// cannot commit our mouse action. /// </summary> protected override void OnClicked(MouseActionEventArgs e) { try { myInOnClicked = true; myDeactivatedDuringOnClick = false; base.OnClicked(e); #if VISUALSTUDIO_10_0 if (IsActive) { Cancel(e.DiagramClientView); } #endif myInOnClicked = false; if (myDeactivatedDuringOnClick) { OnMouseActionDeactivated(e); } } finally { myInOnClicked = false; } }
/// <summary> /// Get the source object type or role after the /// base class sets the source shape /// </summary> /// <param name="e">MouseActionEventArgs</param> protected override void OnClicked(MouseActionEventArgs e) { base.OnClicked(e); if (mySourceObjectType == null && mySourceRole == null) { RoleBase roleBase = myLastMouseDownRole; if (roleBase != null) { Role role = roleBase.Role; mySourceRole = roleBase; FactTypeShape factShape; if (null != role.RolePlayer && null != (factShape = MouseDownHitShape as FactTypeShape)) { bool haveConnectorForRole = false; foreach (RolePlayerLink connector in MultiShapeUtility.GetEffectiveAttachedLinkShapesFrom<RolePlayerLink>(factShape)) { if (connector.AssociatedRolePlayerLink.PlayedRole == role) { haveConnectorForRole = true; break; } } mySourceRoleMissingConnector = !haveConnectorForRole; } } else { mySourceObjectType = ObjectTypeFromShape(MouseDownHitShape); } } }