private void ClearConsoleBtn_Click(object sender, RoutedEventArgs e)
 {
     this.Dispatcher.Invoke(() =>
     {
         ConsoleTextBox.Clear();
         ConsoleTextBox.ScrollToEnd();
     });
 }
        private void HandlePasteCommand()
        {
            string plainText = Clipboard.GetText(TextDataFormat.UnicodeText);

            // make sure paste lands at the end
            ConsoleTextBox.Selection.Select(ConsoleTextBox.Document.ContentEnd, ConsoleTextBox.Document.ContentEnd);
            ConsoleTextBox.ScrollToEnd();
            AddUserText(plainText);
        }
示例#3
0
        public void WriteConsole(string text, Color color)
        {
            Paragraph para = new Paragraph();

            para.Margin     = new Thickness(0);
            para.Foreground = new SolidColorBrush(color);
            para.Inlines.Add(new Run($"[{DateTime.Now:HH:mm:ss}] {text}"));
            ConsoleTextBox.Document.Blocks.Add(para);
            ConsoleTextBox.ScrollToEnd();
        }
        public void ConsoleWriteLine(params object[] content)
        {
            StringBuilder buf = new StringBuilder();

            foreach (var itemt in content)
            {
                buf.Append(itemt.ToString() + " ");
            }
            ConsoleTextBox.Text += "[" + DateTime.Now.ToString("O") + "] " + buf.ToString() + "\n";
            ConsoleTextBox.ScrollToEnd();
        }
 public void WriteColoredText(string ColoredText)
 {
     lock (locker)
     {
         foreach (var part in TextColor.toParts(ColoredText))
         {
             this.AppendText(part.text, part.textColor, false);
         }
         this.AppendText("", Color.White, true);
     }
     ConsoleTextBox.ScrollToEnd();
 }
示例#6
0
        public void ConsoleWriteCommand(string command)
        {
            Paragraph p = new Paragraph();

            p.Inlines.Add(new Bold(new Run(command))
            {
                Foreground = ConsoleCommandBrush
            });

            ConsoleTextBox.Document.Blocks.Add(p);
            ConsoleTextBox.ScrollToEnd();
        }
示例#7
0
        public void ConsoleWriteError(string txt)
        {
            mConsoleBuffer.Append("ERROR:" + txt);

            Paragraph p = new Paragraph();

            p.Inlines.Add(new Bold(new Run("ERROR: " + txt))
            {
                Foreground = Foreground = ConsoleErrorBrush
            });

            ConsoleTextBox.Document.Blocks.Add(p);
            ConsoleTextBox.ScrollToEnd();
        }
示例#8
0
        private void UpdateTrainingStatus(TrainingStatus status)
        {
            string string1 = $"epoch: {status.EpochsDone}/{_epochs} ({status.Correct}/{dataContainer.GetTestingSetSize()} - e: {status.Error})\n";
            string string2 = $"elapsed {status.ElapsedTime.ToString()}, remaining {status.TimeLeft.ToString()}\n";
            //save nn to temp.nn
            string fileName = "temp.nn";

            neuralNetwork.SaveToFile(fileName);
            string string3 = $"Saved nn state to: \"{fileName}\"\n";

            model.ConsoleString += string1 + string2 + string3 + "\n";
            Dispatcher.Invoke(() => ConsoleTextBox.ScrollToEnd());
            //save accuracy and error into a csv file
            using (StreamWriter sw = File.AppendText(_tempCsvFileName))
            {
                sw.WriteLine($"{(double)status.Correct / dataContainer.GetTestingSetSize()},{status.Error}");
            }
        }
示例#9
0
        public void ConsoleWriteText(string txt, bool applyFormat = false)
        {
            mConsoleBuffer.Append(txt + Environment.NewLine);
            Paragraph p = new Paragraph();

            p.LineHeight = 10;
            if (applyFormat == true)
            {
                ApplyStyleToText(txt, ref p);
            }
            else
            {
                p.Inlines.Add(new Bold(new Run(txt))
                {
                    Foreground = ConsoleTextBrush
                });
            }
            ConsoleTextBox.Document.Blocks.Add(p);
            ConsoleTextBox.ScrollToEnd();
        }
示例#10
0
        private void HandleProgressReport(CmdExecutorProgress o)
        {
            if (o.Message != null)
            {
                var message = o.Message;
                message.TrimStart('\n');
                if (!o.Message.EndsWith("\n"))
                {
                    message += "\n";
                }

                ConsoleTextBox.Text += message;
            }

            if (o.OutputStream != null)
            {
                StreamReader reader = new StreamReader(o.OutputStream);
                ConsoleTextBox.Text += reader.ReadToEnd();
            }

            ConsoleTextBox.ScrollToEnd();
            AnimateProgressBar(o);
        }
