Exemplo n.º 1
0
        public bool Reload(IDsDocumentLoader documentLoader)
        {
            const bool isReload = true;

            if (documentLoader == null)
            {
                documentLoader = new DefaultDsDocumentLoader(documentTabService.DocumentTreeView.DocumentService);
            }
            if (!CanReload)
            {
                return(false);
            }
            if (!CheckCanLoad(isReload))
            {
                return(false);
            }
            SaveCurrentDocumentsToList();

            NotifyBeforeLoad(isReload);
            var tgws = documentTabSerializer.SaveTabs();

            using (DisableSaveToList())
                using (documentTabService.OnReloadAll()) {
                    documentTabService.CloseAll();
                    documentTabService.DocumentTreeView.DocumentService.Clear();
                    var documents = documentListService.SelectedDocumentList.Documents.Select(a => new DocumentToLoad(a)).ToList();
                    foreach (var tgw in tgws)
                    {
                        foreach (var g in tgw.TabGroups)
                        {
                            foreach (var t in g.Tabs)
                            {
                                foreach (var f in t.AutoLoadedDocuments)
                                {
                                    documents.Add(new DocumentToLoad(f, true));
                                }
                            }
                        }
                    }
                    documentLoader.Load(documents);
                }
            NotifyAfterLoad(isReload);

            // The documentss in the TV is loaded with a delay so make sure we delay before restoring
            // or the code that tries to find the nodes might fail to find them.
            disableLoadAndReload = true;
            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => {
                GC.Collect();
                GC.WaitForPendingFinalizers();
                foreach (var o in documentTabSerializer.Restore(tgws))
                {
                }
                disableLoadAndReload = false;
            }));
            return(true);
        }
Exemplo n.º 2
0
        public void Save(ISettingsService settingsService)
        {
            var section = settingsService.RecreateSection(SETTINGS_GUID);

            documentListLoader.Save(section.GetOrCreateSection(DOCUMENT_LISTS_SECTION));

            if (documentTabService.Settings.RestoreTabs)
            {
                foreach (var tgw in documentTabSerializer.SaveTabs())
                {
                    tgw.Save(section.CreateSection(TABGROUPWINDOW_SECTION));
                }
            }
        }