/// <summary>
        /// Callback method that updates the state of the Undo related UI elements
        /// </summary>
        private void UpdateUndoState()
        {
            UndoEngine engine = graphControl.Graph.GetUndoEngine();

            undoButton.ToolTipText = engine != null ? engine.UndoName : string.Empty;
            redoButton.ToolTipText = engine != null ? engine.RedoName : string.Empty;
        }
Beispiel #2
0
        public void PushPopSingle()
        {
            var val = 1;
            var ue  = new UndoEngine();

            Assert.False(ue.CanUndo);
            ue.PushAndDoAction(() => val = 2, () => val = 1);
            Assert.True(ue.CanUndo);
            Assert.Equal(2, val);
            ue.Redo(); // should do nothing but not crash
            Assert.True(ue.CanUndo);
            Assert.Equal(2, val);
            ue.Undo();
            Assert.False(ue.CanUndo);
            Assert.True(ue.CanRedo);
            Assert.Equal(1, val);
            ue.Undo(); // should do nothing but should not crash.
            Assert.False(ue.CanUndo);
            Assert.True(ue.CanRedo);
            Assert.Equal(1, val);
            ue.Redo();
            Assert.True(ue.CanUndo);
            Assert.False(ue.CanRedo);
            Assert.Equal(2, val);
        }
