internal Bookmark(UndoEngine undoEngine, BookmarkUndoUnit undoUnit) { this.undoEngine = undoEngine; this.containerUndoUnit = undoUnit; }
//加载流程 void loadWorkflowFromFile(string workflowFilePathName) { desienerPanel.Content = null; propertyPanel.Content = null; designer = new WorkflowDesigner(); try { designer.Load(workflowFilePathName); modelService = designer.Context.Services.GetService<ModelService>(); rootModelItem = modelService.Root; undoEngine = designer.Context.Services.GetService<UndoEngine>(); undoEngine.UndoUnitAdded += delegate(object ss, UndoUnitEventArgs ee) { designer.Flush(); //调用Flush使designer.Text得到数据 desigeerActionList.Items.Add(string.Format("{0} , {1}", DateTime.Now.ToString(), ee.UndoUnit.Description)); }; designerView = designer.Context.Services.GetService<DesignerView>(); designerView.WorkflowShellBarItemVisibility = ShellBarItemVisibility.Arguments //如果不使用Activity做根,无法出现参数选项 | ShellBarItemVisibility.Imports | ShellBarItemVisibility.MiniMap | ShellBarItemVisibility.Variables | ShellBarItemVisibility.Zoom ; desienerPanel.Content = designer.View; propertyPanel.Content = designer.PropertyInspectorView; } catch (SystemException ex) { MessageBox.Show(ex.Message); } }
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 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()); 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(); } } }; }
private void SetWorkflowDesigner(Activity activity, TreeViewItem treeViewItem) { // services //DesignerConfigurationService configService = // _workflowDesigner.Context.Services.GetRequiredService<DesignerConfigurationService>(); //configService.AnnotationEnabled = true; /* maybe, see explanation of TargetFrameworkName*/ //configService.AutoConnectEnabled = true; //configService.AutoSplitEnabled = true; //configService.AutoSurroundWithSequenceEnabled = true; //configService.BackgroundValidationEnabled = true; //configService.MultipleItemsContextMenuEnabled = true; //configService.MultipleItemsDragDropEnabled = true; //configService.NamespaceConversionEnabled = true; //configService.PanModeEnabled = true; //configService.RubberBandSelectionEnabled = true; //configService.LoadingFromUntrustedSourceEnabled = true; //configService.TargetFrameworkName = new FrameworkName(".NETFramework,Version=v4.5"); //before load activity, if it is CallTestScreen, check if it has some new steps // var ts = activity as CallTestScreenActivity; // if (ts != null) // { // var tsx = XElement.Parse(ts.Steps); // var screenId = tsx.GetAttributeValue(Constants._ID); // if (!string.IsNullOrEmpty(screenId)) // { // var screenContent = DBFactory.GetData().Read(screenId); // if (screenContent!=null) // { // var a = Utilities.GetActivityFromContentString(screenContent.ToString()) as TestScreenActivity; // if (a != null) // { // bool updated = false; // foreach (var step in XElement.Parse(a.Steps).Descendants("Step")) // { // var id = step.GetAttributeValue(Constants._ID); // if (tsx.GetSubElement(Constants._ID, id) == null) // { // tsx.Add(step); // updated = true; // } // } // if (updated) // { // ts.Steps = tsx.ToString(); ////TODO update it in db right now??? // } // } // } // } // } _workflowDesigner.Load(activity); // Flush the workflow when the model changes _workflowDesigner.ModelChanged += (s, e) => WorkflowSourceChanged(treeViewItem); WorkflowSourceChanged(treeViewItem); _undoEngineService = _workflowDesigner.Context.Services.GetService <UndoEngine>(); _undoEngineService.UndoUnitAdded += UndoEngineServiceUndoUnitAdded; var designerView = _workflowDesigner.Context.Services.GetService <DesignerView>(); //hide the shell bar of designer //designerView.WorkflowShellBarItemVisibility = ShellBarItemVisibility.None; designerView.WorkflowShellHeaderItemsVisibility = ShellHeaderItemsVisibility.All; designerView.WorkflowShellBarItemVisibility = ShellBarItemVisibility.MiniMap | ShellBarItemVisibility.Zoom | ShellBarItemVisibility.PanMode | ShellBarItemVisibility.Variables; //CompileExpressions(activity); /*** visual tracker things * IDesignerHost designer = _workflowDesigner.Context.Services.GetService<IDesignerHost>(); * * if(surface!=null) * surface.Dispose(); * surface = new WorkflowDesignSurface(new MemberCreationService()); * * var glyphService = * designerView.Context.Services.GetService(typeof(IDesignerGlyphProviderService)) as IDesignerGlyphProviderService; * var glyphProvider = new WorkflowMonitorDesignerGlyphProvider(activityStatusList); * if (glyphService != null) * glyphService.AddGlyphProvider(glyphProvider); * *****/ }
private void WorkflowEditorVM_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { switch (e.PropertyName) { case "WorkflowDesigner": { this.undoEngine = WorkflowEditorVM.WorkflowDesigner.Context.Services.GetService<UndoEngine>(); this.undoEngine.UndoRedoBufferChanged += new EventHandler(WorkflowDesignerChanged); } break; case "TaskActivityAssignException": { WorkflowEditorVM.WorkflowDesigner.Context.Services.GetService<UndoEngine>().Undo(); AddInMessageBoxService.CannotAssign(); } break; } }
private void SetWorkflowDesigner(Activity activity, TreeViewItem treeViewItem) { // services //DesignerConfigurationService configService = // _workflowDesigner.Context.Services.GetRequiredService<DesignerConfigurationService>(); //configService.AnnotationEnabled = true; /* maybe, see explanation of TargetFrameworkName*/ //configService.AutoConnectEnabled = true; //configService.AutoSplitEnabled = true; //configService.AutoSurroundWithSequenceEnabled = true; //configService.BackgroundValidationEnabled = true; //configService.MultipleItemsContextMenuEnabled = true; //configService.MultipleItemsDragDropEnabled = true; //configService.NamespaceConversionEnabled = true; //configService.PanModeEnabled = true; //configService.RubberBandSelectionEnabled = true; //configService.LoadingFromUntrustedSourceEnabled = true; //configService.TargetFrameworkName = new FrameworkName(".NETFramework,Version=v4.5"); //before load activity, if it is CallTestScreen, check if it has some new steps // var ts = activity as CallTestScreenActivity; // if (ts != null) // { // var tsx = XElement.Parse(ts.Steps); // var screenId = tsx.GetAttributeValue(Constants._ID); // if (!string.IsNullOrEmpty(screenId)) // { // var screenContent = DBFactory.GetData().Read(screenId); // if (screenContent!=null) // { // var a = Utilities.GetActivityFromContentString(screenContent.ToString()) as TestScreenActivity; // if (a != null) // { // bool updated = false; // foreach (var step in XElement.Parse(a.Steps).Descendants("Step")) // { // var id = step.GetAttributeValue(Constants._ID); // if (tsx.GetSubElement(Constants._ID, id) == null) // { // tsx.Add(step); // updated = true; // } // } // if (updated) // { // ts.Steps = tsx.ToString(); ////TODO update it in db right now??? // } // } // } // } // } _workflowDesigner.Load(activity); // Flush the workflow when the model changes _workflowDesigner.ModelChanged += (s, e) => WorkflowSourceChanged(treeViewItem); WorkflowSourceChanged(treeViewItem); _undoEngineService = _workflowDesigner.Context.Services.GetService<UndoEngine>(); _undoEngineService.UndoUnitAdded += UndoEngineServiceUndoUnitAdded; var designerView = _workflowDesigner.Context.Services.GetService<DesignerView>(); //hide the shell bar of designer //designerView.WorkflowShellBarItemVisibility = ShellBarItemVisibility.None; designerView.WorkflowShellHeaderItemsVisibility = ShellHeaderItemsVisibility.All; designerView.WorkflowShellBarItemVisibility = ShellBarItemVisibility.MiniMap | ShellBarItemVisibility.Zoom | ShellBarItemVisibility.PanMode | ShellBarItemVisibility.Variables; //CompileExpressions(activity); /*** visual tracker things IDesignerHost designer = _workflowDesigner.Context.Services.GetService<IDesignerHost>(); if(surface!=null) surface.Dispose(); surface = new WorkflowDesignSurface(new MemberCreationService()); var glyphService = designerView.Context.Services.GetService(typeof(IDesignerGlyphProviderService)) as IDesignerGlyphProviderService; var glyphProvider = new WorkflowMonitorDesignerGlyphProvider(activityStatusList); if (glyphService != null) glyphService.AddGlyphProvider(glyphProvider); * *****/ }