static Type ResolveGenericParameters(DependencyObject dropTarget, EditingContext context, Type type) { // look to see if there is a DefaultTypeArgumentAttribute on it DefaultTypeArgumentAttribute typeArgumentAttribute = ExtensibilityAccessor.GetAttribute <DefaultTypeArgumentAttribute>(type); if (typeArgumentAttribute != null && typeArgumentAttribute.Type != null) { type = type.MakeGenericType(typeArgumentAttribute.Type); } else //require user to resolve generic arguments { ActivityTypeResolver wnd = new ActivityTypeResolver(); if (null != context) { WindowHelperService service = context.Services.GetService <WindowHelperService>(); if (null != service) { service.TrySetWindowOwner(dropTarget, wnd); } } TypeResolvingOptions dropTargetOptions = null; TypeResolvingOptions activityTypeOptions = null; //try to see if the container has any customization for type resolver ICompositeView container = dropTarget as ICompositeView; if (container != null) { dropTargetOptions = container.DroppingTypeResolvingOptions; } //try to see if the activity type in discourse has any customization for type resolver TypeResolvingOptionsAttribute attr = WorkflowViewService.GetAttribute <TypeResolvingOptionsAttribute>(type); if (attr != null) { activityTypeOptions = attr.TypeResolvingOptions; } //if both have type resolver, try to merge them TypeResolvingOptions options = TypeResolvingOptions.Merge(dropTargetOptions, activityTypeOptions); if (options != null) { wnd.Options = options; } wnd.Context = context; wnd.EditedType = type; wnd.Width = 340; wnd.Height = 200; type = (true == wnd.ShowDialog() ? wnd.ConcreteType : null); } return(type); }
bool?Show(bool okCancel) { WorkflowElementDialogWindow wnd = new WorkflowElementDialogWindow(this, okCancel, this.EnableMinimizeButton, this.EnableMaximizeButton, this.OnOk) { Title = this.Title }; if (null != this.Context) { WindowHelperService srv = this.Context.Services.GetService <WindowHelperService>(); if (null != srv) { srv.TrySetWindowOwner(this.Owner, wnd); } } wnd.Closed += (s, e) => { this.OnWorkflowElementDialogClosed(((Window)s).DialogResult); }; return(wnd.ShowDialog()); }
public WorkflowDesigner() { // create our perf trace provider first this.perfEventProvider = new DesignerPerfEventProvider(); this.idManager = new ViewStateIdManager(); this.context = new EditingContext(); this.ModelSearchService = new ModelSearchServiceImpl(this); this.context.Items.SetValue(new ReadOnlyState { IsReadOnly = false }); this.view = new Grid(); this.view.Focusable = false; //add the resource dictionary to application resource so every component could reference it if (Application.Current == null) { //create an application if it doesn't exist, make sure it will not shutdown after windows being shut down Application app = new Application(); app.ShutdownMode = ShutdownMode.OnExplicitShutdown; } Fx.Assert(Application.Current != null, "Application and resources must be there"); Application.Current.Resources.MergedDictionaries.Add(WorkflowDesignerColors.FontAndColorResources); Application.Current.Resources.MergedDictionaries.Add(WorkflowDesignerIcons.IconResourceDictionary); AttachedPropertiesService propertiesService = new AttachedPropertiesService(); this.context.Services.Publish(typeof(AttachedPropertiesService), propertiesService); undoEngine = new UndoEngine(context); this.context.Services.Publish(typeof(UndoEngine), undoEngine); undoEngine.UndoCompleted += new EventHandler <UndoUnitEventArgs>(OnUndoCompleted); this.context.Services.Publish <ValidationService>(this.ValidationService); this.context.Services.Publish <ObjectReferenceService>(this.ObjectReferenceService); this.context.Services.Publish <DesignerPerfEventProvider>(this.perfEventProvider); this.context.Services.Publish <FeatureManager>(new FeatureManager(this.context)); this.context.Services.Publish <DesignerConfigurationService>(new DesignerConfigurationService()); if (!LocalAppContextSwitches.UseLegacyAccessibilityFeatures) { // Keeps track of a dictionary of session objects on current Workflow Designer. // The initial purpose is to pass the focused VisualBasicEditor from NetFx to VS. this.context.Services.Publish <Dictionary <string, object> >(new Dictionary <string, object>()); } this.context.Services.Subscribe <ICommandService>((s) => { const string addinTypeName = "Microsoft.VisualStudio.Activities.AddIn.WorkflowDesignerAddIn"; if (s != null && s.GetType().FullName.Equals(addinTypeName)) { DesignerConfigurationService service = this.context.Services.GetService <DesignerConfigurationService>(); if (service != null) { service.WorkflowDesignerHostId = WorkflowDesignerHostId.Dev10; } } }); this.context.Services.Subscribe <IVSSqmService>((service) => { const string serviceTypeName = "Microsoft.VisualStudio.Activities.AddIn.VSSqmService"; if (service != null && service.GetType().FullName.Equals(serviceTypeName)) { DesignerConfigurationService configurationService = this.context.Services.GetService <DesignerConfigurationService>(); if (configurationService != null) { configurationService.WorkflowDesignerHostId = WorkflowDesignerHostId.Dev11; } } }); this.Context.Items.Subscribe <ErrorItem>(delegate(ErrorItem errorItem) { ErrorView errorView = new ErrorView(); errorView.Message = errorItem.Message; errorView.Details = errorItem.Details; errorView.Context = this.Context; // Clear views this.view.Children.Clear(); this.view.Children.Add(errorView); if (this.outlineView != null) { this.outlineView.Children.Clear(); } } ); this.context.Items.Subscribe <ReadOnlyState>(new SubscribeContextCallback <ReadOnlyState>(OnReadonlyStateChanged)); this.context.Services.Subscribe <IXamlLoadErrorService>(s => this.xamlLoadErrorService = s); this.PreviewLoad += NamespaceSettingsHandler.PreviewLoadRoot; this.view.Loaded += (s, e) => { //when view is loaded, check if user did provide his own WindowHelperService - if not, provide a default one if (!this.context.Services.Contains <WindowHelperService>()) { IntPtr hWND = IntPtr.Zero; Window ownerWindow = Window.GetWindow(this.view); if (null != ownerWindow) { WindowInteropHelper helper = new WindowInteropHelper(ownerWindow); hWND = helper.Handle; } this.Context.Services.Publish <WindowHelperService>(new WindowHelperService(hWND)); } WindowHelperService whs = this.context.Services.GetService <WindowHelperService>(); whs.View = this.view; //check if workflow command extension item is available - if not, provide default one if (!this.context.Items.Contains <WorkflowCommandExtensionItem>()) { WorkflowCommandExtensionItem item = new WorkflowCommandExtensionItem(new DefaultCommandExtensionCallback()); this.context.Items.SetValue(item); } ComponentDispatcher.EnterThreadModal += new EventHandler(ComponentDispatcher_EnterThreadModal); ComponentDispatcher.LeaveThreadModal += new EventHandler(ComponentDispatcher_LeaveThreadModal); }; this.view.Unloaded += (s, e) => { ComponentDispatcher.EnterThreadModal -= new EventHandler(ComponentDispatcher_EnterThreadModal); ComponentDispatcher.LeaveThreadModal -= new EventHandler(ComponentDispatcher_LeaveThreadModal); }; this.view.IsKeyboardFocusWithinChanged += (s, e) => { // The ModelTreeManager is null when there is an active ErrorItem. // We have nothing to write to text in this case. if (this.modelTreeManager != null && (bool)e.NewValue == false) { if ((FocusManager.GetFocusedElement(this.view) as TextBox) != null) { FocusManager.SetFocusedElement(this.view, null); this.NotifyModelChanged(); } } }; }
public bool?ShowDialog(DependencyObject owner) { WindowHelperService.TrySetWindowOwner(owner, this.Context, this); this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() => { this.perfEventProvider.TypeBrowserApplicationIdleAfterShowDialog(); })); return(base.ShowDialog()); }
void SetWindowOwner(Window wnd) { WindowHelperService.TrySetWindowOwner(this, this.Context, wnd); }