private void WriteErrorResult(Exception ex)
        {
            ConsoleTextBox.AppendText(string.Format("\r\n****** {0} ******\r\n", ex.GetType().Name));
            if (enableVerboseOutputCheckBox.Checked)
            {
                ConsoleTextBox.AppendText(string.Format("[ Message ]\r\n\t{0}\r\n", ex));
            }
            else
            {
                ConsoleTextBox.AppendText(string.Format("[ Message ]\r\n\t{0}\r\n", ex.Message));
            }

            if (ex is ConfigurationErrorsException)
            {
                var cex = ex as ConfigurationErrorsException;
                ConsoleTextBox.AppendText(string.Format("[ XML Line # ] {0}\r\n", cex.Line));
                ConsoleTextBox.AppendText(string.Format("[ {0} Errors ]\r\n", cex.Errors.Count));
                // If error count == 1, it's the error we already printed.
                if (cex.Errors.Count > 1)
                {
                    foreach (ConfigurationErrorsException err in cex.Errors)
                    {
                        ConsoleTextBox.AppendText(string.Format("\t+ {0}\r\n", err.Message));
                    }
                }
                //cex.Errors
                if (false && ex.InnerException != null)
                {
                    ConsoleTextBox.AppendText(string.Format("\r\n------ {0} ------\r\n", cex.GetBaseException().GetType().Name));
                    ConsoleTextBox.AppendText(string.Format("[ Message ]\r\n\t{0}\r\n", cex.GetBaseException().Message));
                }
            }
            //ConsoleTextBox.AppendText(string.Format("[ StackTr ]\r\n\t{0}\r\n", ex.StackTrace));
            ConsoleTextBox.AppendText("\r\n*****************\r\n\r\n");
        }
示例#2
0
 public void Write(string s)
 {
     if (!quiet)
     {
         textBox.AppendText(s);
     }
 }
        private void WriteEndResult()
        {
            ConsoleTextBox.AppendText(string.Format("\r\n========================"));
            ConsoleTextBox.AppendText(string.Format("\r\n== {0}", "Demo Complete!"));
            ConsoleTextBox.AppendText(string.Format("\r\n========================\r\n"));

            //ConsoleTextBox.AppendText("\r\n*** Demo Complete! **\r\n\r\n");
        }
示例#4
0
 public void WriteLineToConsole(String line)
 {
     if (!(ConsoleTextBox is null))
     {
         ConsoleTextBox.BeginInvoke((MethodInvoker) delegate {
             ConsoleTextBox.AppendText(line + "\n");
         });
     }
 }
示例#5
0
 public MainWindow()
 {
     InitializeComponent();
     jsExecutor.Initialize((s) =>
     {
         ConsoleTextBox.AppendText(s + "\n");
     });
     textEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(textEditor.Options);
     InitializeTextMarkerService();
 }
示例#6
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            int[] List;
            int   nBoards = 0;

            // with extra FTDI Drivers this can take a long time
            // so only call occasionally when not connected
            if (!Connected && ++skip == 10)
            {
                skip = 0;

                // check how many boards connected
                List = KM.GetBoards(out nBoards);
                if (nBoards > 0)
                {
                    Connected = true;
                    this.Text = String.Format("Dynomotion C# Forms App - Connected - USB location {0:X}", List[0]);
                }
                else
                {
                    Connected = false;
                    this.Text = "Dynomotion C# Forms App - Disconnected";
                }
            }

            if (Connected && KM.WaitToken(100) == KMOTION_TOKEN.KMOTION_LOCKED)
            {
                KM_MainStatus MainStatus;

                try
                {
                    MainStatus = KM.GetStatus(false);  // we already have a lock
                    KM.ReleaseToken();
                    XPos.Text        = String.Format("{0:F1}", MainStatus.Destination[0]);
                    XEnabled.Checked = (MainStatus.Enables & (1 << 0)) != 0;
                }
                catch (DMException ex) // in case disconnect in the middle of reading status
                {
                    KM.ReleaseToken();
                    MessageBox.Show(ex.InnerException.Message);
                }
            }
            else
            {
                Connected = false;
            }

            ConsoleMutex.WaitOne();  // make sure we are thread safe
            if (ConsoleMessageReceived != null && ConsoleMessageReceived != "")
            {
                ConsoleTextBox.AppendText(ConsoleMessageReceived);
                ConsoleMessageReceived = "";
            }
            ConsoleMutex.ReleaseMutex();
        }
 private void WriteStartResult(string resultName)
 {
     if (ConsoleTextBox.Text.Length > 0)
     {
         // Add space if console has existing text.
         ConsoleTextBox.AppendText(string.Format("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"));
     }
     ConsoleTextBox.AppendText(string.Format("\r\n========================"));
     ConsoleTextBox.AppendText(string.Format("\r\n== {0}", resultName));
     ConsoleTextBox.AppendText(string.Format("\r\n========================\r\n"));
 }
