private CallMethodAction CreateCallMethodAction(string methodName)
        {
            CallMethodAction action = new CallMethodAction();

            action.MethodName = methodName;
            return(action);
        }
        private StubTrigger AttachAction(CallMethodAction action, DependencyObject host)
        {
            StubTrigger trigger = CreateTrigger();

            trigger.Actions.Add(action);
            Interaction.GetTriggers(host).Add(trigger);
            return(trigger);
        }
Пример #3
0
        public static void ReplaceDependency(IFigure figure, IFigure oldDependency, IFigure newDependency)
        {
            var action = new CallMethodAction(
                () => figure.ReplaceDependency(oldDependency, newDependency),
                () => figure.ReplaceDependency(newDependency, oldDependency));

            figure.Drawing.ActionManager.RecordAction(action);
        }
Пример #4
0
        public static void Select(UIElement element)
        {
            var action = new CallMethodAction(() =>
            {
                SelectionManager.Select(element);
            }, null);

            Record(action);
        }
        public void Invoke_NonExistantMethodWithNoTarget_DoesNothing()
        {
            MethodObjectStub host    = CreateMethodObject();
            CallMethodAction action  = CreateCallMethodAction("NonExistantMethodName");
            StubTrigger      trigger = AttachAction(action, host);

            trigger.FireStubTrigger();
            Assert.AreEqual(host.LastMethodCalled, "None", "No method should be called");
        }
        public void Invoke_IncorrectParametersWithTargetSet_DoesNothing()
        {
            MethodObjectStub host    = CreateMethodObject();
            CallMethodAction action  = CreateCallMethodAction("IncompatibleParameters");
            StubTrigger      trigger = AttachAction(action, host);

            trigger.FireStubTrigger();
            Assert.AreEqual(host.LastMethodCalled, "None", "No method should be called");
        }
        public void Invoke_IncorrectParametersWithTargetSet_ThrowsArgumentException()
        {
            Rectangle        host    = CreateRectangle();
            MethodObjectStub target  = CreateMethodObject();
            CallMethodAction action  = CreateCallMethodAction("IncompatibleParameters");
            StubTrigger      trigger = AttachAction(action, host);

            action.TargetObject = target;
            trigger.FireStubTrigger();
        }
        public void Invoke_NonExistantMethodWithTargetSet_ThrowsArgumentException()
        {
            Rectangle        host    = CreateRectangle();
            MethodObjectStub target  = CreateMethodObject();
            CallMethodAction action  = CreateCallMethodAction("NonExistantMethodName");
            StubTrigger      trigger = AttachAction(action, host);

            action.TargetObject = target;
            trigger.FireStubTrigger();
        }
        public void Invoke_MultipleMethodsWithSpecificParameter_MostDerivedSignatureIsCalled()
        {
            MethodObjectStub methodObject = CreateMethodObject();
            CallMethodAction action       = CreateCallMethodAction("DuplicatedMethod");
            StubTrigger      trigger      = AttachAction(action, methodObject);

            trigger.FireStubTrigger(new StubEventArgs());

            Assert.AreEqual(methodObject.LastMethodCalled, "DuplicatedMethodWithStubEventArgsSignature", "DuplicatedMethodWithStubEventArgsSignature was not called.");
        }
        public void Invoke_MultipleMethodsWithSameName_EventHandlerSignatureIsCalled()
        {
            MethodObjectStub methodObject = CreateMethodObject();
            CallMethodAction action       = CreateCallMethodAction("DuplicatedMethod");
            StubTrigger      trigger      = AttachAction(action, methodObject);

            trigger.FireStubTrigger(EventArgs.Empty);

            Assert.AreEqual(methodObject.LastMethodCalled, "DuplicatedMethodWithEventHandlerSignature", "DuplicatedMethodWithEventHandlerSignature was not called.");
        }
        public void Invoke_UniqueMethodWithNoParameters_IsCalled()
        {
            MethodObjectStub methodObject = CreateMethodObject();
            CallMethodAction action       = CreateCallMethodAction("UniqueMethodWithNoParameters");
            StubTrigger      trigger      = AttachAction(action, methodObject);

            trigger.FireStubTrigger();

            Assert.AreEqual(methodObject.LastMethodCalled, "UniqueMethodWithNoParameters", "UniqueMethodWithNoParameters was not called.");
        }
