Added remember main window size setting

This commit is contained in:
Jaex 2013-11-20 15:36:02 +02:00
parent 6ffbd029f8
commit 4c3cdcc0f2
5 changed files with 113 additions and 82 deletions

View file

@ -56,6 +56,8 @@ public class ApplicationConfig : SettingsBase<ApplicationConfig>
public bool AutoCheckUpdate = true;
public bool TrayIconProgressEnabled = true;
public bool TaskbarProgressEnabled = true;
public bool RememberMainFormSize = false;
public Size MainFormSize = Size.Empty;
#endregion General

View file

@ -103,6 +103,8 @@ private void InitializeComponent()
this.tsmiTestURLShortener = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiTestUploaders = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiTestShapeCapture = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiDonate = new System.Windows.Forms.ToolStripButton();
this.tsmiAbout = new System.Windows.Forms.ToolStripButton();
this.scMain = new HelpersLib.SplitContainerCustomSplitter();
this.lblDragAndDropTip = new System.Windows.Forms.Label();
this.lblSplitter = new System.Windows.Forms.Label();
@ -201,13 +203,11 @@ private void InitializeComponent()
this.tsmiScreenshotsFolder = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiTrayHistory = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiTrayImageHistory = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiTrayAbout = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiTrayDonate = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiTrayAbout = new System.Windows.Forms.ToolStripMenuItem();
this.tssTray3 = new System.Windows.Forms.ToolStripSeparator();
this.tsmiTrayExit = new System.Windows.Forms.ToolStripMenuItem();
this.ssToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiAbout = new System.Windows.Forms.ToolStripButton();
this.tsmiDonate = new System.Windows.Forms.ToolStripButton();
this.tsMain.SuspendLayout();
this.scMain.Panel1.SuspendLayout();
this.scMain.Panel2.SuspendLayout();
@ -676,6 +676,26 @@ private void InitializeComponent()
this.tsmiTestShapeCapture.Text = "Test shape capture...";
this.tsmiTestShapeCapture.Click += new System.EventHandler(this.tsmiTestShapeCapture_Click);
//
// tsmiDonate
//
this.tsmiDonate.Image = global::ShareX.Properties.Resources.present;
this.tsmiDonate.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.tsmiDonate.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsmiDonate.Name = "tsmiDonate";
this.tsmiDonate.Size = new System.Drawing.Size(147, 20);
this.tsmiDonate.Text = "Donate...";
this.tsmiDonate.Click += new System.EventHandler(this.tsbDonate_Click);
//
// tsmiAbout
//
this.tsmiAbout.Image = global::ShareX.Properties.Resources.application_browser;
this.tsmiAbout.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.tsmiAbout.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsmiAbout.Name = "tsmiAbout";
this.tsmiAbout.Size = new System.Drawing.Size(147, 20);
this.tsmiAbout.Text = "About...";
this.tsmiAbout.Click += new System.EventHandler(this.tsbAbout_Click);
//
// scMain
//
this.scMain.Dock = System.Windows.Forms.DockStyle.Fill;
@ -1495,14 +1515,6 @@ private void InitializeComponent()
this.tsmiTrayImageHistory.Text = "Image history...";
this.tsmiTrayImageHistory.Click += new System.EventHandler(this.tsbImageHistory_Click);
//
// tsmiTrayAbout
//
this.tsmiTrayAbout.Image = global::ShareX.Properties.Resources.application_browser;
this.tsmiTrayAbout.Name = "tsmiTrayAbout";
this.tsmiTrayAbout.Size = new System.Drawing.Size(188, 22);
this.tsmiTrayAbout.Text = "About...";
this.tsmiTrayAbout.Click += new System.EventHandler(this.tsbAbout_Click);
//
// tsmiTrayDonate
//
this.tsmiTrayDonate.Image = global::ShareX.Properties.Resources.present;
@ -1511,6 +1523,14 @@ private void InitializeComponent()
this.tsmiTrayDonate.Text = "Donate...";
this.tsmiTrayDonate.Click += new System.EventHandler(this.tsbDonate_Click);
//
// tsmiTrayAbout
//
this.tsmiTrayAbout.Image = global::ShareX.Properties.Resources.application_browser;
this.tsmiTrayAbout.Name = "tsmiTrayAbout";
this.tsmiTrayAbout.Size = new System.Drawing.Size(188, 22);
this.tsmiTrayAbout.Text = "About...";
this.tsmiTrayAbout.Click += new System.EventHandler(this.tsbAbout_Click);
//
// tssTray3
//
this.tssTray3.Name = "tssTray3";
@ -1530,26 +1550,6 @@ private void InitializeComponent()
this.ssToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.ssToolStripMenuItem.Text = "ss";
//
// tsmiAbout
//
this.tsmiAbout.Image = global::ShareX.Properties.Resources.application_browser;
this.tsmiAbout.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.tsmiAbout.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsmiAbout.Name = "tsmiAbout";
this.tsmiAbout.Size = new System.Drawing.Size(147, 20);
this.tsmiAbout.Text = "About...";
this.tsmiAbout.Click += new System.EventHandler(this.tsbAbout_Click);
//
// tsmiDonate
//
this.tsmiDonate.Image = global::ShareX.Properties.Resources.present;
this.tsmiDonate.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.tsmiDonate.ImageTransparentColor = System.Drawing.Color.Magenta;
this.tsmiDonate.Name = "tsmiDonate";
this.tsmiDonate.Size = new System.Drawing.Size(147, 20);
this.tsmiDonate.Text = "Donate...";
this.tsmiDonate.Click += new System.EventHandler(this.tsbDonate_Click);
//
// MainForm
//
this.AllowDrop = true;
@ -1560,7 +1560,6 @@ private void InitializeComponent()
this.Controls.Add(this.tsMain);
this.DoubleBuffered = true;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(430, 430);
this.Name = "MainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ShareX";