示例#8
0
 private void ISLogger_MessageOut(object sender, string text)
 {
     if (ConsoleTextBox.InvokeRequired)
     {
         ConsoleTextBox.Invoke(new Action(() => ISLogger_MessageOut(null, text)));
     }
     else
     {
         ConsoleTextBox.AppendText(text);
     }
 }
示例#9
0
        //private void ConsoleAppendText(String str)
        //{
        //    this.ConsoleTextBox.ConsoleAppendText(str);
        //}

        private void ConsoleAppendText(String str)
        {
            if (this.ConsoleTextBox.InvokeRequired)
            {
                this.Invoke(ConsoleAppendTextCallBack, str);
            }
            else
            {
                ConsoleTextBox.AppendText(str);
            }
        }
示例#10
0
 public void WriteLineToConsole(String line)
 {
     if (!(ConsoleTextBox is null))
     {
         lock (locker)
         {
             ConsoleTextBox.BeginInvoke((MethodInvoker) delegate
             {
                 ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length;
                 ConsoleTextBox.AppendText(line + "\n");
             });
         }
         DoAutoScroll();
     }
 }
示例#11
0
 private void LogError(string text)
 {
     try
     {
         if (InvokeRequired)
         {
             Invoke(new Action(() => { LogError(text); }));
         }
         else
         {
             ConsoleTextBox.AppendText(text + "\r\n");
         }
     }
     catch { }
 }
示例#12
0
 public void AppendColoredTextToConsole(String line, Color color, bool addNewLine = false)
 {
     if (!(ConsoleTextBox is null))
     {
         ConsoleTextBox.BeginInvoke((MethodInvoker) delegate
         {
             ConsoleTextBox.SuspendLayout();
             ConsoleTextBox.SelectionColor = color;
             ConsoleTextBox.AppendText(addNewLine
                 ? $"{line}{Environment.NewLine}"
                 : line);
             ConsoleTextBox.ScrollToCaret();
             ConsoleTextBox.ResumeLayout();
         });
     }
 }
示例#13
0
 private void LogError(string text)
 {
     try
     {
         if (InvokeRequired)
         {
             Invoke(new Action(() => { LogError(text); }));
         }
         else
         {
             //TODO: error logging..
             ConsoleTextBox.AppendText(text + "\r\n");
             //StatusLabel.Text = text;
             //MessageBox.Show(text);
         }
     }
     catch { }
 }
示例#14
0
 private void RunButton_Click(object sender, RoutedEventArgs e)
 {
     textMarkerService.RemoveAll(m => true);
     try
     {
         ConsoleTextBox.Foreground = Brushes.Black;
         ConsoleTextBox.Clear();
         jsExecutor.Execute(textEditor.Text);
     }
     catch (JavascriptException ex)
     {
         ConsoleTextBox.Foreground = Brushes.Red;
         ConsoleTextBox.AppendText($"line {ex.Line} col {ex.StartColumn}: {ex.Message}");
         var         lineIndex = FindIndex(ex.Line - 1);
         ITextMarker marker    = textMarkerService.Create(lineIndex + ex.StartColumn, ex.EndColumn - ex.StartColumn);
         marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
         marker.MarkerColor = Colors.Red;
     }
 }
示例#15
0
 private void AppendToLog(string text)
 {
     try
     {
         var textToAppend = DateTime.Now + " | " + text + "\n";
         try
         {
             ConsoleTextBox.AppendText(textToAppend);
         }
         catch (InvalidOperationException ex)
         {
             ConsoleTextBox.Invoke(new Action(() => ConsoleTextBox.AppendText(textToAppend)));
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex.Message, ex);
         throw;
     }
 }