Пример #12
0
        public static void InsertChild(Panel panel, UIElement draggedElement, int index)
        {
            var action = new CallMethodAction(() =>
            {
                panel.Children.Insert(index, draggedElement);
            },
                                              () =>
            {
                panel.Children.Remove(draggedElement);
            });

            Record(action);
        }
Пример #13
0
        public static void InsertDependency(IFigure figure, int index, IFigure dependency)
        {
            var action = new CallMethodAction(
                () =>
            {
                figure.InsertDependencyCore(index, dependency);
            },
                () =>
            {
                figure.RemoveDependencyCore(index, dependency);
            });

            figure.Drawing.ActionManager.RecordAction(action);
        }
Пример #14
0
        public static void InvalidateLayout(Panel panel)
        {
            var action = new CallMethodAction(() =>
            {
                panel.InvalidateMeasure();
                panel.InvalidateArrange();
            },
                                              () =>
            {
                panel.InvalidateMeasure();
                panel.InvalidateArrange();
            });

            Record(action);
        }
Пример #15
0
        public void CallMethodActionWorks()
        {
            bool             capturedFlag = false;
            ActionManager    am           = new ActionManager();
            CallMethodAction action       = new CallMethodAction(
                () => capturedFlag = true,
                () => capturedFlag = false);

            am.RecordAction(action);
            Assert.IsTrue(capturedFlag);
            am.Undo();
            Assert.IsFalse(capturedFlag);
            am.Redo();
            Assert.IsTrue(capturedFlag);
        }
Пример #16
0
        public void ShouldRaiseCollectionChangedEventForFirstAction()
        {
            int collectionChanges = 0;

            var actionManager = new ActionManager();

            actionManager.CollectionChanged += (sender, e) =>
            {
                collectionChanges++;
            };

            var action = new CallMethodAction(() => { }, () => { });

            actionManager.Execute(action);
            Assert.AreEqual(1, collectionChanges);
        }
Пример #17
0
        private void BindLoadDataEvent()
        {
            var ev = new Microsoft.Xaml.Behaviors.EventTrigger()
            {
                EventName = "Loaded"
            };

            ev.SourceObject = this;
            var callMethod = new CallMethodAction {
                MethodName = "LoadData"
            };
            var binding = new Binding();

            BindingOperations.SetBinding(callMethod, CallMethodAction.TargetObjectProperty, binding);
            ev.Actions.Add(callMethod);

            Interaction.GetTriggers(this).Add(ev);
        }
Пример #18
0
        public void ShouldRaiseCollectionChangedEventForFirstTransaction()
        {
            int collectionChanges = 0;

            var actionManager = new ActionManager();

            actionManager.CollectionChanged += (sender, e) =>
            {
                collectionChanges++;
            };

            var action      = new CallMethodAction(() => { }, () => { });
            var transaction = actionManager.CreateTransaction();

            transaction.Add(action);
            transaction.Commit();
            Assert.AreEqual(1, collectionChanges);
        }
        private void InputParametersTreeView_OnItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e)
        {
            if (e.PreparedItem.Item is WebMethodCallParameterViewModel)
            {
                var eventTrigger = new EventTrigger(RadTreeViewItem.LoadOnDemandEvent.Name);
                var action = new CallMethodAction
                             {
                                 MethodName =
                                     ReflectionHelper.GetMethodName<WebMethodCallParameterViewModel>(
                                         x => x.PopulateChildren(null, null))
                             };

                BindingOperations.SetBinding(action, CallMethodAction.TargetObjectProperty, new Binding());
                eventTrigger.Actions.Add(action);

                var triggers = Interaction.GetTriggers(e.PreparedItem);
                triggers.Add(eventTrigger);
            }
        }
