Exemplo n.º 1
0
        private void AddSubLevels(string parentNodeId, BaseLevelExperimentViewModel experiment)
        {
            if (experiment == null)
            {
                throw new ArgumentNullException("experiment");
            }

            foreach (ExperimentNode node in experiment.Vertices)
            {
                CompositeComponentNode compositeNode = node as CompositeComponentNode;
                if (compositeNode != null)
                {
                    CompositeComponentBaseMetadata data = compositeNode.Data.Metadata as CompositeComponentBaseMetadata;

                    string subLevelId;
                    if (String.IsNullOrEmpty(parentNodeId) == false)
                    {
                        subLevelId = parentNodeId + ":" + compositeNode.ID;
                    }
                    else
                    {
                        subLevelId = compositeNode.ID;
                    }

                    CreateSubLevelViewModel(data.ComponentGraph, subLevelId, experiment);
                }
            }
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
 public ExperimentCrumb(BaseLevelExperimentViewModel viewModel)
 {
     Value       = viewModel;
     DisplayText = viewModel.Title;
     if (viewModel is SubLevelExperimentViewModel)
     {
         var node = ((TraceLab.Core.Experiments.CompositeComponentGraph)viewModel.GetExperiment()).OwnerNode;
         DisplayText = node.Data.Metadata.Label;
     }
 }
 public ExperimentCrumb(BaseLevelExperimentViewModel viewModel)
 {
     Value = viewModel;
     DisplayText = viewModel.Title;
     if (viewModel is SubLevelExperimentViewModel)
     {
         var node = ((TraceLab.Core.Experiments.CompositeComponentGraph)viewModel.GetExperiment()).OwnerNode;
         DisplayText = node.Data.Metadata.Label;
     }
 }
        public BaseLevelExperimentViewModel(IExperiment experiment, BaseLevelExperimentViewModel owner)
        {
            if (experiment == null)
                throw new ArgumentNullException("experiment", "Wrapped experiment cannot be null");

            m_experiment = experiment;
            m_experiment.PropertyChanged += m_experiment_PropertyChanged;
            Owner = owner;

            ToggleInfoPaneForNode = new DelegateCommand(ToggleInfoPaneForNodeFunc);
        }
        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);
            }
        }
        public BaseLevelExperimentViewModel(IExperiment experiment, BaseLevelExperimentViewModel owner)
        {
            if (experiment == null)
            {
                throw new ArgumentNullException("experiment", "Wrapped experiment cannot be null");
            }

            m_experiment = experiment;
            m_experiment.PropertyChanged += m_experiment_PropertyChanged;
            Owner = owner;

            ToggleInfoPaneForNode = new DelegateCommand(ToggleInfoPaneForNodeFunc);
        }
Exemplo n.º 8
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);
            }
        }
        public override bool Equals(object obj)
        {
            BaseLevelExperimentViewModel experimentWrapper = obj as BaseLevelExperimentViewModel;

            if (experimentWrapper != null)
            {
                return(m_experiment.Equals(experimentWrapper.GetExperiment()));
            }

            IExperiment experiment = obj as IExperiment; //at this moment it is not known it is not TopLevelExperimentViewModel, so it is actual m_experiment

            if (experiment != null)
            {
                return(m_experiment.Equals(experiment));
            }

            return(base.Equals(obj));
        }
Exemplo n.º 10
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;
        }
        private void AddSubLevels(string parentNodeId, BaseLevelExperimentViewModel experiment)
        {
            if (experiment == null)
                throw new ArgumentNullException("experiment");

            foreach (ExperimentNode node in experiment.Vertices)
            {
                CompositeComponentNode compositeNode = node as CompositeComponentNode;
                if (compositeNode != null)
                {
                    CompositeComponentBaseMetadata data = compositeNode.Data.Metadata as CompositeComponentBaseMetadata;
                    
                    string subLevelId;
                    if (String.IsNullOrEmpty(parentNodeId) == false)
                    {
                        subLevelId = parentNodeId + ":" + compositeNode.ID;
                    }
                    else
                    {
                        subLevelId = compositeNode.ID;
                    }

                    CreateSubLevelViewModel(data.ComponentGraph, subLevelId, experiment);
                }
            }
        }
Exemplo n.º 13
0
 public bool Equals(BaseLevelExperimentViewModel otherWrapper)
 {
     return(this == otherWrapper);
 }
Exemplo n.º 14
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;
                }
            }
        }
 public SubLevelExperimentViewModel(CompositeComponentGraph componentGraph, BaseLevelExperimentViewModel owner)
     : base(componentGraph, owner)
 {
 }
 public bool Equals(BaseLevelExperimentViewModel otherWrapper)
 {
     return (this == otherWrapper);
 }
Exemplo n.º 17
0
 public SubLevelExperimentViewModel(CompositeComponentGraph componentGraph, BaseLevelExperimentViewModel owner)
     : base(componentGraph, owner)
 {
 }
        /// <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;
                }
            }
        }