public void OnUpdate(EventArgs e) { if ((DateTime.UtcNow - LastCheck).TotalSeconds >= 1) { GuiSkin.Text = Utils.GetTitle(false); GuiSkin.Invalidate(); } }
private void Gui_Load(object sender, EventArgs e) { bool HackyWorkAround = true; TextBox_Input.ForeColor = System.Drawing.Color.FromArgb(Convert.ToByte(TShock.Config.BroadcastRGB[0]), Convert.ToByte(TShock.Config.BroadcastRGB[1]), Convert.ToByte(TShock.Config.BroadcastRGB[2])); Action <string> WriteToTextbox = (s) => { bool HasConsoleCleared = false; if (s.Length > 0) { if (s == ": ") { return; } if ((int)s[s.Length - 1] == 52) //Clear console { TextBoxConsoleOutput.MainThreadInvoke(() => { HasConsoleCleared = true; if (HackyWorkAround) { HackyWorkAround = false; TextBoxConsoleOutput.AppendText(string.Empty); return; } TextBoxConsoleOutput.Clear(); }); GuiSkin.Text = Console.Title; GuiSkin.Invalidate(); } TextBoxConsoleOutput.MainThreadInvoke(() => { TextBoxConsoleOutput.Append(s, Console.ForegroundColor); if (HasConsoleCleared) { TextBoxConsoleOutput.Append(string.Empty); } }); } }; main.ConsoleInput = new TaskReader(Console.In); Console.SetOut(new TaskWriter(Console.Out, WriteToTextbox)); //Redirect console output to RichTextBox Console.SetIn(main.ConsoleInput); //Redirect console input to textbox ListBoxUsernames.ListBoxSkin.MouseDoubleClick += ListBoxUsernames_MouseDoubleClick; //Add here because the designer removes the code (because of the .ListBX). pictureBox1.MouseDown += new MouseEventHandler(pictureBox1_MouseDown); pictureBox1.MouseUp += new MouseEventHandler(pictureBox1_MouseUp); pictureBox1.MouseMove += new MouseEventHandler(pictureBox1_MouseMove); pictureBox1.MouseWheel += new MouseEventHandler(pictureBox1_MouseWheel); pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; }
public void ServerLeave(LeaveEventArgs e) { ListBoxUsernames.MainThreadInvoke(() => { ListBoxUsernames.Clear(); ListBoxUsernames.AddRange((from tsplr in TShock.Players where tsplr != null && tsplr.Index != e.Who orderby tsplr.Name select tsplr.Name).ToArray()); }); if (TShock.Utils.ActivePlayers() == 1) { GuiSkin.Text = Utils.GetTitle(true); GuiSkin.Invalidate(); } }
public void OnPostInit(EventArgs e) { GuiSkin.Text = Utils.GetTitle(false); GuiSkin.Invalidate(); }