Пример #20
0
        private static bool GetVertex(CallMethodAction callMethod, out Vertex vertex)
        {
            vertex = null;

            if (callMethod.CallingMethod == ElementList.GetElement <V_Vector>())
            {
                double x = 0, y = 0, z = 0;

                if (callMethod.ParameterValues[0] != null)
                {
                    var num = callMethod.ParameterValues[0] as NumberAction;
                    if (num == null)
                    {
                        return(false);
                    }
                    x = num.Value;
                }
                if (callMethod.ParameterValues[1] != null)
                {
                    var num = callMethod.ParameterValues[1] as NumberAction;
                    if (num == null)
                    {
                        return(false);
                    }
                    y = num.Value;
                }
                if (callMethod.ParameterValues[2] != null)
                {
                    var num = callMethod.ParameterValues[2] as NumberAction;
                    if (num == null)
                    {
                        return(false);
                    }
                    z = num.Value;
                }

                vertex = new Vertex(x, y, z);
                return(true);
            }
            return(false);
        }
Пример #21
0
 public void InitializeComponent()
 {
     if (!this._contentLoaded)
     {
         this._contentLoaded = true;
         Application.LoadComponent(this, new Uri("/TWC.OVP;component/Views/Shell/LiveTVShellView.xaml", UriKind.Relative));
         this.userControl = (UserControl) base.FindName("userControl");
         this.LayoutRoot = (Grid) base.FindName("LayoutRoot");
         this.ChannelBrowserStates = (VisualStateGroup) base.FindName("ChannelBrowserStates");
         this.CBScrollIn = (Storyboard) base.FindName("CBScrollIn");
         this.ShowChannelBrowser = (VisualState) base.FindName("ShowChannelBrowser");
         this.CBScrollOut = (Storyboard) base.FindName("CBScrollOut");
         this.HideChannelBrowser = (VisualState) base.FindName("HideChannelBrowser");
         this.AssetInfoStates = (VisualStateGroup) base.FindName("AssetInfoStates");
         this.ShowAssetInfo = (VisualState) base.FindName("ShowAssetInfo");
         this.InfoPanelIn = (Storyboard) base.FindName("InfoPanelIn");
         this.HideAssetInfo = (VisualState) base.FindName("HideAssetInfo");
         this.ShowSmallAssetInfoPopupBubble = (VisualState) base.FindName("ShowSmallAssetInfoPopupBubble");
         this.CaptionSettingsStates = (VisualStateGroup) base.FindName("CaptionSettingsStates");
         this.ShowCaptionSettings = (VisualState) base.FindName("ShowCaptionSettings");
         this.HideCaptionSettings = (VisualState) base.FindName("HideCaptionSettings");
         this.CaptionSettingsPopupStates = (VisualStateGroup) base.FindName("CaptionSettingsPopupStates");
         this.ShowSettingsBubble = (VisualState) base.FindName("ShowSettingsBubble");
         this.HideSettingsBubble = (VisualState) base.FindName("HideSettingsBubble");
         this.BackgroundRectangle = (Rectangle) base.FindName("BackgroundRectangle");
         this.AssetViewer = (ContentControl) base.FindName("AssetViewer");
         this.ClickHideChannelBrowserAction = (ActionMessage) base.FindName("ClickHideChannelBrowserAction");
         this.MouseMoveShowChannelBrowserAction = (ActionMessage) base.FindName("MouseMoveShowChannelBrowserAction");
         this.MouseMoveShowControlerAction = (CallMethodAction) base.FindName("MouseMoveShowControlerAction");
         this.ChannelBrowserGrid = (Grid) base.FindName("ChannelBrowserGrid");
         this.ChannelBrowser = (ChannelBrowserView) base.FindName("ChannelBrowser");
         this.rectangle = (Rectangle) base.FindName("rectangle");
         this.controller = (OnDemandController) base.FindName("controller");
         this.assetInfoContentControl = (BubbleContentControl) base.FindName("assetInfoContentControl");
         this.assetInfoBubbleContents = (AssetInfoBubbleContents) base.FindName("assetInfoBubbleContents");
         this.captionBubble = (BubbleContentControl) base.FindName("captionBubble");
         this.CaptionSettings = (ContentControl) base.FindName("CaptionSettings");
         this.Interaction = (ContentControl) base.FindName("Interaction");
     }
 }
