diff --git a/v2rayN/v2rayN/Forms/MainForm.cs b/v2rayN/v2rayN/Forms/MainForm.cs index ed086e2e..f0f6b29a 100644 --- a/v2rayN/v2rayN/Forms/MainForm.cs +++ b/v2rayN/v2rayN/Forms/MainForm.cs @@ -52,6 +52,14 @@ namespace v2rayN.Forms v2rayHandler = new V2rayHandler(); v2rayHandler.ProcessEvent += v2rayHandler_ProcessEvent; + if(!config.formMainSize.IsEmpty) { + this.Left = config.formMainSize.X; + this.Top = config.formMainSize.Y; + this.Width = config.formMainSize.Width; + this.Height = config.formMainSize.Height; + } + this.WindowState = config.windowState; + if (config.enableStatistics) { statistics = new StatisticsHandler(config, UpdateStatisticsHandler); @@ -87,6 +95,10 @@ namespace v2rayN.Forms { if (e.CloseReason == CloseReason.UserClosing) { + if (this.WindowState != FormWindowState.Maximized) + config.formMainSize = new Rectangle(this.Left, this.Top, this.Width, this.Height); + config.windowState = this.WindowState; + e.Cancel = true; HideForm(); return; @@ -973,7 +985,6 @@ namespace v2rayN.Forms private void menuExit_Click(object sender, EventArgs e) { - this.Visible = false; this.Close(); @@ -984,7 +995,7 @@ namespace v2rayN.Forms private void ShowForm() { this.Show(); - this.WindowState = FormWindowState.Normal; + //this.WindowState = config.windowState; this.Activate(); //this.notifyIcon1.Visible = false; this.ShowInTaskbar = true; diff --git a/v2rayN/v2rayN/Mode/Config.cs b/v2rayN/v2rayN/Mode/Config.cs index 24baa514..32556e05 100644 --- a/v2rayN/v2rayN/Mode/Config.cs +++ b/v2rayN/v2rayN/Mode/Config.cs @@ -36,6 +36,17 @@ namespace v2rayN.Mode get; set; } + /// + /// 主窗口的大小和位置 + /// + public System.Drawing.Rectangle formMainSize + { + get; set; + } + public System.Windows.Forms.FormWindowState windowState + { + get; set; + } /// /// 活动配置序号 ///