Beispiel #1
0
        private async void InputThread()
        {
            try
            {
                while (true)
                {
                    char ch = await ConsoleService.ReadCharAsync();

                    SerialPortService.Write(ch);
                }
            }
            catch (Exception e)
            {
                await DialogService.ShowErrorDialogAsync(e.Message, "Exception");
            }
        }
        private async Task PasteAndSendCommandImpl()
        {
            try
            {
                if (ConsoleService.IsEnabled)
                {
                    string text = ClipboardService.GetText();

                    int index = ConsoleService.SelectionStart;
                    await ConsoleService.InsertText(index, text);

                    SerialPortService.Write(text);
                }
            }
            catch (ArgumentException e)
            {
                await DialogService.ShowErrorDialogAsync(e.Message, "Exception");
            }
        }
        private async Task PasteAndSendLinesCommandImpl()
        {
            try
            {
                if (ConsoleService.IsEnabled)
                {
                    string text = ClipboardService.GetText();

                    var lines = Regex.Split(text, $"(?={SettingsService.NewLine})");
                    if (lines.Length > 1)
                    {
                        foreach (var line in lines)
                        {
                            if (!Session.IsRunning)
                            {
                                // The session has ended break the loop.
                                break;
                            }

                            int index = ConsoleService.SelectionStart;
                            await ConsoleService.InsertText(index, line);

                            SerialPortService.Write(line);

                            if (SettingsService.LinePushDelay > 0)
                            {
                                await TaskHelpers.Delay(SettingsService.LinePushDelay);
                            }
                        }
                    }
                }
            }
            catch (ArgumentException e)
            {
                await DialogService.ShowErrorDialogAsync(e.Message, "Exception");
            }
        }