/// <summary> /// Toogles off/on the info pane for the given vertex /// </summary> /// <param name="vertexControl">The vertex control.</param> /// <param name="toggleInfoPaneForNodeCommand">The toggle info pane for node command.</param> private static void Toogle(GraphSharp.Controls.VertexControl vertexControl, ICommand toggleInfoPaneForNodeCommand) { if (toggleInfoPaneForNodeCommand != null) { var node = vertexControl.Vertex as ExperimentNode; if (node != null) { Point suggestedLocation = new Point(); var param = new TraceLab.UI.WPF.Commands.ToggleNodeInfoParameters() { SuggestedLocation = suggestedLocation, Node = node }; if (vertexControl != null) { const int padding = 5; suggestedLocation = new Point(vertexControl.TopLeftX + vertexControl.ActualWidth, vertexControl.TopLeftY + vertexControl.ActualHeight + padding); param.SuggestedLocation = suggestedLocation; } toggleInfoPaneForNodeCommand.Execute(param); } } }
/// <summary> /// Initializes a new instance of the <see cref="DecisionNodeInfo"/> class. /// </summary> /// <param name="originVertexControl">The origin vertex control.</param> internal DecisionNodeInfo(GraphSharp.Controls.VertexControl originVertexControl) : base(originVertexControl) { }
/// <summary> /// Initializes a new instance of the <see cref="ComponentNodeInfo"/> class. /// </summary> /// <param name="originVertexControl">The origin vertex control.</param> internal ComponentNodeInfo(GraphSharp.Controls.VertexControl originVertexControl) : base(originVertexControl) { }
private static Point FindOptimalLocation(GraphSharp.Controls.VertexControl vertexControl) { Point suggestedLocation = new Point(); var node = vertexControl.Vertex as ExperimentNode; if (node != null) { if (vertexControl != null) { const int padding = 5; suggestedLocation = new Point(vertexControl.TopLeftX + vertexControl.ActualWidth, vertexControl.TopLeftY + vertexControl.ActualHeight + padding); //special case, if node belongs to the graph in the scope var ownerGraph = node.Owner as CompositeComponentEditableGraph; if (ownerGraph != null) { var scopeNode = ownerGraph.OwnerNode as ScopeNodeBase; if (scopeNode != null) { var data = scopeNode.DataWithSize; double labelBorderHeight = 23; // check scope node control suggestedLocation = new Point(suggestedLocation.X + data.X - (data.Width / 2), suggestedLocation.Y + data.Y - (data.Height / 2) + labelBorderHeight); } } } } return suggestedLocation; }
public static Boolean GetIsSelected(GraphSharp.Controls.VertexControl element) { return (Boolean)element.GetValue(IsSelectedProperty); }
public static void SetIsSelected(GraphSharp.Controls.VertexControl element, Boolean value) { element.SetValue(IsSelectedProperty, value); }
/// <summary> /// Creates the info panel view model for the given vertex control based on its type /// </summary> /// <param name="vertexControl">The vertex control for which the info is created.</param> /// <returns>node info view model</returns> public static ExperimentNodeInfo CreateInfo(GraphSharp.Controls.VertexControl vertexControl) { var node = vertexControl.Vertex as ExperimentNode; if (node == null) { throw new ArgumentNullException("node"); } if (node.Data == null) { throw new InvalidOperationException("Cannot create info for node with invalid data."); } ExperimentNodeInfo info = null; //there are different types of node info view models depending on what vertex control type is //based on the node info type different view templates are used to render the info panel //most common is component, so check it first if (node.Data.Metadata is ComponentMetadata) { info = new ComponentNodeInfo(vertexControl); } else if (node.Data.Metadata is CompositeComponentMetadata) { info = new CompositeComponentNodeInfo(vertexControl); } else if (node.Data.Metadata is DecisionMetadata) { info = new DecisionNodeInfo(vertexControl); } else if (node.Data.Metadata is LoopScopeMetadata) { info = new LoopDecisionNodeInfo(vertexControl); } return info; }
/// <summary> /// Initializes a new instance of the <see cref="ExperimentNodeInfo"/> class. /// </summary> /// <param name="originVertexControl">The origin vertex control.</param> protected ExperimentNodeInfo(GraphSharp.Controls.VertexControl originVertexControl) { OriginVertexControl = originVertexControl; Node = (ExperimentNode)originVertexControl.Vertex; }
/// <summary> /// Creates the route point on edge. /// </summary> /// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param> /// <param name="hitEdge">The hit edge.</param> private void CreateRoutePointOnEdge(MouseButtonEventArgs e, GraphSharp.Controls.EdgeControl hitEdge) { ExperimentNodeConnection connection = (ExperimentNodeConnection)hitEdge.Edge; Point canvasPoint = e.GetPosition(GraphLayout); RoutePoint finalPoint = new RoutePoint(canvasPoint.X, canvasPoint.Y); connection.RoutePoints.Add(finalPoint); }
private void RevealHACKControls(Point clickPoint, GraphSharp.Controls.VertexControl parent) { PotentialLinkSource = parent; HACK_VertexControl.CenterX = clickPoint.X; HACK_VertexControl.CenterY = clickPoint.Y; HACK_VertexControl.Visibility = Visibility.Visible; HACK_VertexControl.PreviewMouseLeftButtonUp += HACK_Control_PreviewMouseLeftButtonUp; HACK_VertexControl.PreviewMouseMove += HACK_Control_PreviewMouseMove; HACK_EdgeControl.SetValue(GraphSharp.Controls.EdgeControl.SourceProperty, parent); HACK_EdgeControl.SetValue(GraphSharp.Controls.EdgeControl.TargetProperty, HACK_VertexControl); HACK_EdgeControl.Visibility = Visibility.Visible; }
private void StartCreateLinkDrag(GraphSharp.Controls.VertexControl node) { Point clickPoint = Mouse.GetPosition(GraphLayout); RevealHACKControls(clickPoint, node); int timestamp = new TimeSpan(DateTime.Now.Ticks).Milliseconds; BeginDrag(Mouse.PrimaryDevice, timestamp, MouseButton.Left); }
/// <summary> /// Determines whether the edge can be redirected /// </summary> /// <param name="edge">The edge.</param> /// <returns> /// <c>true</c> if this instance [can redirect link] the specified current edge; otherwise, <c>false</c>. /// </returns> private bool CanRedirectLink(GraphSharp.Controls.EdgeControl edge) { bool canRedirect = false; if (edge != null) { ExperimentNodeConnection connection = edge.Edge as ExperimentNodeConnection; if (connection != null && connection.IsFixed == false) { canRedirect = true; } } return canRedirect; }
private void StartRedirectLinkDrag(MouseButtonEventArgs e, Point clickPoint, GraphSharp.Controls.EdgeControl currentEdge) { // Cache information about currentEdge LinkBeingMoved = currentEdge; GraphSharp.Controls.VertexControl source = currentEdge.Source; // Reveal the manipulation controls. RevealHACKControls(clickPoint, source); // handle mouse event so any other control e.Handled = true; // When we lose mouse capture, then cancel all dragging. BeginDrag(e.MouseDevice, e.Timestamp, e.ChangedButton); }