Пример #1
0
            public bool set(string key, Type filter, AVal aval, MouseState.Flags ifType = MouseState.Flags.LMR)
            {
                if (!args[idx].Eq(key))
                {
                    return(false);
                }
                LSender.Send(this, $"Found '{key}' key in {idx} position.", Message.Level.Debug);

                MouseState.Flags type;
                if (ifType != MouseState.Flags.None)
                {
                    type = MouseState.Extract(args[++idx]);
                    LSender.Send(this, $"type = {type} by {idx}", Message.Level.Debug);
                }
                else
                {
                    type = MouseState.Flags.None;
                }

                string val;

                if (aval != null)
                {
                    val = args[++idx];
                    LSender.Send(this, $"value = {val} by {idx}", Message.Level.Debug);
                }
                else
                {
                    val = null;
                }

                Guid g = filter.GUID;

                if (Filters[g] == null)
                {
                    LSender.Send(this, $"Filter '{g}' is not registered.", Message.Level.Debug);
                    return(true);
                }
                Filters[g].Activated = true;

                aval?.Invoke(Filters[g], val);

                if (ifType == MouseState.Flags.None)
                {
                    return(true);
                }

                if ((ifType & type) == 0)
                {
                    throw new ArgumentException($"Incorrect Flags {type} -> {ifType}");
                }

                Filters[g].Handler = type;
                return(true);
            }
Пример #2
0
        public void ExtractTest2()
        {
            Assert.AreEqual(MouseState.Flags.Left | MouseState.Flags.Down, MouseState.Extract(SysMessages.WM_LBUTTONDOWN));
            Assert.AreEqual(MouseState.Flags.Left | MouseState.Flags.Up, MouseState.Extract(SysMessages.WM_LBUTTONUP));

            Assert.AreEqual(MouseState.Flags.Middle | MouseState.Flags.Down, MouseState.Extract(SysMessages.WM_MBUTTONDOWN));
            Assert.AreEqual(MouseState.Flags.Middle | MouseState.Flags.Up, MouseState.Extract(SysMessages.WM_MBUTTONUP));

            Assert.AreEqual(MouseState.Flags.Right | MouseState.Flags.Down, MouseState.Extract(SysMessages.WM_RBUTTONDOWN));
            Assert.AreEqual(MouseState.Flags.Right | MouseState.Flags.Up, MouseState.Extract(SysMessages.WM_RBUTTONUP));
        }
Пример #3
0
        public void ExtractTest1()
        {
            Assert.AreEqual(MouseState.Flags.None, MouseState.Extract(""));
            Assert.AreEqual(MouseState.Flags.Left, MouseState.Extract("L"));
            Assert.AreEqual(MouseState.Flags.Middle, MouseState.Extract("M"));
            Assert.AreEqual(MouseState.Flags.Right, MouseState.Extract("R"));

            Assert.AreEqual(MouseState.Flags.Left | MouseState.Flags.Middle | MouseState.Flags.Right, MouseState.Extract("RLM"));
            Assert.AreEqual(MouseState.Flags.LMR, MouseState.Extract("lmr"));
            Assert.AreEqual(MouseState.Flags.Left | MouseState.Flags.Middle, MouseState.Extract("LM"));
            Assert.AreEqual(MouseState.Flags.Left | MouseState.Flags.Right, MouseState.Extract("LR"));
            Assert.AreEqual(MouseState.Flags.Middle | MouseState.Flags.Right, MouseState.Extract("MR"));
        }