protected virtual void RunApplication() { ExpressionApplication.StartGlobalPerformanceInstrumentation(); PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Application Created"); try { this.Run(); } catch (TargetInvocationException ex) { if (ex.InnerException != null) { this.ShowSafeMessageBox(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.ApplicationTargetInvocationDialogMessage, new object[1] { (object)ex.InnerException.ToString() }), StringTable.ApplicationTargetInvocationDialogTitle); } throw; } catch (SecurityException ex) { this.ShowSafeMessageBox(ex.ToString(), StringTable.ApplicationSecurityExceptionDialogTitle); } catch (MissingSatelliteAssemblyException ex) { this.ShowSafeMessageBox(ex.Message, "Microsoft Expression"); } }
public Cursor GetCursor(string name) { name = name.ToLower(CultureInfo.InvariantCulture); name = name.Replace("\\", "/"); PerformanceUtility.StartPerformanceSequence(PerformanceEvent.GetCursorFileResource); Stream cursorStream = (Stream)this.resourceManager.GetObject(name, Thread.CurrentThread.CurrentUICulture); PerformanceUtility.MarkInterimStep(PerformanceEvent.GetCursorFileResource, "Loaded " + name); Cursor cursor = new Cursor(cursorStream); PerformanceUtility.EndPerformanceSequence(PerformanceEvent.GetCursorFileResource); return(cursor); }
private ImageSource GetImageSourceCore(string name) { name = name.ToLower(CultureInfo.InvariantCulture); name = name.Replace("\\", "/"); Stream stream = (Stream)this.resourceManager.GetObject(name, Thread.CurrentThread.CurrentUICulture); PerformanceUtility.MarkInterimStep(PerformanceEvent.GetImageFileResource, "Loaded " + name); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.StreamSource = stream; bitmapImage.EndInit(); bitmapImage.Freeze(); return((ImageSource)bitmapImage); }
public override void Execute() { this.HandleBasicExceptions(() => { string str = base.SelectProject(StringTable.OpenProjectDialogTitle); if (!string.IsNullOrEmpty(str)) { PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.OpenProjectInner); ISolution solution = this.ProjectManager().OpenSolution(DocumentReference.Create(str), true, true); PerformanceUtility.MarkInterimStep(PerformanceEvent.OpenProjectInner, "Finished loading, now closing all projects."); if (solution != null) { this.ProjectManager().DefaultOpenProjectPath = Path.GetDirectoryName(Path.GetDirectoryName(solution.DocumentReference.Path)); } } }); }
internal bool HandleDrag(Point dragStartPosition, Point dragCurrentPosition) { PerformanceUtility.MarkInterimStep(PerformanceEvent.DragTool, "HandlingTheDragEvent"); if (this.HasMouseMovedAfterDown && this.ShouldMotionlessAutoScroll()) { this.StartMotionlessAutoScroll(dragStartPosition, dragCurrentPosition); return(true); } this.StopMotionlessAutoScroll(); try { return(this.OnDrag(dragStartPosition, dragCurrentPosition, false)); } finally { this.HasMouseMovedAfterDown = true; } }
protected void CreateFileWatcher(string path) { if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(path)) { return; } PerformanceUtility.StartPerformanceSequence(PerformanceEvent.CreateFileWatcher); this.watcher = new FileSystemWatcher(path) { NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.Attributes | NotifyFilters.Size | NotifyFilters.LastWrite | NotifyFilters.CreationTime }; PerformanceUtility.MarkInterimStep(PerformanceEvent.CreateFileWatcher, "Add EventHandlers to FileSystemWatcher"); this.watcher.Deleted += new FileSystemEventHandler(this.Watcher_Changed); this.watcher.Renamed += new RenamedEventHandler(this.Watcher_Changed); this.watcher.Changed += new FileSystemEventHandler(this.Watcher_Changed); this.UpdateFileInformation(); this.EnableWatchingForChanges(); PerformanceUtility.EndPerformanceSequence(PerformanceEvent.CreateFileWatcher); }
public override bool Save() { CancelEventArgs e = new CancelEventArgs(false); this.OnSaving(e); if (!e.Cancel) { PerformanceUtility.StartPerformanceSequence(PerformanceEvent.SaveDocument, this.DocumentReference.Path); bool saveSucceeded = false; string str = this.DocumentReference.Path + ".temporary"; if (PathHelper.FileExists(this.DocumentReference.Path)) { if ((File.GetAttributes(this.DocumentReference.Path) & FileAttributes.ReadOnly) != (FileAttributes)0) { throw new UnauthorizedAccessException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, ExceptionStringTable.DocumentIsReadOnly, new object[1] { (object)this.DocumentReference.Path })); } } try { DirectoryInfo directory = new FileInfo(str).Directory; if (!PathHelper.DirectoryExists(Path.GetDirectoryName(str))) { directory.Create(); } PerformanceUtility.MarkInterimStep(PerformanceEvent.SaveDocument, "SaveCore"); using (Stream stream = (Stream) new FileStream(str, FileMode.Create, FileAccess.Write)) { this.SaveCore(stream); saveSucceeded = true; } } finally { if (this.Container != null) { PerformanceUtility.MarkInterimStep(PerformanceEvent.SaveDocument, "BeginDocumentSave"); this.Container.BeginDocumentSave((IDocument)this); } try { if (saveSucceeded) { bool flag = false; DateTime creationTime = DateTime.Now; try { if (PathHelper.FileExists(this.DocumentReference.Path)) { PerformanceUtility.MarkInterimStep(PerformanceEvent.SaveDocument, "Delete document"); creationTime = File.GetCreationTime(this.DocumentReference.Path); flag = true; File.SetAttributes(this.DocumentReference.Path, FileAttributes.Normal); File.Delete(this.DocumentReference.Path); } } catch (IOException ex) { } PerformanceUtility.MarkInterimStep(PerformanceEvent.SaveDocument, "Move"); File.Move(str, this.DocumentReference.Path); if (flag) { File.SetCreationTime(this.DocumentReference.Path, creationTime); } } else { PerformanceUtility.MarkInterimStep(PerformanceEvent.SaveDocument, "Delete temporary"); if (PathHelper.FileExists(str)) { File.Delete(str); } } } finally { if (this.Container != null) { PerformanceUtility.MarkInterimStep(PerformanceEvent.SaveDocument, "DocumentSaveCompleted"); this.Container.DocumentSaveCompleted((IDocument)this, saveSucceeded); } } } this.SourceIsDirty = false; this.UndoService.SetClean(); PerformanceUtility.EndPerformanceSequence(PerformanceEvent.SaveDocument, this.DocumentReference.Path); this.OnSaved(EventArgs.Empty); this.OnIsDirtyChanged(EventArgs.Empty); } return(!e.Cancel); }
public void Load(IServices services) { this.services = services; PerformanceUtility.StartPerformanceSequence(PerformanceEvent.FrameworkPackageLoad); UIThreadDispatcher.InitializeInstance(); IExpressionMefHostingService mefHostingService = (IExpressionMefHostingService) new ExpressionMefHostingService(services); this.services.AddService(typeof(IExpressionMefHostingService), (object)mefHostingService); mefHostingService.AddInternalPart((object)mefHostingService); IMessageDisplayService messageDisplayService = (IMessageDisplayService) new MessageDisplayService(services.GetService <IExpressionInformationService>()); this.services.AddService(typeof(IMessageDisplayService), (object)messageDisplayService); mefHostingService.AddInternalPart((object)this.services.GetService <IMessageDisplayService>()); PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create SchedulingService"); this.services.AddService(typeof(ISchedulingService), (object)new SchedulingService()); mefHostingService.AddInternalPart((object)this.services.GetService <ISchedulingService>()); string str = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Microsoft\\Expression\\Blend 4"); PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create ConfigurationService"); IConfigurationService configurationService = (IConfigurationService) new ConfigurationService(str); this.services.AddService(typeof(IConfigurationService), (object)configurationService); PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create OptionsDialogService"); IOptionsDialogService optionsDialogService = (IOptionsDialogService) new OptionsDialogService(configurationService); this.services.AddService(typeof(IOptionsDialogService), (object)optionsDialogService); PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create CommandService"); ICommandService commandService = (ICommandService) new CommandService(services.GetService <IFeedbackService>()); this.services.AddService(typeof(ICommandService), (object)commandService); PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Add Commands"); this.AddCommand("Application_Exit", (ICommand) new FrameworkPackage.ExitCommand()); this.AddCommand("Application_Options", (ICommand) new FrameworkPackage.OptionsCommand(optionsDialogService)); PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create DocumentService"); DocumentService documentService = (DocumentService) new BlendDocumentService(commandService, messageDisplayService); this.services.AddService(typeof(IDocumentService), (object)documentService); this.services.AddService(typeof(IViewService), (object)documentService); ICommandBarService commandBarService = (ICommandBarService) new CommandBarService(commandService); this.services.AddService(typeof(ICommandBarService), (object)commandBarService); PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create WorkspaceService"); WorkspaceService workspaceService = new WorkspaceService(configurationService["WorkspaceService"], Path.Combine(str, "Workspaces"), (IEnumerable <string>) new string[2] { StringTable.DesignWorkspaceName, StringTable.AnimationWorkspaceName }, (IEnumerable <Uri>) new Uri[2] { new Uri("pack://application:,,,/Shopdrawing.Application;Component/Resources/Workspaces/Design.xaml", UriKind.Absolute), new Uri("pack://application:,,,/Shopdrawing.Application;Component/Resources/Workspaces/Animation.xaml", UriKind.Absolute) }, messageDisplayService); commandService.AddTarget((ICommandTarget)workspaceService); this.services.AddService(typeof(IWorkspaceService), (object)workspaceService); this.frameworkIcons = new ResourceDictionary(); this.frameworkIcons.Source = new Uri("pack://application:,,,/Microsoft.Expression.Framework;Component/Resources/Icons/FrameworkIcons.xaml", UriKind.Absolute); List <Theme> list = new List <Theme>(2); Uri resourceDictionaryUriToMerge1 = new Uri("pack://application:,,,/Shopdrawing.Application;Component/Resources/BlendDarkTheme.xaml", UriKind.Absolute); list.Add(new Theme(StringTable.ThemeNameExpressionDark, "Resources\\UserInterface\\ExpressionDark.xaml", resourceDictionaryUriToMerge1)); Uri resourceDictionaryUriToMerge2 = new Uri("pack://application:,,,/Shopdrawing.Application;Component/Resources/BlendLightTheme.xaml", UriKind.Absolute); list.Add(new Theme(StringTable.ThemeNameExpressionLight, "Resources\\UserInterface\\ExpressionLight.xaml", resourceDictionaryUriToMerge2)); PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Create WindowService"); WindowService windowService = new WindowService(configurationService["WindowService"], commandBarService, commandService, (IViewService)documentService, (IWorkspaceService)workspaceService, messageDisplayService, services.GetService <IFeedbackService>(), services.GetService <IExpressionInformationService>().MainWindowRootElement, this.frameworkIcons, list.AsReadOnly(), this.suppressViewUI); this.services.AddService(typeof(Microsoft.Expression.Framework.UserInterface.IWindowService), (object)windowService); this.services.AddService(typeof(IOrderedViewProvider), (object)windowService); workspaceService.SetPaletteRegistry(windowService.PaletteRegistry); PerformanceUtility.MarkInterimStep(PerformanceEvent.FrameworkPackageLoad, "Register CommandTargets"); commandService.AddTarget((ICommandTarget)this); commandService.AddTarget((ICommandTarget)documentService); this.services.AddService(typeof(IMessageLoggingService), (object)new FrameworkPackage.NullMessageLoggingService()); this.services.AddService(typeof(IErrorService), (object)new FrameworkPackage.ErrorService()); this.services.AddService(typeof(IImporterService), (object)new ImporterService(configurationService["ImporterService"], Path.Combine(str, "ImportersDataStore"))); this.shellOptionsPage = new ShellOptionsPage((Microsoft.Expression.Framework.UserInterface.IWindowService)windowService); optionsDialogService.OptionsPages.Add((IOptionsPage)this.shellOptionsPage); Dialog.ServiceProvider = (IServiceProvider)services; PerformanceUtility.EndPerformanceSequence(PerformanceEvent.FrameworkPackageLoad); }
private void SetActiveDocumentAndView(IView view, DocumentService.Item item) { PerformanceUtility.StartPerformanceSequence(PerformanceEvent.SetActiveDocumentAndView); ViewChangedEventArgs e1 = view != this.activeView ? new ViewChangedEventArgs(this.activeView, view) : (ViewChangedEventArgs)null; IDocument oldDocument = this.activeItem != null ? this.activeItem.Document : (IDocument)null; IDocument newDocument = item != null ? item.Document : (IDocument)null; DocumentChangedEventArgs e2 = item != this.activeItem ? new DocumentChangedEventArgs(oldDocument, newDocument) : (DocumentChangedEventArgs)null; if (e1 != null || e2 != null) { if (e1 != null) { PerformanceUtility.MarkInterimStep(PerformanceEvent.SetActiveDocumentAndView, "OnActiveViewChanging"); if (e1.OldView != null) { e1.OldView.Deactivating(); } this.OnActiveViewChanging(e1); } if (e2 != null) { PerformanceUtility.MarkInterimStep(PerformanceEvent.SetActiveDocumentAndView, "OnActiveDocumentChanging"); this.OnActiveDocumentChanging(e2); } this.activeItem = item; this.activeView = view; if (this.activeView != null) { PerformanceUtility.MarkInterimStep(PerformanceEvent.SetActiveDocumentAndView, "RecordViewUse"); this.RecordViewUse(this.activeView); this.activeView.ReturnFocus(); } else { try { if (Application.Current != null) { if (Application.Current.MainWindow != null) { FocusManager.SetFocusedElement((DependencyObject)Application.Current.MainWindow, (IInputElement)Application.Current.MainWindow); } } } catch { } } if (e2 != null) { PerformanceUtility.MarkInterimStep(PerformanceEvent.SetActiveDocumentAndView, "OnActiveDocumentChanged"); this.OnActiveDocumentChanged(e2); } if (e1 != null) { PerformanceUtility.MarkInterimStep(PerformanceEvent.SetActiveDocumentAndView, "OnActiveViewChanged"); if (e1.OldView != null) { e1.OldView.Deactivated(); ICommandTarget target = e1.OldView as ICommandTarget; if (target != null) { this.commandService.RemoveTarget(target); } } if (e1.NewView != null) { e1.NewView.Activated(); ICommandTarget target = e1.NewView as ICommandTarget; if (target != null) { this.commandService.AddTarget(target); } } this.OnActiveViewChanged(e1); } if (e2 != null) { PerformanceUtility.MarkInterimStep(PerformanceEvent.SetActiveDocumentAndView, "UpdateTargets"); ICommandTarget target1; if ((target1 = oldDocument as ICommandTarget) != null) { this.commandService.RemoveTarget(target1); } ICommandTarget target2; if ((target2 = newDocument as ICommandTarget) != null) { this.commandService.AddTarget(target2); } } } PerformanceUtility.EndPerformanceSequence(PerformanceEvent.SetActiveDocumentAndView); }
public WindowService(IConfigurationObject configuration, ICommandBarService commandBarService, ICommandService commandService, IViewService viewService, IWorkspaceService workspaceService, IMessageDisplayService messageDisplayService, IFeedbackService feedbackService, FrameworkElement mainWindowRootElement, ResourceDictionary icons, ReadOnlyCollection <Theme> themes, bool suppressViewUI) { PerformanceUtility.StartPerformanceSequence(PerformanceEvent.WindowServiceConstructor); this.applicationWindow = new ApplicationWindow(configuration, feedbackService); this.applicationWindow.Closed += new EventHandler(this.ApplicationWindow_Closed); this.applicationWindow.Closing += new CancelEventHandler(this.ApplicationWindow_Closing); this.applicationWindow.ClosingCanceled += new EventHandler(this.ApplicationWindow_ClosingCanceled); this.applicationWindow.KeyDown += new KeyEventHandler(this.ApplicationWindow_KeyDown); this.applicationWindow.PreviewKeyDown += new KeyEventHandler(this.ApplicationWindow_PreviewKeyDown); this.applicationWindow.ThemeChanged += new EventHandler(this.ApplicationWindow_ThemeChanged); this.applicationWindow.StateChanged += new EventHandler(this.ApplicationWindow_StateChanged); this.applicationWindow.SourceInitialized += new EventHandler(this.ApplicationWindow_SourceInitialized); EventManager.RegisterClassHandler(typeof(GroupControl), UIElement.GotKeyboardFocusEvent, (Delegate) new KeyboardFocusChangedEventHandler(this.OnTabGroupGotKeyboardFocus)); EventManager.RegisterClassHandler(typeof(DocumentGroupControl), UIElement.KeyDownEvent, (Delegate) new KeyEventHandler(this.OnDocumentGroupKeyDownOrUp)); EventManager.RegisterClassHandler(typeof(DocumentGroupControl), UIElement.KeyUpEvent, (Delegate) new KeyEventHandler(this.OnDocumentGroupKeyDownOrUp)); this.commandService = commandService; this.viewService = viewService; this.workspaceService = workspaceService; if (icons != null) { this.AddResourceDictionary(icons); } if (themes.Count > 0) { foreach (ITheme theme in themes) { this.Themes.Add(theme); } if (configuration != null) { this.ActiveTheme = (string)configuration.GetProperty("ActiveTheme", (object)this.Themes[0].Name); int num = -1; for (int index = 0; index < this.Themes.Count; ++index) { if (this.Themes[index].Name == this.ActiveTheme) { num = index; break; } } if (feedbackService != null) { feedbackService.SetData(25, num + 1); } } } PerformanceUtility.MarkInterimStep(PerformanceEvent.WindowServiceConstructor, "Create PaletteRegistry"); this.paletteRegistry = new PaletteRegistry(workspaceService); ViewElementFactory.Current = (ViewElementFactory) new ExpressionViewElementFactory(); if (!suppressViewUI) { this.dockingViewManager = new ExpressionViewManager(); ViewManager.Instance = (ViewManager)this.dockingViewManager; DockManager.Instance = (DockManager) new ExpressionDockManager(); if (viewService != null) { this.viewBridge = new ViewBridge(this.workspaceService, this.viewService, messageDisplayService); } } PerformanceUtility.MarkInterimStep(PerformanceEvent.WindowServiceConstructor, "Create CommandBarService"); this.commandBarService = commandBarService; TextBoxHelper.RegisterType(typeof(TextBox)); PerformanceUtility.MarkInterimStep(PerformanceEvent.WindowServiceConstructor, "Load Window Content"); this.mainBody = mainWindowRootElement; if (this.mainBody != null) { this.mainBody.DataContext = (object)this; FrameworkElement frameworkElement = this.commandBarService as FrameworkElement; if (frameworkElement != null) { frameworkElement.Name = "CommandBarService"; frameworkElement.VerticalAlignment = VerticalAlignment.Top; frameworkElement.SetValue(Grid.ColumnSpanProperty, (object)2); ((Panel)this.mainBody).Children.Insert(0, (UIElement)frameworkElement); } } PerformanceUtility.MarkInterimStep(PerformanceEvent.WindowServiceConstructor, "Hookup Tree to Window Content"); this.applicationWindow.Content = (object)mainWindowRootElement; PerformanceUtility.EndPerformanceSequence(PerformanceEvent.WindowServiceConstructor); }
protected void OpenProjectInternal(INamedProject project) { PerformanceUtility.MarkInterimStep(PerformanceEvent.ProjectManagerOpenProject, "projects.Add"); this.AddProject(project); this.OnAnyProjectOpened(new NamedProjectEventArgs(project)); }
protected override void OnStartup(StartupEventArgs e) { this.InitializeUnhandledExceptionHandlers(); CultureManager.ForceCulture(Path.GetDirectoryName(this.GetType().Module.FullyQualifiedName), "en"); SplashService splashService = new SplashService("{5d76ab22-cd7a-42ea-9756-629f133abd8ex}", this.RegistryPath); this.ReplaceWithWelcomeSplashScreen(splashService.GetSplashVersion() == 1 ? "pack://application:,,,/Shopdrawing.Application;Component/licensing/SplashScreenSketchFlow.png" : "pack://application:,,,/Shopdrawing.Application;Component/licensing/SplashScreen.png"); this.DoEvents(); PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Creating Services and ExpressionInformationService"); this.CreateInitialServices(ExpressionApplication.Version); this.ExpressionInformationService.MainWindowRootElement = FileTable.GetElement("MainWindow.xaml"); //this.InitializeLicenseService(ExpressionFeatureMapper.Blend, (ApplicationLicenses) new BlendTrialRtmV4Licenses(), (ApplicationLicenses) new BlendMobileRtmV4Licenses()); FrameworkPackage.RegisterCommandLineService(this.Services); ICommandLineService service1 = this.Services.GetService <ICommandLineService>(); this.CreateFeedbackService("Shopdrawing", BlendFeedbackValues.CommandToFeedbackValues); this.Services.AddService(typeof(SplashService), (object)splashService); string name = service1.GetArgument("culture"); if (!string.IsNullOrEmpty(name)) { Thread.CurrentThread.CurrentCulture = new CultureInfo(name); Thread.CurrentThread.CurrentUICulture = new CultureInfo(name); } PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Load resources"); PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Register FrameworkPackage"); this.Services.RegisterPackage((IPackage) new FrameworkPackage()); IExpressionMefHostingService service2 = this.Services.GetService <IExpressionMefHostingService>(); Microsoft.Expression.Framework.UserInterface.IWindowService service3 = this.Services.GetService <Microsoft.Expression.Framework.UserInterface.IWindowService>(); service3.Title = StringTable.ApplicationTitle; FocusScopeManager.SetFocusScopePriority((DependencyObject)System.Windows.Application.Current.MainWindow, 0); //FocusScopeManager.Instance.ReturnFocusCallback = new ReturnFocusCallback(((ExpressionApplication)this).FocusScopeManagerReturnFocusCallback); this.Services.RegisterPackage((IPackage) new WebServerPackage()); this.Services.RegisterPackage((IPackage) new SourceControlPackage()); this.Services.RegisterPackage((IPackage) new ProjectPackage()); this.Services.RegisterPackage((IPackage) new CodePackage()); PlatformPackage platformPackage = new PlatformPackage(); this.Services.RegisterPackage((IPackage)platformPackage); if (service2 != null) { service2.AddInternalPart((object)platformPackage); } this.Services.RegisterPackage((IPackage) new DesignerPackage()); this.Services.GetService <IHelpService>().RegisterHelpProvider((IHelpProvider) new BlendSDKHelpProvider()); PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Discovering external packages"); BlendApplication.disableWhitecap = service1.GetArgument("DisableWhitecap") != null; if (BlendApplication.disableWhitecap) { this.Services.ExcludeAddIn("Microsoft.Expression.PrototypeHostEnvironment.dll"); } this.Services.LoadAddIns("Microsoft.Expression.*.addin"); this.Services.LoadAddIns("AddIns\\*.addin"); this.InitializeMefHostingService(service1); ICommandService service4 = this.Services.GetService <ICommandService>(); service4.AddTarget((ICommandTarget) new ApplicationCommandTarget(this.Services)); PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Creating Menu"); ICommandBar menuBar = this.Services.GetService <ICommandBarService>().CommandBars.AddMenuBar("MainMenu"); MenuBar.Create(menuBar, this.Services); DebugCommands.CreateDebugMenu(menuBar, this.Services); this.DoEvents(); PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Show ApplicationWindow"); PerformanceUtility.StartPerformanceSequence(PerformanceEvent.ShowMainWindow); service3.Initialized += new EventHandler(this.MainWindow_SourceInitialized); service3.IsVisible = true; this.MainWindow = service3.MainWindow; this.MainWindow.IsEnabled = false; PerformanceUtility.EndPerformanceSequence(PerformanceEvent.ShowMainWindow); this.Services.GetService <IWorkspaceService>().LoadConfiguration(service1.GetArgument("DefaultWorkspace") != null); service4.AddTarget((ICommandTarget) new DebugCommands(this.Services)); PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Initializing Project System"); IProjectManager service5 = this.Services.GetService <IProjectManager>(); service5.SolutionOpened += new EventHandler <SolutionEventArgs>(this.ProjectManager_SolutionOpened); service5.SolutionClosed += new EventHandler <SolutionEventArgs>(this.ProjectManager_SolutionClosed); service5.SolutionMigrated += new EventHandler <SolutionEventArgs>(this.ProjectManager_SolutionMigrated); this.DoEvents(); BlendServer.StartRemoteService((IServiceProvider)this.Services); if (service1.GetArgument("ExceptionLog") != null) { ExceptionHandler.Attach(AppDomain.CurrentDomain); DebugVariables.Instance.ExceptionHandlerEnabled = true; } string[] arguments = service1.GetArguments("addin"); if (arguments != null) { foreach (string fileName in arguments) { try { this.Services.LoadAddIn(fileName); } catch (Exception ex) { IMessageDisplayService service6 = this.Services.GetService <IMessageDisplayService>(); if (service6 != null) { service6.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.ApplicationAssemblyLoadErrorDialogMessage, new object[2] { (object)fileName, (object)ex.Message })); } } } } this.OnStartupIdleProcessing(); base.OnStartup(e); }
public void Load(IServices services) { PerformanceUtility.StartPerformanceSequence(PerformanceEvent.DesignerPackageLoad); this.services = services; PropertyReference.RegisterAssemblyNamespace(typeof(DesignerPackage).Assembly, new string[] { "Microsoft.Expression.DesignSurface", "Microsoft.Expression.DesignSurface.Properties" }); IWindowService service = this.services.GetService <IWindowService>(); IProjectTypeManager projectTypeManager = this.services.GetService <IProjectTypeManager>(); IDocumentTypeManager documentTypeManager = this.services.GetService <IDocumentTypeManager>(); IOptionsDialogService optionsDialogService = this.services.GetService <IOptionsDialogService>(); this.services.GetService <IProjectManager>(); this.designSurfaceIcons = FileTable.GetResourceDictionary("Resources/Icons/DesignSurfaceIcons.xaml"); service.AddResourceDictionary(this.designSurfaceIcons); SceneViewModel.RegisterPipelineTasks(this.services.GetService <ISchedulingService>()); this.designerContext = new DesignerContext(this.services); this.designerContext.Initialize(); this.services.AddService(typeof(SelectionManager), this.designerContext.SelectionManager); this.services.AddService(typeof(ToolManager), this.designerContext.ToolManager); this.services.AddService(typeof(SnappingEngine), this.designerContext.SnappingEngine); this.services.AddService(typeof(ICodeAidProvider), this.designerContext.CodeAidProvider); this.services.AddService(typeof(IAttachedPropertyMetadataFactory), new AttachedPropertyMetadataFactory()); IOutOfBrowserDeploymentService outOfBrowserDeploymentService = new OutOfBrowserDeploymentService(this.services); this.services.AddService(typeof(IOutOfBrowserDeploymentService), outOfBrowserDeploymentService); this.services.AddService(typeof(IPlatformContextChanger), this.designerContext.PlatformContextChanger); PerformanceUtility.MarkInterimStep(PerformanceEvent.DesignerPackageLoad, "Registering Document Types"); this.documentTypes.Add(new LicxDocumentType()); this.documentTypes.Add(new SceneDocumentType(this.designerContext)); this.documentTypes.Add(new ResourceDictionaryDocumentType(this.designerContext)); this.documentTypes.Add(new ImageDocumentType(this.designerContext)); this.documentTypes.Add(new IconImageDocumentType(this.designerContext)); this.documentTypes.Add(new PngImageDocumentType(this.designerContext)); this.documentTypes.Add(new JpgImageDocumentType(this.designerContext)); this.documentTypes.Add(new GifImageDocumentType(this.designerContext)); this.documentTypes.Add(new TifImageDocumentType(this.designerContext)); this.documentTypes.Add(new FontDocumentType()); this.documentTypes.Add(new WpfMediaDocumentType(this.designerContext)); this.documentTypes.Add(new SilverlightAndWpfMediaDocumentType(this.designerContext)); this.documentTypes.Add(new XapDocumentType()); this.documentTypes.Add(new WavefrontObjAsset(this.designerContext)); this.documentTypes.Add(new WavefrontMtlDocumentType(this.designerContext)); this.documentTypes.Add(new ApplicationDefinitionDocumentType(this.designerContext)); foreach (IDocumentType documentType in this.documentTypes) { documentTypeManager.Register(documentType); } PerformanceUtility.MarkInterimStep(PerformanceEvent.DesignerPackageLoad, "Initializing DesignTime Metadata Store"); IDesignerDefaultPlatformService designerDefaultPlatformService = new DesignerDefaultPlatformService(this.services); this.services.AddService(typeof(IDesignerDefaultPlatformService), designerDefaultPlatformService); IHelpService helpService = new HelpService(); this.services.AddService(typeof(IHelpService), helpService); CanonicalTransform3D.Initialize(this.designerContext); PerformanceUtility.MarkInterimStep(PerformanceEvent.DesignerPackageLoad, "Creating Managers"); this.unitsOptionsPage = new UnitsOptionsPage(this.designerContext); optionsDialogService.OptionsPages.Add(this.unitsOptionsPage); this.artboardOptionsPage = new ArtboardOptionsPage(this.designerContext); optionsDialogService.OptionsPages.Add(this.artboardOptionsPage); this.viewOptionsPage = new ViewOptionsPage(this.designerContext); optionsDialogService.OptionsPages.Add(this.viewOptionsPage); this.annotationsOptionsPage = new AnnotationsOptionsPage(this.designerContext); optionsDialogService.OptionsPages.Add(this.annotationsOptionsPage); this.projectTypes.Add(new ExecutableProjectType()); this.projectTypes.Add(new WindowsExecutableProjectType()); this.projectTypes.Add(new WpfProjectType()); this.projectTypes.Add(new SilverlightProjectType(services)); foreach (IProjectType projectType in this.projectTypes) { projectTypeManager.Register(projectType); } IAssemblyService assemblyService = services.GetService <IAssemblyService>(); this.silverLightAssemblyResolver = new SilverlightAssemblyResolver(AppDomain.CurrentDomain, services); assemblyService.RegisterPlatformResolver(".NETFramework", new ClrAssemblyResolver()); assemblyService.RegisterPlatformResolver("Silverlight", this.silverLightAssemblyResolver); service.AddResourceDictionary(FileTable.GetResourceDictionary("Resources\\DesignSurfaceStyles.xaml")); PerformanceUtility.MarkInterimStep(PerformanceEvent.ApplicationStartup, "Opening Panels"); PerformanceUtility.StartPerformanceSequence(PerformanceEvent.OpeningPanels); ToolContext toolContext = this.designerContext.ToolContext; PerformanceUtility.MarkInterimStep(PerformanceEvent.OpeningPanels, "Tools"); service.RegisterPalette("Designer_ToolPane", new ToolPane(this.designerContext, toolContext), StringTable.ToolPaneTitle, null, new StandaloneViewProperties(false, true, false)); ProjectPane projectPane = new ProjectPane(services); service.RegisterPalette("Designer_ProjectPane", projectPane, StringTable.ProjectPaneTitle); PerformanceUtility.MarkInterimStep(PerformanceEvent.OpeningPanels, "Data"); service.RegisterPalette("Designer_DataPane", new DataPane(this.designerContext), StringTable.DataPaneTitle); PerformanceUtility.MarkInterimStep(PerformanceEvent.OpeningPanels, "Resources"); service.RegisterPalette("Designer_ResourcePane", new ResourcePane(this.designerContext, this.designerContext.ProjectManager, this.designerContext.ResourceManager), StringTable.ResourcePaneTitle); PerformanceUtility.MarkInterimStep(PerformanceEvent.OpeningPanels, "PropertyInspector"); service.RegisterPalette("Designer_PropertyInspector", new SceneNodePropertyInspectorPane(this.designerContext.PropertyInspectorModel), StringTable.PropertyInspectorPaneTitle); PerformanceUtility.MarkInterimStep(PerformanceEvent.OpeningPanels, "Timeline"); service.RegisterPalette("Designer_TimelinePane", new TimelinePane(this.designerContext), StringTable.TimelinePaneTitle); PerformanceUtility.MarkInterimStep(PerformanceEvent.OpeningPanels, "Triggers"); service.RegisterPalette("Designer_TriggersPane", new TriggersPane(this.designerContext), StringTable.TriggersPaneTitle); PerformanceUtility.MarkInterimStep(PerformanceEvent.OpeningPanels, "States"); service.RegisterPalette("Interaction_Skin", new SkinView(this.designerContext), StringTable.SkinPaneTitle); PerformanceUtility.MarkInterimStep(PerformanceEvent.OpeningPanels, "Asset"); service.RegisterPalette("Designer_AssetPane", new AssetPane(this.designerContext, toolContext), StringTable.AssetPaneTitle); PerformanceUtility.MarkInterimStep(PerformanceEvent.OpeningPanels, "Parts"); service.RegisterPalette("Interaction_Parts", new PartsPane(this.designerContext), StringTable.PartsPaneTitle); PerformanceUtility.MarkInterimStep(PerformanceEvent.OpeningPanels, "Results"); ResultsPane resultsPane = new ResultsPane(this.designerContext, new ProjectErrorTaskCollection(this.designerContext)); KeyBinding keyBinding = new KeyBinding() { Key = Key.F12 }; resultsPane.Palette = service.RegisterPalette("Designer_ResultsPane", resultsPane, StringTable.ResultsPaneTitle, keyBinding); PerformanceUtility.EndPerformanceSequence(PerformanceEvent.OpeningPanels); this.services.RemoveService(typeof(IErrorService)); this.services.RemoveService(typeof(IMessageLoggingService)); this.services.AddService(typeof(IErrorService), resultsPane.ErrorManager); this.services.AddService(typeof(IMessageLoggingService), resultsPane.MessageLoggingService); this.designerContext.ErrorManager = resultsPane.ErrorManager; this.designerContext.MessageLoggingService = resultsPane.MessageLoggingService; PerformanceUtility.MarkInterimStep(PerformanceEvent.DesignerPackageLoad, "Adding Tools to ToolManager"); this.tools.Add(new SelectionTool(toolContext)); this.tools.Add(new SubselectionTool(toolContext)); this.tools.Add(new RectangleTool(toolContext)); this.tools.Add(new EllipseTool(toolContext)); this.tools.Add(new LineTool(toolContext)); this.tools.Add(new PenTool(toolContext)); this.tools.Add(new PencilTool(toolContext)); this.tools.Add(new PanTool(toolContext)); this.tools.Add(new ZoomTool(toolContext)); this.tools.Add(new EyedropperTool(toolContext)); this.tools.Add(new PaintBucketTool(toolContext)); this.tools.Add(new GradientBrushTool(toolContext)); this.tools.Add(new BrushTransformTool(toolContext)); this.tools.Add(new CameraOrbitTool(toolContext)); foreach (ITypeId textToolType in TextTool.TextToolTypes) { this.tools.Add(new TextTool(toolContext, textToolType)); } this.tools.Add(new GenericControlTool(toolContext, PlatformTypes.Grid, ToolCategory.LayoutPanels)); this.tools.Add(new GenericControlTool(toolContext, PlatformTypes.Canvas, ToolCategory.LayoutPanels)); this.tools.Add(new GenericControlTool(toolContext, PlatformTypes.StackPanel, ToolCategory.LayoutPanels)); this.tools.Add(new GenericControlTool(toolContext, ProjectNeutralTypes.WrapPanel, ToolCategory.LayoutPanels)); this.tools.Add(new GenericControlTool(toolContext, ProjectNeutralTypes.DockPanel, ToolCategory.LayoutPanels)); this.tools.Add(new GenericControlTool(toolContext, PlatformTypes.ScrollViewer, ToolCategory.LayoutPanels)); this.tools.Add(new GenericControlTool(toolContext, PlatformTypes.Border, ToolCategory.LayoutPanels)); this.tools.Add(new GenericControlTool(toolContext, PlatformTypes.UniformGrid, ToolCategory.LayoutPanels)); this.tools.Add(new GenericControlTool(toolContext, ProjectNeutralTypes.Viewbox, ToolCategory.LayoutPanels)); foreach (ITypeId knownGenericControlType in DesignerPackage.KnownGenericControlTypes) { this.tools.Add(new GenericControlTool(toolContext, knownGenericControlType, ToolCategory.CommonControls)); } foreach (Tool tool in this.tools) { this.designerContext.ToolManager.Add(tool); } this.sharedColorSpaceManager = new SharedColorSpaceManager(this.designerContext.Configuration); this.annotationService = new AnnotationService(this.designerContext); services.AddService(typeof(AnnotationService), this.annotationService); this.commandTarget = new CommandTarget(); this.commandTarget.AddCommand("Application_AddNewItem", new AddNewItemCommand(this.designerContext, null)); CommandTarget commandTarget = this.commandTarget; DesignerContext designerContext = this.designerContext; string[] strArrays = new string[] { "ResourceDictionary.xaml" }; commandTarget.AddCommand("Application_AddNewResource", new AddNewItemCommand(designerContext, strArrays)); this.commandTarget.AddCommand("Project_OpenView", new OpenViewCommand(this.designerContext)); this.commandTarget.AddCommand("Project_EnablePlatformExtensions", new EnablePlatformExtensionsCommand(services)); this.commandTarget.AddCommand("Project_EnableOutOfBrowser", new EnableApplicationOutsideBrowserCommand(services)); this.commandTarget.AddCommand("Project_EnablePreviewOutOfBrowser", new EnablePreviewOutOfBrowserCommand(services)); this.commandTarget.AddCommand("Project_EnableElevatedOutOfBrowser", new EnableElevatedOutOfBrowserCommand(services)); this.commandTarget.AddCommand("Project_AddReference", new AddReferenceCommand(services)); this.designerContext.CommandService.AddTarget(this.commandTarget); PerformanceUtility.EndPerformanceSequence(PerformanceEvent.DesignerPackageLoad); EventRouter.InitializeKeyboardHook(this.designerContext); XamlPerformanceEvents.RegisterEvents(); UIThreadDispatcherHelper.Capture(); ViewNodeManager.EnsureLayoutRequired += new EventHandler(this.ViewNodeManager_EnsureLayoutRequired); KnownProjectBase.MetadataStore = new DesignerPackage.MetadataStore(); UIThreadDispatcher.Instance.BeginInvoke(DispatcherPriority.SystemIdle, new Action(FontResolver.CleanFontCache)); }