示例#16
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);
        }
        private void RunDemoButton_Click(object sender, EventArgs e)
        {
            try
            {
                switch ((string)DemoSelectComboBox.SelectedItem)
                {
                case "Sample Demo":
                    RunSampleConfigDemo("");
                    break;

                case "School Demo":
                    RunSchoolRegistryConfigDemo("");
                    break;

                case "Basic Demo - Config File":
                    throw new Exception("Not yet implemented.");
                    break;

                case "Sample Demo - Config File":
                    RunSampleConfigDemo("SampleConfigDemo01.config");
                    // RunSampleConfigDemo_File();
                    break;

                case "School Demo - Config File":
                    throw new Exception("Not yet implemented.");
                    break;

                default:
                    throw new Exception("Invalid demo selection.");
                    break;
                }
            }
            catch (Exception ex)
            {
                ConsoleTextBox.AppendText("\r\nException Occured: " + ex + "\r\n");
            }
        }
 private void WriteResult(string format, params object[] vals)
 {
     ConsoleTextBox.AppendText(string.Format(format, vals));
 }
 private void WriteStartResult(string resultName)
 {
     ConsoleTextBox.AppendText(string.Format("\r\n===== {0} =====\r\n", resultName));
 }
示例#20
0
 private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
 {
     this.Invoke(new MethodInvoker(() =>
     {
         if (!String.IsNullOrEmpty(e.Data))
         {
             if (!string.IsNullOrWhiteSpace(ConsoleTextBox.Text))
             {
                 ConsoleTextBox.AppendText("\r\n" + e.Data);
                 if (e.Data.Contains("UUID of player"))
                 {
                     string[] line   = e.Data.Split(' ');
                     this.playerUUID = line[line.Length - 1];
                 }
                 string data = e.Data;
                 if (data.Contains("Done (") && data.Contains("type \"help\" or \"?\""))
                 {
                     if (this.playerManager.FileNotFound())
                     {
                         this.playerManager.RetryFileParsing();
                     }
                 }
                 if (data.Contains("logged in"))
                 {
                     string[] line = e.Data.Split(' ');
                     string name   = line[2].Split('[')[0];
                     Console.WriteLine(name);
                     Dictionary <object, string> player_information = new Dictionary <object, string>
                     {
                         ["name"]        = name,
                         ["ip"]          = line[2].Split('/')[1].Replace("]", string.Empty),
                         ["uuid"]        = this.playerUUID,
                         ["time-joined"] = DateTime.Now.ToString("h:mm tt"),
                         ["whitelisted"] = this.playerManager.PlayerIsWhitelisted(name).ToString(),
                         ["op"]          = this.playerManager.PlayerIsOp(name).ToString()
                     };
                     Console.WriteLine(String.Format("Player {0} joined with IP {1} and UUID {2}", player_information["name"], player_information["ip"], player_information["uuid"]));
                     Add_Player(player_information);
                     players_list.Add(player_information["name"], player_information);
                     this.playerUUID = "";
                 }
                 else if (data.Contains("left the game"))
                 {
                     string name = e.Data.Split(' ')[2];
                     players_list.Remove(name);
                     Remove_Player(name);
                 }
                 if (data.Contains("Opped") || data.Contains("opped"))
                 {
                     string[] line = e.Data.Split(' ');
                     string name   = line[line.Length - 1];
                     foreach (DataGridViewRow row in this.PlayersGridView.Rows)
                     {
                         if (row.Cells["Name"].Value.ToString().Equals(name))
                         {
                             row.Cells["OP"].Value = data.Contains("Opped") ? "True" : "False";
                             break;
                         }
                     }
                 }
                 else if (data.Contains("from the whitelist") || data.Contains("to the whitelist"))
                 {
                     string[] line = e.Data.Split(' ');
                     string name   = line[3];
                     foreach (DataGridViewRow row in this.PlayersGridView.Rows)
                     {
                         if (row.Cells["Name"].Value.ToString().Equals(name))
                         {
                             row.Cells["Whitelisted"].Value = data.Contains("from the whitelist") ? "False" : "True";
                             break;
                         }
                     }
                 }
             }
             else
             {
                 ConsoleTextBox.AppendText(e.Data);
             }
             ConsoleTextBox.Select(ConsoleTextBox.TextLength, 0);
             ConsoleTextBox.ScrollToCaret();
         }
     }));
 }
