public void Canceled(object sender, InputModeEventArgs e) { if (editingContext != null) { editingContext.CancelDrag(); editingContext = null; } }
/// <summary> /// The component is currently be moved or resized. /// For each drag a new layout is calculated and applied if the previous one is completed. /// </summary> private void OnDragged(object sender, InputModeEventArgs e) { if (sender is ComponentDropInputMode graphDropInputMode) { layoutHelper.Location = graphDropInputMode.MousePosition.ToPointD(); layoutHelper.RunLayout(); } }
public void Finished(object sender, InputModeEventArgs e) { if (editingContext != null) { editingContext.DragFinished(); editingContext = null; } }
/// <summary> /// The component is upon to be moved or resized. /// </summary> private void OnDragStarting(object sender, InputModeEventArgs e) { if (sender is ComponentDropInputMode graphDropInputMode) { var component = graphDropInputMode.DropData as IGraph; layoutHelper = new ClearAreaLayoutHelper(graphControl, component, keepComponentsButton.Checked ? graphComponents : null); layoutHelper.InitializeLayout(); } }
/// <summary> /// Dragging the component has been canceled. /// The state before the gesture must be restored. /// </summary> private void OnDragCanceled(object sender, InputModeEventArgs e) { var graphDropInputMode = sender as ComponentDropInputMode; if (graphDropInputMode != null) { layoutHelper.CancelLayout(); } }
private void InputModeOnDragCanceled(object sender, InputModeEventArgs inputModeEventArgs) { Unregister(); if (graph.Contains(bend)) { var edge = bend.Owner; var bendIndex = bend.GetIndex(); IBend previousBend = null; IBend nextBend = null; if (bendIndex > 0) { previousBend = edge.Bends[bendIndex - 1]; } IBend prevPrevBend = null; if (bendIndex > 1) { prevPrevBend = edge.Bends[bendIndex - 2]; } if (bendIndex < edge.Bends.Count - 1) { nextBend = edge.Bends[bendIndex + 1]; } IBend nextNextBend = null; if (bendIndex < edge.Bends.Count - 2) { nextNextBend = edge.Bends[bendIndex + 2]; } graph.Remove(bend); //Also remove the additional bends if (previousBend != null) { graph.Remove(previousBend); } if (nextBend != null) { graph.Remove(nextBend); } //And roll back the position change of the adjacent bends if (prevPrevBend != null) { PointD oldLocation; if (bendInputMode.LocationMementos.TryGetValue(prevPrevBend, out oldLocation)) { graph.SetBendLocation(prevPrevBend, oldLocation); } } if (nextNextBend != null) { PointD oldLocation; if (bendInputMode.LocationMementos.TryGetValue(nextNextBend, out oldLocation)) { graph.SetBendLocation(nextNextBend, oldLocation); } } } }
/// <summary> /// The component is currently be moved or resized. /// For each drag a new layout is calculated and applied if the previous one is completed. /// </summary> private void OnDragged(object sender, InputModeEventArgs e) { var graphDropInputMode = sender as ComponentDropInputMode; if (graphDropInputMode != null) { layoutHelper.Location = graphDropInputMode.MousePosition.ToPointD(); layoutHelper.RunLayout(); } }
/// <summary> /// The component is upon to be moved or resized. /// </summary> private void OnDragStarting(object sender, InputModeEventArgs e) { var graphDropInputMode = sender as ComponentDropInputMode; if (graphDropInputMode != null) { var component = graphDropInputMode.DropData as IGraph; layoutHelper = new ClearAreaLayoutHelper(GraphControl, component, ConsiderComponents.IsChecked == true ? components : null); layoutHelper.InitializeLayout(); } }
/// <summary> /// Notifies the current <see cref="GraphSnapContext"/> which nodes are going to be reshaped. /// </summary> private void RegisterReshapedNodes(object sender, InputModeEventArgs e) { // register reshaped nodes var snapContext = e.Context.Lookup <GraphSnapContext>(); if (snapContext != null && snapContext.Enabled) { foreach (var node in rectangle.Nodes) { snapContext.AddItemToBeReshaped(node); } } }
public void Starting(object sender, InputModeEventArgs e) { IInputModeContext context = e.Context; var edgeEditingContext = context.Lookup <OrthogonalEdgeEditingContext>(); if (edgeEditingContext != null && !edgeEditingContext.IsInitializing && !edgeEditingContext.IsInitialized) { editingContext = edgeEditingContext; editingContext.InitializeDrag(context); } else { editingContext = null; } }
/// <summary> /// Notifies the layout of the new positions of the interactively moved nodes. /// </summary> private void OnMoving(object sender, InputModeEventArgs inputModeEventArgs) { if (layout != null) { CopiedLayoutGraph copy = this.copiedLayoutGraph; foreach (INode node in movedNodes) { Node copiedNode = copy.GetCopiedNode(node); if (copiedNode != null) { //Update the position of the node in the CLG to match the one in the IGraph layout.SetCenter(copiedNode, node.Layout.GetCenter().X, node.Layout.GetCenter().Y); //Increasing the heat has the effect that the layout will consider these nodes as not completely placed... IncreaseHeat(copiedNode, layout, 0.05); } } //Notify the layout algorithm that there is new work to do... layout.WakeUp(); } }
// Before the move gesture starts, we store all moved nodes, their parents and the maximum z-order of // children of their parents private void MoveStarting(object sender, InputModeEventArgs e) { Graph = e.Context.GetGraph(); ZOrderSupport = Graph.Lookup <ZOrderSupport>(); // store all selected nodes which might get reparented MovedNodes = Geim.GraphSelection.SelectedNodes.ToList(); // sort this list by their relative z-order MovedNodes.Sort(ZOrderSupport); // calculate max z-order for all group nodes containing any moved node foreach (var node in MovedNodes) { var parent = Graph.GetParent(node); oldParents[node] = parent; GetOrCalculateMaxZOrder(parent); } // calculate max z-order of top-level nodes GetOrCalculateMaxZOrder(null); }
/// <summary> /// The listener for a finished drag gesture, will add all affected edges and bends into a list /// and route the affected edges. /// </summary> private async void DragFinishedListenerHandle(object sender, InputModeEventArgs e) { var affectedEdges = new List <IEdge>(); var graphSelection = graphControl.Selection; foreach (var node in graphSelection.SelectedNodes) { foreach (var edge in Graph.EdgesAt(node)) { affectedEdges.Add(edge); } } foreach (var bend in graphSelection.SelectedBends) { // add bend owners to the affected edges' list affectedEdges.Add(bend.Owner); } // route the affected edges await RouteAffectedEdges(affectedEdges); }
/// <summary> /// Called once the interactive move is finished. /// </summary> /// <remarks> /// Updates the state of the interactive layout. /// </remarks> private void OnMovedFinished(object sender, InputModeEventArgs inputModeEventArgs) { if (layout != null) { CopiedLayoutGraph copy = this.copiedLayoutGraph; foreach (INode node in movedNodes) { Node copiedNode = copy.GetCopiedNode(node); if (copiedNode != null) { //Update the position of the node in the CLG to match the one in the IGraph layout.SetCenter(copiedNode, node.Layout.GetCenter().X, node.Layout.GetCenter().Y); layout.SetStress(copiedNode, 0); } } foreach (var copiedNode in copy.Nodes) { //Reset the node's inertia to be fixed layout.SetInertia(copiedNode, 1.0); layout.SetStress(copiedNode, 0); } } }
/// <summary> /// The rectangular area is currently be moved or resized. /// For each drag a new layout is calculated and applied if the previous one is completed. /// </summary> private void OnDragged(object sender, InputModeEventArgs e) { if (IsShiftPressed(e)) { // We do not change the layout now, instead we check if we are hovering a group node. // If so, we use that group node inside which the cleared area should be located. // In addition, the group node is highlighted to better recognize him. if (nodeHitTester != null) { var hitGroupNode = GetHitGroupNode(e.Context); if (hitGroupNode != groupNode) { if (groupNode != null) { GraphControl.HighlightIndicatorManager.RemoveHighlight(groupNode); } if (hitGroupNode != null) { GraphControl.HighlightIndicatorManager.AddHighlight(hitGroupNode); } groupNode = hitGroupNode; } } } else { if (IsShiftChanged(e) && groupNode != null) { // now we remove the highlight of the group GraphControl.HighlightIndicatorManager.RemoveHighlight(groupNode); } // invoke the layout calculation and animation layoutHelper.GroupNode = groupNode; layoutHelper.RunLayout(); } }
/// <summary> /// Moving or resizing the rectangular area has been canceled. /// The state before the gesture must be restored. /// </summary> private void OnDragCanceled(object sender, InputModeEventArgs e) { layoutHelper.CancelLayout(); groupNode = null; }
/// <summary> /// The rectangular area is upon to be moved or resized. /// </summary> private void OnDragStarting(object sender, InputModeEventArgs e) { nodeHitTester = e.Context.Lookup <IHitTester <INode> >(); layoutHelper = new ClearAreaLayoutHelper(GraphControl, clearRect, options); layoutHelper.InitializeLayout(); }
/// <summary> /// Clears the <see cref="MoveInputMode.PositionHandler"/> property. /// </summary> /// <param name="inputModeEventArgs"></param> protected override void OnDragCanceled(InputModeEventArgs inputModeEventArgs) { base.OnDragCanceled(inputModeEventArgs); PositionHandler = null; }
/// <summary> /// Sets the <see cref="MoveInputMode.PositionHandler"/> property. /// </summary> /// <param name="inputModeEventArgs"></param> protected override void OnDragStarting(InputModeEventArgs inputModeEventArgs) { PositionHandler = handler; base.OnDragStarting(inputModeEventArgs); }
private void MoveCanceled(object sender, InputModeEventArgs e) { // clear temporary z-orders and keep the original ones. ZOrderSupport.ClearTempZOrders(); Cleanup(); }
private void InputModeOnDragStarted(object sender, InputModeEventArgs inputModeEventArgs) { initialized = true; }
private void InputModeOnDragFinished(object sender, InputModeEventArgs inputModeEventArgs) { Unregister(); }
// TODO: Improve to select first entry when user starts using the keyboard private void InputManager_InputModeChanged(InputModeEventArgs e) { if(e.NewInputMode == InputMode.Keyboard) focusedButton = components.Count - 1; }
/// <summary> /// Moving or resizing the rectangular area has been finished. /// We execute the layout to the final state. /// </summary> private void OnDragFinished(object sender, InputModeEventArgs e) { layoutHelper.StopLayout(); groupNode = null; }
private void MoveFinished(object sender, InputModeEventArgs e) { // Apply the temporary z-orders for all reparented nodes ZOrderSupport.ApplyTempZOrders(); Cleanup(); }
/// <summary> /// Determines whether <see cref="ModifierKeys.Shift"/> state has been changed. /// </summary> private static bool IsShiftChanged(InputModeEventArgs e) { return((e.Context.CanvasControl.LastMouse2DEvent.ChangedModifiers & ModifierKeys.Shift) == ModifierKeys.Shift); }
/// <summary> /// Determines whether <see cref="Keys.Shift"/> is currently is pressed. /// </summary> private static bool IsShiftPressed(InputModeEventArgs e) { return((e.Context.CanvasControl.LastMouse2DEvent.Modifiers & Keys.Shift) == Keys.Shift); }