Beispiel #3
0
        internal void Initialize()
        {
            IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host == null)
            {
                return;
            }
            //
            try
            {
                // Set SelectionService - SelectionChanged event handler
                _selectionService = (ISelectionService)(this.ServiceContainer.GetService(typeof(ISelectionService)));
                _selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);
                //
                UndoEngine undoEngine = (UndoEngine)host.GetService(typeof(UndoEngine));
                if (undoEngine != null)
                {
                    undoEngine.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #4
0
        public WorkflowDesignerViewModel()
        {
            (new DesignerMetadata()).Register();
            _workflowToolboxControl = new ToolboxControl()
            {
                Categories = WorkflowToolbox.LoadToolbox()
            };

            _designer   = new WorkflowDesigner();
            _undoEngine = _designer.Context.Services.GetService <UndoEngine>();
            _undoEngine.UndoUnitAdded += delegate(object ss, UndoUnitEventArgs ee)
            {
                _designer.Flush();
                CanUndo = true;
            };
            DesignerView    = _designer.View;
            PropertyContent = _designer.PropertyInspectorView;
            _designer.Text  = "<Activity mc:Ignorable=\"sap\" x:Class=\"WorkflowInvokerSample.流程图\" xmlns=\"http://schemas.microsoft.com/netfx/2009/xaml/activities\" xmlns:av=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:mv=\"clr-namespace:Microsoft.VisualBasic;assembly=System\" xmlns:mva=\"clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities\" xmlns:s=\"clr-namespace:System;assembly=mscorlib\" xmlns:s1=\"clr-namespace:System;assembly=System\" xmlns:s2=\"clr-namespace:System;assembly=System.Xml\" xmlns:s3=\"clr-namespace:System;assembly=System.Core\" xmlns:s4=\"clr-namespace:System;assembly=System.ServiceModel\" xmlns:sad=\"clr-namespace:System.Activities.Debugger;assembly=System.Activities\" xmlns:sap=\"http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation\" xmlns:scg=\"clr-namespace:System.Collections.Generic;assembly=mscorlib\" xmlns:scg1=\"clr-namespace:System.Collections.Generic;assembly=System\" xmlns:scg2=\"clr-namespace:System.Collections.Generic;assembly=System.ServiceModel\" xmlns:scg3=\"clr-namespace:System.Collections.Generic;assembly=System.Core\" xmlns:sd=\"clr-namespace:System.Data;assembly=System.Data\" xmlns:sl=\"clr-namespace:System.Linq;assembly=System.Core\" xmlns:st=\"clr-namespace:System.Text;assembly=mscorlib\" xmlns:w=\"clr-namespace:WorkflowInvokerSample\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">\r\n  <x:Members>\r\n    <x:Property Name=\"WorkflowInstanceID\" Type=\"InArgument(x:Int32)\" />\r\n    <x:Property Name=\"ExchangeParams\" Type=\"InOutArgument(scg:Dictionary(x:String, x:Object))\" />\r\n    <x:Property Name=\"FirstActor\" Type=\"InArgument(x:String)\" />\r\n    <x:Property Name=\"LastActor\" Type=\"InOutArgument(x:String)\" />\r\n  </x:Members>\r\n  <sap:VirtualizedContainerService.HintSize>654,676</sap:VirtualizedContainerService.HintSize>\r\n  <mva:VisualBasic.Settings>Assembly references and imported namespaces for internal implementation</mva:VisualBasic.Settings>\r\n  <Flowchart DisplayName=\"流程图\" sad:XamlDebuggerXmlReader.FileName=\"C:\\Users\\Administrator\\Downloads\\WorkflowInvokerSample\\WorkflowInvokerSample\\流程图.xaml\" sap:VirtualizedContainerService.HintSize=\"614,636\">\r\n    <sap:WorkflowViewStateService.ViewState>\r\n      <scg:Dictionary x:TypeArguments=\"x:String, x:Object\">\r\n        <x:Boolean x:Key=\"IsExpanded\">False</x:Boolean>\r\n        <av:Point x:Key=\"ShapeLocation\">270,2.5</av:Point>\r\n        <av:Size x:Key=\"ShapeSize\">60,75</av:Size>\r\n        <av:PointCollection x:Key=\"ConnectorLocation\">300,77.5 300,107.5 300,189</av:PointCollection>\r\n      </scg:Dictionary>\r\n    </sap:WorkflowViewStateService.ViewState>\r\n    <Flowchart.StartNode>\r\n      <x:Null />\r\n    </Flowchart.StartNode>\r\n  </Flowchart>\r\n</Activity>";
            _designer.Load();
            WorkflowName = "新建工作流";
            CanUndo      = false;
            CanRedo      = false;
            EditState    = "add";

            OpenCommand   = new DelegateCommand <object>(OpenWorkflowListWindow);
            AddCommand    = new DelegateCommand <object>(Add);
            DeleteCommand = new DelegateCommand <object>(Delete, CanDeleteWorkflowExecute);
            SaveCommand   = new DelegateCommand <object>(Save);
            UndoCommand   = new DelegateCommand <object>(Undo);
            RedoCommand   = new DelegateCommand <object>(Redo);
            DebugCommand  = new DelegateCommand <object>(Debug);
        }
Beispiel #5
0
        public void OpenWorkflow(int workflowID)
        {
            Workflow = SystemService.GetDynObjectByID("Workflow", workflowID);
            if (Workflow != null)
            {
                _designer   = new WorkflowDesigner();
                _undoEngine = _designer.Context.Services.GetService <UndoEngine>();
                _undoEngine.UndoUnitAdded += delegate(object ss, UndoUnitEventArgs ee)
                {
                    _designer.Flush();
                    CanUndo = true;
                };

                DesignerView    = _designer.View;
                PropertyContent = _designer.PropertyInspectorView;
                _designer.Text  = Workflow["Definition"].ToString();
                _designer.Load();
                WorkflowName = Workflow["WorkflowName"].ToString();
                EditState    = "modify";
                CanUndo      = false;
                CanRedo      = false;
                DeleteCommand.RaiseCanExecuteChanged();
            }
            else
            {
                MessageBox.Show("所选的工作流在数据库中不存在,请检查!");
            }
        }
 public ImmediateEditingScope(ModelTreeManager modelTreeManager, UndoEngine.Bookmark undoEngineBookmark)
     : base(modelTreeManager, null)
 {
     Fx.Assert(modelTreeManager != null, "modelTreeManager should never be null!");
     Fx.Assert(undoEngineBookmark != null, "undoEngineBookmark should never be null!");
     this.modelTreeManager = modelTreeManager;
     this.undoEngineBookmark = undoEngineBookmark;
 }
Beispiel #7
0
        /// <summary>
        /// Clears the undo queue.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ClearUndoClicked(object sender, EventArgs e)
        {
            UndoEngine engine = graphControl.Graph.GetUndoEngine();

            if (engine != null)
            {
                engine.Clear();
            }
        }
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);
            this.host = (IDesignerHost)this.GetService(typeof(IDesignerHost));
            if (((ToolStripKeyboardHandlingService)this.GetService(typeof(ToolStripKeyboardHandlingService))) == null)
            {
                ToolStripKeyboardHandlingService service = new ToolStripKeyboardHandlingService(component.Site);
            }
            if (((ISupportInSituService)this.GetService(typeof(ISupportInSituService))) == null)
            {
                ISupportInSituService service2 = new ToolStripInSituService(base.Component.Site);
            }
            this.dropDown         = (ToolStripDropDown)base.Component;
            this.dropDown.Visible = false;
            this.AutoClose        = this.dropDown.AutoClose;
            this.AllowDrop        = this.dropDown.AllowDrop;
            this.selSvc           = (ISelectionService)this.GetService(typeof(ISelectionService));
            if (this.selSvc != null)
            {
                if ((this.host != null) && !this.host.Loading)
                {
                    this.selSvc.SetSelectedComponents(new IComponent[] { this.host.RootComponent }, SelectionTypes.Replace);
                }
                this.selSvc.SelectionChanging += new EventHandler(this.OnSelectionChanging);
                this.selSvc.SelectionChanged  += new EventHandler(this.OnSelectionChanged);
            }
            this.designMenu          = new MenuStrip();
            this.designMenu.Visible  = false;
            this.designMenu.AutoSize = false;
            this.designMenu.Dock     = DockStyle.Top;
            Control rootComponent = this.host.RootComponent as Control;

            if (rootComponent != null)
            {
                this.menuItem           = new ToolStripMenuItem();
                this.menuItem.BackColor = SystemColors.Window;
                this.menuItem.Name      = base.Component.Site.Name;
                this.menuItem.Text      = (this.dropDown != null) ? this.dropDown.GetType().Name : this.menuItem.Name;
                this.designMenu.Items.Add(this.menuItem);
                rootComponent.Controls.Add(this.designMenu);
                this.designMenu.SendToBack();
                this.nestedContainer = this.GetService(typeof(INestedContainer)) as INestedContainer;
                if (this.nestedContainer != null)
                {
                    this.nestedContainer.Add(this.menuItem, "ContextMenuStrip");
                }
            }
            new EditorServiceContext(this, TypeDescriptor.GetProperties(base.Component)["Items"], System.Design.SR.GetString("ToolStripItemCollectionEditorVerb"));
            if (this.undoEngine == null)
            {
                this.undoEngine = this.GetService(typeof(UndoEngine)) as UndoEngine;
                if (this.undoEngine != null)
                {
                    this.undoEngine.Undone += new EventHandler(this.OnUndone);
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Called upon loading of the form.
        /// This method initializes the graph and the input mode.
        /// </summary>
        /// <seealso cref="InitializeInputModes"/>
        /// <seealso cref="InitializeGraph"/>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            description.LoadFile(new MemoryStream(Resources.description), RichTextBoxStreamType.RichText);

            //Keep shared instances of copied node styles
            graphControl.Clipboard.FromClipboardCopier.Clone = graphControl.Clipboard.FromClipboardCopier.Clone & ~GraphCopier.CloneTypes.NodeStyle;
            graphControl.Clipboard.ToClipboardCopier.Clone   = graphControl.Clipboard.ToClipboardCopier.Clone & ~GraphCopier.CloneTypes.NodeStyle;

            // write symbolic style name in graphml to make the nodes use the default style when imported, not the specific style instance
            // otherwise, 'change color' wouldn't work on imported nodes
            graphControl.GraphMLIOHandler.QueryReferenceId += delegate(object sender, QueryReferenceIdEventArgs args) { if (args.Value == defaultStyle)
                                                                                                                        {
                                                                                                                            args.ReferenceId = "defaultStyle";
                                                                                                                        }
            };

            // if node style is string "defaultStyle" in graphml, assign defaultStyle
            graphControl.GraphMLIOHandler.ResolveReference += delegate(object sender, ResolveReferenceEventArgs args) { if (args.ReferenceId == "defaultStyle")
                                                                                                                        {
                                                                                                                            args.Value = defaultStyle;
                                                                                                                        }
            };

            graphControl.Graph.SetUndoEngineEnabled(true);
            UndoEngine engine = graphControl.Graph.GetUndoEngine();

            if (engine != null)
            {
                engine.AutoMergeTime    = TimeSpan.FromMilliseconds(100);
                engine.PropertyChanged += delegate {
                    UpdateUndoState();
                };
            }
            UpdateUndoState();

            // Add some more interesting port candidates.
            GraphDecorator decorator = graphControl.Graph.GetDecorator();

            decorator.NodeDecorator.PortCandidateProviderDecorator.SetFactory(
                node => PortCandidateProviders.FromShapeGeometry(node));

            // add callbacks to the business objects at the nodes in the graph
            graphControl.Graph.NodeCreated += OnNodeCreated;
            graphControl.Graph.NodeRemoved += OnNodeRemoved;

            // initialize the graph
            InitializeGraph();

            // reset the Undo queue so the initial graph creation cannot be undone
            graphControl.Graph.GetUndoEngine().Clear();

            // initialize the input mode
            InitializeInputModes();
        }
        public MoonlightController(GtkSilver moonlight)
        {
            this.moonlight = moonlight;
            serializer = new Serializer();
            undo = new UndoEngine();
            Selection = new StandardSelection(this);
            CurrentTool = new SelectionTool(this);
            propertyManager = new PropertyManager(this);

            SetupCanvas();
        }
Beispiel #11
0
        public void PushClearsRedoStack()
        {
            var val = 1;
            var ue  = new UndoEngine();

            ue.PushAndDoAction(() => val = 10, () => val = 1);
            ue.Undo();
            Assert.Equal(1, val);
            Assert.True(ue.CanRedo);
            ue.PushAndDoAction(() => val = 100, () => val = 1);
            Assert.False(ue.CanRedo);
        }
Beispiel #12
0
        static OptionHandler CreateHandler(GraphEditorForm form)
        {
            GraphControl         gc   = form.GraphControl;
            IGraph               g    = form.Graph;
            GraphEditorInputMode geim = form.GraphEditorInputMode;


            OptionHandler handler      = new OptionHandler(NAME);
            OptionGroup   controlGroup = handler.AddGroup(UI_DEFAULTS);

            controlGroup.AddDouble(HitTestRadius, gc.HitTestRadius);
            controlGroup.AddBool(AutoRemoveEmptyLabels, geim.AutoRemoveEmptyLabels);

//      var gridEnabledItem = controlGroup.AddBool(GridEnabled, form.Grid.Enabled);
            var gridVisibleItem  = controlGroup.AddBool(GridVisible, form.GridVisible);
            var gridWidthItem    = controlGroup.AddInt(GridWidth, form.GridWidth);
            var gridSnapTypeItem = controlGroup.AddList <GridSnapTypes>(GridSnapeType, new List <GridSnapTypes>
            {
                GridSnapTypes.All, GridSnapTypes.GridPoints, GridSnapTypes.HorizontalLines, GridSnapTypes.Lines, GridSnapTypes.None, GridSnapTypes.VerticalLines
            }, form.GridSnapType);

            ConstraintManager cm = new ConstraintManager(handler);

            cm.SetEnabledOnCondition(
                ConstraintManager.LogicalCondition.Or(cm.CreateValueEqualsCondition(gridVisibleItem, true),
                                                      cm.CreateValueEqualsCondition(gridVisibleItem, true)),
                gridWidthItem);
            cm.SetEnabledOnValueEquals(gridVisibleItem, true, gridSnapTypeItem);

            if (g != null)
            {
                OptionGroup graphGroup = handler.AddGroup(GRAPH_SETTINGS);
                graphGroup.AddBool(AutoAdjustPreferredLabelSize, g.NodeDefaults.Labels.AutoAdjustPreferredSize);
                graphGroup.AddBool(AutoCleanupPorts, g.NodeDefaults.Ports.AutoCleanUp);
                OptionGroup sharingGroup = graphGroup.AddGroup(SHARING_SETTINGS);

                sharingGroup.AddBool(ShareDefaultNodeStyleInstance, g.NodeDefaults.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultEdgeStyleInstance, g.EdgeDefaults.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultNodeLabelStyleInstance, g.NodeDefaults.Labels.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultEdgeLabelStyleInstance, g.EdgeDefaults.Labels.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultPortStyleInstance, g.NodeDefaults.Ports.ShareStyleInstance);
                sharingGroup.AddBool(ShareDefaultNodeLabelModelParameter, g.NodeDefaults.Labels.ShareLayoutParameterInstance);
                sharingGroup.AddBool(ShareDefaultEdgeLabelModelParameter, g.EdgeDefaults.Labels.ShareLayoutParameterInstance);
            }
            OptionGroup miscGroup  = handler.AddGroup(MISC_SETTINGS);
            UndoEngine  undoEngine = form.Graph.GetUndoEngine();

            if (undoEngine != null)
            {
                miscGroup.AddInt(UndoEngine_Size, undoEngine.Size);
            }
            return(handler);
        }
Beispiel #13
0
        // This utility method connects the designer to various
        // services it will use.
        private void InitializeServices()
        {
            // Acquire a reference to DesignerActionService.
            this.actionService = GetService(typeof(DesignerActionService)) as DesignerActionService;

            // Acquire a reference to DesignerActionUIService.
            this.actionUiService = GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;

            // Acquire a reference to IComponentChangeService.
            this.changeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            // Acquire a reference to IDesignerHost.
            this.host = GetService(typeof(IDesignerHost)) as IDesignerHost;

            // Acquire a reference to IDesignerOptionService.
            this.optionService =
                GetService(typeof(IDesignerOptionService)) as IDesignerOptionService;

            // Acquire a reference to IEventBindingService.
            this.eventBindingService =
                GetService(typeof(IEventBindingService)) as IEventBindingService;

            // Acquire a reference to IExtenderListService.
            this.listService =
                GetService(typeof(IExtenderListService)) as IExtenderListService;

            // Acquire a reference to IReferenceService.
            this.referenceService =
                GetService(typeof(IReferenceService)) as IReferenceService;

            // Acquire a reference to ITypeResolutionService.
            this.typeResService = GetService(typeof(ITypeResolutionService))
                                  as ITypeResolutionService;

            // Acquire a reference to IComponentDiscoveryService.
            this.componentDiscoveryService = GetService(typeof(IComponentDiscoveryService))
                                             as IComponentDiscoveryService;

            // Acquire a reference to IToolboxService.
            this.toolboxService = GetService(typeof(IToolboxService)) as IToolboxService;

            // Acquire a reference to UndoEngine.
            this.undoEng = GetService(typeof(UndoEngine)) as UndoEngine;

            if (this.undoEng != null)
            {
                //MessageBox.Show("UndoEngine");
            }
        }
Beispiel #14
0
        //加载流程
        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;

                propertyGrid.setWfDesigner(designer);

                //this.xamlTextBox.Text = designer.Text;
            }
            catch (SystemException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }  //end
