Esempio n. 1
0
 private void OpenItem(UserControls.ViewModel.TabItem toOpen)
 {
     if (!Tabs.Contains(toOpen))
     {
         Tabs.Add(toOpen);
         toOpen.CloseIt = MainWindowViewModel_CloseIt;
         if (toOpen.Content is DominoProviderTabItem ti && ti.CurrentProject != null)
         {
             ti.GetNewViewModel      = GetNewViewModel;
             ti.RegisterNewViewModel = RegisterNewViewModel;
         }
         if (toOpen.Content is EditProjectVM v)
         {
             v.RecreateCanvasViewModel();
         }
     }
     SelectedTab = toOpen;
 }
Esempio n. 2
0
        private async Task <bool> RemoveItem(UserControls.ViewModel.TabItem tabItem)
        {
            bool remove = false;

            if (tabItem.Content.UnsavedChanges)
            {
                var msgbox = MessageBoxManager.GetMessageBoxStandardWindow(_("Warning"), string.Format(_("Save unsaved changes of {0}?"), tabItem.Header.TrimEnd('*')),
                                                                           ButtonEnum.YesNoCancel, Icon.Warning);
                var result = await msgbox.ShowDialogWithParent <MainWindow>();

                if (result == ButtonResult.Yes)
                {
                    remove = await SaveCurrentOpenProject();
                }
                if (result == ButtonResult.No)
                {
                    // we need to close all files and remove all references to the DominoProvider,
                    // so the file can be reopened again from disk


                    void RecurseProjects(AssemblyNodeVM assembly)
                    {
                        foreach (NodeVM node in assembly.Children)
                        {
                            if (node is AssemblyNodeVM assy)
                            {
                                RecurseProjects(assy);
                            }
                            else if (node is DocumentNodeVM dn)
                            {
                                try
                                {
                                    if (dn.AbsolutePath == tabItem.Path)
                                    {
                                        dn.DocumentModel.CloseFile();
                                    }
                                }
                                catch
                                {
                                    // happens if one reference to another file is broken, in this case
                                    // we simply don't care
                                }
                            }
                        }
                    }

                    foreach (AssemblyNodeVM node in Projects)
                    {
                        RecurseProjects(node);
                    }
                    remove = true;
                }
            }
            else
            {
                remove = true;
            }
            if (remove)
            {
                Tabs.Remove(tabItem);
            }
            return(remove);
        }
Esempio n. 3
0
 /// <summary>
 /// Aktuelles TabItem schließen
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async Task <bool> MainWindowViewModel_CloseIt(UserControls.ViewModel.TabItem tabItem)
 {
     return(await RemoveItem(tabItem));
 }
Esempio n. 4
0
 private DominoProviderTabItem GetNewViewModel(DominoProviderTabItem oldVM)
 {
     UserControls.ViewModel.TabItem tabItem = Tabs.Where(x => x.Content == oldVM).FirstOrDefault();
     return(UserControls.ViewModel.TabItem.ViewModelGenerator(((DominoProviderTabItem)tabItem.Content).CurrentProject, tabItem.Path));
 }
Esempio n. 5
0
 private void RegisterReplacementViewModel(DominoProviderTabItem oldVM, DominoProviderTabItem newVM)
 {
     UserControls.ViewModel.TabItem tabItem = Tabs.Where(x => x.Content == oldVM).FirstOrDefault();
     tabItem.Content = newVM;
 }
Esempio n. 6
0
 private void RegisterNewViewModel(DominoProviderTabItem oldViewModel, DominoProviderTabItem newViewModel)
 {
     UserControls.ViewModel.TabItem tabItem = Tabs.Where(x => x.Content == oldViewModel).FirstOrDefault();
     tabItem.Content = newViewModel;
 }