示例#11
0
 private void ConsoleTextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     ConsoleTextBox.ScrollToEnd();
 }
 private void WriteToConsole(string text)
 {
     ConsoleTextBox.Text += DateTime.Now.TimeOfDay.ToString().Substring(0, 8) + ": " + text + Environment.NewLine;
     ConsoleTextBox.ScrollToEnd();
 }
示例#13
0
        public void StartConsole()
        {
            //SelectedDebugger.SetC2ClockStrobe(0x25); // doesn't seem to do anything
            SelectedDebugger.RunTarget();
            cts   = new CancellationTokenSource();
            token = cts.Token;

            consoleTask = Task.Factory.StartNew(async() =>
            {
                int readAddress = int.Parse(ReadAddress.Replace("0x", ""), System.Globalization.NumberStyles.AllowHexSpecifier);
                while (SelectedDebugger != null)
                {
                    if (token.IsCancellationRequested)
                    {
                        SelectedDebugger.Disconnect();
                        IsConnected       = false;
                        connectionPending = false; // resume scanning
                        return;
                    }

                    // we have to halt the target to read RAM
                    SelectedDebugger.HaltTarget();
                    var flag = SelectedDebugger.GetXRAMMemory(readAddress + ReadLength - 1, 1)[0];
                    if (flag > 0)
                    {
                        // we have a new message! Read the whole thing out
                        var data = SelectedDebugger.GetXRAMMemory(readAddress, flag);
                        var text = Encoding.ASCII.GetString(data);
                        Application.Current.Dispatcher.Invoke(new Action(() => { ConsoleTextBox.AppendText(text); ConsoleTextBox.ScrollToEnd(); }));
                        SelectedDebugger.SetXRAMMemory(readAddress + ReadLength - 1, new byte[1] {
                            0x00
                        });
                    }
                    // resume target
                    SelectedDebugger.RunTarget();
                    await Task.Delay(20);
                }
            }, token);
        }
        public void Write(string text)
        {
            var doc = ConsoleTextBox.Document;
            // todo: process console navigation commands...
            int len = text.Length;

            if (len > 3 && text[len - 1] == 'K' && text[len - 2] == '[' && text[len - 3] == '\x1b')
            {
                // this is an ERASE_END_LINE command which we ignore.
                text = text.Substring(0, len - 3);
            }
            Paragraph last = doc.Blocks.LastBlock as Paragraph;

            if (last == null)
            {
                last = new Paragraph();
                doc.Blocks.Add(last);
            }
            // slide the output into a run "just before" the user editing so that user editing always slides to the bottom of the document.
            Run run = last.Inlines.LastInline as Run;

            if (run != null && (string)run.Tag != "user")
            {
                // Ah, user must have deleted everything, so recreate out setup here...
                run.Foreground = ConsoleTextBrush;

                var userRun = new Run(" ")
                {
                    Tag = "user"
                };
                last.Inlines.Add(userRun);
            }

            if (run == null)
            {
                // different color stops these two runs from getting merged automatically.
                run = new Run()
                {
                    Foreground = ConsoleTextBrush
                };
                last.Inlines.Add(run);

                var userRun = new Run(" ")
                {
                    Tag = "user"
                };
                last.Inlines.Add(userRun);
            }

            if ((string)run.Tag == "user")
            {
                var previousrun = run.PreviousInline as Run;
                if (previousrun == null)
                {
                    var newrun = new Run()
                    {
                        Foreground = ConsoleTextBrush
                    };
                    last.Inlines.InsertBefore(run, newrun);
                    run = newrun;
                }
                else
                {
                    run = previousrun;
                }
            }

            // todo: process binary console commands embedded in the text...
            run.Text += text;

            // scroll to end.
            ConsoleTextBox.Selection.Select(ConsoleTextBox.Document.ContentEnd, ConsoleTextBox.Document.ContentEnd);
            ConsoleTextBox.ScrollToEnd();
        }
 void Append(object obj)
 {
     ConsoleTextBox.AppendText(obj + "");
     ConsoleTextBox.ScrollToEnd();
     ConsoleTextBox.CaretIndex = ConsoleTextBox.Text.Length;
 }
示例#16
0
 void MyConnectionControl_OnConsole(string MessageText)
 {
     ConsoleTextBox.Append(MessageText);
     ConsoleTextBox.ScrollToEnd();
 }
 private void ConsoleText_Changed(object sender, System.Windows.Controls.TextChangedEventArgs e)
 {
     ConsoleTextBox.ScrollToEnd();
 }