From 89ee15c1b3acd70766084f009b3f7b4266ca3ceb Mon Sep 17 00:00:00 2001 From: Carbon Date: Wed, 23 Sep 2020 22:35:43 -0500 Subject: [PATCH 1/4] Fixes confusion with the second console window --- AmongUsCapture/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AmongUsCapture/Program.cs b/AmongUsCapture/Program.cs index a987412a..5aaf0685 100644 --- a/AmongUsCapture/Program.cs +++ b/AmongUsCapture/Program.cs @@ -11,7 +11,7 @@ namespace AmongUsCapture { static class Program { - private static bool debugGui = false; + private static bool doConsole = false; public static ConsoleInterface conInterface = null; /// /// The main entry point for the application. @@ -19,7 +19,7 @@ static class Program [STAThread] static void Main() { - if(!debugGui) + if(doConsole) { AllocConsole(); // needs to be the first call in the program to prevent weird bugs } From 92e9a0263d6d076b5095df675ea8c8fb9a77ed70 Mon Sep 17 00:00:00 2001 From: Carbon Date: Thu, 24 Sep 2020 10:21:05 -0500 Subject: [PATCH 2/4] Added a context menu to the Console window for AutoScroll Setting. Also enabled AutoScroll by default. --- .../DesignTimeBuild/.dtbcache.v2 | Bin 74548 -> 74548 bytes AmongUsCapture/AmongUsCapture - Backup.csproj | 28 +++++++++++ AmongUsCapture/UserForm.Designer.cs | 45 +++++++++++++++++- AmongUsCapture/UserForm.cs | 20 ++++++++ AmongUsCapture/UserForm.resx | 3 -- 5 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 AmongUsCapture/AmongUsCapture - Backup.csproj diff --git a/.vs/AmongUsCapture/DesignTimeBuild/.dtbcache.v2 b/.vs/AmongUsCapture/DesignTimeBuild/.dtbcache.v2 index d8dd94da602bb1faedbc9c0cdc1924a65084ba98..201af303c52a03f40501b455b62a1f1028af15f3 100644 GIT binary patch delta 327 zcmXZWPfG$(6b112#u>A8`fq7vYO5d+XVfRQN?S<~;j$Jn<9ibcC8*0Ft9_7{K1Ew0 zYU#p7^jYdcD;^F2m6!FR zT^FvWq?L6%CohB)b*V~OT1va%dPQYrg#)Lf52)}ce2vUmW@H-e<~6H9cd`$WKnzlP z4JzXXKLl>Y;B34HFXL1=l<7FF3)N|}oB!o5e2+r#=$p{=gHZL);mv=C+sTQivA>vf zR!Nksk#!Oyak4=+$reeFZIUD@!bzG;b3~BcBS#GbsNbQ{<2?+Papw7x$J1q8#w85l g3eI5|BR^D3oW})R>~=4&6su03eHa+81B15`zl>L74FCWD delta 453 zcmdmTjAhF)7N#>y6Pf(njSMZ!%}vaV43d+~jgu{t4N{UVOj0c^%`J?L4HA=0jFSyb z%@U0gEi6rpjg68mEeuRe3{s4fO-<7*lTroEi-*`4Wsji$vxV7NN{UKTA!0z+=%?i5FbJVJ03^nTD#pN~2NDf}8YMaT24f&&<>V9J z>}-95LB30gaV{+?O3f>Yamvh#K{&@bKNsjbJ*Z?@YEf|}kPCBK5Xb~mY$hmS(0Cx + + + WinExe + netcoreapp3.1 + true + app.manifest + + + + true + + + + true + none + + + + + all + + + + + icon.ico + + \ No newline at end of file diff --git a/AmongUsCapture/UserForm.Designer.cs b/AmongUsCapture/UserForm.Designer.cs index 23c7dfc6..6c9e1023 100644 --- a/AmongUsCapture/UserForm.Designer.cs +++ b/AmongUsCapture/UserForm.Designer.cs @@ -28,6 +28,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.UserSettings = new System.Windows.Forms.GroupBox(); this.ConnectCodeGB = new System.Windows.Forms.GroupBox(); @@ -37,6 +38,9 @@ private void InitializeComponent() this.CurrentState = new System.Windows.Forms.Label(); this.ConsoleGroupBox = new System.Windows.Forms.GroupBox(); this.ConsoleTextBox = new System.Windows.Forms.RichTextBox(); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.AutoScrollMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.checkBox1 = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -45,6 +49,7 @@ private void InitializeComponent() this.ConnectCodeGB.SuspendLayout(); this.CurrentStateGroupBox.SuspendLayout(); this.ConsoleGroupBox.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // // splitContainer1 @@ -141,6 +146,7 @@ private void InitializeComponent() // ConsoleGroupBox // this.ConsoleGroupBox.Controls.Add(this.ConsoleTextBox); + this.ConsoleGroupBox.Controls.Add(this.checkBox1); this.ConsoleGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.ConsoleGroupBox.Location = new System.Drawing.Point(0, 0); this.ConsoleGroupBox.Name = "ConsoleGroupBox"; @@ -152,8 +158,8 @@ private void InitializeComponent() // ConsoleTextBox // this.ConsoleTextBox.AutoWordSelection = true; - this.ConsoleTextBox.BackColor = System.Drawing.SystemColors.Control; this.ConsoleTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.ConsoleTextBox.ContextMenuStrip = this.contextMenuStrip1; this.ConsoleTextBox.Dock = System.Windows.Forms.DockStyle.Fill; this.ConsoleTextBox.Location = new System.Drawing.Point(3, 19); this.ConsoleTextBox.Name = "ConsoleTextBox"; @@ -161,6 +167,35 @@ private void InitializeComponent() this.ConsoleTextBox.Size = new System.Drawing.Size(540, 454); this.ConsoleTextBox.TabIndex = 0; this.ConsoleTextBox.Text = ""; + this.ConsoleTextBox.TextChanged += new System.EventHandler(this.ConsoleTextBox_TextChanged); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.AutoScrollMenuItem}); + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(130, 26); + // + // AutoScrollMenuItem + // + this.AutoScrollMenuItem.BackColor = System.Drawing.SystemColors.ControlDark; + this.AutoScrollMenuItem.Checked = true; + this.AutoScrollMenuItem.CheckOnClick = true; + this.AutoScrollMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.AutoScrollMenuItem.ForeColor = System.Drawing.SystemColors.ControlLightLight; + this.AutoScrollMenuItem.Name = "AutoScrollMenuItem"; + this.AutoScrollMenuItem.Size = new System.Drawing.Size(129, 22); + this.AutoScrollMenuItem.Text = "AutoScroll"; + // + // checkBox1 + // + this.checkBox1.AutoSize = true; + this.checkBox1.Location = new System.Drawing.Point(250, 315); + this.checkBox1.Name = "checkBox1"; + this.checkBox1.Size = new System.Drawing.Size(83, 19); + this.checkBox1.TabIndex = 2; + this.checkBox1.Text = "checkBox1"; + this.checkBox1.UseVisualStyleBackColor = true; // // UserForm // @@ -170,6 +205,7 @@ private void InitializeComponent() this.Controls.Add(this.splitContainer1); this.Name = "UserForm"; this.Text = "Among Us Capture"; + this.Load += new System.EventHandler(this.OnLoad); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); @@ -180,6 +216,8 @@ private void InitializeComponent() this.CurrentStateGroupBox.ResumeLayout(false); this.CurrentStateGroupBox.PerformLayout(); this.ConsoleGroupBox.ResumeLayout(false); + this.ConsoleGroupBox.PerformLayout(); + this.contextMenuStrip1.ResumeLayout(false); this.ResumeLayout(false); } @@ -189,11 +227,14 @@ private void InitializeComponent() private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.GroupBox UserSettings; private System.Windows.Forms.GroupBox ConsoleGroupBox; - private System.Windows.Forms.RichTextBox ConsoleTextBox; private System.Windows.Forms.Button SubmitButton; private System.Windows.Forms.TextBox ConnectCodeBox; private System.Windows.Forms.GroupBox CurrentStateGroupBox; private System.Windows.Forms.Label CurrentState; private System.Windows.Forms.GroupBox ConnectCodeGB; + private System.Windows.Forms.RichTextBox ConsoleTextBox; + private System.Windows.Forms.CheckBox checkBox1; + private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; + private System.Windows.Forms.ToolStripMenuItem AutoScrollMenuItem; } } \ No newline at end of file diff --git a/AmongUsCapture/UserForm.cs b/AmongUsCapture/UserForm.cs index 43a95726..f90aa1a6 100644 --- a/AmongUsCapture/UserForm.cs +++ b/AmongUsCapture/UserForm.cs @@ -27,6 +27,14 @@ public UserForm(ClientSocket sock) } + private void OnLoad(object sender, EventArgs e) + { + for (int i = 0; i < 100; i++) + { + WriteLineToConsole(i.ToString()); + } + } + private void OnChatMessageAdded(object sender, ChatMessageEventArgs e) { WriteLineToConsole($"[CHAT] {e.Sender}: {e.Message}"); @@ -105,6 +113,16 @@ private void SubmitButton_Click(object sender, EventArgs e) } } + private void ConsoleTextBox_TextChanged(object sender, EventArgs e) + { + if (AutoScrollMenuItem.Checked) + { + ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length; + ConsoleTextBox.ScrollToCaret(); + } + } + + public void WriteLineToConsole(String line) { if(!(ConsoleTextBox is null)) @@ -115,5 +133,7 @@ public void WriteLineToConsole(String line) } } + + } } diff --git a/AmongUsCapture/UserForm.resx b/AmongUsCapture/UserForm.resx index 182bea4f..f298a7be 100644 --- a/AmongUsCapture/UserForm.resx +++ b/AmongUsCapture/UserForm.resx @@ -57,7 +57,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - \ No newline at end of file From b30b0fd31a46fcf04e688b3413cd76f5db89b298 Mon Sep 17 00:00:00 2001 From: Carbon Date: Thu, 24 Sep 2020 10:25:39 -0500 Subject: [PATCH 3/4] Remove Debug function to test autoscroll --- AmongUsCapture/UserForm.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/AmongUsCapture/UserForm.cs b/AmongUsCapture/UserForm.cs index f90aa1a6..50cb226b 100644 --- a/AmongUsCapture/UserForm.cs +++ b/AmongUsCapture/UserForm.cs @@ -29,10 +29,7 @@ public UserForm(ClientSocket sock) private void OnLoad(object sender, EventArgs e) { - for (int i = 0; i < 100; i++) - { - WriteLineToConsole(i.ToString()); - } + //TestFillConsole(100); } private void OnChatMessageAdded(object sender, ChatMessageEventArgs e) @@ -122,6 +119,13 @@ private void ConsoleTextBox_TextChanged(object sender, EventArgs e) } } + private void TestFillConsole(int entries) //Helper test method to see if filling console works. + { + for (int i = 0; i < entries; i++) + { + WriteLineToConsole(i.ToString()); + } + } public void WriteLineToConsole(String line) { From 3a03c18ce74bcf13579c7ec7c401bf94ef1270dd Mon Sep 17 00:00:00 2001 From: Carbon Date: Thu, 24 Sep 2020 12:44:35 -0500 Subject: [PATCH 4/4] Added table formatting and layout. --- AmongUsCapture/ClientSocket.cs | 2 + AmongUsCapture/UserForm.Designer.cs | 66 +++++++++++++++++++++-------- AmongUsCapture/UserForm.cs | 4 +- 3 files changed, 53 insertions(+), 19 deletions(-) diff --git a/AmongUsCapture/ClientSocket.cs b/AmongUsCapture/ClientSocket.cs index 860263ac..5f5e5510 100644 --- a/AmongUsCapture/ClientSocket.cs +++ b/AmongUsCapture/ClientSocket.cs @@ -24,9 +24,11 @@ public void Connect(string url) GameMemReader.getInstance().PlayerChanged += PlayerChangedHandler; }; + socket.ConnectAsync(); } + public void SendConnectCode(string connectCode) { ConnectCode = connectCode; diff --git a/AmongUsCapture/UserForm.Designer.cs b/AmongUsCapture/UserForm.Designer.cs index 6c9e1023..f543924b 100644 --- a/AmongUsCapture/UserForm.Designer.cs +++ b/AmongUsCapture/UserForm.Designer.cs @@ -32,8 +32,9 @@ private void InitializeComponent() this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.UserSettings = new System.Windows.Forms.GroupBox(); this.ConnectCodeGB = new System.Windows.Forms.GroupBox(); - this.SubmitButton = new System.Windows.Forms.Button(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.ConnectCodeBox = new System.Windows.Forms.TextBox(); + this.SubmitButton = new System.Windows.Forms.Button(); this.CurrentStateGroupBox = new System.Windows.Forms.GroupBox(); this.CurrentState = new System.Windows.Forms.Label(); this.ConsoleGroupBox = new System.Windows.Forms.GroupBox(); @@ -47,6 +48,7 @@ private void InitializeComponent() this.splitContainer1.SuspendLayout(); this.UserSettings.SuspendLayout(); this.ConnectCodeGB.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); this.CurrentStateGroupBox.SuspendLayout(); this.ConsoleGroupBox.SuspendLayout(); this.contextMenuStrip1.SuspendLayout(); @@ -85,43 +87,69 @@ private void InitializeComponent() // // ConnectCodeGB // - this.ConnectCodeGB.Controls.Add(this.SubmitButton); - this.ConnectCodeGB.Controls.Add(this.ConnectCodeBox); + this.ConnectCodeGB.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.ConnectCodeGB.Controls.Add(this.tableLayoutPanel1); this.ConnectCodeGB.Dock = System.Windows.Forms.DockStyle.Top; + this.ConnectCodeGB.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.ConnectCodeGB.Location = new System.Drawing.Point(3, 19); this.ConnectCodeGB.Name = "ConnectCodeGB"; - this.ConnectCodeGB.Size = new System.Drawing.Size(268, 61); + this.ConnectCodeGB.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.ConnectCodeGB.Size = new System.Drawing.Size(268, 63); this.ConnectCodeGB.TabIndex = 4; this.ConnectCodeGB.TabStop = false; this.ConnectCodeGB.Text = "Connect Code"; // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.AutoSize = true; + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Controls.Add(this.ConnectCodeBox, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.SubmitButton, 1, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 19); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(8); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(3); + this.tableLayoutPanel1.RowCount = 1; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(262, 41); + this.tableLayoutPanel1.TabIndex = 3; + // + // ConnectCodeBox + // + this.ConnectCodeBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.ConnectCodeBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.ConnectCodeBox.Location = new System.Drawing.Point(6, 6); + this.ConnectCodeBox.MaxLength = 6; + this.ConnectCodeBox.Name = "ConnectCodeBox"; + this.ConnectCodeBox.Size = new System.Drawing.Size(122, 23); + this.ConnectCodeBox.TabIndex = 0; + this.ConnectCodeBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // // SubmitButton // + this.SubmitButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SubmitButton.AutoSize = true; + this.SubmitButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.SubmitButton.BackColor = System.Drawing.SystemColors.Control; this.SubmitButton.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveCaption; this.SubmitButton.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.SubmitButton.ForeColor = System.Drawing.SystemColors.ControlText; - this.SubmitButton.Location = new System.Drawing.Point(187, 22); + this.SubmitButton.Location = new System.Drawing.Point(134, 6); this.SubmitButton.Name = "SubmitButton"; - this.SubmitButton.Size = new System.Drawing.Size(75, 23); + this.SubmitButton.Size = new System.Drawing.Size(122, 25); this.SubmitButton.TabIndex = 2; this.SubmitButton.Text = "Submit"; this.SubmitButton.UseVisualStyleBackColor = true; this.SubmitButton.Click += new System.EventHandler(this.SubmitButton_Click); // - // ConnectCodeBox - // - this.ConnectCodeBox.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.ConnectCodeBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.ConnectCodeBox.Location = new System.Drawing.Point(9, 22); - this.ConnectCodeBox.MaxLength = 6; - this.ConnectCodeBox.Name = "ConnectCodeBox"; - this.ConnectCodeBox.Size = new System.Drawing.Size(100, 23); - this.ConnectCodeBox.TabIndex = 0; - this.ConnectCodeBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // // CurrentStateGroupBox // + this.CurrentStateGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.CurrentStateGroupBox.Controls.Add(this.CurrentState); this.CurrentStateGroupBox.Location = new System.Drawing.Point(6, 414); this.CurrentStateGroupBox.Name = "CurrentStateGroupBox"; @@ -161,6 +189,7 @@ private void InitializeComponent() this.ConsoleTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.ConsoleTextBox.ContextMenuStrip = this.contextMenuStrip1; this.ConsoleTextBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.ConsoleTextBox.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.ConsoleTextBox.Location = new System.Drawing.Point(3, 19); this.ConsoleTextBox.Name = "ConsoleTextBox"; this.ConsoleTextBox.ReadOnly = true; @@ -213,6 +242,8 @@ private void InitializeComponent() this.UserSettings.ResumeLayout(false); this.ConnectCodeGB.ResumeLayout(false); this.ConnectCodeGB.PerformLayout(); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); this.CurrentStateGroupBox.ResumeLayout(false); this.CurrentStateGroupBox.PerformLayout(); this.ConsoleGroupBox.ResumeLayout(false); @@ -236,5 +267,6 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox checkBox1; private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; private System.Windows.Forms.ToolStripMenuItem AutoScrollMenuItem; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; } } \ No newline at end of file diff --git a/AmongUsCapture/UserForm.cs b/AmongUsCapture/UserForm.cs index 50cb226b..0ca944eb 100644 --- a/AmongUsCapture/UserForm.cs +++ b/AmongUsCapture/UserForm.cs @@ -105,8 +105,8 @@ private void SubmitButton_Click(object sender, EventArgs e) if(ConnectCodeBox.TextLength == 6) { clientSocket.SendConnectCode(ConnectCodeBox.Text); - ConnectCodeBox.Enabled = false; - SubmitButton.Enabled = false; + //ConnectCodeBox.Enabled = false; + //SubmitButton.Enabled = false; } }