Esempio n. 1
0
        public void When_StateTrigger_DataBound_Late()
        {
            var SUT = new UserControl();
            var mgr = VisualStateManager.GetVisualStateManager(SUT);

            var group = new VisualStateGroup();

            var state = new VisualState();

            group.States.Add(state);

            var trigger = new StateTrigger();

            trigger.SetBinding(StateTrigger.IsActiveProperty, new Binding()
            {
                Path = "a"
            });

            var groups = new List <VisualStateGroup>();

            groups.Add(group);
            state.StateTriggers.Add(trigger);
            VisualStateManager.SetVisualStateGroups(SUT, groups);

            Assert.IsNull(trigger.DataContext);
            Assert.IsFalse(trigger.IsActive);

            SUT.DataContext = new { a = true };

            Assert.IsNotNull(group.DataContext);
            Assert.IsNotNull(state.DataContext);
            Assert.IsNotNull(trigger.DataContext);
            Assert.IsTrue(trigger.IsActive);
        }
Esempio n. 2
0
        public void When_StateTrigger_DataBound_Early()
        {
            var group = new VisualStateGroup();

            group.DataContext = new { a = true };

            var    state = new VisualState();
            object stateDataContextValue = null;

            state.DataContextChanged += (_, e) => {
                stateDataContextValue = e.NewValue;
            };

            var trigger = new StateTrigger();

            state.StateTriggers.Add(trigger);

            group.States.Add(state);

            Assert.IsNull(stateDataContextValue);
            Assert.IsFalse(trigger.IsActive);

            trigger.SetBinding(StateTrigger.IsActiveProperty, new Binding()
            {
                Path = "a"
            });

            Assert.IsNotNull(stateDataContextValue);
            Assert.IsTrue(trigger.IsActive);
        }
Esempio n. 3
0
        public void CheckDecisionsTriggers(StateMachine stateMachine, StateTrigger trigger)
        {
            if (UnusedDecisionsStateTriggers.Contains(trigger))
            {
                return;
            }

            foreach (Decision decision in Decisions)
            {
                if (!decision.Logic)
                {
                    continue;
                }

                decision.Logic.StateMachine = stateMachine;

                switch (trigger)
                {
                case StateTrigger.OnStateEnter:
                    decision.Logic.OnEnter();
                    break;

                case StateTrigger.OnStateExit:
                    decision.Logic.OnExit();
                    break;
                }
            }
        }
Esempio n. 4
0
 public override void EnterCircle(StateTrigger t)
 {
     t.SetEnabled(false);
     Messenger.instance.KillMessage(m);
     m = new Message("Great Scott! I thought you were lost!\n" +
                     "We were sucked into <insert plot device here>\nand ended up here.\n", "Captn S");
     Messenger.instance.AddMessage(m);
     m = new Message("You seem to have lost your mining laser,\nget into the hangar so we can get you a new one!", "Captn S", callback: OpenHatch);
     Messenger.instance.AddMessage(m);
 }
Esempio n. 5
0
	public override void EnterCircle(StateTrigger t) {
		t.SetEnabled (false);
		Messenger.instance.KillMessage (m);
		m = new Message ("Great Scott! I thought you were lost!\n" +
			"We were sucked into <insert plot device here>\nand ended up here.\n", "Captn S");
		Messenger.instance.AddMessage (m);
		m = new Message("You seem to have lost your mining laser,\nget into the hangar so we can get you a new one!", "Captn S" , callback: OpenHatch);
		Messenger.instance.AddMessage (m);


	}
Esempio n. 6
0
        public void When_DependencyObjectCollection_And_XBind()
        {
            var SUT = new Border();

            var root = new
            {
                MyElement = new Border()
                {
                    Tag = true
                }
            };

            var group = new VisualStateGroup();
            var state = new VisualState();

            var compositeTrigger = new CompositeTrigger();

            var stateTrigger = new StateTrigger();

            stateTrigger.SetBinding(
                StateTrigger.IsActiveProperty,
                new Binding {
                Path           = "MyElement.Tag",
                CompiledSource = root
            }
                );

            Assert.AreEqual(false, stateTrigger.IsActive);

            var triggers = new DependencyObjectCollection();

            triggers.Add(stateTrigger);
            compositeTrigger.TriggerCollection = triggers;

            state.StateTriggers.Add(compositeTrigger);

            group.States.Add(state);

            VisualStateManager.SetVisualStateGroups(SUT, new List <VisualStateGroup>()
            {
                group
            });

            SUT.ForceLoaded();
            SUT.ApplyCompiledBindings();

            Assert.AreEqual(true, stateTrigger.IsActive);

            compositeTrigger.TriggerCollection = null;

            Assert.IsNull(triggers.GetParent());
        }