Beispiel #15
0
        public void ShowDialog(ModelItem activity, EditingContext context)
        {
            Fx.Assert(activity != null, "Activity model item shouldn't be null!");
            Fx.Assert(context != null, "EditingContext shouldn't be null!");


            string bookmarkTitle = (string)this.InlineEditorTemplate.Resources["bookmarkTitle"];

            UndoEngine undoEngine = context.Services.GetService <UndoEngine>();

            Fx.Assert(null != undoEngine, "UndoEngine should be available");

            using (EditingScope scope = context.Services.GetRequiredService <ModelTreeManager>().CreateEditingScope(bookmarkTitle, true))
            {
                if ((new EditorWindow(activity, context)).ShowOkCancel())
                {
                    scope.Complete();
                }
            }
        }
Beispiel #16
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            // register metadata

            (new DesignerMetadata()).Register();

            // create the workflow designer

            wd.Load(new Sequence());

            DesignerBorder.Child = wd.View;

            PropertyBorder.Child = wd.PropertyInspectorView;

            undoEngineService = wd.Context.Services.GetService <UndoEngine>();

            undoEngineService.UndoUnitAdded += OnUndoUnitAdded;
        }
Beispiel #17
0
        private static void CommitValuesToForm(OptionHandler handler, GraphEditorForm form)
        {
            GraphControl         gc   = form.GraphControl;
            IGraph               g    = form.Graph;
            GraphEditorInputMode geim = form.GraphEditorInputMode;

            OptionGroup controlGroup = handler.GetGroupByName(UI_DEFAULTS);

            OptionGroup graphGroup   = handler.GetGroupByName(GRAPH_SETTINGS);
            OptionGroup sharingGroup = graphGroup.GetGroupByName(SHARING_SETTINGS);
            OptionGroup miscGroup    = handler.GetGroupByName(MISC_SETTINGS);

            gc.HitTestRadius           = (double)controlGroup[HitTestRadius].Value;
            geim.AutoRemoveEmptyLabels = (bool)controlGroup[AutoRemoveEmptyLabels].Value;

            form.GridWidth    = (int)controlGroup[GridWidth].Value;
            form.GridSnapType = (GridSnapTypes)controlGroup[GridSnapeType].Value;
            form.GridVisible  = (bool)controlGroup[GridVisible].Value;

            if (g != null)
            {
                g.NodeDefaults.Labels.AutoAdjustPreferredSize = g.EdgeDefaults.Labels.AutoAdjustPreferredSize = (bool)graphGroup[AutoAdjustPreferredLabelSize].Value;
                g.NodeDefaults.Ports.AutoCleanUp = g.EdgeDefaults.Ports.AutoCleanUp = (bool)graphGroup[AutoCleanupPorts].Value;

                g.NodeDefaults.ShareStyleInstance                  = (bool)sharingGroup[ShareDefaultNodeStyleInstance].Value;
                g.EdgeDefaults.ShareStyleInstance                  = (bool)sharingGroup[ShareDefaultEdgeStyleInstance].Value;
                g.NodeDefaults.Labels.ShareStyleInstance           = (bool)sharingGroup[ShareDefaultNodeLabelStyleInstance].Value;
                g.EdgeDefaults.Labels.ShareStyleInstance           = (bool)sharingGroup[ShareDefaultEdgeLabelStyleInstance].Value;
                g.NodeDefaults.Ports.ShareStyleInstance            = g.EdgeDefaults.Ports.ShareStyleInstance = (bool)sharingGroup[ShareDefaultPortStyleInstance].Value;
                g.NodeDefaults.Labels.ShareLayoutParameterInstance = (bool)sharingGroup[ShareDefaultNodeLabelModelParameter].Value;
                g.EdgeDefaults.Labels.ShareLayoutParameterInstance = (bool)sharingGroup[ShareDefaultEdgeLabelModelParameter].Value;
            }
            UndoEngine undoEngine = form.Graph.GetUndoEngine();

            if (undoEngine != null)
            {
                undoEngine.Size = (int)miscGroup[UndoEngine_Size].Value;
            }
        }
