using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Windows.Forms; namespace ScreenConnect; public class TextBoxForm : Form { private List entries; private int nextEntryWriteIndex; private TextBox textBox; private TextBox filterTextBox; public TextBoxForm() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0059: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0080: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown ((Form)this)._002Ector(); ((Control)this).Width = 1600; ((Control)this).Height = 800; ((Form)this).KeyPreview = true; ControlCollection controls = ((Control)this).Controls; TextBox val = new TextBox { Dock = (DockStyle)5, ReadOnly = true, Multiline = true, WordWrap = false, ScrollBars = (ScrollBars)3 }; TextBox val2 = val; textBox = val; controls.Add((Control)(object)val2); ControlCollection controls2 = ((Control)this).Controls; TextBox val3 = new TextBox { Visible = false, Dock = (DockStyle)2 }; val2 = val3; filterTextBox = val3; controls2.Add((Control)(object)val2); ((Control)filterTextBox).TextChanged += OnFilterTextBoxTextChanged; ((Control)textBox).ContextMenuStrip = new ContextMenuStrip(); ((ToolStrip)((Control)textBox).ContextMenuStrip).Items.Add("dummy"); ((ToolStripDropDown)((Control)textBox).ContextMenuStrip).Opening += OnContextMenuStripOpening; entries = new List(); WindowsNative.SetTimer(((Control)this).Handle, IntPtr.Zero, 250u, IntPtr.Zero); } protected override void WndProc(ref Message m) { ((Form)this).WndProc(ref m); if (((Message)(ref m)).Msg != 275) { return; } IList list = null; lock (entries) { list = entries.GetRange(nextEntryWriteIndex, entries.Count - nextEntryWriteIndex).ToList(); nextEntryWriteIndex = entries.Count; } if (list.Count == 0) { return; } StringBuilder stringBuilder = new StringBuilder(); string text = ((((Control)filterTextBox).Visible && ((Control)filterTextBox).Text != string.Empty) ? ((Control)filterTextBox).Text : null); foreach (string item in list) { try { if (text == null || Regex.IsMatch(item, text, RegexOptions.IgnoreCase | RegexOptions.Singleline)) { stringBuilder.Append(item); } } catch { } } if (stringBuilder.Length != 0) { int selectionStart = ((TextBoxBase)textBox).SelectionStart; int selectionLength = ((TextBoxBase)textBox).SelectionLength; ((TextBoxBase)textBox).AppendText(stringBuilder.ToString()); ((TextBoxBase)textBox).Select(((TextBoxBase)textBox).TextLength, 0); ((TextBoxBase)textBox).ScrollToCaret(); ((TextBoxBase)textBox).Select(selectionStart, selectionLength); } } private void OnContextMenuStripOpening(object sender, CancelEventArgs e) { ((ToolStrip)((Control)textBox).ContextMenuStrip).Items.Clear(); PopulateContextMenuStripItems(((Control)textBox).ContextMenuStrip); } protected virtual void PopulateContextMenuStripItems(ContextMenuStrip contextMenuStrip) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown ((ToolStrip)contextMenuStrip).Items.Add((ToolStripItem)new ToolStripMenuItem("Select All", (Image)null, (EventHandler)delegate { ((TextBoxBase)textBox).SelectAll(); }, (Keys)131137)); ((ToolStrip)contextMenuStrip).Items.Add((ToolStripItem)new ToolStripSeparator()); ((ToolStrip)contextMenuStrip).Items.Add((ToolStripItem)new ToolStripMenuItem("Clear", (Image)null, (EventHandler)delegate { Clear(); }, (Keys)113)); ((ToolStrip)contextMenuStrip).Items.Add((ToolStripItem)new ToolStripMenuItem(((Control)filterTextBox).Visible ? "Hide Filter" : "Show Filter", (Image)null, (EventHandler)delegate { ToggleFilter(); }, (Keys)114)); } protected override void OnKeyDown(KeyEventArgs e) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 ((Control)this).OnKeyDown(e); if ((int)e.KeyCode == 113) { Clear(); } else if ((int)e.KeyCode == 114) { ToggleFilter(); } else if (e.Control && (int)e.KeyCode == 65) { ((TextBoxBase)textBox).SelectAll(); } } private void ToggleFilter() { lock (entries) { ((Control)filterTextBox).Visible = !((Control)filterTextBox).Visible; ((TextBoxBase)textBox).Clear(); nextEntryWriteIndex = 0; ((TextBoxBase)filterTextBox).SelectAll(); ((Control)filterTextBox).Focus(); } } private void OnFilterTextBoxTextChanged(object sender, EventArgs e) { lock (entries) { ((TextBoxBase)textBox).Clear(); nextEntryWriteIndex = 0; } } public void Clear() { lock (entries) { ((TextBoxBase)textBox).Clear(); entries.Clear(); nextEntryWriteIndex = 0; } } public void Write(string message) { lock (entries) { entries.Add(message); } } }