Exemplo n.º 1
0
 private PhysicalConsole()
 {
     Console.CancelKeyPress += (o, e) =>
     {
         CancelKeyPress?.Invoke(o, e);
     };
 }
Exemplo n.º 2
0
 public ConsoleInput()
 {
     Name           = "ConsoleInput";
     backgroundTask = new Task(() =>
     {
         while (true)
         {
             var message = Console.ReadLine();
             if (message?.Trim().Length > 0)
             {
                 if (message == "stop")
                 {
                     CancelKeyPress?.Invoke(null, null);
                     continue;
                 }
                 lock (_syncObj)
                     messageQueue.Add(message);
                 //       resetEvent.Set();
             }
             //if (CanRead)
             //{
             //    currentMessage = message;
             //}
             //else
             //{
             //    if (message == "stop")
             //    {
             //        CancelKeyPress?.Invoke(null, null);
             //    }
             //}
         }
     });
     backgroundTask.Start();
 }
Exemplo n.º 3
0
        public void AddInput(IInput input)
        {
            // Input.SetResetEvent(resetEvent);
            input.SetQueue(ownQueue);
            inputs.Add(input);

            // Input.RegisterEventHandler(CancelKeyPress);
            input.CancelKeyPress += (sender, args) => CancelKeyPress?.Invoke(sender, args);
        }
        public void RaiseCancelKeyPress()
        {
            // See https://github.com/dotnet/corefx/blob/f2292af3a1794378339d6f5c8adcc0f2019a2cf9/src/System.Console/src/System/ConsoleCancelEventArgs.cs#L14
            var eventArgs = typeof(ConsoleCancelEventArgs)
                            .GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance)
                            .First()
                            .Invoke(new object[] { ConsoleSpecialKey.ControlC });

            CancelKeyPress?.Invoke(this, (ConsoleCancelEventArgs)eventArgs);
        }
Exemplo n.º 5
0
        //private void OnConnected(TcpSession client)
        //{
        //    Console.WriteLine("added client!");
        //    clients.Add(client);
        //}

        public void OnMessage(string message)
        {
            if (message?.Trim().Length > 0)
            {
                if (message == "stop")
                {
                    CancelKeyPress?.Invoke(null, null);
                    return;
                }
                lock (_syncObj)
                    messageQueue.Add(message);
                // resetEvent.Set();
            }
        }
Exemplo n.º 6
0
        static Console()
        {
            //Instance = new Console();
            SystemConsole.CancelKeyPress += (sender, args) => CancelKeyPress?.Invoke(sender, args);

            mDefaultError = Error;
            mDefaultOut   = Out;

            Context = new ConsoleContext();

#if CONSOLE_EXTENSIONS
            Error      = new ConsoleWriter(Context, Error);
            ContextOut = new ConsoleWriter(Context, Out);
            Out        = ContextOut;
#endif
        }
Exemplo n.º 7
0
 private static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
 {
     CancelKeyPress.Invoke(sender, e);
 }
Exemplo n.º 8
0
 private void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
 {
     e.Cancel = true;
     CancelKeyPress?.Invoke(this, e);
 }
Exemplo n.º 9
0
 private void OnConsoleCancelKeyPress(object sender, ConsoleCancelEventArgs e)
 {
     CancelKeyPress.Invoke(sender, e);
 }
 protected virtual void OnCancelKeyPress(object sender, ConsoleCancelEventArgs consoleCancelEventArgs)
 {
     CancelKeyPress?.Invoke(sender, consoleCancelEventArgs);
 }
Exemplo n.º 11
0
 public Ui()
 {
     Console.CursorVisible   = false;
     Console.OutputEncoding  = Encoding.Unicode;
     Console.CancelKeyPress += (sender, args) => CancelKeyPress?.Invoke(sender, args);
 }
Exemplo n.º 12
0
 public void RaiseCancelKeyPress()
 {
     CancelKeyPress?.Invoke(this, default);
 }