Example #1
0
        public void OpenComponentGraphFunc(object param)
        {
            CompositeComponentGraph     componentGraph   = param as CompositeComponentGraph;
            SubLevelExperimentViewModel componentGraphVM = param as SubLevelExperimentViewModel;
            CompositeComponentNode      node             = param as CompositeComponentNode;
            TopLevelExperimentViewModel topLevel         = param as TopLevelExperimentViewModel;

            if (node != null)
            {
                componentGraph = node.CompositeComponentMetadata.ComponentGraph;
            }
            else if (componentGraphVM != null)
            {
                componentGraph = (CompositeComponentGraph)componentGraphVM.GetExperiment();
            }

            BaseLevelExperimentViewModel view = null;

            if (componentGraph != null)
            {
                view = FindSubLevel(componentGraph.GraphIdPath);
            }
            else if (topLevel != null)
            {
                view = topLevel;
            }

            CurrentView = view;
        }
Example #2
0
        internal BaseLevelExperimentViewModel FindSubLevel(string id)
        {
            SubLevelExperimentViewModel vm = null;

            m_subLevels.TryGetValue(id, out vm);
            return(vm);
        }
Example #3
0
        /// <summary>
        /// Finds the owner node in the top level experiment, (at the top of the subgraphs hierarchy) of this sublevel component graph.
        /// Also it sets the node id full path. It contains the id of all the owners node of the subgraphs all the way to the top.
        /// </summary>
        private CompositeComponentNode GetTopOwnerNode()
        {
            //if the top owner node has not yet been discovered
            if (m_topOwnerCompositeComponentNode == null)
            {
                if (Owner == null)
                {
                    throw new InvalidOperationException("Application is at invalid state. Sublevel experiment always need to have an owner.");
                }

                // if the owner of this sublevel experiment is the top level experiment
                TopLevelExperimentViewModel topLevel = Owner as TopLevelExperimentViewModel;
                if (topLevel != null)
                {
                    // then return this component graph owner node (which is a part of the top level experiment)
                    CompositeComponentGraph componentGraph = (CompositeComponentGraph)GetExperiment();
                    m_topOwnerCompositeComponentNode = componentGraph.OwnerNode;
                }
                else
                {
                    //otherwise recursive to subgraph above this graph, until it finds top level experiment
                    SubLevelExperimentViewModel levelAbove = (SubLevelExperimentViewModel)Owner;
                    m_topOwnerCompositeComponentNode = levelAbove.GetTopOwnerNode();

                    //in addition, set this component graph node if path.
                    CompositeComponentGraph componentGraph = (CompositeComponentGraph)GetExperiment();
                    GraphIdPath = componentGraph.OwnerNode.ID;
                }
            }

            return(m_topOwnerCompositeComponentNode);
        }
Example #4
0
        private void PushParent(BaseLevelExperimentViewModel experiment, List <Crumb> crumbs)
        {
            SubLevelExperimentViewModel subExperimentVM = experiment as SubLevelExperimentViewModel;

            if (subExperimentVM != null)
            {
                BaseLevelExperimentViewModel parent = subExperimentVM.Owner;
                PushParent(parent, crumbs);

                Crumb crumb = new ExperimentCrumb(parent);
                crumbs.Add(crumb);
            }
        }
Example #5
0
        /// <summary>
        /// Creates sub level view for the given composite component graph.
        /// SubLevelViewModel represents the view for the breadcrumbs.
        ///
        /// Method also collects the sub level into dictionary of sublevel id to its corresponding view model,
        /// so that when user opens subgraph it can locate coressponging view model.
        /// </summary>
        /// <param name="componentGraph">The component graph.</param>
        /// <param name="subLevelId">The sub level id.</param>
        /// <param name="parentLevelViewModel">The parent level view model - it may either top level experiment view model, or another sublevel view model.</param>
        private void CreateSubLevelViewModel(CompositeComponentGraph componentGraph, string subLevelId, BaseLevelExperimentViewModel parentLevelViewModel)
        {
            //if it is null the loading failed... and node should be marked with error already
            if (componentGraph != null)
            {
                var subLevel = new SubLevelExperimentViewModel(componentGraph, parentLevelViewModel);
                m_subLevels.Add(subLevelId, subLevel);
                AddSubLevels(subLevelId, subLevel);

                //if the graph is editable graph listen to added node event
                if (componentGraph is CompositeComponentEditableGraph)
                {
                    componentGraph.NodeAdded += OnNodeAdded;
                }
            }
        }
        /// <summary>
        /// Creates sub level view for the given composite component graph.
        /// SubLevelViewModel represents the view for the breadcrumbs.
        /// 
        /// Method also collects the sub level into dictionary of sublevel id to its corresponding view model,
        /// so that when user opens subgraph it can locate coressponging view model.
        /// </summary>
        /// <param name="componentGraph">The component graph.</param>
        /// <param name="subLevelId">The sub level id.</param>
        /// <param name="parentLevelViewModel">The parent level view model - it may either top level experiment view model, or another sublevel view model.</param>
        private void CreateSubLevelViewModel(CompositeComponentGraph componentGraph, string subLevelId, BaseLevelExperimentViewModel parentLevelViewModel)
        {
            //if it is null the loading failed... and node should be marked with error already
            if (componentGraph != null)
            {
                var subLevel = new SubLevelExperimentViewModel(componentGraph, parentLevelViewModel);
                m_subLevels.Add(subLevelId, subLevel);
                AddSubLevels(subLevelId, subLevel);

                //if the graph is editable graph listen to added node event
                if (componentGraph is CompositeComponentEditableGraph)
                {
                    componentGraph.NodeAdded += OnNodeAdded;
                }
            }
        }