Exemplo n.º 1
0
        protected override void InvokeCommand(object obj)
        {
            // Find the navigation tree item for this relationship
            SyncRelationshipNodeViewModel relatonshipNavItem =
                App.Current.MainWindowsViewModel.NavigationItems.OfType <SyncRelationshipNodeViewModel>().FirstOrDefault(
                    n => n.Item == this.relationship);

            Debug.Assert(relatonshipNavItem != null, "relatonshipNavItem != null");

            // Check if an Analyze item is already present under this relationship
            NavigationNodeViewModel analyzeItem =
                relatonshipNavItem.Children.OfType <AnalyzeJobNodeViewModel>().FirstOrDefault();

            // An analyze item is not present, so add a new one.
            if (analyzeItem == null)
            {
                AnalyzeJobPanelViewModel viewModel = new AnalyzeJobPanelViewModel(this.relationship);

                analyzeItem = new AnalyzeJobNodeViewModel(relatonshipNavItem, viewModel);
                relatonshipNavItem.Children.Add(analyzeItem);
            }

            analyzeItem.IsSelected = true;
            AnalyzeJobPanelViewModel analyzeJobViewModel = (AnalyzeJobPanelViewModel)analyzeItem.Item;

            if (analyzeJobViewModel.BeginAnalyzeCommand.CanExecute(null))
            {
                analyzeJobViewModel.BeginAnalyzeCommand.Execute(null);
            }
        }
Exemplo n.º 2
0
        private void DeleteRelationship(object obj)
        {
            if (!this.CanDeleteRelationship(obj))
            {
                throw new InvalidOperationException("Relationship cannot be deleted");
            }

            Global.SyncRelationships.Remove(this.BaseModel);
            App.Current.MainWindowsViewModel.SyncRelationships.Remove(this);
            SyncRelationshipNodeViewModel navigationNode = App.Current.MainWindowsViewModel.NavigationItems
                                                           .OfType <SyncRelationshipNodeViewModel>()
                                                           .FirstOrDefault(i => i.Relationship == this);

            if (navigationNode != null)
            {
                App.Current.MainWindowsViewModel.NavigationItems.Remove(navigationNode);
            }

            this.BaseModel.Delete();
        }