Пример #1
0
        public bool Load(DocumentList documentList, IDsDocumentLoader documentLoader)
        {
            const bool isReload = false;

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

            NotifyBeforeLoad(isReload);
            using (DisableSaveToList()) {
                documentTabService.CloseAll();
                documentTabService.DocumentTreeView.DocumentService.Clear();
                documentLoader.Load(documentList.Documents.Select(a => new DocumentToLoad(a)));
            }
            NotifyAfterLoad(isReload);

            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }));
            return(true);
        }
Пример #2
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);
        }
Пример #3
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 documents 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;
		}
Пример #4
0
		public bool Load(DocumentList documentList, IDsDocumentLoader documentLoader) {
			const bool isReload = false;
			if (documentLoader == null)
				documentLoader = new DefaultDsDocumentLoader(documentTabService.DocumentTreeView.DocumentService);
			if (!CanLoad)
				return false;
			if (!CheckCanLoad(isReload))
				return false;
			if (documentList != documentListService.SelectedDocumentList)
				SaveCurrentDocumentsToList();

			NotifyBeforeLoad(isReload);
			using (DisableSaveToList()) {
				documentTabService.CloseAll();
				documentTabService.DocumentTreeView.DocumentService.Clear();
				documentLoader.Load(documentList.Documents.Select(a => new DocumentToLoad(a)));
			}
			NotifyAfterLoad(isReload);

			Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => {
				GC.Collect();
				GC.WaitForPendingFinalizers();
			}));
			return true;
		}