Beispiel #18
0
        public void DoCompositeUndo()
        {
            var v1 = 0;
            var v2 = 0;
            var ue = new UndoEngine();

            ue.CompositeUndo(() =>
            {
                ue.PushAndDoAction(() => v1 = 1, () => v1 = 2);
                ue.PushAndDoAction(() => v2 = 10, () => v2 = 20);
            });

            Assert.Equal(1, v1);
            Assert.Equal(10, v2);

            ue.Undo();
            Assert.Equal(2, v1);
            Assert.Equal(20, v2);

            ue.Redo();
            Assert.Equal(1, v1);
            Assert.Equal(10, v2);
        }
        public void ShowDialog(ModelItem modelItem, EditingContext context)
        {
            Fx.Assert(modelItem != null, "Activity model item shouldn't be null!");
            Fx.Assert(context != null, "EditingContext shouldn't be null!");


            string bookmarkTitle = (string)this.InlineEditorTemplate.Resources["bookmarkTitle"];

            UndoEngine undoEngine = context.Services.GetService <UndoEngine>();

            Fx.Assert(null != undoEngine, "UndoEngine should be available");

            using (ModelEditingScope editingScope = modelItem.BeginEdit(bookmarkTitle, shouldApplyChangesImmediately: true))
            {
                if ((new EditorWindow(modelItem, context)).ShowOkCancel())
                {
                    editingScope.Complete();
                }
                else
                {
                    editingScope.Revert();
                }
            }
        }
