diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs
index 3473aeff..e269e0bd 100644
--- a/MainForm.Designer.cs
+++ b/MainForm.Designer.cs
@@ -33,21 +33,74 @@ namespace VRCX
///
private void InitializeComponent()
{
+ this.components = new System.ComponentModel.Container();
+ this.TrayMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.TrayMenu_Open = new System.Windows.Forms.ToolStripMenuItem();
+ 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.TrayMenu.SuspendLayout();
this.SuspendLayout();
//
+ // TrayMenu
+ //
+ 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);
+ //
+ // TrayMenu_Open
+ //
+ this.TrayMenu_Open.Name = "TrayMenu_Open";
+ this.TrayMenu_Open.Size = new System.Drawing.Size(131, 22);
+ 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);
+ //
+ // TrayMenu_Quit
+ //
+ this.TrayMenu_Quit.Name = "TrayMenu_Quit";
+ this.TrayMenu_Quit.Size = new System.Drawing.Size(131, 22);
+ this.TrayMenu_Quit.Text = "Quit VRCX";
+ this.TrayMenu_Quit.Click += new System.EventHandler(this.TrayMenu_Quit_Click);
+ //
+ // TrayIcon
+ //
+ this.TrayIcon.ContextMenuStrip = this.TrayMenu;
+ this.TrayIcon.Text = "VRCX";
+ this.TrayIcon.Visible = true;
+ this.TrayIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TrayIcon_MouseDoubleClick);
+ //
// MainForm
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
- this.ClientSize = new System.Drawing.Size(1263, 842);
- this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+ this.ClientSize = new System.Drawing.Size(842, 561);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "VRCX";
+ this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
+ this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
+ this.Load += new System.EventHandler(this.MainForm_Load);
+ this.Move += new System.EventHandler(this.MainForm_Move);
+ this.Resize += new System.EventHandler(this.MainForm_Resize);
+ this.TrayMenu.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
+
+ private System.Windows.Forms.ContextMenuStrip TrayMenu;
+ private System.Windows.Forms.ToolStripMenuItem TrayMenu_Open;
+ private System.Windows.Forms.ToolStripSeparator TrayMenu_Separator;
+ private System.Windows.Forms.ToolStripMenuItem TrayMenu_Quit;
+ private System.Windows.Forms.NotifyIcon TrayIcon;
}
}
\ No newline at end of file
diff --git a/MainForm.cs b/MainForm.cs
index a38f1fa2..ad65203a 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -15,6 +15,10 @@ namespace VRCX
{
public static MainForm Instance { get; private set; }
public static ChromiumWebBrowser Browser { get; private set; }
+ private int LastLocationX;
+ private int LastLocationY;
+ private int LastSizeWidth;
+ private int LastSizeHeight;
public MainForm()
{
@@ -22,7 +26,10 @@ namespace VRCX
InitializeComponent();
try
{
- Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
+ var location = Assembly.GetExecutingAssembly().Location;
+ var icon = Icon.ExtractAssociatedIcon(location);
+ Icon = icon;
+ TrayIcon.Icon = icon;
}
catch
{
@@ -52,5 +59,110 @@ namespace VRCX
};
Controls.Add(Browser);
}
+
+ private void MainForm_Load(object sender, System.EventArgs e)
+ {
+ try
+ {
+ int.TryParse(VRCXStorage.Instance.Get("VRCX_LocationX"), out LastLocationX);
+ int.TryParse(VRCXStorage.Instance.Get("VRCX_LocationY"), out LastLocationY);
+ int.TryParse(VRCXStorage.Instance.Get("VRCX_SizeWidth"), out LastSizeWidth);
+ int.TryParse(VRCXStorage.Instance.Get("VRCX_SizeHeight"), out LastSizeHeight);
+ var location = new Point(LastLocationX, LastLocationY);
+ var size = new Size(LastSizeWidth, LastSizeHeight);
+ var screen = Screen.FromPoint(location);
+ if (screen.Bounds.Contains(location.X, location.Y))
+ {
+ Location = location;
+ }
+ if (size.Width > 0 && size.Height > 0)
+ {
+ Size = size;
+ }
+ }
+ catch
+ {
+ }
+ try
+ {
+ var state = WindowState;
+ if (int.TryParse(VRCXStorage.Instance.Get("VRCX_WindowState"), out int v))
+ {
+ state = (FormWindowState)v;
+ }
+ if (state == FormWindowState.Minimized)
+ {
+ state = FormWindowState.Normal;
+ }
+ if ("true".Equals(VRCXStorage.Instance.Get("VRCX_StartAsMinimizedState")))
+ {
+ state = FormWindowState.Minimized;
+ }
+ WindowState = state;
+ }
+ catch
+ {
+ }
+ }
+
+ private void MainForm_Resize(object sender, System.EventArgs e)
+ {
+ if (WindowState != FormWindowState.Normal)
+ {
+ return;
+ }
+ LastSizeWidth = Size.Width;
+ LastSizeHeight = Size.Height;
+ }
+
+ private void MainForm_Move(object sender, System.EventArgs e)
+ {
+ if (WindowState != FormWindowState.Normal)
+ {
+ return;
+ }
+ LastLocationX = Location.X;
+ LastLocationY = Location.Y;
+ }
+
+ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ if (e.CloseReason == CloseReason.UserClosing &&
+ "true".Equals(VRCXStorage.Instance.Get("VRCX_CloseToTray")))
+ {
+ e.Cancel = true;
+ Hide();
+ }
+ }
+
+ private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
+ {
+ VRCXStorage.Instance.Set("VRCX_LocationX", LastLocationX.ToString());
+ VRCXStorage.Instance.Set("VRCX_LocationY", LastLocationY.ToString());
+ VRCXStorage.Instance.Set("VRCX_SizeWidth", LastSizeWidth.ToString());
+ VRCXStorage.Instance.Set("VRCX_SizeHeight", LastSizeHeight.ToString());
+ VRCXStorage.Instance.Set("VRCX_WindowState", ((int)WindowState).ToString());
+ }
+
+ private void TrayIcon_MouseDoubleClick(object sender, MouseEventArgs e)
+ {
+ TrayMenu_Open_Click(sender, e);
+ }
+
+ private void TrayMenu_Open_Click(object sender, System.EventArgs e)
+ {
+ if (WindowState == FormWindowState.Minimized)
+ {
+ WindowState = FormWindowState.Normal;
+ }
+ Show();
+ Focus();
+ }
+
+ private void TrayMenu_Quit_Click(object sender, System.EventArgs e)
+ {
+ Application.Exit();
+ }
+
}
}
\ No newline at end of file
diff --git a/MainForm.resx b/MainForm.resx
index 1af7de15..b05fa11b 100644
--- a/MainForm.resx
+++ b/MainForm.resx
@@ -117,4 +117,10 @@