diff --git a/YTMusicUploader/CustomControls/OptimisedMetroForm.cs b/YTMusicUploader/CustomControls/OptimisedMetroForm.cs index 6f1d1332b..845125413 100644 --- a/YTMusicUploader/CustomControls/OptimisedMetroForm.cs +++ b/YTMusicUploader/CustomControls/OptimisedMetroForm.cs @@ -56,7 +56,6 @@ protected override void WndProc(ref Message message) { try { - if (message.Msg == WM_SYSCOMMAND && (message.WParam.ToInt32() & 0xfff0) == SC_SIZE) { if (FormResizable) diff --git a/YTMusicUploader/Dialogues/ManageYTMusic.cs b/YTMusicUploader/Dialogues/ManageYTMusic.cs index 8e022c62b..fc9676b42 100644 --- a/YTMusicUploader/Dialogues/ManageYTMusic.cs +++ b/YTMusicUploader/Dialogues/ManageYTMusic.cs @@ -76,7 +76,7 @@ private void ClearFields() tvUploads.AfterSelect += TvUploads_AfterSelect; tbSearchArtists.TextChanged += TbSearchArtists_TextChanged; - tbSearchArtists.KeyDown += TbSearchArtists_KeyDown; + tbSearchArtists.KeyDown += TbSearchArtists_KeyDown; } private void GetArtists() @@ -444,15 +444,12 @@ private void ResetMusicFileEntryStates() private void ResetUserDatabase() { - new Thread((ThreadStart)delegate - { - DisableAllActionButtons(true); - DataAccess.ResetDatabase(); - AppendUpdatesText("Database reset complete.", - ColourHelper.HexStringToColor("#0d5601")); - DisableAllActionButtons(false); - ShowPreloader(false); - }).Start(); + DisableAllActionButtons(true); + DataAccess.ResetDatabase(); + AppendUpdatesText("Database reset complete.", + ColourHelper.HexStringToColor("#0d5601")); + DisableAllActionButtons(false); + ShowPreloader(false); } private void DeleteTracksFromYouTubeMusic() @@ -599,6 +596,6 @@ private void ManageYTMusic_FormClosing(object sender, FormClosingEventArgs e) DialogResult = DialogResult.Yes; else DialogResult = DialogResult.Cancel; - } + } } } diff --git a/YTMusicUploader/MainForm.Delegates.cs b/YTMusicUploader/MainForm.Delegates.cs index ecd2a1260..02e1920eb 100644 --- a/YTMusicUploader/MainForm.Delegates.cs +++ b/YTMusicUploader/MainForm.Delegates.cs @@ -349,12 +349,23 @@ public void ShowForm() { try { - CenterForm(); Show(); - ShowInTaskbar = true; + + if (Opacity == 0) + CenterForm(); if (WindowState == FormWindowState.Minimized) + { WindowState = FormWindowState.Normal; + if (StartHidden) + { + StartHidden = false; + CenterForm(); + } + } + + ShowInTaskbar = true; + Opacity = 1; } catch { } diff --git a/YTMusicUploader/MainForm.Events.Menu.cs b/YTMusicUploader/MainForm.Events.Menu.cs index d9e460d9d..bbe7d6a3f 100644 --- a/YTMusicUploader/MainForm.Events.Menu.cs +++ b/YTMusicUploader/MainForm.Events.Menu.cs @@ -20,7 +20,19 @@ private void TrayIcon_MouseClick(object sender, MouseEventArgs e) else { if (WindowState == FormWindowState.Minimized) - WindowState = FormWindowState.Normal; + { + WindowState = FormWindowState.Normal; + + if (StartHidden) + { + StartHidden = false; + CenterForm(); + } + + Opacity = 1; + } + + ShowInTaskbar = true; Activate(); Focus(); diff --git a/YTMusicUploader/MainForm.cs b/YTMusicUploader/MainForm.cs index 32e37e0c9..4790be3f2 100644 --- a/YTMusicUploader/MainForm.cs +++ b/YTMusicUploader/MainForm.cs @@ -74,6 +74,8 @@ public enum ManagingYTMusicStatusEnum public bool Aborting { get; set; } = false; public ManagingYTMusicStatusEnum ManagingYTMusicStatus { get; set; } = ManagingYTMusicStatusEnum.NeverShown; + private bool StartHidden = false; + // // MusicBrainz Access // @@ -89,7 +91,6 @@ public enum ManagingYTMusicStatusEnum public ToolTip YtMusicManageTooltip { get; set; } public ToolTip AboutTooltip { get; set; } - // // Threads // @@ -104,16 +105,17 @@ public MainForm(bool hidden) : base(formResizable: false) #endif CultureHelper.GloballySetCultureToGB(); MainFormInstance = this; + InitializeComponent(); if (hidden) { ShowInTaskbar = false; - Hide(); + CenterForm(); + WindowState = FormWindowState.Minimized; + Opacity = 0; + StartHidden = true; } - InitializeComponent(); - SuspendDrawing(this); - MusicDataFetcher = new MusicDataFetcher(); SetVersion("v" + Global.ApplicationVersion); @@ -148,8 +150,16 @@ private void RunDebugCommands() private void MainForm_Load(object sender, EventArgs e) { - OnLoad(e); - ResumeDrawing(this); + if (StartHidden) + { + BeginInvoke(new MethodInvoker(delegate + { + Hide(); + })); + } + + OnLoad(e); + ResumeDrawing(this); } private void InitialiseTimers() @@ -486,6 +496,7 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { Hide(); e.Cancel = true; + Opacity = 0; ShowInTaskbar = false; } else diff --git a/YTMusicUploader/YTMusicUploader.csproj b/YTMusicUploader/YTMusicUploader.csproj index a77eff683..cbcb507fa 100644 --- a/YTMusicUploader/YTMusicUploader.csproj +++ b/YTMusicUploader/YTMusicUploader.csproj @@ -252,7 +252,7 @@ Form - ManageYTMusic.cs + ManageYTMusic.cs Form