Пример #1
0
        public TabsVM GetTabs()
        {
            TabsVM tabs = new TabsVM();

            tabs.TabIndex = 1;
            for (int i = 0; i < 4; i++)
            {
                tabs.Tabs.Add(this.CreateTab(string.Format("Tab{0}", i.ToString())));
            }
            return(tabs);
        }
Пример #2
0
        void ShowTabsDlg()
        {
            var win = new TabsDlg();
            var vm  = new TabsVM(documentTabService, saveService, tabsVMSettings, classificationFormatMap, textElementProvider);

            win.DataContext = vm;
            win.Owner       = appWindow.MainWindow;
            win.ShowDialog();

            // The original tab group gets back its keyboard focus by ShowDialog(). Make sure that
            // the correct tab is activated.
            if (vm.LastActivated != null)
            {
                vm.LastActivated.Tab.DocumentTabService.SetFocus(vm.LastActivated.Tab);
            }
        }
Пример #3
0
        void ShowTabsDlg()
        {
            var win = new TabsDlg();
            var vm  = new TabsVM(fileTabManager, saveManager, tabsVMSettings);

            win.DataContext = vm;
            win.Owner       = appWindow.MainWindow;
            win.ShowDialog();

            // The original tab group gets back its keyboard focus by ShowDialog(). Make sure that
            // the correct tab is activated.
            if (vm.LastActivated != null)
            {
                vm.LastActivated.Tab.FileTabManager.SetFocus(vm.LastActivated.Tab);
            }
        }
Пример #4
0
        private static void Application_Idle(object sender, EventArgs e)
        {
            try
            {
                Application.Idle -= Application_Idle;
                Logger.Log.Info("RestoreTabs Application_Idle");
                var tabVM    = new TabsVM(_tabs);
                var tabsView = new TabsView(tabVM);
                if (Application.ShowModalWindow(tabsView) == true)
                {
                    try
                    {
                        Application.DocumentManager.DocumentCreated -= DocumentManager_DocumentCreated;
                        var closeDocs   = Application.DocumentManager.Cast <Document>().Where(w => !w.IsNamedDrawing).ToList();
                        var tabsRestore = tabVM.Sessions.SelectMany(s => s.Tabs.Where(w => w.Restore)).Select(s => s.File).ToList();
                        if (tabVM.HasHistory)
                        {
                            tabsRestore = tabsRestore.Union(tabVM.History.Where(w => w.Restore).Select(s => s.File)).Distinct().ToList();
                        }

                        foreach (var item in tabsRestore)
                        {
                            try
                            {
                                Application.DocumentManager.Open(item, false);
                            }
                            catch (Exception ex)
                            {
                                Inspector.AddError($"Ошибка открытия файла '{item}' - {ex.Message}");
                            }
                        }

                        // Закрыть пустые чертежи
                        foreach (var doc in closeDocs)
                        {
                            try
                            {
                                doc.CloseAndDiscard();
                            }
                            catch (Exception ex)
                            {
                                Logger.Log.Error(ex, "RestoreTabs. Закрыть пустые чертежи.");
                            }
                        }

                        if (tabsRestore?.Any() == true)
                        {
                            LogRestoreTabs(tabsRestore);
                        }
                    }
                    finally
                    {
                        Application.DocumentManager.DocumentCreated += DocumentManager_DocumentCreated;
                        Inspector.Show();
                    }
                }

                if (tabVM.SessionCount != _tabs.SessionCount)
                {
                    _tabs.SessionCount = tabVM.SessionCount;
                    var tabsData = LoadData();
                    tabsData.Data.SessionCount = tabVM.SessionCount;
                    tabsData.TrySave();
                }
            }
            catch (Exception ex)
            {
                Logger.Log.Error(ex, "RestoreTabs.Application_Idle");
            }
        }