void Initialize() { ComputeStateStorageDirectory(this.AppName, this.AppVersion); this.ExtensionManager = new ExtensionManager(this.StateStorageDirectory); this.ExtensionManager.LoadState(this.ExtensionAssemblies); this.RootServiceProvider = new RootServiceProvider(this.ExtensionManager); this.RootServiceProvider.AddService(typeof(IUserNotificationService), new SimpleNotificationService(this.AppTitle)); this.RootServiceProvider.AddService(typeof(ToolsUIApplication), this); this.RootServiceProvider.AddService(this.GetType(), this); this.RootServiceProvider.AddService(typeof(Dispatcher), Dispatcher.CurrentDispatcher); this.sessionStateService = new SessionStateService(); this.RootServiceProvider.AddService(typeof(ISessionStateService), this.sessionStateService); this.windowStateFileName = Path.Combine(this.StateStorageDirectory, "WindowState.xml"); this.sessionStateFileName = Path.Combine(this.StateStorageDirectory, "SessionState.xml"); if (File.Exists(this.sessionStateFileName)) { try { XElement sessionState = XElement.Load(this.sessionStateFileName); this.sessionStateService.SetFullSessionState(sessionState); } catch (Exception) { } } this.sessionStateService.StateSaveRequested += OnSessionStateSaveRequested; InitializeTheme(); this.viewCreators = this.ExtensionManager.BuildViewCreatorDictionary(); this.RecentDocumentService = this.RootServiceProvider.GetService(typeof(RecentDocumentService)) as RecentDocumentService; if (this.RecentDocumentService != null) { ((INotifyCollectionChanged)this.RecentDocumentService.DocumentIdentities).CollectionChanged += OnRecentDocumentIdentitiesCollectionChanged; OnRecentDocumentIdentitiesCollectionChanged(null, null); } this.FoldersSource.GroupDescriptions.Add(new PropertyGroupDescription { PropertyName = "Category" }); if (this.RecentDocumentService != null) { NotifyCollectionChangedEventHandler handler = (s, e) => { this.FoldersSource.Source = new CategorizedFolder[] { new CategorizedFolder { Category = "Current Folder", DirectoryInfo = new DirectoryInfo(Directory.GetCurrentDirectory()), ShortcutKey = "C" } }.Concat(this.RecentDocumentService.RecentFolders.Select((d, i) => new CategorizedFolder { Category = "Recent Folders", DirectoryInfo = d, ShortcutKey = string.Format("D{0}", i + 1) })); }; ((INotifyCollectionChanged)this.RecentDocumentService.RecentFolders).CollectionChanged += handler; handler(null, null); } this.documentCategories = new List<DocumentCategory>(); foreach (var factoryName in this.ExtensionManager.DocumentFactoryNames) { var factory = this.ExtensionManager.LookupDocumentFactory(factoryName); if (factory != null) { var category = new DocumentCategory { DisplayName = factory.DocumentKind, DocumentFactoryName = factoryName }; BindingOperations.SetBinding(category, DocumentCategory.ColorProperty, Theme.CreateBinding(factory.ColorThemePropertyName)); this.documentCategories.Add(category); } } this.documentCategories.Add(new DocumentCategory { Color = Colors.Transparent, DisplayName = "Any", DocumentFactoryName = null }); OnInitialized(); }
void Initialize() { ComputeStateStorageDirectory(this.AppName, this.AppVersion); this.ExtensionManager = new ExtensionManager(this.StateStorageDirectory); this.ExtensionManager.LoadState(this.ExtensionAssemblies); this.RootServiceProvider = new RootServiceProvider(this.ExtensionManager); this.RootServiceProvider.AddService(typeof(IUserNotificationService), new SimpleNotificationService(this.AppTitle)); this.RootServiceProvider.AddService(typeof(ToolsUIApplication), this); this.RootServiceProvider.AddService(this.GetType(), this); this.RootServiceProvider.AddService(typeof(Dispatcher), Dispatcher.CurrentDispatcher); this.sessionStateService = new SessionStateService(); this.RootServiceProvider.AddService(typeof(ISessionStateService), this.sessionStateService); this.windowStateFileName = Path.Combine(this.StateStorageDirectory, "WindowState.xml"); this.sessionStateFileName = Path.Combine(this.StateStorageDirectory, "SessionState.xml"); if (File.Exists(this.sessionStateFileName)) { try { XElement sessionState = XElement.Load(this.sessionStateFileName); this.sessionStateService.SetFullSessionState(sessionState); } catch (Exception) { } } this.sessionStateService.StateSaveRequested += OnSessionStateSaveRequested; InitializeTheme(); this.viewCreators = this.ExtensionManager.BuildViewCreatorDictionary(); this.RecentDocumentService = this.RootServiceProvider.GetService(typeof(RecentDocumentService)) as RecentDocumentService; if (this.RecentDocumentService != null) { ((INotifyCollectionChanged)this.RecentDocumentService.DocumentIdentities).CollectionChanged += OnRecentDocumentIdentitiesCollectionChanged; OnRecentDocumentIdentitiesCollectionChanged(null, null); } this.FoldersSource.GroupDescriptions.Add(new PropertyGroupDescription { PropertyName = "Category" }); if (this.RecentDocumentService != null) { NotifyCollectionChangedEventHandler handler = (s, e) => { this.FoldersSource.Source = new CategorizedFolder[] { new CategorizedFolder { Category = "Current Folder", DirectoryInfo = new DirectoryInfo(Directory.GetCurrentDirectory()), ShortcutKey = "C" } }.Concat(this.RecentDocumentService.RecentFolders.Select((d, i) => new CategorizedFolder { Category = "Recent Folders", DirectoryInfo = d, ShortcutKey = string.Format("D{0}", i + 1) })); }; ((INotifyCollectionChanged)this.RecentDocumentService.RecentFolders).CollectionChanged += handler; handler(null, null); } this.documentCategories = new List <DocumentCategory>(); foreach (var factoryName in this.ExtensionManager.DocumentFactoryNames) { var factory = this.ExtensionManager.LookupDocumentFactory(factoryName); if (factory != null) { var category = new DocumentCategory { DisplayName = factory.DocumentKind, DocumentFactoryName = factoryName }; BindingOperations.SetBinding(category, DocumentCategory.ColorProperty, Theme.CreateBinding(factory.ColorThemePropertyName)); this.documentCategories.Add(category); } } this.documentCategories.Add(new DocumentCategory { Color = Colors.Transparent, DisplayName = "Any", DocumentFactoryName = null }); OnInitialized(); }