Exemplo n.º 1
0
        /// <summary>
        /// Connects the end.
        /// When connecting the end, it also updates information in the experiment model data.
        /// </summary>
        /// <param name='end'>
        /// End.
        /// </param>
        public override void ConnectEnd(MonoHotDraw.Connectors.IConnector end)
        {
            base.ConnectEnd(end);

            if (end != null)
            {
                IComponentControl startComponentControl = StartConnector.Owner as IComponentControl;
                IComponentControl endComponentControl   = end.Owner as IComponentControl;
                if (endComponentControl != null && startComponentControl != null)
                {
                    //get access to owner experiment
                    IEditableExperiment ownerExperiment = endComponentControl.ExperimentNode.Owner as IEditableExperiment;
                    if (ownerExperiment != null)
                    {
                        ExperimentNodeConnection nodeConnection = ownerExperiment.AddConnection(startComponentControl.ExperimentNode, endComponentControl.ExperimentNode);
                        OnConnectionCompleted(nodeConnection);
                        m_experimentNodeConnection = nodeConnection;

                        // SPRINT 2: TLAB-129
                        CommentNode comment = nodeConnection.Source as CommentNode;
                        if (comment != null)
                        {
                            isSourceComment = true;
                        }
                        // END SPRINT 2: TLAB-129
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void DrawEdge(ExperimentNodeConnection edge, bool editable) 
        {
            ExperimentNode source = edge.Source;
            ExperimentNode target = edge.Target;
            
            BasicNodeControl sourceControl, targetControl;
            if(m_nodeControlFactory.TryGetNodeControl(source, out sourceControl) &&
               m_nodeControlFactory.TryGetNodeControl(target, out targetControl))
            {   
                NodeConnectionControl connection = m_nodeConnectionControlFactory.CreateNewNodeConnectionControl(sourceControl, targetControl);
                connection.ConnectStart(sourceControl.ConnectorAt(source.Data.X, source.Data.Y));
                connection.ConnectEnd(targetControl.ConnectorAt(target.Data.X, target.Data.Y));
                connection.UpdateConnection();

                // HERZUM SPRINT 2.4 TLAB-157
                if (connection.ExperimentNodeConnection != null && connection.ExperimentNodeConnection.Source != null && connection.ExperimentNodeConnection.Target != null)
                // END HERZUM SPRINT 2.4 TLAB-157
                // HERZUM SPRINT 2.3: TLAB-160
                if ((connection.ExperimentNodeConnection.Source is ExperimentDecisionNode && connection.ExperimentNodeConnection.Target is ScopeNode)||
                    (connection.ExperimentNodeConnection.Target is ExitDecisionNode))
                    connection.IsEditable = false;
                else
                // END HERZUM SPRINT 2.3: TLAB-160
                    connection.IsEditable = editable;
                
                m_experimentCanvasWidget.ExperimentCanvas.View.Drawing.Add(connection);
                m_experimentCanvasWidget.ExperimentCanvas.View.ClearSelection();
            }
        }
Exemplo n.º 3
0
 // HERZUM SPRINT 3.0: TLAB-176
 private bool IncludeChallenge(CompositeComponentGraph experiment)
 {
     if (experiment == null)
     {
         return(false);
     }
     foreach (ExperimentNode node in experiment.Vertices)
     {
         ChallengeMetadata ch_meta = node.Data.Metadata as ChallengeMetadata;
         if (ch_meta != null)
         {
             // HERZUM SPRINT 3.0: TLAB-176
             ExperimentNodeConnection firstInEdge  = experiment.InEdge(node, 0);
             ExperimentNodeConnection firstOutEdge = experiment.OutEdge(node, 0);
             if (firstInEdge != null && firstInEdge.Source != null && firstOutEdge != null && firstOutEdge.Target != null)
             {
                 experiment.AddEdge(new ExperimentNodeConnection(Guid.NewGuid().ToString(), firstInEdge.Source, firstOutEdge.Target));
             }
             // END HERZUM SPRINT 3.0: TLAB-176
             experiment.RemoveVertex(node);
             return(true);
         }
         CompositeComponentBaseMetadata meta = node.Data.Metadata as CompositeComponentBaseMetadata;
         if (meta != null)
         {
             return(IncludeChallenge(meta.ComponentGraph));
         }
     }
     return(false);
 }
Exemplo n.º 4
0
        public void AddNewConnectionTwice()
        {
            IExperiment experiment = ExperimentManager.New();

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ComponentMetadataDefinition def1 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test.dll"), "IDontExist");
            ExperimentNode node1             = ((IEditableExperiment)experiment).AddComponentFromDefinition(def1, -5, 5);

            ComponentMetadataDefinition def2 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test2.dll"), "IDontExistEither");
            ExperimentNode node2             = ((IEditableExperiment)experiment).AddComponentFromDefinition(def2, -5, 5);

            Assert.AreEqual(0, experiment.EdgeCount);
            ExperimentNodeConnection newEdge = ((IEditableExperiment)experiment).AddConnection(node1, node2);

            Assert.IsNotNull(newEdge);
            Assert.AreEqual(1, experiment.EdgeCount);

            //add the same connection once again
            ExperimentNodeConnection newEdge2 = ((IEditableExperiment)experiment).AddConnection(node1, node2);

            Assert.IsNotNull(newEdge2);
            Assert.AreEqual(newEdge, newEdge2);
            // the amount of edges should still be the same
            Assert.AreEqual(1, experiment.EdgeCount);
        }
Exemplo n.º 5
0
        public void RemoveConnection()
        {
            IExperiment experiment = ExperimentManager.New();

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ComponentMetadataDefinition def1 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test.dll"), "IDontExist");
            ExperimentNode node1             = ((IEditableExperiment)experiment).AddComponentFromDefinition(def1, -5, 5);

            ComponentMetadataDefinition def2 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test2.dll"), "IDontExistEither");
            ExperimentNode node2             = ((IEditableExperiment)experiment).AddComponentFromDefinition(def2, -5, 5);

            Assert.AreEqual(0, experiment.EdgeCount);
            ExperimentNodeConnection newEdge = ((IEditableExperiment)experiment).AddConnection(node1, node2);

            Assert.IsNotNull(newEdge);
            Assert.AreEqual(1, experiment.EdgeCount);

            experiment.ResetModifiedFlag();

            Assert.AreEqual(4, experiment.VertexCount);
            ((IEditableExperiment)experiment).RemoveConnection(newEdge);

            // Verify that the edge was existed and the number of vertices was unaffected.
            Assert.AreEqual(0, experiment.EdgeCount);
            Assert.AreEqual(4, experiment.VertexCount);

            Assert.IsTrue(experiment.IsModified);
        }
Exemplo n.º 6
0
 private void OnConnectionCompleted(ExperimentNodeConnection nodeConnection)
 {
     if (ConnectionCompleted != null)
     {
         ConnectionCompleted(this, new ConnectionCompletedEventArgs(nodeConnection));
     }
 }
Exemplo n.º 7
0
        /// <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);
        }
Exemplo n.º 8
0
        public void AddNewConnectionCannotTargetStartNode()
        {
            IExperiment experiment = ExperimentManager.New();

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ComponentMetadataDefinition def2 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test.dll"), "IDontExist");
            ExperimentNode node2             = ((IEditableExperiment)experiment).AddComponentFromDefinition(def2, -5, 5);

            ExperimentNodeConnection newEdge = ((IEditableExperiment)experiment).AddConnection(node2, experiment.StartNode);
        }
Exemplo n.º 9
0
        /// <summary>
        /// When edge is removed in model experiment,
        /// the edge control must be also removed from the view to keep view and model synced.
        /// </summary>
        /// <param name='edge'>
        /// Edge.
        /// </param>
        private void OnEdgeRemoved(ExperimentNodeConnection nodeConnection)
        {
            NodeConnectionControl connectionControl;

            if (m_applicationContext.NodeConnectionControlFactory.TryGetConnectionControl(nodeConnection, out connectionControl))
            {
                m_experimentCanvasWidget.ExperimentCanvas.View.RemoveFromSelection(connectionControl);
                m_experimentCanvasWidget.ExperimentCanvas.View.Remove(connectionControl);
                m_applicationContext.NodeConnectionControlFactory.RemoveFromLookup(nodeConnection);
            }
        }
Exemplo n.º 10
0
        public void AddNewConnectionNullNode2()
        {
            IExperiment experiment = ExperimentManager.New();

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ComponentMetadataDefinition def1 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test.dll"), "IDontExist");
            ExperimentNode node2             = ((IEditableExperiment)experiment).AddComponentFromDefinition(def1, -5, 5);

            Assert.AreEqual(0, experiment.EdgeCount);
            ExperimentNodeConnection newEdge = ((IEditableExperiment)experiment).AddConnection(null, node2);

            Assert.IsNotNull(newEdge);
            Assert.AreEqual(1, experiment.EdgeCount);
        }
Exemplo n.º 11
0
        /// <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);
        }
 public void DrawEdge(ExperimentNodeConnection edge, bool editable) 
 {
     ExperimentNode source = edge.Source;
     ExperimentNode target = edge.Target;
     
     BasicNodeControl sourceControl, targetControl;
     if(m_nodeControlFactory.TryGetNodeControl(source, out sourceControl) &&
        m_nodeControlFactory.TryGetNodeControl(target, out targetControl))
     {   
         NodeConnectionControl connection = m_nodeConnectionControlFactory.CreateNewNodeConnectionControl(sourceControl, targetControl);
         connection.ConnectStart(sourceControl.ConnectorAt(source.Data.X, source.Data.Y));
         connection.ConnectEnd(targetControl.ConnectorAt(target.Data.X, target.Data.Y));
         connection.UpdateConnection();
         connection.IsEditable = editable;
         
         m_experimentCanvasWidget.ExperimentCanvas.View.Drawing.Add(connection);
         m_experimentCanvasWidget.ExperimentCanvas.View.ClearSelection();
     }
 }
Exemplo n.º 13
0
        private void DrawEdge(ExperimentNodeConnection edge)
        {
            ExperimentNode source = edge.Source;
            ExperimentNode target = edge.Target;

            BasicNodeControl sourceControl, targetControl;

            if (m_applicationContext.NodeControlFactory.TryGetNodeControl(source, out sourceControl) &&
                m_applicationContext.NodeControlFactory.TryGetNodeControl(target, out targetControl))
            {
                NodeConnectionControl connection = m_applicationContext.NodeConnectionControlFactory.CreateNewNodeConnectionControl(sourceControl, targetControl);
                connection.ConnectStart(sourceControl.ConnectorAt(source.Data.X, source.Data.Y));
                connection.ConnectEnd(targetControl.ConnectorAt(target.Data.X, target.Data.Y));
                connection.UpdateConnection();

                m_experimentCanvasWidget.ExperimentCanvas.View.Drawing.Add(connection);
                m_experimentCanvasWidget.ExperimentCanvas.View.ClearSelection();
                m_experimentCanvasWidget.ExperimentCanvas.View.AddToSelection(connection);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Connects the end.
        /// When connecting the end, it also updates information in the experiment model data.
        /// </summary>
        /// <param name='end'>
        /// End.
        /// </param>
        public override void ConnectEnd(MonoHotDraw.Connectors.IConnector end)
        {
            base.ConnectEnd(end);

            if (end != null)
            {
                IComponentControl startComponentControl = StartConnector.Owner as IComponentControl;
                IComponentControl endComponentControl   = end.Owner as IComponentControl;
                if (endComponentControl != null && startComponentControl != null)
                {
                    //get access to owner experiment
                    IEditableExperiment ownerExperiment = endComponentControl.ExperimentNode.Owner as IEditableExperiment;
                    if (ownerExperiment != null)
                    {
                        ExperimentNodeConnection nodeConnection = ownerExperiment.AddConnection(startComponentControl.ExperimentNode, endComponentControl.ExperimentNode);
                        OnConnectionCompleted(nodeConnection);
                        m_experimentNodeConnection = nodeConnection;
                    }
                }
            }
        }
Exemplo n.º 15
0
        public void AddNewConnection()
        {
            IExperiment experiment = ExperimentManager.New();

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            ComponentMetadataDefinition def1 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test.dll"), "IDontExist");
            ExperimentNode node1             = ((IEditableExperiment)experiment).AddComponentFromDefinition(def1, -5, 5);

            ComponentMetadataDefinition def2 = new ComponentMetadataDefinition(Guid.NewGuid().ToString(), System.IO.Path.Combine(AppContext.BaseTestDirectory, "Test2.dll"), "IDontExistEither");
            ExperimentNode node2             = ((IEditableExperiment)experiment).AddComponentFromDefinition(def2, -5, 5);

            // We know already that experiments are modified after adding components, but we
            // want to make sure that they're modified after adding a connection too, so lets clear the modification flag first.
            experiment.ResetModifiedFlag();
            Assert.IsFalse(experiment.IsModified);

            Assert.AreEqual(0, experiment.EdgeCount);
            ExperimentNodeConnection newEdge = ((IEditableExperiment)experiment).AddConnection(node1, node2);

            Assert.IsNotNull(newEdge);
            Assert.AreEqual(1, experiment.EdgeCount);
            Assert.IsTrue(experiment.IsModified);
        }
Exemplo n.º 16
0
        public void DrawEdge(ExperimentNodeConnection edge, bool editable)
        {
            ExperimentNode source = edge.Source;
            ExperimentNode target = edge.Target;

            BasicNodeControl sourceControl, targetControl;

            if (m_nodeControlFactory.TryGetNodeControl(source, out sourceControl) &&
                m_nodeControlFactory.TryGetNodeControl(target, out targetControl))
            {
                NodeConnectionControl connection = m_nodeConnectionControlFactory.CreateNewNodeConnectionControl(sourceControl, targetControl);
                connection.ConnectStart(sourceControl.ConnectorAt(source.Data.X, source.Data.Y));
                connection.ConnectEnd(targetControl.ConnectorAt(target.Data.X, target.Data.Y));
                connection.UpdateConnection();

                // HERZUM SPRINT 2.4 TLAB-157
                if (connection.ExperimentNodeConnection != null && connection.ExperimentNodeConnection.Source != null && connection.ExperimentNodeConnection.Target != null)
                {
                    // END HERZUM SPRINT 2.4 TLAB-157
                    // HERZUM SPRINT 2.3: TLAB-160
                    if ((connection.ExperimentNodeConnection.Source is ExperimentDecisionNode && connection.ExperimentNodeConnection.Target is ScopeNode) ||
                        (connection.ExperimentNodeConnection.Target is ExitDecisionNode))
                    {
                        connection.IsEditable = false;
                    }
                    else
                    {
                        // END HERZUM SPRINT 2.3: TLAB-160
                        connection.IsEditable = editable;
                    }
                }

                m_experimentCanvasWidget.ExperimentCanvas.View.Drawing.Add(connection);
                m_experimentCanvasWidget.ExperimentCanvas.View.ClearSelection();
            }
        }
        /// <summary>
        /// Executes drop
        /// </summary>
        /// <param name="param">The param.</param>
        private void DropFunc(object param)
        {
            if (IsExperimentRunning == false)
            {
                TraceLab.UI.WPF.EventArgs.GraphDragEventArgs args     = param as TraceLab.UI.WPF.EventArgs.GraphDragEventArgs;
                TraceLab.UI.WPF.EventArgs.DropLinkEventArgs  linkArgs = param as TraceLab.UI.WPF.EventArgs.DropLinkEventArgs;
                if (args != null)
                {
                    MetadataDefinition metadataDefinition = args.DragArguments.Data.GetData("ComponentDefinition") as MetadataDefinition;

                    if (metadataDefinition != null)
                    {
                        System.Windows.Point pos = args.Position;
                        AddComponentFromDefinition(metadataDefinition, pos.X, pos.Y);
                    }
                }
                else if (linkArgs != null)
                {
                    ExperimentNodeConnection edge = (ExperimentNodeConnection)linkArgs.ExistingEdge;

                    // If we're NOT removing an edge, OR the new edge will be different than the old edge.
                    if (linkArgs.ExistingEdge == null || (edge.Source == linkArgs.Source && edge.Target != linkArgs.Target))
                    {
                        if (linkArgs.ExistingEdge != null)
                        {
                            RemoveConnection(edge);
                        }

                        if (linkArgs.Source != null && linkArgs.Target != null)
                        {
                            AddConnection((ExperimentNode)linkArgs.Source, (ExperimentNode)linkArgs.Target);
                        }
                    }
                }
            }
        }
 public ConnectionCompletedEventArgs(ExperimentNodeConnection nodeConnection) 
 {
     ExperimentNodeConnection = nodeConnection;
 }
 /// <summary>
 /// Removes the given connection from the m_experiment.
 /// </summary>
 /// <param name="edge">The edge to remove</param>
 /// <exception cref="System.InvalidOperationException">Thrown if the ViewModel is in a bad state that it cannot recover from</exception>
 public void RemoveConnection(ExperimentNodeConnection edge)
 {
     m_experiment.RemoveConnection(edge);
 }
Exemplo n.º 20
0
 public bool RemoveFromLookup(ExperimentNodeConnection nodeConnection)
 {
     return(m_mapEdgesToControls.Remove(nodeConnection));
 }
Exemplo n.º 21
0
 public bool TryGetConnectionControl(ExperimentNodeConnection nodeConnection, out NodeConnectionControl connectionControl)
 {
     return(m_mapEdgesToControls.TryGetValue(nodeConnection, out connectionControl));
 }
Exemplo n.º 22
0
 /// <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;
 }
Exemplo n.º 23
0
        /// <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;
        }
 /// <summary>
 /// Removes the given connection from the m_experiment.
 /// </summary>
 /// <param name="edge">The edge to remove</param>
 /// <exception cref="System.InvalidOperationException">Thrown if the ViewModel is in a bad state that it cannot recover from</exception>
 public void RemoveConnection(ExperimentNodeConnection edge)
 {
     m_experiment.RemoveConnection(edge);
 }
Exemplo n.º 25
0
 /// <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;
 }
 public bool RemoveFromLookup(ExperimentNodeConnection nodeConnection)
 {
     return m_mapEdgesToControls.Remove(nodeConnection);
 }
Exemplo n.º 27
0
 /// <summary>
 /// When edge is removed in model experiment,
 /// the edge control must be also removed from the view to keep view and model synced.
 /// </summary>
 /// <param name='edge'>
 /// Edge.
 /// </param>
 private void OnEdgeRemoved(ExperimentNodeConnection nodeConnection) 
 {
     NodeConnectionControl connectionControl;
     if(m_applicationContext.NodeConnectionControlFactory.TryGetConnectionControl(nodeConnection, out connectionControl)) 
     {
         m_experimentCanvasWidget.ExperimentCanvas.View.RemoveFromSelection(connectionControl);
         m_experimentCanvasWidget.ExperimentCanvas.View.Remove(connectionControl);
         m_applicationContext.NodeConnectionControlFactory.RemoveFromLookup(nodeConnection);
     }
 }
 public bool TryGetConnectionControl(ExperimentNodeConnection nodeConnection, out NodeConnectionControl connectionControl)
 {
     return m_mapEdgesToControls.TryGetValue(nodeConnection, out connectionControl);
 }
Exemplo n.º 29
0
 public bool TryGetEdge(ExperimentNode source, ExperimentNode target, out ExperimentNodeConnection edge)
 {
     return(m_experiment.TryGetEdge(source, target, out edge));
 }
Exemplo n.º 30
0
 public bool ContainsEdge(ExperimentNodeConnection edge)
 {
     return(m_experiment.ContainsEdge(edge));
 }
        /// <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)
            {
                if (!TraceLabSDK.RuntimeInfo.IsRunInMono)
                {
                    compositeComponentGraph.References = new ObservableCollection<TraceLabSDK.PackageSystem.IPackageReference>(originalExperiment.References);
                }
                else
                {
                    // Mono currently has not implemented constructor of ObservableCollection(IEnumerable<T> collection)
                    // thus we have to add references manually
                    compositeComponentGraph.References = new ObservableCollection<TraceLabSDK.PackageSystem.IPackageReference>();
                    foreach (TraceLabSDK.PackageSystem.IPackageReference reference in originalExperiment.References)
                    {
                        compositeComponentGraph.References.Add(reference);
                    }
                }
            }

            compositeComponentGraph.OwnerNode = null;

            return compositeComponentGraph;
        }
 private void OnConnectionCompleted(ExperimentNodeConnection nodeConnection) 
 {
     if(ConnectionCompleted != null) 
     {
         ConnectionCompleted(this, new ConnectionCompletedEventArgs(nodeConnection));
     }
 }
Exemplo n.º 33
0
 public ConnectionCompletedEventArgs(ExperimentNodeConnection nodeConnection)
 {
     ExperimentNodeConnection = nodeConnection;
 }
 public bool TryGetEdge(ExperimentNode source, ExperimentNode target, out ExperimentNodeConnection edge)
 {
     return m_experiment.TryGetEdge(source, target, out edge);
 }
 /// <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);
 }
 public bool ContainsEdge(ExperimentNodeConnection edge)
 {
     return m_experiment.ContainsEdge(edge);
 }