示例#21
0
        private void button1_Click(object sender, EventArgs e)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            OutputBox.Clear();
            Operation op       = new Operation();
            string    compiled = "";

            string[] lineIn = new string[4];
            string[] lineInTemp;
            string   lineOut = "";
            int      lineNum = 0;
            int      hexLine = 0;

            foreach (string element in InputBox.Lines)
            {
                for (int i = 0; i < 4; i++)
                {
                    lineIn[i] = "0000";
                }
                lineInTemp = element.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < lineInTemp.Length; i++)
                {
                    lineInTemp[i].Trim();
                }
                for (int i = 0; i < lineInTemp.Length; i++)
                {
                    lineIn[i] = lineInTemp[i];
                }
                try
                {
                    op = Ops.Find(x => x.mnemonic == lineIn[0]);
                    if (op == null)
                    {
                        ConsoleTextBox.Text += "ERROR on line " + lineNum + ": operation \"" + lineIn[0] + "\" not recognized" + Environment.NewLine;
                        return;
                    }
                    lineOut = op.OPCode;
                    if (op.parameters.Length == lineInTemp.Length - 1)
                    {
                        if (op.parameters.Contains('D'))
                        {
                            if (lineIn[1][0] == 'D' && lineIn[1][1] - '0' <= 7)
                            {
                                lineOut += Convert.ToString(lineIn[1][1] - '0', 2).PadLeft(3, '0');
                            }
                            else
                            {
                                ConsoleTextBox.Text += "ERROR on line " + lineNum + ": invalid address for \"D\"" + Environment.NewLine;
                                return;
                            }
                        }
                        else
                        {
                            lineOut += "000";
                        }

                        if (op.parameters.Contains('A'))
                        {
                            if (lineIn[1][0] == 'A' && lineIn[1][1] - '0' <= 7)
                            {
                                lineOut += Convert.ToString(lineIn[1][1] - '0', 2).PadLeft(3, '0');
                            }
                            else if ((lineIn[2][0] == 'A' && lineIn[2][1] - '0' <= 7))
                            {
                                lineOut += Convert.ToString(lineIn[2][1] - '0', 2).PadLeft(3, '0');
                            }
                            else
                            {
                                ConsoleTextBox.Text += "ERROR on line " + lineNum + ": invalid address for \"A\"" + Environment.NewLine;
                                return;
                            }
                        }
                        else
                        {
                            lineOut += "000";
                        }

                        if (op.parameters.Contains('B'))
                        {
                            if (lineIn[1][0] == 'B' && lineIn[1][1] - '0' <= 7)
                            {
                                lineOut += Convert.ToString(lineIn[1][1] - '0', 2).PadLeft(3, '0');
                            }
                            else if ((lineIn[2][0] == 'B' && lineIn[2][1] - '0' <= 7))
                            {
                                lineOut += Convert.ToString(lineIn[2][1] - '0', 2).PadLeft(3, '0');
                            }
                            else if ((lineIn[3][0] == 'B' && lineIn[3][1] - '0' <= 7))
                            {
                                lineOut += Convert.ToString(lineIn[3][1] - '0', 2).PadLeft(3, '0');
                            }
                            else
                            {
                                ConsoleTextBox.Text += "ERROR on line " + lineNum + ": invalid address for \"B\"" + Environment.NewLine;
                                return;
                            }
                        }
                        else
                        {
                            lineOut += "000";
                        }
                    }
                    else
                    {
                        ConsoleTextBox.Text += "ERROR on line " + lineNum + ": invalid number of parameters" + Environment.NewLine;
                        return;
                    }
                }
                catch (ArgumentNullException)
                {
                    ConsoleTextBox.Text += "ERROR on line " + lineNum + ": operation \"" + lineIn[0] + "\" not recognized" + Environment.NewLine;
                    return;
                }
                if ((string)OutputTypeList.SelectedItem == "Binary")
                {
                    if (CScheckBox.Checked && InputBox.Lines.Length > lineNum + 1)
                    {
                        lineOut += ",";
                    }
                    //if (MLcheckBox.Checked && InputBox.Lines.Length > lineNum + 1)
                    compiled += lineOut + Environment.NewLine;
                    //else

                    //compiled += lineOut;
                }
                else
                {
                    compiled = compiled.Insert(hexLine, Convert.ToInt32(lineOut, 2).ToString("X").PadLeft(4, '0'));
                    if (lineNum == 15)
                    {
                        compiled += Environment.NewLine;
                        hexLine  += 65;
                        lineNum   = 0;
                    }
                }
                lineNum++;
            }
            stopwatch.Stop();
            OutputBox.Text = compiled;
            ConsoleTextBox.AppendText("Program compiled successfully in  " + stopwatch.ElapsedMilliseconds + "ms." + Environment.NewLine);
        }
 private void WriteEndResult()
 {
     ConsoleTextBox.AppendText("*** Demo Complete! **\r\n\r\n");
 }
示例#23
0
 public void Log(String log)
 {
     ConsoleTextBox.AppendText(log + "\r\n");
     ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length;
     ConsoleTextBox.ScrollToCaret();
 }
 void Append(object obj)
 {
     ConsoleTextBox.AppendText(obj + "");
     ConsoleTextBox.ScrollToEnd();
     ConsoleTextBox.CaretIndex = ConsoleTextBox.Text.Length;
 }