Beispiel #1
0
        public void Reset()
        {
            int    a = 0;
            Action b = () =>
            {
                a = 2;
            };
            Action <object> ba = (o) =>
            {
                b();
            };

            var h = EventsBuiltin.RegisterEvent(EventID.TEST2);

            EventsBuiltin.RegisterListener(EventID.TEST2, ba);

            h.Notify();
            Thread.Sleep(10);

            Assert.IsTrue(pass);
            Assert.AreEqual(2, a);

            b = () =>
            {
                a = 4;
            };
            h.Notify();
            Thread.Sleep(10);
            Assert.AreEqual(4, a);
        }
        public MacrosView()
        {
            InitializeComponent();

            EventsBuiltin.RegisterListener <Recording>(EventID.REC,
                                                       (r) =>
            {
                this.Dispatcher.Invoke(() => { onRec(r); });
            });

            recLoaded = EventsBuiltin.RegisterEvent <Recording>(EventID.REC_LOADED);

            //test
            //model = new RecordingModel();
            //keyframesControl.DataContext = model;
            //var n1 = new OpenLinkedListNode<Recording.KeyFrame>(new Recording.KeyFrameK(KeyActions.PRESS, System.Windows.Forms.Keys.A, 1200));
            //var n2 = new OpenLinkedListNode<Recording.KeyFrame>(new Recording.KeyFrameK(KeyActions.PRESS, System.Windows.Forms.Keys.B, 1300));
            //n1.Next = n2;
            //var container = new RecordingModel.FocusContainer();
            //var t1 = new InfoTray(n1, null, focusedTray: container);
            //var t2 = new InfoTray(n2, t1.Model, focusedTray: container);
            //model.Keyframes.Add(t1);
            //model.Keyframes.Add(t2);

            //Recording rec = new Recording();
            ////rec.AddKeyFrame(new Recording.KeyFrameK(KeyActions.PRESS, System.Windows.Forms.Keys.A, 1200));
            ////rec.AddKeyFrame(new Recording.KeyFrameK(KeyActions.PRESS, System.Windows.Forms.Keys.B, 1300));
            //rec.AddKeyframe(MouseAction.WM_LBUTTONDOWN, 25, 1, 1200);
            //rec.AddKeyframe(MouseAction.WM_LBUTTONUP, 35, 2, 1300);
            //onRec(rec);
        }
Beispiel #3
0
        public EventsTests()
        {
            setPass = (o) =>
            {
                pass = true;
            };
            handle = EventsBuiltin.RegisterEvent(EventID.TEST);
            EventsBuiltin.RegisterListener(EventID.TEST, setPass);
            handle.Notify();

            Thread.Sleep(10);
        }
        private static void init()
        {
            monitors = new Dictionary <Key, ExternalKeyMonitor>();
            var hook = Hook.I();

            hook.AddKeyHook((k) =>
            {
                lock (monitors)
                {
                    if (monitors.ContainsKey(k))
                    {
                        var m = monitors[k];
                        m.seenVSent++;
                        if (m.seenVSent >= 1)
                        {
                            Task.Delay(16).ContinueWith((t) =>
                            {
                                bool call = false;
                                lock (monitors)
                                {
                                    if (m.seenVSent >= 1)
                                    {
                                        call = true; m.seenVSent--;
                                    }
                                }

                                if (!call)
                                {
                                    return;
                                }

                                foreach (Action c in m.callbacks)
                                {
                                    c();
                                }
                            });
                        }
                    }
                }
            }, (ku) => { });

            EventsBuiltin.RegisterListener <Key>(EventID.KEY_SENT, (k) =>
            {
                lock (monitors)
                {
                    if (monitors.ContainsKey(k))
                    {
                        monitors[k].seenVSent--;
                    }
                }
            });
        }
        public Overlay()
        {
            InitializeComponent();


            BLUE  = (Color)FindResource("blue0");
            GREEN = (Color)FindResource("green0");

            //todo multimonitors?
            W = SystemParameters.PrimaryScreenWidth;
            H = SystemParameters.PrimaryScreenHeight;

            EventsBuiltin.RegisterListener <Callbacks>(EventID.SELECT_MOUSE_LOCATION, selectMouseLocation);
            EventsBuiltin.RegisterListener <MyColors>(EventID.BORDER_SHOW, show);
            EventsBuiltin.RegisterListener(EventID.BORDER_HIDE, (o) => { hide(); });

            hide();
        }
Beispiel #6
0
        public RecordingManager()
        {
            hook.AddKeyHook(onKeyDown, onKeyUp);
            hook.AddMouseHook(onMouse);
            currState.Set(State.IDLE);

            rec = new Recording();

            newRecordingHandle = EventsBuiltin.RegisterEvent <Recording>(EventID.REC);
            newRecordingHandle.Notify(rec);

            showOverlayHandle = EventsBuiltin.RegisterEvent <MyColors>(EventID.BORDER_SHOW);
            hideOverlayHandle = EventsBuiltin.RegisterEvent(EventID.BORDER_HIDE);
            ExternalKeyMonitor.Monitor(Key.Escape, () => { rec?.Stop(); });

            EventsBuiltin.RegisterListener <Recording>(EventID.REC_LOADED, (r) =>
            {
                rec = r;
                //Console.WriteLine("here");
            });
        }