Beispiel #1
0
        public void updateTextBox(string msg)
        {
            // 有調用需求
            if (this.InvokeRequired)
            {
                // 建立Dalegate 物件

                /*
                 * 建立委派物件(TextBoxDalegate)並委派使用"updateTextBox"方法
                 */
                TextBoxDalegate TBDalegate = new TextBoxDalegate(updateTextBox);

                // 調用委派的方法
                this.Invoke(TBDalegate, msg);
            }
            else
            {
                int lineCount = ConsoleTextBox.GetLineFromCharIndex(ConsoleTextBox.Text.Length);

                if (lineCount >= 100)
                {
                    ConsoleTextBox.Text = ConsoleTextBox.Text.Remove(0, (ConsoleTextBox.Lines[0].Length + Environment.NewLine.Length));
                }

                ConsoleTextBox.Text          += msg;
                ConsoleTextBox.Text          += Environment.NewLine;
                ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length;
                ConsoleTextBox.ScrollToCaret();
            }
        }
Beispiel #2
0
 private void ConsoleTextBox_TextChanged(object sender, EventArgs e)
 {
     if (AutoScrollMenuItem.Checked)
     {
         ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length;
         ConsoleTextBox.ScrollToCaret();
     }
 }
 public void WriteToConsole(string message)
 {
     ConsoleTextBox.Text += message + ((message.IndexOf((char)27) != -1)?"":"\n");
     if (ConsoleTextBox.Text.Contains((char)27))
     {
         ConsoleTextBox_TextChanged(null, null);
     }
     ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length;
     ConsoleTextBox.ScrollToCaret();
 }
Beispiel #4
0
 private void DoAutoScroll()
 {
     if (AutoScrollMenuItem.Checked)
     {
         ConsoleTextBox.BeginInvoke((MethodInvoker) delegate
         {
             ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length;
             ConsoleTextBox.ScrollToCaret();
         });
     }
 }
Beispiel #5
0
 /// <summary>
 /// Function to write text on the ConsoleTextBox
 /// </summary>
 /// <param name="text"></param>
 public void WriteTextOnConsole(string text)
 {
     if (this.ConsoleTextBox.InvokeRequired)
     {
         WriteTextOnConsoleDelegate d = new WriteTextOnConsoleDelegate(WriteTextOnConsole);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         this.ConsoleTextBox.AppendText("\r\n" + text);
         // Scrool automatique de la textBox.
         ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length;
         ConsoleTextBox.ScrollToCaret();
     }
 }
Beispiel #6
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();
         });
     }
 }
Beispiel #7
0
 public ServerGui()
 {
     InitializeComponent();
     ConsoleTextBox.VisibleChanged += (sender, e) =>
     {
         if (ConsoleTextBox.Visible)
         {
             ConsoleTextBox.SelectionStart = ConsoleTextBox.TextLength;
             ConsoleTextBox.ScrollToCaret();
         }
     };
     playersDataGridData.Columns.Add("Name");
     playersDataGridData.Columns.Add("IP");
     playersDataGridData.Columns.Add("Time Joined");
     playersDataGridData.Columns.Add("Whitelisted");
     playersDataGridData.Columns.Add("OP");
     PlayersGridView.DataSource = playersDataGridData;
     this.playerManager         = new PlayerManager(this.workingDirectory);
 }
Beispiel #8
0
        private void FinishedProcess(string dataReceived)
        {
            if (tabControl1.SelectedIndex == 0)
            {
                if (dataReceived != "")
                {
                    if (dataReceived.Contains("error"))
                    {
                        dataReceived = dataReceived.Substring(dataReceived.IndexOf("error"));
                    }
                    else
                    {
                        dataReceived = dataReceived.Substring(dataReceived.IndexOf("avrdude.exe"));
                    }
                    ConsoleTextBox.Text += dataReceived;

                    ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length;
                    ConsoleTextBox.ScrollToCaret();
                    ConsoleTextBox.Cursor = Cursors.IBeam;
                }
            }
            else if (tabControl1.SelectedIndex == 1)
            {
                if (dataReceived != "")
                {
                    ConsoleFuseTextBox.Text += dataReceived;

                    ConsoleFuseTextBox.SelectionStart = ConsoleTextBox.Text.Length;
                    ConsoleFuseTextBox.ScrollToCaret();
                    ConsoleFuseTextBox.Cursor = Cursors.IBeam;
                }
            }

            Form1.ActiveForm.Cursor = Cursors.Arrow;
            Form1.ActiveForm.Text   = "Avr Flasher Tool " + Properties.Settings.Default.Version;
        }
Beispiel #9
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();
         }
     }));
 }
Beispiel #10
0
 public void Log(String log)
 {
     ConsoleTextBox.AppendText(log + "\r\n");
     ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length;
     ConsoleTextBox.ScrollToCaret();
 }
Beispiel #11
0
 private void ConsoleTextBox_TextChanged(object sender, EventArgs e)
 {
     ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length;
     ConsoleTextBox.ScrollToCaret();
 }