Exemple #1
0
        public Form1()
        {
            InitializeComponent();

            // set a filter for 5 seconds
            m_filter = new InactivityFilter(5000);
            m_filter.InactivityElapsed += new MethodInvoker(m_filter_InactivityElapsed);
            Application2.AddMessageFilter(m_filter);
        }
Exemple #2
0
 public Keytest3AKsdfForm()
 {
     InitializeComponent();
     initListView();
     _hwnd = new List <IntPtr>();
     _hwnd.Add(this.Handle);
     _hwnd.Add(this.listView1.Handle);
     Application2.AddMessageFilter(this);
     win32.AllKeys(true);
 }
        public void KeyboardHookFilterPositive()
        {
            int  pressedkey = -1;
            bool fired      = false;

            KeyboardHook hook = new KeyboardHook();

            hook.KeyDetected += new KeyHookEventHandler(
                delegate(OpenNETCF.Win32.WM keyMessage, KeyData keyData)
            {
                pressedkey = keyData.KeyCode;
                fired      = true;
            });

            Form f = new Form();

            f.ClientSize = new System.Drawing.Size(240, 268);
            TextBox t = new TextBox();

            t.Multiline = true;
            f.Controls.Add(t);
            f.Show();
            Application2.DoEvents();
            t.Focus();
            Application2.DoEvents();

            SendKeys.Send("a");
            Application2.DoEvents();

            Assert.IsFalse(fired, "hook fired when disabled");

            hook.Enabled = true;
            SendKeys.Send("h");
            Application2.DoEvents();

            Assert.IsTrue(fired, "hook did not fire when enabled");
            Assert.AreEqual((int)Keys.H, pressedkey);
            Application2.DoEvents();
            Assert.AreEqual("ah", t.Text);

            hook.PassOnKeys = false;
            fired           = false;
            SendKeys.Send("a");
            Application2.DoEvents();

            // hook should fire, get the key data, but the textbox should *not* get the character
            Assert.IsTrue(fired, "hook did not fire");
            Assert.AreEqual((int)Keys.A, pressedkey);
            Application2.DoEvents();
            Assert.AreEqual("ah", t.Text);

            hook.Dispose();
            f.Close();
            f.Dispose();
        }
Exemple #4
0
 static void Main()
 {
     //if i use AddMessageFilter only in the forms code, I was unable to any msg
     //using Application.Run()
     //MUST use Application2.Run()
     //###########################
     //FilterMsg filterCloseMsg = new FilterMsg();
     //Application2.AddMessageFilter(FilterMsg);
     //Application2.Run(new Form1());
     Application2.Run(new Keytest3AKsdfForm());
 }
Exemple #5
0
        private static void Exit(object o)
        {
            int  start       = Environment.TickCount;
            bool consoleRead = true;

            if (consoleRead)
            {
                Thread.Sleep(1000);
                Console.Out.WriteLine("Press ENTER to exit the Service Layer.");
                Console.In.ReadLine();
            }
            Application2.Exit();
        }
Exemple #6
0
        private (string pageId, XDocument doc) GetCurrentPageData()
        {
            var app = new Application2();

            var w = app.Windows.CurrentWindow;

            if (w == null)
            {
                return(null, null);
            }

            app.GetPageContent(w.CurrentPageId, out var xml);

            return(w.CurrentPageId, XDocument.Parse(xml));
        }
        public Keytest3AKwm61()
        {
            InitializeComponent();
            //prepare listview
            initListView();

            Application2.AddMessageFilter(this);
            win32.AllKeys(true);

            this.KeyPreview = true;

            _hwnd = new List <IntPtr>();
            _hwnd.Add(this.Handle);
            _hwnd.Add(listView1.Handle);
        }
Exemple #8
0
        public void AddMessageFilterTest()
        {
            AutoResetEvent filterEvent = new AutoResetEvent(false);
            TestFilter     filter      = new TestFilter(filterEvent);

            Application2.AddMessageFilter(filter);

            Form f = new Form();

            f.Visible = true;
            Application2.DoEvents();

            Assert.IsTrue(filterEvent.WaitOne(1000, false), "Filter PreFilterMessage was not called");

            filterEvent.Close();
            f.Dispose();
            Application2.Exit();
        }
 private void mnuIMessageFilter_Click(object sender, EventArgs e)
 {
     mnuIMessageFilter.Checked = !mnuIMessageFilter.Checked;
     if (mnuIMessageFilter.Checked)
     {
         if (!_bMessageFilterActive)
         {
             Application2.AddMessageFilter(this);
             _bMessageFilterActive = true;
         }
     }
     else
     {
         if (_bMessageFilterActive)
         {
             Application2.RemoveMessageFilter(this);
             _bMessageFilterActive = false;
         }
     }
 }
Exemple #10
0
        public void Save(IMindMapRoot root)
        {
            var app = new Application2();

            // Get Page
            app.GetPageContent(root.PageId, out var xml);

            if (xml == null)
            {
                return;
            }

            var doc = XDocument.Parse(xml);

            // Merge QuickStyleDefs
            var headingIndexByDepth = MergeQuickStyleDefs(doc, root);

            // Rewrite contents of first Outline
            UpdateOutline(doc, root, headingIndexByDepth);

            app.UpdatePageContent(doc.ToString(SaveOptions.OmitDuplicateNamespaces));
        }
Exemple #11
0
        public void SendKeysTestPositive()
        {
            Form f = new Form();

            f.ClientSize = new System.Drawing.Size(240, 268);
            TextBox t = new TextBox();

            t.Multiline = true;
            f.Controls.Add(t);
            f.Show();
            Application2.DoEvents();
            t.Focus();
            Application2.DoEvents();
            SendKeys.Send("hello");

            Application2.DoEvents();
            Application2.DoEvents();

            Assert.AreEqual("hello", t.Text);

            f.Close();
            f.Dispose();
        }
Exemple #12
0
 static void Main()
 {
     Application2.Run(new Keytest3AKwm61());
 }
Exemple #13
0
 public static void Main()
 {
     Application2.AddMessageFilter(mudFilter);
     Application2.Run(new MainForm());
 }
Exemple #14
0
        static void Main()
        {
            ThreadPool.QueueUserWorkItem(Exit);

            Application2.Run();
        }
Exemple #15
0
 static void Main()
 {
     Application2.Run(new Form1());
 }
Exemple #16
0
 private void mnuExit_Click(object sender, EventArgs e)
 {
     Application2.Exit();
 }