Пример #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;
        }
Пример #2
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);
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExperimentViewModel"/> class.
        /// </summary>
        /// <param name="experiment">The experiment that this ViewModel represents.  This is intentionally NOT the interface</param>
        public ExperimentViewModel(BaseExperiment experiment)
        {
            if (experiment == null)
            {
                throw new ArgumentNullException("experiment");
            }

            //determine if experiment is editable
            IEditableExperiment editableExperiment = experiment as IEditableExperiment;

            if (editableExperiment != null)
            {
                m_topLevel = new TopLevelEditableExperimentViewModel(editableExperiment);
            }
            else
            {
                m_topLevel = new TopLevelExperimentViewModel(experiment);
            }

            m_currentView = m_topLevel;

            OpenComponentGraph     = new DelegateCommand(OpenComponentGraphFunc, CanOpenComponentGraph);
            RunExperiment          = new DelegateCommand(RunExperimentFunc, CanRunExperimentFunc);
            StopExperiment         = new DelegateCommand(StopExperimentFunc, CanStopExperimentFunc);
            AboutExperimentCommand = new DelegateCommand(DoAboutExperiment);
            PackExperiment         = new DelegateCommand(PackExperimentFunc);

            //top level does not have parent id
            AddSubLevels(String.Empty, m_topLevel);

            experiment.NodeAdded   += OnNodeAdded;
            experiment.NodeRemoved += OnNodeRemoved;

            experiment.NodeFinished += OnNodeFinished;
            experiment.NodeHasError += OnNodeHasError;

            experiment.ExperimentStarted   += OnExperimentStarted;
            experiment.ExperimentCompleted += OnExperimentCompleted;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ExperimentViewModel"/> class.
        /// </summary>
        /// <param name="experiment">The experiment that this ViewModel represents.  This is intentionally NOT the interface</param>
        public ExperimentViewModel(BaseExperiment experiment)
        {
            if (experiment == null)
                throw new ArgumentNullException("experiment");
        
            //determine if experiment is editable
            IEditableExperiment editableExperiment = experiment as IEditableExperiment;
            if (editableExperiment != null)
            {
                m_topLevel = new TopLevelEditableExperimentViewModel(editableExperiment);
            }
            else
            {
                m_topLevel = new TopLevelExperimentViewModel(experiment);
            }

            m_currentView = m_topLevel;
            
            OpenComponentGraph = new DelegateCommand(OpenComponentGraphFunc, CanOpenComponentGraph);
            RunExperiment = new DelegateCommand(RunExperimentFunc, CanRunExperimentFunc);
            StopExperiment = new DelegateCommand(StopExperimentFunc, CanStopExperimentFunc);
            AboutExperimentCommand = new DelegateCommand(DoAboutExperiment);
            PackExperiment = new DelegateCommand(PackExperimentFunc);

            //top level does not have parent id
            AddSubLevels(String.Empty, m_topLevel);

            experiment.NodeAdded += OnNodeAdded;
            experiment.NodeRemoved += OnNodeRemoved;

            experiment.NodeFinished += OnNodeFinished;
            experiment.NodeHasError += OnNodeHasError;

            experiment.ExperimentStarted += OnExperimentStarted;
            experiment.ExperimentCompleted += OnExperimentCompleted;
        }