public bool Resolve(IDocumentContext documentContext, EditDesignTimeResourceModelMode mode, string missingResourceName) { if (documentContext == null) { throw new ArgumentNullException("documentContext"); } bool success = false; UIThreadDispatcherHelper.Invoke(DispatcherPriority.ApplicationIdle, (Action)(() => { EditDesignTimeResourceModel model = this.CreateModel(documentContext, mode, missingResourceName); if (model == null || !model.CanResolveDesignTimeResources) { return; } if (mode != EditDesignTimeResourceModelMode.Manual) { bool?doNotAskAgain = model.DoNotAskAgain; if ((doNotAskAgain.GetValueOrDefault() ? 0 : (doNotAskAgain.HasValue ? true : false)) == 0) { return; } } bool?nullable = new EditDesignTimeResourcesDialog(model).ShowDialog(); success = nullable.GetValueOrDefault() && nullable.HasValue; })); return(success); }
public void OnInitialized(IInstanceBuilderContext context, ViewNode target, object instance) { if (instance != null && this.targetType.IsAssignableFrom(instance.GetType())) { ITypeResolver typeResolver = target.DocumentNode.TypeResolver; IPlatform platform = context.Platform; platform.ViewObjectFactory.Instantiate(instance).SetValue(typeResolver, typeResolver.ResolveProperty(DesignTimeProperties.InstanceBuilderContextProperty), (object)new WeakReference((object)context)); IDesignModeValueProviderContext valueProviderContext = context as IDesignModeValueProviderContext; if (valueProviderContext != null) { ValueTranslationService valueTranslationService = valueProviderContext.ValueTranslationService; foreach (PropertyIdentifier identifier in valueTranslationService.GetProperties(this.targetType)) { if (valueTranslationService.HasValueTranslation(this.targetType, identifier)) { ReferenceStep referenceStep = target.Type.GetMember(MemberType.Property, identifier.Name, MemberAccessTypes.All) as ReferenceStep; if (referenceStep != null) { if (!target.Properties.ContainsKey((IProperty)referenceStep)) { ReferenceStep referenceStep1 = (ReferenceStep)DesignTimeProperties.GetShadowProperty((IProperty)referenceStep, (ITypeId)target.Type); object valueToSet = referenceStep.GetValue(instance); if (typeResolver.IsCapabilitySet(PlatformCapability.IsWpf) || valueToSet != null) { referenceStep1.SetValue(instance, valueToSet); } } PropertyIdentifier localProperty = identifier; UIThreadDispatcherHelper.BeginInvoke(DispatcherPriority.Send, (Delegate)(o => { if (target.Parent != null) { DesignModeValueProviderService.RunDesignModeValueProvider(instance, platform, valueTranslationService, target.Type, this.targetType, localProperty, referenceStep, true); } return((object)null); }), (object)null); } } } } } if (!context.IsSerializationScope) { return; } this.builder.OnInitialized(context, target, instance); }
public XamlNameResolverImpl(object target, IMetadataResolver metadataResolver) { if (InstanceBuilderOperations.InstanceBuilderServiceProvider.XamlNameResolverImpl.DesignTimeNameScopeProperty == null) { DependencyPropertyReferenceStep dependencyPropertyReferenceStep = metadataResolver.ResolveProperty(DesignTimeProperties.DesignTimeNameScopeProperty) as DependencyPropertyReferenceStep; if (dependencyPropertyReferenceStep != null) { InstanceBuilderOperations.InstanceBuilderServiceProvider.XamlNameResolverImpl.DesignTimeNameScopeProperty = (DependencyProperty)dependencyPropertyReferenceStep.DependencyProperty; } } this.target = target; this.FindNameScope(); UIThreadDispatcherHelper.BeginInvoke(DispatcherPriority.Send, new DispatcherOperationCallback((object o) => { this.isInitialized = true; this.FindNameScope(); if (this.OnNameScopeInitializationComplete != null) { this.OnNameScopeInitializationComplete(this, EventArgs.Empty); } return(null); }), null); }
protected override bool ShouldFilterViewException(Exception exception) { ObjectDisposedException objectDisposedException = exception as ObjectDisposedException; if (objectDisposedException != null && string.Equals(objectDisposedException.ObjectName, "NativeObject", StringComparison.Ordinal)) { if (!this.disposedExceptionCaught) { base.DesignerContext.PlatformContextChanger.UpdateForPlatformChange(this, null, true, true); } this.disposedExceptionCaught = true; } if (!this.IsExceptionCatastrophicFailure(exception.Message) && (exception.InnerException == null || !this.IsExceptionCatastrophicFailure(exception.InnerException.Message)) || this.catastrohpicFailureCaught) { return(base.ShouldFilterViewException(exception)); } UIThreadDispatcherHelper.BeginInvoke(DispatcherPriority.ContextIdle, new DispatcherOperationCallback((object o) => { base.UpdateLayout(); return(null); }), null); this.catastrohpicFailureCaught = true; return(true); }
public override void Execute() { BaseFrameworkElement selectedElement = this.SelectedElement; if (selectedElement == null) { return; } IType type1 = this.SceneViewModel.ProjectContext.ResolveType(PlatformTypes.Style); CreateResourceModel.ContextFlags contextFlags = this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsImplicitStyles) ? CreateResourceModel.ContextFlags.CanApplyAutomatically : CreateResourceModel.ContextFlags.None; if (this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.SupportsImplicitStyles)) { contextFlags = CreateResourceModel.ContextFlags.CanApplyAutomatically; } CreateResourceModel createResourceModel = new CreateResourceModel(this.SceneViewModel, this.DesignerContext.ResourceManager, type1.RuntimeType, this.DefaultContainerType.RuntimeType, PlatformTypes.Style.Name, (SceneElement)null, (SceneNode)selectedElement, contextFlags); if (this.ShowUI) { bool?nullable = this.CreateDialog(createResourceModel).ShowDialog(); if ((!nullable.GetValueOrDefault() ? 1 : (!nullable.HasValue ? true : false)) != 0) { return; } } using (this.SceneViewModel.DisableUpdateChildrenOnAddAndRemove()) { using (SceneEditTransaction editTransaction1 = this.SceneViewModel.CreateEditTransaction(this.UndoString, false)) { using (this.SceneViewModel.ForceBaseValue()) { using (this.SceneViewModel.DisableDrawIntoState()) { this.SceneViewModel.AnimationEditor.DeleteAllAnimationsInSubtree((SceneElement)selectedElement); this.SceneViewModel.ElementSelectionSet.Clear(); IDocumentContext documentContext = this.SceneViewModel.Document.DocumentContext; IProjectContext projectContext = this.SceneViewModel.Document.ProjectContext; Type type2 = (Type)null; if (createResourceModel.TargetTypeAsset != null && createResourceModel.TargetTypeAsset.EnsureTypeReferenced(this.SceneViewModel.ProjectContext as ProjectContext)) { type2 = createResourceModel.TargetTypeAsset.Type.RuntimeType; } if (type2 == (Type)null) { type2 = createResourceModel.TargetType; } IType type3 = projectContext.GetType(type2); DocumentCompositeNode documentCompositeNode1 = (DocumentCompositeNode)selectedElement.DocumentNode; this.SceneViewModel.GetLayoutDesignerForChild((SceneElement)selectedElement, true).ClearUnusedLayoutProperties(selectedElement); DocumentCompositeNode visualTreeNode = documentContext.CreateNode((ITypeId)documentCompositeNode1.Type); Dictionary <IProperty, DocumentNode> dictionary = new Dictionary <IProperty, DocumentNode>(); bool addRenderTransforms = false; foreach (IPropertyId propertyId in this.GetLayoutProperties((SceneElement)selectedElement, addRenderTransforms)) { IProperty property = this.DesignerContext.ActiveSceneViewModel.ProjectContext.ResolveProperty(propertyId); if (property != null && documentCompositeNode1.Properties.Contains(property)) { dictionary.Add(property, documentCompositeNode1.Properties[(IPropertyId)property].Clone(documentContext)); documentCompositeNode1.ClearValue((IPropertyId)property); } } foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentCompositeNode1.Properties) { IPropertyId index = (IPropertyId)keyValuePair.Key; DependencyPropertyReferenceStep propertyReferenceStep = index as DependencyPropertyReferenceStep; if ((propertyReferenceStep == null || !propertyReferenceStep.IsAttachable || propertyReferenceStep.MemberType == MemberType.DesignTimeProperty) && (!index.Equals((object)BaseFrameworkElement.WidthProperty) && !index.Equals((object)BaseFrameworkElement.HeightProperty))) { visualTreeNode.Properties[index] = keyValuePair.Value.Clone(documentContext); } } if (documentCompositeNode1.SupportsChildren) { foreach (DocumentNode documentNode in (IEnumerable <DocumentNode>)documentCompositeNode1.Children) { visualTreeNode.Children.Add(documentNode.Clone(documentContext)); } } if (!PlatformTypes.Panel.IsAssignableFrom((ITypeId)documentCompositeNode1.Type)) { GridElement gridElement = (GridElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Grid); SceneNode sceneNode = this.SceneViewModel.GetSceneNode((DocumentNode)visualTreeNode); gridElement.Children.Add(sceneNode); visualTreeNode = (DocumentCompositeNode)gridElement.DocumentNode; } StyleNode styleNode = (StyleNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.Style); styleNode.StyleTargetTypeId = type3; SetterSceneNode setterSceneNode = (SetterSceneNode)this.SceneViewModel.CreateSceneNode(PlatformTypes.Setter); DependencyPropertyReferenceStep propertyReferenceStep1 = (DependencyPropertyReferenceStep)this.SceneViewModel.ProjectContext.ResolveProperty(ControlElement.TemplateProperty); setterSceneNode.Property = propertyReferenceStep1; BaseFrameworkElement frameworkElement = (BaseFrameworkElement)this.SceneViewModel.CreateSceneNode(type2); DocumentCompositeNode documentCompositeNode2 = (DocumentCompositeNode)frameworkElement.DocumentNode; this.AddPresenterIfNecessary(visualTreeNode, (SceneElement)frameworkElement); ControlTemplateElement controlTemplateElement = (ControlTemplateElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.ControlTemplate); controlTemplateElement.ControlTemplateTargetTypeId = (ITypeId)type3; controlTemplateElement.DefaultInsertionPoint.Insert(this.SceneViewModel.GetSceneNode((DocumentNode)visualTreeNode)); if (PlatformTypes.Button.Equals((object)type3) && controlTemplateElement.CanEditTriggers && this.SceneViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf)) { DocumentCompositeNode node = documentContext.CreateNode(typeof(TriggerCollection)); node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsFocusedProperty, (object)true)); node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsDefaultedProperty, (object)true)); node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, BaseFrameworkElement.IsMouseOverProperty, (object)true)); node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, ButtonProperties.IsPressedProperty, (object)true)); node.Children.Add((DocumentNode)this.CreatePropertyTrigger(documentContext, BaseFrameworkElement.IsEnabledProperty, (object)false)); controlTemplateElement.SetLocalValue(ControlTemplateElement.ControlTemplateTriggersProperty, (DocumentNode)node); } setterSceneNode.SetValueAsSceneNode(SetterSceneNode.ValueProperty, (SceneNode)controlTemplateElement); styleNode.Setters.Add((SceneNode)setterSceneNode); bool useStaticResource = !JoltHelper.TypeSupported((ITypeResolver)this.SceneViewModel.ProjectContext, PlatformTypes.DynamicResource); int index1 = -1; if (useStaticResource && selectedElement.DocumentContext == createResourceModel.CurrentResourceSite.DocumentContext) { index1 = createResourceModel.IndexInResourceSite(selectedElement.DocumentNode); } IList <DocumentCompositeNode> referencedResources = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.FindReferencedResources((DocumentNode)documentCompositeNode1); foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in dictionary) { documentCompositeNode2.Properties[(IPropertyId)keyValuePair.Key] = keyValuePair.Value; } IList <SceneNode> nodes = (IList <SceneNode>) new List <SceneNode>(); nodes.Add((SceneNode)frameworkElement); SceneNode parent = selectedElement.Parent; IProperty propertyForChild = parent.GetPropertyForChild((SceneNode)selectedElement); ISceneNodeCollection <SceneNode> collectionForProperty = parent.GetCollectionForProperty((IPropertyId)propertyForChild); int index2 = collectionForProperty.IndexOf((SceneNode)selectedElement); collectionForProperty[index2] = (SceneNode)frameworkElement; if (createResourceModel.SelectedResourceDictionary != null) { ResourceContainer instance = createResourceModel.SelectedResourceDictionary.Instance; if (instance != null && instance.DocumentNode == documentCompositeNode1) { createResourceModel = new CreateResourceModel(this.SceneViewModel, this.DesignerContext.ResourceManager, type1.RuntimeType, type2, PlatformTypes.Style.Name, (SceneElement)frameworkElement, (SceneNode)null, contextFlags); } } if (createResourceModel.CurrentResourceSite != null && !PlatformTypes.PlatformsCompatible(createResourceModel.CurrentResourceSite.DocumentContext.TypeResolver.PlatformMetadata, styleNode.DocumentNode.PlatformMetadata)) { editTransaction1.Cancel(); return; } DocumentCompositeNode resource = createResourceModel.CreateResource(styleNode.DocumentNode, StyleNode.TargetTypeProperty, index1); if (resource == null) { editTransaction1.Cancel(); return; } DocumentNode resourceReference = createResourceModel.CreateResourceReference(this.SceneViewModel.Document.DocumentContext, resource, useStaticResource); DefaultTypeInstantiator typeInstantiator = new DefaultTypeInstantiator(this.SceneView); if (resourceReference != null) { documentCompositeNode2.Properties[BaseFrameworkElement.StyleProperty] = resourceReference; } foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentCompositeNode1.Properties) { IPropertyId index3 = (IPropertyId)keyValuePair.Key; DependencyPropertyReferenceStep propertyReferenceStep2 = index3 as DependencyPropertyReferenceStep; if (propertyReferenceStep2 != null && propertyReferenceStep2.IsAttachable && propertyReferenceStep2.MemberType != MemberType.DesignTimeProperty) { documentCompositeNode2.Properties[index3] = keyValuePair.Value.Clone(documentContext); } } DocumentCompositeNode hostNode = createResourceModel.CurrentResourceSite.HostNode; SceneViewModel viewModel = this.SceneViewModel.GetViewModel(hostNode.DocumentRoot, false); using (SceneEditTransaction editTransaction2 = viewModel.CreateEditTransaction(this.UndoString)) { Microsoft.Expression.DesignSurface.Utility.ResourceHelper.CopyResourcesToNewResourceSite(referencedResources, viewModel, hostNode, resource, createResourceModel.IndexInResourceSite((DocumentNode)resource)); editTransaction2.Commit(); } editTransaction1.Update(); if (this.SceneView.IsValid) { typeInstantiator.ApplyAfterInsertionDefaultsToElements(nodes, (SceneNode)null); } this.SceneView.CandidateEditingContainer = frameworkElement.DocumentNodePath; editTransaction1.Update(); this.SceneViewModel.ElementSelectionSet.ExtendSelection((SceneElement)frameworkElement); this.PostProcessing((SceneNode)selectedElement, (SceneNode)frameworkElement, resource); if (frameworkElement.GetComputedValue(ControlElement.TemplateProperty) != null) { this.ActivateTemplateEditingMode((SceneElement)frameworkElement); } else { UIThreadDispatcherHelper.BeginInvoke(DispatcherPriority.ApplicationIdle, (Delegate) new Action <SceneElement>(this.ActivateTemplateEditingMode), (object)frameworkElement); } this.SceneView.CandidateEditingContainer = (DocumentNodePath)null; } editTransaction1.Commit(); } } } }
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)); }