Esempio n. 7
0
    private void _Init()
    {
        if (mTriggers.Count > 0)
        {
            return;
        }

        string[] toNextStates = StateTriggers.Split('|');
        for (int i = 0; i < toNextStates.Length; i++)
        {
            StateTrigger trigger = new StateTrigger(toNextStates[i]);
            mTriggers.Add(trigger);
        }
    }
Esempio n. 8
0
        public override void Init()
        {
            Game.Instance.MapManager = new MapManager(Game.Instance, Game.Instance.SpriteBatch);

            World world = Game.Instance.World;

            PlayerOne          = new KeyboardPlayer(world);
            PlayerOne.Position = new Vector2(500, 500);
            players[0]         = PlayerOne;

            if (players.Length == 2)
            {
                PlayerTwo          = new GamepadPlayer(world, PlayerIndex.One);
                PlayerTwo.Position = new Vector2(500, 700);
                Players[1]         = PlayerTwo;
            }
            else
            {
                WeaponComponent weaponComponent = PlayerOne.Components
                                                  .FirstOrDefault(c => c is WeaponComponent)
                                                  as WeaponComponent;

                weaponComponent.CurrentWeapon.AddPower(15);
            }

            topWall    = new Wall(world, new Vector2(Game.Instance.ScreenWidth / 2f, Game.Instance.ScreenHeight / 2f - 50), Game.Instance.ScreenWidth * 2, 100);
            bottomWall = new Wall(world, new Vector2(Game.Instance.ScreenWidth / 2f, Game.Instance.ScreenHeight + 50), Game.Instance.ScreenWidth * 2, 100);
            leftWall   = new Wall(world, new Vector2(-50, Game.Instance.ScreenHeight / 2f), 100, Game.Instance.ScreenHeight);
            rightWall  = new Wall(world, new Vector2(Game.Instance.ScreenWidth + 50, Game.Instance.ScreenHeight / 2f), 100, Game.Instance.ScreenHeight);

            Game.Instance.Components.Add(Game.Instance.MapManager);

            StateTrigger trigger = new StateTrigger(Game.Instance);

            Game.Instance.Components.Add(trigger);

            Game.Instance.MapManager.ChangeMap("testmap");


            Song bgmusic = Game.Instance.Content.Load <Song>("music\\bgmusic");

            MediaPlayer.Play(bgmusic);
            MediaPlayer.Volume = 0.15f;

            MediaPlayer.IsRepeating = true;
        }
Esempio n. 9
0
        public void When_ElementNameSetter()
        {
            var  g         = new Grid();
            Grid innerGrid = null;
            var  subject   = new ElementNameSubject(false, "test");
            var  stub      = new ElementStub
            {
                ContentBuilder = () => {
                    innerGrid = new Grid()
                    {
                        Name = "test"
                    };
                    subject.ElementInstance = innerGrid;
                    return(innerGrid);
                }
            };

            subject.ElementInstance = stub;

            g.Children.Add(stub);

            var SUT = new Setter(new TargetPropertyPath(subject, "Tag"), 42);

            var trigger = new StateTrigger()
            {
                IsActive = false
            };
            var vs = new VisualState {
                Setters = { SUT }, StateTriggers = { trigger }
            };

            var group = new VisualStateGroup();

            group.States.Add(vs);

            VisualStateManager.SetVisualStateGroups(g, new List <VisualStateGroup>()
            {
                group
            });

            Assert.IsNull(innerGrid);

            trigger.IsActive = true;
            Assert.IsNotNull(innerGrid);
            Assert.AreEqual(42, innerGrid.Tag);
        }