View file

@ -29,6 +29,7 @@ You should have received a copy of the GNU General Public License
using ScreenCaptureLib;
using ShareX.Properties;
using System;
using System.Drawing;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
@ -336,8 +337,15 @@ private void LoadSettings()
niTray.Icon = ShareXResources.Icon;
niTray.Visible = Program.Settings.ShowTray;
UpdateMainFormSettings();
if (Program.Settings.RememberMainFormSize && !Program.Settings.MainFormSize.IsEmpty)
{
StartPosition = FormStartPosition.Manual;
Size = Program.Settings.MainFormSize;
Screen currentScreen = Screen.FromPoint(Cursor.Position);
Location = new Point(currentScreen.Bounds.Width / 2 - Size.Width / 2, currentScreen.Bounds.Height / 2 - Size.Height / 2);
}
UpdateMainFormSettings();
UpdateMenu();
UpdateUploaderMenuNames();
RegisterMenuClosing();
@ -581,6 +589,8 @@ private void MainForm_Resize(object sender, EventArgs e)
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
Program.Settings.MainFormSize = Size;
if (e.CloseReason == CloseReason.UserClosing && Program.Settings.ShowTray && !forceClose)
{
e.Cancel = true;

View file

@ -30,6 +30,8 @@ private void InitializeComponent()
{
this.tcSettings = new System.Windows.Forms.TabControl();
this.tpGeneral = new System.Windows.Forms.TabPage();
this.cbTaskbarProgressEnabled = new System.Windows.Forms.CheckBox();
this.cbTrayIconProgressEnabled = new System.Windows.Forms.CheckBox();
this.cbShellContextMenu = new System.Windows.Forms.CheckBox();
this.cbCheckUpdates = new System.Windows.Forms.CheckBox();
this.cbStartWithWindows = new System.Windows.Forms.CheckBox();
@ -75,17 +77,16 @@ private void InitializeComponent()
this.btnClipboardFormatEdit = new System.Windows.Forms.Button();
this.btnClipboardFormatRemove = new System.Windows.Forms.Button();
this.btnClipboardFormatAdd = new System.Windows.Forms.Button();
this.lvClipboardFormats = new HelpersLib.MyListView();
this.chDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chFormat = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.cbIfUploadFailRetryOnce = new System.Windows.Forms.CheckBox();
this.tpPrint = new System.Windows.Forms.TabPage();
this.cbDontShowPrintSettingDialog = new System.Windows.Forms.CheckBox();
this.btnShowImagePrintSettings = new System.Windows.Forms.Button();
this.tpAdvanced = new System.Windows.Forms.TabPage();
this.pgSettings = new System.Windows.Forms.PropertyGrid();
this.cbTrayIconProgressEnabled = new System.Windows.Forms.CheckBox();
this.cbTaskbarProgressEnabled = new System.Windows.Forms.CheckBox();
this.lvClipboardFormats = new HelpersLib.MyListView();
this.chDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.chFormat = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.cbRememberMainFormSize = new System.Windows.Forms.CheckBox();
this.tcSettings.SuspendLayout();
this.tpGeneral.SuspendLayout();
this.tpPaths.SuspendLayout();
@ -116,6 +117,7 @@ private void InitializeComponent()
//
// tpGeneral
//
this.tpGeneral.Controls.Add(this.cbRememberMainFormSize);
this.tpGeneral.Controls.Add(this.cbTaskbarProgressEnabled);
this.tpGeneral.Controls.Add(this.cbTrayIconProgressEnabled);
this.tpGeneral.Controls.Add(this.cbShellContextMenu);
@ -131,6 +133,28 @@ private void InitializeComponent()
this.tpGeneral.Text = "General";
this.tpGeneral.UseVisualStyleBackColor = true;
//
// cbTaskbarProgressEnabled
//
this.cbTaskbarProgressEnabled.AutoSize = true;
this.cbTaskbarProgressEnabled.Location = new System.Drawing.Point(16, 160);
this.cbTaskbarProgressEnabled.Name = "cbTaskbarProgressEnabled";
this.cbTaskbarProgressEnabled.Size = new System.Drawing.Size(178, 17);
this.cbTaskbarProgressEnabled.TabIndex = 6;
this.cbTaskbarProgressEnabled.Text = "Show progress in taskbar button";
this.cbTaskbarProgressEnabled.UseVisualStyleBackColor = true;
this.cbTaskbarProgressEnabled.CheckedChanged += new System.EventHandler(this.cbTaskbarProgressEnabled_CheckedChanged);
//
// cbTrayIconProgressEnabled
//
this.cbTrayIconProgressEnabled.AutoSize = true;
this.cbTrayIconProgressEnabled.Location = new System.Drawing.Point(16, 136);
this.cbTrayIconProgressEnabled.Name = "cbTrayIconProgressEnabled";
this.cbTrayIconProgressEnabled.Size = new System.Drawing.Size(150, 17);
this.cbTrayIconProgressEnabled.TabIndex = 5;
this.cbTrayIconProgressEnabled.Text = "Show progress in tray icon";
this.cbTrayIconProgressEnabled.UseVisualStyleBackColor = true;
this.cbTrayIconProgressEnabled.CheckedChanged += new System.EventHandler(this.cbTrayIconProgressEnabled_CheckedChanged);
//
// cbShellContextMenu
//
this.cbShellContextMenu.AutoSize = true;
@ -619,6 +643,30 @@ private void InitializeComponent()
this.btnClipboardFormatAdd.UseVisualStyleBackColor = true;
this.btnClipboardFormatAdd.Click += new System.EventHandler(this.btnAddClipboardFormat_Click);
//
// lvClipboardFormats
//
this.lvClipboardFormats.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.chDescription,
this.chFormat});
this.lvClipboardFormats.FullRowSelect = true;
this.lvClipboardFormats.Location = new System.Drawing.Point(8, 48);
this.lvClipboardFormats.Name = "lvClipboardFormats";
this.lvClipboardFormats.Size = new System.Drawing.Size(472, 104);
this.lvClipboardFormats.TabIndex = 3;
this.lvClipboardFormats.UseCompatibleStateImageBehavior = false;
this.lvClipboardFormats.View = System.Windows.Forms.View.Details;
this.lvClipboardFormats.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvClipboardFormats_MouseDoubleClick);
//
// chDescription
//
this.chDescription.Text = "Description";
this.chDescription.Width = 135;
//
// chFormat
//
this.chFormat.Text = "Format";
this.chFormat.Width = 320;
//
// cbIfUploadFailRetryOnce
//
this.cbIfUploadFailRetryOnce.AutoSize = true;
@ -682,51 +730,16 @@ private void InitializeComponent()
this.pgSettings.Size = new System.Drawing.Size(516, 302);
this.pgSettings.TabIndex = 0;
//
// cbTrayIconProgressEnabled
// cbRememberMainFormSize
//
this.cbTrayIconProgressEnabled.AutoSize = true;
this.cbTrayIconProgressEnabled.Location = new System.Drawing.Point(16, 136);
this.cbTrayIconProgressEnabled.Name = "cbTrayIconProgressEnabled";
this.cbTrayIconProgressEnabled.Size = new System.Drawing.Size(150, 17);
this.cbTrayIconProgressEnabled.TabIndex = 5;
this.cbTrayIconProgressEnabled.Text = "Show progress in tray icon";
this.cbTrayIconProgressEnabled.UseVisualStyleBackColor = true;
this.cbTrayIconProgressEnabled.CheckedChanged += new System.EventHandler(this.cbTrayIconProgressEnabled_CheckedChanged);
//
// cbTaskbarProgressEnabled
//
this.cbTaskbarProgressEnabled.AutoSize = true;
this.cbTaskbarProgressEnabled.Location = new System.Drawing.Point(16, 160);
this.cbTaskbarProgressEnabled.Name = "cbTaskbarProgressEnabled";
this.cbTaskbarProgressEnabled.Size = new System.Drawing.Size(178, 17);
this.cbTaskbarProgressEnabled.TabIndex = 6;
this.cbTaskbarProgressEnabled.Text = "Show progress in taskbar button";
this.cbTaskbarProgressEnabled.UseVisualStyleBackColor = true;
this.cbTaskbarProgressEnabled.CheckedChanged += new System.EventHandler(this.cbTaskbarProgressEnabled_CheckedChanged);
//
// lvClipboardFormats
//
this.lvClipboardFormats.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.chDescription,
this.chFormat});
this.lvClipboardFormats.FullRowSelect = true;
this.lvClipboardFormats.Location = new System.Drawing.Point(8, 48);
this.lvClipboardFormats.Name = "lvClipboardFormats";
this.lvClipboardFormats.Size = new System.Drawing.Size(472, 104);
this.lvClipboardFormats.TabIndex = 3;
this.lvClipboardFormats.UseCompatibleStateImageBehavior = false;
this.lvClipboardFormats.View = System.Windows.Forms.View.Details;
this.lvClipboardFormats.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvClipboardFormats_MouseDoubleClick);
//
// chDescription
//
this.chDescription.Text = "Description";
this.chDescription.Width = 135;
//
// chFormat
//
this.chFormat.Text = "Format";
this.chFormat.Width = 320;
this.cbRememberMainFormSize.AutoSize = true;
this.cbRememberMainFormSize.Location = new System.Drawing.Point(16, 184);
this.cbRememberMainFormSize.Name = "cbRememberMainFormSize";
this.cbRememberMainFormSize.Size = new System.Drawing.Size(162, 17);
this.cbRememberMainFormSize.TabIndex = 7;
this.cbRememberMainFormSize.Text = "Remember main window size";
this.cbRememberMainFormSize.UseVisualStyleBackColor = true;
this.cbRememberMainFormSize.CheckedChanged += new System.EventHandler(this.cbRememberMainFormSize_CheckedChanged);
//
// SettingsForm
//
@ -825,5 +838,6 @@ private void InitializeComponent()
private System.Windows.Forms.PropertyGrid pgSettings;
private System.Windows.Forms.CheckBox cbTaskbarProgressEnabled;
private System.Windows.Forms.CheckBox cbTrayIconProgressEnabled;
private System.Windows.Forms.CheckBox cbRememberMainFormSize;
}
}

View file

@ -63,6 +63,7 @@ private void LoadSettings()
cbTrayIconProgressEnabled.Checked = Program.Settings.TrayIconProgressEnabled;
cbTaskbarProgressEnabled.Enabled = TaskbarManager.IsPlatformSupported;
cbTaskbarProgressEnabled.Checked = Program.Settings.TaskbarProgressEnabled;
cbRememberMainFormSize.Checked = Program.Settings.RememberMainFormSize;
// Paths
cbUseCustomUploadersConfigPath.Checked = Program.Settings.UseCustomUploadersConfigPath;
@ -194,6 +195,11 @@ private void cbTaskbarProgressEnabled_CheckedChanged(object sender, EventArgs e)
}
}
private void cbRememberMainFormSize_CheckedChanged(object sender, EventArgs e)
{
Program.Settings.RememberMainFormSize = cbRememberMainFormSize.Checked;
}
#endregion General
#region Paths