Пример #22
0
        public void TestEndToEnd1()
        {
            var actionManager = new ActionManager();
            var sb            = new StringBuilder();
            var action1       = new CallMethodAction(
                () => sb.Append("execute1 "),
                () => sb.Append("unexecute1 "));
            var action2 = new CallMethodAction(
                () => sb.Append("execute2 "),
                () => sb.Append("unexecute2 "));

            Assert.IsFalse(actionManager.CanUndo);
            Assert.IsFalse(actionManager.CanRedo);
            Assert.AreEqual(0, actionManager.EnumUndoableActions().Count());
            Assert.AreEqual(0, actionManager.EnumRedoableActions().Count());

            actionManager.Execute(action1);
            Assert.AreEqual("execute1 ", sb.ToString());
            Assert.IsTrue(actionManager.CanUndo);
            Assert.IsFalse(actionManager.CanRedo);
            Assert.AreEqual(action1, actionManager.EnumUndoableActions().Single());
            Assert.AreEqual(0, actionManager.EnumRedoableActions().Count());

            actionManager.Execute(action2);
            Assert.AreEqual("execute1 execute2 ", sb.ToString());
            Assert.IsTrue(actionManager.CanUndo);
            Assert.IsFalse(actionManager.CanRedo);
            Assert.IsTrue(actionManager.EnumUndoableActions().SequenceEqual(new IAction[]
                                                                            { action1, action2 }));
            Assert.AreEqual(0, actionManager.EnumRedoableActions().Count());

            actionManager.Undo();
            Assert.AreEqual("execute1 execute2 unexecute2 ", sb.ToString());
            Assert.IsTrue(actionManager.CanUndo);
            Assert.IsTrue(actionManager.CanRedo);
            Assert.AreEqual(action1, actionManager.EnumUndoableActions().Single());
            Assert.AreEqual(action2, actionManager.EnumRedoableActions().Single());

            actionManager.Undo();
            Assert.AreEqual("execute1 execute2 unexecute2 unexecute1 ", sb.ToString());
            Assert.IsFalse(actionManager.CanUndo);
            Assert.IsTrue(actionManager.CanRedo);
            Assert.AreEqual(0, actionManager.EnumUndoableActions().Count());
            Assert.IsTrue(actionManager.EnumRedoableActions().SequenceEqual(new IAction[]
                                                                            { action1, action2 }));

            actionManager.Redo();
            Assert.AreEqual("execute1 execute2 unexecute2 unexecute1 execute1 ", sb.ToString());
            Assert.IsTrue(actionManager.CanUndo);
            Assert.IsTrue(actionManager.CanRedo);
            Assert.AreEqual(action1, actionManager.EnumUndoableActions().Single());
            Assert.AreEqual(action2, actionManager.EnumRedoableActions().Single());

            actionManager.Redo();
            Assert.AreEqual("execute1 execute2 unexecute2 unexecute1 execute1 execute2 ", sb.ToString());
            Assert.IsTrue(actionManager.CanUndo);
            Assert.IsFalse(actionManager.CanRedo);
            Assert.IsTrue(actionManager.EnumUndoableActions().SequenceEqual(new IAction[]
                                                                            { action1, action2 }));
            Assert.AreEqual(0, actionManager.EnumRedoableActions().Count());
        }
Пример #23
0
 /// <summary>
 /// Executes the call method action
 /// </summary>
 /// <param name="action"></param>
 /// <param name="context"></param>
 public void Execute(CallMethodAction action, IExecutionContext context)
 {
     var method = context.MethodRegister.Get(action.MethodName);
     context.RoutineExecutor.Execute(new MacroRoutine(1, method.Actions), context.MethodRegister, context.CancellationToken, context.PauseToken);
 }