예제 #1
0
        async Task ProcessKeys(TcpClient client)
        {
            try
            {
                var stream  = client.GetStream();
                var buffer  = new byte[sizeof(int)];
                var presser = new KeyPresser();

                while (true)
                {
                    var read = await stream.ReadAsync(buffer, 0, sizeof(int));

                    if (read < sizeof(int))
                    {
                        break;
                    }
                    var key = (ConsoleKey)BitConverter.ToInt32(buffer, 0);
                    LastKey = key.ToString();
                    presser.PressKey(key);
                }
            }
            finally
            {
                client.Dispose();
                Status     = "No connection";
                NotStarted = true;
                LastKey    = "None";
            }
        }
예제 #2
0
        public KeyPresserPanel(KeyPresser plugin)
        {
            InitializeComponent();

            mPlugin = plugin;
            mConfig = plugin.Config as ViewerConfig;

            mPlugin.Started += () => {
                if (InvokeRequired)
                {
                    Invoke(new Action(() => startButton.Text = "Stop"));
                }
                else
                {
                    startButton.Text = "Stop";
                }
            };

            mPlugin.Stopped += () => {
                if (InvokeRequired)
                {
                    Invoke(new Action(() => startButton.Text = "Start"));
                }
                else
                {
                    startButton.Text = "Start";
                }
            };

            intervalS.Value     = new Decimal(mConfig.IntervalMS / 1000);
            stopM.Value         = new Decimal(mConfig.StopM);
            shutdownBox.Checked = mConfig.AutoShutdown;

            key.Text = mConfig.Key;
        }