private void CreateAssetPopupAndButton(DesignerContext designerContext, ToolContext toolContext) { ToggleButton button = new ToggleButton(); button.Name = "AssetToolMoreButton"; button.ToolTip = (object)StringTable.AssetToolMoreButtonToolTip; button.SetResourceReference(FrameworkElement.StyleProperty, (object)"MoreButtonStyle"); this.currentToolGroupPanel.Children.Add((UIElement)button); AssetPopup assetPopup = new AssetPopup(designerContext.AssetLibrary, designerContext.Configuration); assetPopup.PlacementTarget = (UIElement)button; button.ClickMode = ClickMode.Press; button.Checked += (RoutedEventHandler)((s, e) => assetPopup.IsOpen = true); assetPopup.Closed += (EventHandler)((s, e) => button.IsChecked = new bool?(false)); assetPopup.SetBinding(Popup.PlacementProperty, (BindingBase) new Binding() { Source = (object)this.ToolsRoot, Path = new PropertyPath("Orientation", new object[0]), Converter = (IValueConverter) new InverseOrientationToPopupPlacementConverter(), Mode = BindingMode.OneWay }); ICommandService commandService = this.designerContext.CommandService; commandService.AddTarget((ICommandTarget) new ToolPane.ToolPaneCommandTarget(commandService, assetPopup)); assetPopup.AssetView.SelectedAssetChanged += (EventHandler <AssetEventArgs>)((s, e) => toolContext.AssetMruList.OnSelectAsset(e.Asset)); assetPopup.AssetView.AssetSingleClicked += (EventHandler <AssetEventArgs>)((s, e) => assetPopup.IsOpen = false); assetPopup.Closed += (EventHandler)((s, e) => { toolContext.AssetMruList.ActivateAssetTool(); if (designerContext.ActiveView == null) { return; } designerContext.ActiveView.ReturnFocus(); }); }
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); }
public void Load(IServices services) { this.services = services; ICommandService service1 = this.services.GetService <ICommandService>(); this.services.GetService <IDocumentService>(); IDocumentTypeManager service2 = this.services.GetService <IDocumentTypeManager>(); IViewService service3 = this.services.GetService <IViewService>(); IProjectManager service4 = this.services.GetService <IProjectManager>(); IAssemblyService service5 = this.services.GetService <IAssemblyService>(); IMessageDisplayService service6 = this.services.GetService <IMessageDisplayService>(); IWindowService service7 = this.services.GetService <IWindowService>(); CodeOptionsModel codeOptionsModel = new CodeOptionsModel(); this.editingService = new EditingService((IServiceProvider)this.services, codeOptionsModel); this.services.AddService(typeof(ITextEditorService), (object)this.editingService); this.services.AddService(typeof(ITextBufferService), (object)this.editingService); ICodeProjectService codeProjectService = (ICodeProjectService) new CodeProjectService(service4, service5, service6, service3, service2); this.services.AddService(typeof(ICodeModelService), (object)new CodeModelService(this.services, codeProjectService)); if (service2 != null) { this.csharpDocumentType = (IDocumentType) new CSharpDocumentType(codeProjectService, service3, codeOptionsModel, service7); service2.Register(this.csharpDocumentType); this.visualBasicDocumentType = (IDocumentType) new VisualBasicDocumentType(codeProjectService, service3, codeOptionsModel, service7); service2.Register(this.visualBasicDocumentType); this.javascriptDocumentType = (IDocumentType) new JavascriptDocumentType(codeProjectService, service3, codeOptionsModel, service7); service2.Register(this.javascriptDocumentType); this.fSharpDocumentType = (IDocumentType) new FSharpDocumentType(codeProjectService, service3, codeOptionsModel, service7); service2.Register(this.fSharpDocumentType); this.fSharpScriptDocumentType = (IDocumentType) new FSharpScriptDocumentType(codeProjectService, service3, codeOptionsModel, service7); service2.Register(this.fSharpScriptDocumentType); this.fSharpTemplateDocumentType = (IDocumentType) new FSharpTemplateDocumentType(codeProjectService, service3, codeOptionsModel, service7); service2.Register(this.fSharpTemplateDocumentType); this.cPlusPlusDocumentType = (IDocumentType) new CPlusPlusDocumentType(codeProjectService, service3, codeOptionsModel, service7); service2.Register(this.cPlusPlusDocumentType); this.headerDocumentType = (IDocumentType) new HeaderDocumentType(codeProjectService, service3, codeOptionsModel, service7); service2.Register(this.headerDocumentType); this.htmlDocumentType = (IDocumentType) new HTMLDocumentType(this.editingService); service2.Register(this.htmlDocumentType); this.xmlDocumentType = (IDocumentType) new XmlDocumentType(this.editingService); service2.Register(this.xmlDocumentType); this.limitedXamlDocumentType = (IDocumentType) new LimitedXamlDocumentType(this.editingService); service2.Register(this.limitedXamlDocumentType); this.fxgDocumentType = (IDocumentType) new FxgDocumentType(this.editingService); service2.Register(this.fxgDocumentType); } IOptionsDialogService service8 = this.services.GetService <IOptionsDialogService>(); if (service8 != null) { this.codeOptionsPage = (IOptionsPage) new CodeOptionsPage(this.editingService); service8.OptionsPages.Add(this.codeOptionsPage); } if (service1 == null) { return; } this.commandTarget = new CommandTarget(); this.commandTarget.AddCommand("Project_EditVisualStudio", (ICommand) new EditVisualStudioCommand(service4, service1, service6)); service1.AddTarget((ICommandTarget)this.commandTarget); }
public void Load(IServices services) { this.services = services; ICommandService service = (ICommandService)this.services.GetService(typeof(ICommandService)); IExpressionMefHostingService expressionMefHostingService = this.services.GetService <IExpressionMefHostingService>(); IDocumentTypeManager documentTypeManager = new DocumentTypeManager(new UnknownDocumentType()); this.services.AddService(typeof(IDocumentTypeManager), documentTypeManager); IProjectTypeManager projectTypeManager = new ProjectTypeManager(); this.services.AddService(typeof(IProjectTypeManager), projectTypeManager); IConfigurationService configurationService = this.services.GetService <IConfigurationService>(); ProjectManager projectManager = new ProjectManager(this.services, configurationService["ProjectManager"]); this.services.AddService(typeof(IProjectManager), projectManager); service.AddTarget(projectManager); this.services.AddService(typeof(IExternalChanges), projectManager); this.solutionService = new SolutionService(projectManager); this.services.AddService(typeof(ISolutionService), this.solutionService); this.assemblyLoggingService = new AssemblyLoggingService(configurationService.ConfigurationDirectoryPath); this.services.AddService(typeof(IAssemblyLoggingService), this.assemblyLoggingService); IProjectAdapterService projectAdapterService = new ProjectAdapterService(this.services); this.services.AddService(typeof(IProjectAdapterService), projectAdapterService); if (expressionMefHostingService != null) { expressionMefHostingService.AddInternalPart(projectAdapterService); expressionMefHostingService.AddInternalPart(this.solutionService); } IOptionsDialogService optionsDialogService = this.services.GetService <IOptionsDialogService>(); this.projectSystemOptionsPage = new ProjectSystemOptionsPage(projectManager, this.assemblyLoggingService); optionsDialogService.OptionsPages.Add(this.projectSystemOptionsPage); this.assemblyDocumentType = new AssemblyDocumentType(); documentTypeManager.Register(this.assemblyDocumentType); this.projectReferenceDocumentType = new ProjectReferenceDocumentType(); documentTypeManager.Register(this.projectReferenceDocumentType); this.folderDocumentType = new FolderDocumentType(); documentTypeManager.Register(this.folderDocumentType); this.comReferenceDocumentType = new ComReferenceDocumentType(); documentTypeManager.Register(this.comReferenceDocumentType); this.cursorDocumentType = new CursorDocumentType(); documentTypeManager.Register(this.cursorDocumentType); this.deepZoomDocumentType = new DeepZoomDocumentType(); documentTypeManager.Register(this.deepZoomDocumentType); this.websiteProjectType = new WebsiteProjectType(); projectTypeManager.Register(this.websiteProjectType); this.webApplicationProjectType = new WebApplicationProjectType(); projectTypeManager.Register(this.webApplicationProjectType); this.assemblyService = new AssemblyService(this.services); this.services.AddService(typeof(IAssemblyService), this.assemblyService); this.services.AddService(typeof(ISatelliteAssemblyResolver), this.assemblyService); this.blendSdkAssemblyResolver = new BlendSdkAssemblyResolver(); this.assemblyService.RegisterLibraryResolver(this.blendSdkAssemblyResolver); this.blendAssemblyResolver = new BlendAssemblyResolver(); this.assemblyService.RegisterLibraryResolver(this.blendAssemblyResolver); Microsoft.Expression.Framework.UserInterface.IWindowService windowService = this.services.GetService <Microsoft.Expression.Framework.UserInterface.IWindowService>(); windowService.Closing += new CancelEventHandler(this.WindowManager_Closing); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new DispatcherOperationCallback((object o) => { Application.Current.SessionEnding += new SessionEndingCancelEventHandler(this.Current_SessionEnding); return(null); }), null); UIThreadDispatcher.Instance.BeginInvoke(DispatcherPriority.SystemIdle, new Action(this.assemblyService.AssemblyCache.Clean)); }
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); }