/// <summary> /// Called when edge is removed from experiment. /// When edge is removed the experiment should be set to be modified. /// </summary> /// <param name="args">The args.</param> protected override void OnEdgeRemoved(ExperimentNodeConnection args) { base.OnEdgeRemoved(args); m_isModified = true; IsModified = true; args.PropertyChanged -= ExperimentNodeConnection_PropertyChanged; }
/// <summary> /// Called when edge is added to experiment. /// When edge is added the experiment should be set to be modified. /// It also attaches listener to edge changes. So it can also set modify flag when edge changes. /// </summary> /// <param name="args">The args.</param> protected override void OnEdgeAdded(ExperimentNodeConnection args) { base.OnEdgeAdded(args); m_isModified = true; IsModified = true; //listen to modification of the edge args.PropertyChanged += ExperimentNodeConnection_PropertyChanged; }
/// <summary> /// Constructs experiment node connection from given xml xpath navigator to the edge. /// </summary> /// <param name="reader">The reader with edge root.</param> /// <returns>experiment node connection</returns> public ExperimentNodeConnection EdgeFactory(XPathNavigator reader) { string id = reader.GetAttribute("id", String.Empty); string source = reader.GetAttribute("source", String.Empty); string target = reader.GetAttribute("target", String.Empty); //try read is fixed attribute string isFixedAttrib = reader.GetAttribute("isFixed", String.Empty); bool isFixed; if (!Boolean.TryParse(isFixedAttrib, out isFixed)) { isFixed = false; } //try read is visible attribute string isVisibleAttrib = reader.GetAttribute("isVisible", String.Empty); bool isVisible; if (!Boolean.TryParse(isVisibleAttrib, out isVisible)) { isVisible = true; } //validate if (m_vertices.ContainsKey(source) == false || m_vertices.ContainsKey(target) == false) { throw new TraceLab.Core.Exceptions.ExperimentLoadException("The experiment is corrupted and could not be loaded. Experiment xml contains edge that refers to non-existing nodes."); } ExperimentNode sourceVert = m_vertices[source]; ExperimentNode targetVert = m_vertices[target]; ExperimentNodeConnection edge = new ExperimentNodeConnection(id, sourceVert, targetVert, isFixed, isVisible); edge.IsModified = false; m_edges[id] = edge; //read in route points from xml edge.RoutePoints.ReadXml(reader.ReadSubtree()); //perform fixes for scopes ScopeNodeHelper.TryFixScopeDecisionEntryAndExitNodes(sourceVert, targetVert); return(edge); }
// END HERZUM SPRINT 4.0: TLAB-204 #region Create Composite Component /// <summary> /// Constructs the graph from selected nodes of the given experiment graph. /// </summary> /// <param name="graph">The graph.</param> /// <returns></returns> public static CompositeComponentGraph ConstructGraphFromSelectedNodes(BaseExperiment originalExperiment) { var compositeComponentGraph = new CompositeComponentGraph(); // Clone experiment info. compositeComponentGraph.ExperimentInfo = new ExperimentInfo(); AssureCompleteDecisionSelection(originalExperiment); //keep lookup from original node to its clone for later edge reproduction Dictionary <ExperimentNode, ExperimentNode> clonedNodeLookup = new Dictionary <ExperimentNode, ExperimentNode>(); // Clone vertices that are selected and add them to the composite component graph foreach (ExperimentNode node in originalExperiment.Vertices) { if (node.IsSelected) { var clonedNode = node.Clone(); clonedNodeLookup[node] = clonedNode; compositeComponentGraph.SetLogLevelSettings(clonedNode, compositeComponentGraph.Settings); compositeComponentGraph.AddVertex(clonedNode); if (clonedNode.ID == "Start" && compositeComponentGraph.StartNode == null) { compositeComponentGraph.StartNode = (ExperimentStartNode)clonedNode; } else if (clonedNode.ID == "End" && compositeComponentGraph.EndNode == null) { compositeComponentGraph.EndNode = (ExperimentEndNode)clonedNode; } } } // Clone edges foreach (ExperimentNodeConnection connection in originalExperiment.Edges) { ExperimentNode cloneSourceNode, cloneTargetNode; //add edges only if both source and target nodes has been found in clones lookup bool foundSourceNode = clonedNodeLookup.TryGetValue(connection.Source, out cloneSourceNode); bool foundTargetNode = clonedNodeLookup.TryGetValue(connection.Target, out cloneTargetNode); if (foundSourceNode && foundTargetNode) { ExperimentNodeConnection clonedConnection = new ExperimentNodeConnection(connection.ID, cloneSourceNode, cloneTargetNode, connection.IsFixed, connection.IsVisible); //copy also all route points clonedConnection.RoutePoints.CopyPointsFrom(connection.RoutePoints); compositeComponentGraph.AddEdge(clonedConnection); //perform fixes for scopes ScopeNodeHelper.TryFixScopeDecisionEntryAndExitNodes(cloneSourceNode, cloneTargetNode); } } ConnectNodesToStartAndEndNode(compositeComponentGraph); //move graph closer to the origin point TraceLab.Core.Utilities.ExperimentHelper.MoveGraphCloserToOriginPoint(compositeComponentGraph, 200, 200); if (originalExperiment.References != null) { compositeComponentGraph.References = originalExperiment.References.CopyCollection(); } compositeComponentGraph.OwnerNode = null; return(compositeComponentGraph); }
/// <summary> /// Initializes a new instance of the <see cref="RoutePointsCollection"/> class. /// </summary> /// <param name="ownerConnection">The owner connection.</param> public RoutePointsCollection(ExperimentNodeConnection ownerConnection) : this() { m_ownerConnection = ownerConnection; }
/// <summary> /// Writes the edge attributes. /// </summary> /// <param name="writer">The writer.</param> /// <param name="flow">The flow.</param> public void WriteEdgeAttributes(XmlWriter writer, ExperimentNodeConnection flow) { WriteXmlAttributesAndElements(writer, flow); }