diff --git a/InvisPopup.Designer.cs b/InvisPopup.Designer.cs new file mode 100644 index 00000000..a40615f7 --- /dev/null +++ b/InvisPopup.Designer.cs @@ -0,0 +1,46 @@ +namespace VRCX +{ + partial class InvisPopup + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // Popup + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(148, 0); + this.Name = "Popup"; + this.Text = "Popup"; + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/InvisPopup.cs b/InvisPopup.cs new file mode 100644 index 00000000..8a4ad712 --- /dev/null +++ b/InvisPopup.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace VRCX +{ + public partial class InvisPopup : Form + { + public InvisPopup() + { + InitializeComponent(); + } + + protected override void SetVisibleCore(bool value) + { + this.WindowState = FormWindowState.Minimized; + base.SetVisibleCore(value); + } + } +} diff --git a/InvisPopup.resx b/InvisPopup.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/InvisPopup.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index e40d3c8e..ef299ac6 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -39,34 +39,37 @@ namespace VRCX this.TrayMenu_Separator = new System.Windows.Forms.ToolStripSeparator(); this.TrayMenu_Quit = new System.Windows.Forms.ToolStripMenuItem(); this.TrayIcon = new System.Windows.Forms.NotifyIcon(this.components); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); this.TrayMenu.SuspendLayout(); this.SuspendLayout(); // // TrayMenu // + this.TrayMenu.ImageScalingSize = new System.Drawing.Size(20, 20); this.TrayMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.TrayMenu_Open, this.TrayMenu_Separator, this.TrayMenu_Quit}); this.TrayMenu.Name = "TrayMenu"; - this.TrayMenu.Size = new System.Drawing.Size(132, 54); + this.TrayMenu.Size = new System.Drawing.Size(147, 58); // // TrayMenu_Open // this.TrayMenu_Open.Name = "TrayMenu_Open"; - this.TrayMenu_Open.Size = new System.Drawing.Size(131, 22); + this.TrayMenu_Open.Size = new System.Drawing.Size(146, 24); this.TrayMenu_Open.Text = "Open"; this.TrayMenu_Open.Click += new System.EventHandler(this.TrayMenu_Open_Click); // // TrayMenu_Separator // this.TrayMenu_Separator.Name = "TrayMenu_Separator"; - this.TrayMenu_Separator.Size = new System.Drawing.Size(128, 6); + this.TrayMenu_Separator.Size = new System.Drawing.Size(143, 6); // // TrayMenu_Quit // this.TrayMenu_Quit.Name = "TrayMenu_Quit"; - this.TrayMenu_Quit.Size = new System.Drawing.Size(131, 22); + this.TrayMenu_Quit.Size = new System.Drawing.Size(146, 24); this.TrayMenu_Quit.Text = "Quit VRCX"; this.TrayMenu_Quit.Click += new System.EventHandler(this.TrayMenu_Quit_Click); // @@ -77,12 +80,35 @@ namespace VRCX this.TrayIcon.Visible = true; this.TrayIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TrayIcon_MouseDoubleClick); // + // button1 + // + this.button1.Location = new System.Drawing.Point(91, 81); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 1; + this.button1.Text = "Dark"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(196, 81); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 2; + this.button2.Text = "Light"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // // MainForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.ClientSize = new System.Drawing.Size(842, 561); - this.MinimumSize = new System.Drawing.Size(320, 240); + this.ClientSize = new System.Drawing.Size(1052, 701); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.MinimumSize = new System.Drawing.Size(396, 288); this.Name = "MainForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "VRCX"; @@ -103,5 +129,7 @@ namespace VRCX private System.Windows.Forms.ToolStripSeparator TrayMenu_Separator; private System.Windows.Forms.ToolStripMenuItem TrayMenu_Quit; private System.Windows.Forms.NotifyIcon TrayIcon; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; } } \ No newline at end of file diff --git a/MainForm.cs b/MainForm.cs index 19b1a47c..d70fdb6f 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -169,5 +169,15 @@ namespace VRCX { Application.Exit(); } + + private void button1_Click(object sender, EventArgs e) + { + WinformThemer.SetGlobalTheme(1); + } + + private void button2_Click(object sender, EventArgs e) + { + WinformThemer.SetGlobalTheme(0); + } } } diff --git a/VRCX.csproj b/VRCX.csproj index 5cde8085..08b96366 100644 --- a/VRCX.csproj +++ b/VRCX.csproj @@ -83,6 +83,12 @@ + + Form + + + InvisPopup.cs + @@ -123,6 +129,9 @@ Form + + InvisPopup.cs + VRForm.cs diff --git a/WinformThemer.cs b/WinformThemer.cs index c89078d3..77710e85 100644 --- a/WinformThemer.cs +++ b/WinformThemer.cs @@ -13,12 +13,6 @@ namespace VRCX internal static class WinformThemer { - [DllImport("DwmApi")] - private static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, int[] pvAttribute, int cbAttribute); - - [DllImport("DwmApi")] - private static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, IntPtr pvAttribute, int cbAttribute); - private static int currentTheme = 0; /// @@ -29,7 +23,14 @@ namespace VRCX public static void SetGlobalTheme(int theme) { currentTheme = theme; - foreach (Form form in Application.OpenForms) + + List
forms = new List(); + foreach(Form form in Application.OpenForms) + { + forms.Add(form); + } + + foreach (Form form in forms) { SetThemeToGlobal(form); } @@ -45,14 +46,32 @@ namespace VRCX public static void SetThemeToGlobal(Form form) { SetThemeToGlobal(form.Handle); + + InvisPopup thisJankThing = new InvisPopup(); + thisJankThing.Show(); + + if (form.WindowState != FormWindowState.Minimized) + { + //attempting to refresh this god forsaken title bar + + //Minimize, Downside: shows animation + //PInvokeFun.ShowWindow(form.Handle, (int)PInvokeFun.SW_TYPES.SW_MINIMIZE); + //PInvokeFun.ShowWindow(form.Handle, (int)PInvokeFun.SW_TYPES.SW_RESTORE); + + //Hide, Downside: reorders window to last in taskbar if not pinned + PInvokeFun.ShowWindow(form.Handle, (int)PInvokeFun.SW_TYPES.SW_HIDE); + PInvokeFun.ShowWindow(form.Handle, (int)PInvokeFun.SW_TYPES.SW_SHOW); + } + + thisJankThing.Close(); } private static void SetThemeToGlobal(IntPtr handle) { if (GetTheme(handle) != currentTheme) { - if (DwmSetWindowAttribute(handle, 19, new[] { currentTheme }, 4) != 0) - DwmSetWindowAttribute(handle, 20, new[] { currentTheme }, 4); + if (PInvokeFun.DwmSetWindowAttribute(handle, 19, new[] { currentTheme }, 4) != 0) + PInvokeFun.DwmSetWindowAttribute(handle, 20, new[] { currentTheme }, 4); } } @@ -62,8 +81,8 @@ namespace VRCX IntPtr curThemePtr = Marshal.AllocHGlobal(4); //See what window state it currently is - if (DwmGetWindowAttribute(handle, 19, curThemePtr, 4) != 0) - DwmGetWindowAttribute(handle, 20, curThemePtr, 4); + if (PInvokeFun.DwmGetWindowAttribute(handle, 19, curThemePtr, 4) != 0) + PInvokeFun.DwmGetWindowAttribute(handle, 20, curThemePtr, 4); //Read current theme (light = 0, dark = 1) int theme = Marshal.ReadInt32(curThemePtr); @@ -73,5 +92,32 @@ namespace VRCX return theme; } + + internal static class PInvokeFun + { + [DllImport("DwmApi")] + internal static extern int DwmSetWindowAttribute(IntPtr hwnd, int dwAttribute, int[] pvAttribute, int cbAttribute); + + [DllImport("DwmApi")] + internal static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, IntPtr pvAttribute, int cbAttribute); + + [DllImport("user32.dll")] + internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); + internal enum SW_TYPES + { + SW_HIDE = 0, + SW_SHOWNORMAL = 1, + SW_SHOWMINIMIZED = 2, + SW_SHOWMAXIMIZED = 3, + SW_SHOWNOACTIVATE = 4, + SW_SHOW = 5, + SW_MINIMIZE = 6, + SW_SHOWMINNOACTIVE = 7, + SW_SHOWNA = 8, + SW_RESTORE = 9, + SW_SHOWDEFAULT = 10, + SW_FORCEMINIMIZE = 11 + } + } } }