Esempio n. 10
0
    void StartStandard()
    {
        // App
        Application.targetFrameRate = 60;

        // Init
        ScoreAdder     scoreAdder     = new ScoreAdder();
        StateTrigger   stateTrigger   = new StateTrigger();
        CursorStandard cursorStandard = new CursorStandard();
        RandomProvider randomProvider = new RandomProvider();
        Resetter       resetter       = new Resetter();
        ParentProvider parentProvider = new ParentProvider();

        // Connect
        inputSender.AddSpawnReceiver(spawnerStandard.GetSpawnReceiver());
        inputSender.SetRandomProvider(randomProvider);
        inputSender.AddAudioReceiver(audioPlayer.GetAudioReceiver());
        inputSenderConstant.AddSpawnReceiver(cursorStandard.GetSpawnReceiver());
        inputSenderConstant.SetRandomProvider(randomProvider);
        spawnerStandard.ReceiveFactory(fruitFactoryStandard);
        cursorStandard.ReceiveFactory(fruitFactoryStandard);
        spawnerStandard.AddScoreReceiver(scoreAdder.GetScoreReceiver());
        spawnerStandard.AddAudioReceiver(audioPlayer.GetAudioReceiver());
        spawnerStandard.AddStateReceiver(stateTrigger.GetStateReceiver());
        spawnerStandard.SetParentProvider(parentProvider);
        scoreAdder.AddScoreReceiver(outputRenderer.GetScoreReceiver());
        stateTrigger.AddStateReceiver(outputRenderer.GetStateReceiver());
        preFailer.AddRedReceiver(redder.GetRedReceiver());
        failer.AddRedReceiver(redder.GetRedReceiver());
        failer.AddStateReceiver(stateTrigger.GetStateReceiver());
        outputRenderer.SetResetter(resetter);
        resetter.AddResetable(inputSender);
        resetter.AddResetable(inputSenderConstant);
        resetter.AddResetable(fruitFactoryStandard);
        resetter.AddResetable(outputRenderer);
        resetter.AddResetable(preFailer);
        resetter.AddResetable(failer);
        resetter.AddResetable(redder);
        resetter.AddResetable(scoreAdder);
        resetter.AddResetable(spawnerStandard);
        resetter.AddResetable(stateTrigger);
        resetter.AddResetable(cursorStandard);
        resetter.AddResetable(randomProvider);
        resetter.AddResetable(parentProvider);
    }
Esempio n. 11
0
        public void CheckTriggers(StateMachine stateMachine, StateTrigger trigger)
        {
            foreach (ActionUsage action in Actions)
            {
                if (action.Trigger != trigger || !action.Logic)
                {
                    continue;
                }

                action.Logic.StateMachine = stateMachine;
                action.Logic.OnUpdate();
            }

            foreach (StateTransition transitionNode in Transitions)
            {
                transitionNode.CheckDecisionsTriggers(stateMachine, trigger);
            }
        }
Esempio n. 12
0
	public void EnterCircle(StateTrigger t) {
		curState.EnterCircle (t);
	}
Esempio n. 13
0
 /// <summary>
 ///   Resume the workflow until it becomes idle with any bookmark
 /// </summary>
 /// <param name="trigger"> The name of the bookmark </param>
 public void Resume(StateTrigger trigger)
 {
     this.Resume(trigger.ToString());
 }
 /// <summary>
 /// The inspector has been enabled.
 /// </summary>
 protected virtual void OnEnable()
 {
     m_StateTrigger = target as StateTrigger;
 }
Esempio n. 15
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Log.Debug(TAG, "OnCreate");
            base.OnCreate(savedInstanceState);

            lock (DatabaseContext.DbLocker)
            {
                using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                {
                    scriptHardware = db.Scripts.Include(x => x.Commands).Include(x => x.TriggerPort).FirstOrDefault(x => x.Id == Intent.Extras.GetInt(nameof(ScriptModel.Id), 0));
                }
            }

            TopLayout    = FindViewById <LinearLayoutCompat>(Resource.Id.script_top_layout);
            FooterLayout = FindViewById <LinearLayoutCompat>(Resource.Id.script_footer_layout);

            CardTitle.Text    = GetText(Resource.String.script_edit_title);
            CardSubtitle.Text = GetText(Resource.String.script_edit_subtitle);

            DeleteScript = new AppCompatButton(this)
            {
                Text = GetText(Resource.String.delete_title)
            };
            DeleteScript.SetTextColor(Color.DarkRed);
            DeleteScript.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            FooterLayout.AddView(DeleteScript);

            ButtonOk.Tag = scriptHardware.Id;

            CommandsScript = new AppCompatButton(this)
            {
                Text = $"{GetString(Resource.String.commands_title)} ({scriptHardware.Commands.Count})"
            };
            CommandsScript.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            TopLayout.AddView(CommandsScript);

            StartScript = new AppCompatButton(this)
            {
                Text    = GetText(Resource.String.run_the_script_title),
                Enabled = scriptHardware.Commands.Count > 0
            };
            StartScript.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);


            TopLayout.AddView(StartScript);

            ScriptName.Text = scriptHardware.Name;
            if (scriptHardware.TriggerPort != null)
            {
                AutorunTrigger.Checked  = true;
                PortTrigger.Enabled     = true;
                HardwareTrigger.Enabled = true;
                StateTrigger.Enabled    = true;

                int indexPosition = Hardwares.Keys.ToList().IndexOf(scriptHardware.TriggerPort.HardwareId);
                HardwareTrigger.SetSelection(indexPosition);

                PortsList_UpdateSpinner(scriptHardware.TriggerPort.HardwareId, ref PortTrigger, scriptHardware.TriggerPort.Id);//, ref Ports

                string[] statuses = Resources.GetStringArray(Resource.Array.script_trigger_port_states_array);
                if (scriptHardware.TriggerPortState == true)
                {
                    indexPosition = Array.IndexOf(statuses, GetString(Resource.String.abc_capital_on));
                }
                else if (scriptHardware.TriggerPortState == false)
                {
                    indexPosition = Array.IndexOf(statuses, GetString(Resource.String.abc_capital_off));
                }
                else
                {
                    indexPosition = Array.IndexOf(statuses, GetString(Resource.String.abc_capital_switch));
                }
                StateTrigger.SetSelection(indexPosition);
            }
        }
