Ejemplo n.º 1
0
 public void Create()
 {
     var trigger = new MouseHoldTrigger(Rectangle.One, 0.5f, MouseButton.Right);
     Assert.AreEqual(Rectangle.One, trigger.HoldArea);
     Assert.AreEqual(0.5f, trigger.HoldTime);
     Assert.AreEqual(MouseButton.Right, trigger.Button);
 }
        public void Create()
        {
            var trigger = new MouseHoldTrigger(Rectangle.One, 0.5f, MouseButton.Right);

            Assert.AreEqual(Rectangle.One, trigger.HoldArea);
            Assert.AreEqual(0.5f, trigger.HoldTime);
            Assert.AreEqual(MouseButton.Right, trigger.Button);
        }
Ejemplo n.º 3
0
 public void HoldLeftClickOnRectangle()
 {
     var drawArea = new Rectangle(0.25f, 0.25f, 0.5f, 0.25f);
     new FilledRect(drawArea, Color.Blue);
     var trigger = new MouseHoldTrigger(drawArea);
     var counter = 0;
     var text = new FontText(Font.Default, "", drawArea.Move(new Vector2D(0.0f, 0.25f)));
     new Command(() => text.Text = "MouseHold Triggered " + ++counter + " times.").Add(trigger);
 }
Ejemplo n.º 4
0
 public void CreateFromString()
 {
     var trigger = new MouseHoldTrigger("1 2 3 4 5.5 Right");
     Assert.AreEqual(new Rectangle(1, 2, 3, 4), trigger.HoldArea);
     Assert.AreEqual(5.5f, trigger.HoldTime);
     Assert.AreEqual(MouseButton.Right, trigger.Button);
     Assert.Throws<MouseHoldTrigger.CannotCreateMouseHoldTriggerWithoutHoldArea>(
         () => new MouseHoldTrigger("1 2 3"));
 }
        public void CreateFromString()
        {
            var trigger = new MouseHoldTrigger("1 2 3 4 5.5 Right");

            Assert.AreEqual(new Rectangle(1, 2, 3, 4), trigger.HoldArea);
            Assert.AreEqual(5.5f, trigger.HoldTime);
            Assert.AreEqual(MouseButton.Right, trigger.Button);
            Assert.Throws <MouseHoldTrigger.CannotCreateMouseHoldTriggerWithoutHoldArea>(
                () => new MouseHoldTrigger("1 2 3"));
        }
Ejemplo n.º 6
0
 public void HoldMouseHovering()
 {
     var drawArea = new Rectangle(0.25f, 0.25f, 0.5f, 0.25f);
     var rect = new FilledRect(drawArea, Color.Blue);
     var trigger = new MouseHoldTrigger(drawArea);
     trigger.Invoked += () => rect.Color = Color.Red;
     trigger.Position = new Vector2D(0.3f, 0.3f);
     Assert.IsFalse(trigger.IsHovering());
     AdvanceTimeAndUpdateEntities(1.05f);
     Assert.IsFalse(trigger.IsHovering());
 }
        public void HoldLeftClickOnRectangle()
        {
            var drawArea = new Rectangle(0.25f, 0.25f, 0.5f, 0.25f);

            new FilledRect(drawArea, Color.Blue);
            var trigger = new MouseHoldTrigger(drawArea);
            var counter = 0;
            var text    = new FontText(Font.Default, "", drawArea.Move(new Vector2D(0.0f, 0.25f)));

            new Command(() => text.Text = "MouseHold Triggered " + ++counter + " times.").Add(trigger);
        }
        public void HoldMouseHovering()
        {
            var drawArea = new Rectangle(0.25f, 0.25f, 0.5f, 0.25f);
            var rect     = new FilledRect(drawArea, Color.Blue);
            var trigger  = new MouseHoldTrigger(drawArea);

            trigger.Invoked += () => rect.Color = Color.Red;
            trigger.Position = new Vector2D(0.3f, 0.3f);
            Assert.IsFalse(trigger.IsHovering());
            AdvanceTimeAndUpdateEntities(1.05f);
            Assert.IsFalse(trigger.IsHovering());
        }
Ejemplo n.º 9
0
        private bool CheckWhichButtonForMouseHoldTriggerToUse(bool foundFreeKey, MouseButton button,
                                                              int index)
        {
            if (foundFreeKey)
            {
                return(true);
            }
            bool keyAlreadyUsed = false;

            foreach (Trigger newTrigger in GetTriggersOfCommand())
            {
                keyAlreadyUsed = CheckIfMouseHoldButtonIsAlreadyUsed(newTrigger, button, keyAlreadyUsed);
            }
            if (keyAlreadyUsed)
            {
                return(false);
            }
            var mouseHoldTrigger = new MouseHoldTrigger(new Rectangle(), 0.5f, button);

            GetTriggersOfCommand()[index] = mouseHoldTrigger;
            return(true);
        }