Beispiel #20
0
 public UndoNotifyCollection(TColl target, UndoEngine undoEngine) : base(target, undoEngine)
 {
 }
Beispiel #21
0
 public UndoUnit(UndoEngine engine, string name)
 {
     throw null;
 }
Beispiel #22
0
        /// <summary>
        /// The edit event that is dispatched by the business object contains a
        /// undo unit which is added to the undo engine here.
        /// </summary>
        private void OnUndoEventHandler(object o, MyEditEventHandlerArgs args)
        {
            UndoEngine engine = graphControl.Graph.GetUndoEngine();

            engine.AddUnit(args.UndoUnit);
        }
Beispiel #23
0
        private void SetupUndoButtons(UndoEngine e)
        {
            e.UndoAdded += delegate {
                UndoAction.Sensitive = true;
            };

            e.RedoAdded += delegate {
                RedoAction.Sensitive = true;
            };

            e.RedoRemoved += delegate (object sender, EventArgs args) {
                RedoAction.Sensitive = ((UndoEngine)sender).RedoCount != 0;
            };

            e.UndoRemoved += delegate (object sender, EventArgs args) {
                UndoAction.Sensitive = ((UndoEngine)sender).UndoCount != 0;
            };
        }
Beispiel #24
0
    // </snippet6>

    // <snippet7>
    // This utility method connects the designer to various
    // services it will use.
    private void InitializeServices()
    {
        // Acquire a reference to DesignerActionService.
        this.actionService =
            GetService(typeof(DesignerActionService))
            as DesignerActionService;

        // Acquire a reference to DesignerActionUIService.
        this.actionUiService =
            GetService(typeof(DesignerActionUIService))
            as DesignerActionUIService;

        // Acquire a reference to IComponentChangeService.
        this.changeService =
            GetService(typeof(IComponentChangeService))
            as IComponentChangeService;

        // <snippet14>
        // Hook the IComponentChangeService events.
        if (this.changeService != null)
        {
            this.changeService.ComponentChanged +=
                new ComponentChangedEventHandler(
                    ChangeService_ComponentChanged);

            this.changeService.ComponentAdded +=
                new ComponentEventHandler(
                    ChangeService_ComponentAdded);

            this.changeService.ComponentRemoved +=
                new ComponentEventHandler(
                    changeService_ComponentRemoved);
        }
        // </snippet14>

        // Acquire a reference to ISelectionService.
        this.selectionService =
            GetService(typeof(ISelectionService))
            as ISelectionService;

        // Hook the SelectionChanged event.
        if (this.selectionService != null)
        {
            this.selectionService.SelectionChanged +=
                new EventHandler(selectionService_SelectionChanged);
        }

        // Acquire a reference to IDesignerEventService.
        this.eventService =
            GetService(typeof(IDesignerEventService))
            as IDesignerEventService;

        if (this.eventService != null)
        {
            this.eventService.ActiveDesignerChanged +=
                new ActiveDesignerEventHandler(
                    eventService_ActiveDesignerChanged);
        }

        // Acquire a reference to IDesignerHost.
        this.host =
            GetService(typeof(IDesignerHost))
            as IDesignerHost;

        // Acquire a reference to IDesignerOptionService.
        this.optionService =
            GetService(typeof(IDesignerOptionService))
            as IDesignerOptionService;

        // Acquire a reference to IEventBindingService.
        this.eventBindingService =
            GetService(typeof(IEventBindingService))
            as IEventBindingService;

        // Acquire a reference to IExtenderListService.
        this.listService =
            GetService(typeof(IExtenderListService))
            as IExtenderListService;

        // Acquire a reference to IReferenceService.
        this.referenceService =
            GetService(typeof(IReferenceService))
            as IReferenceService;

        // Acquire a reference to ITypeResolutionService.
        this.typeResService =
            GetService(typeof(ITypeResolutionService))
            as ITypeResolutionService;

        // Acquire a reference to IComponentDiscoveryService.
        this.componentDiscoveryService =
            GetService(typeof(IComponentDiscoveryService))
            as IComponentDiscoveryService;

        // Acquire a reference to IToolboxService.
        this.toolboxService =
            GetService(typeof(IToolboxService))
            as IToolboxService;

        // Acquire a reference to UndoEngine.
        this.undoEng =
            GetService(typeof(UndoEngine))
            as UndoEngine;

        if (this.undoEng != null)
        {
            MessageBox.Show("UndoEngine");
        }
    }
Beispiel #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Graph"/> class.
 /// </summary>
 public Graph()
 {
     _undoEngine = new UndoEngine();
     _members    = new GraphMemberCollection(this);
     _members.CollectionChanged += _members_CollectionChanged;
 }
Beispiel #26
0
 public SubUndoUnit(UndoEngine engine, string name) : base(engine, name)
 {
 }