Esempio n. 16
0
 public override void EnterBox(StateTrigger t)
 {
     Messenger.instance.KillMessage(m);
     exit = true;
 }
Esempio n. 17
0
 public virtual void EnterCircle(StateTrigger t)
 {
 }
Esempio n. 18
0
	public override void EnterBox(StateTrigger t) {
		Messenger.instance.KillMessage (m);
		Run ();
	}
Esempio n. 19
0
 public void EnterCircle(StateTrigger t)
 {
     curState.EnterCircle(t);
 }
Esempio n. 20
0
 /// <summary>
 ///   Determines if a trigger can be executed
 /// </summary>
 /// <param name="trigger"> The trigger </param>
 /// <returns> true if the trigger can be executed </returns>
 public bool CanExecute(StateTrigger trigger)
 {
     return this.Transitions != null && this.Transitions.Any(t => t == trigger.ToString());
 }
Esempio n. 21
0
	public void EnterBox(StateTrigger t) {
		curState.EnterBox (t);
	}
Esempio n. 22
0
	public virtual void EnterCircle(StateTrigger t) {}
Esempio n. 23
0
	public override void EnterBox(StateTrigger t)
	{
		tControl.TutorialDone();
	}
 public static StateTrigger IsActive(this StateTrigger trigger, bool isActive)
 {
     trigger.IsActive = isActive;
     return(trigger);
 }
Esempio n. 25
0
	public override void EnterBox(StateTrigger t) {
		Messenger.instance.KillMessage (m);
		exit = true;
	}
Esempio n. 26
0
 public override void EnterBox(StateTrigger t)
 {
     tControl.TutorialDone();
 }
Esempio n. 27
0
	public virtual void EnterBox(StateTrigger t) {}
Esempio n. 28
0
 /// <summary>
 ///   Executes a trigger on the state machine
 /// </summary>
 /// <param name="trigger"> The trigger </param>
 private void ExecuteTrigger(StateTrigger trigger)
 {
     this.Model.ResumeBookmark(trigger);
 }
Esempio n. 29
0
 public override void EnterBox(StateTrigger t)
 {
     Messenger.instance.KillMessage(m);
     Run();
 }
Esempio n. 30
0
 public void EnterBox(StateTrigger t)
 {
     curState.EnterBox(t);
 }
Esempio n. 31
0
 public virtual void EnterBox(StateTrigger t)
 {
 }
Esempio n. 32
0
 /// <summary>
 ///   Determines if a trigger can execute
 /// </summary>
 /// <param name="trigger"> The trigger </param>
 /// <returns> true if it can execute, false if not </returns>
 private bool CanExecuteTrigger(StateTrigger trigger)
 {
     return this.Model.CanExecute(trigger);
 }
Esempio n. 33
0
 /// <summary>
 ///   Resume a bookmark
 /// </summary>
 /// <param name="trigger"> The trigger to resume </param>
 public void ResumeBookmark(StateTrigger trigger)
 {
     this.ResumeBookmark(trigger.ToString());
 }