Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Commit

Permalink
* Fix to minimise / restore / show
Browse files Browse the repository at this point in the history
* Fix to 'reset database' - Not always working from a different thread
  • Loading branch information
Jamie Brindle committed Oct 11, 2020
1 parent e16fb4f commit 4be34d7
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 23 deletions.
1 change: 0 additions & 1 deletion YTMusicUploader/CustomControls/OptimisedMetroForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 8 additions & 11 deletions YTMusicUploader/Dialogues/ManageYTMusic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -599,6 +596,6 @@ private void ManageYTMusic_FormClosing(object sender, FormClosingEventArgs e)
DialogResult = DialogResult.Yes;
else
DialogResult = DialogResult.Cancel;
}
}
}
}
15 changes: 13 additions & 2 deletions YTMusicUploader/MainForm.Delegates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }

Expand Down
14 changes: 13 additions & 1 deletion YTMusicUploader/MainForm.Events.Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
25 changes: 18 additions & 7 deletions YTMusicUploader/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand All @@ -89,7 +91,6 @@ public enum ManagingYTMusicStatusEnum
public ToolTip YtMusicManageTooltip { get; set; }
public ToolTip AboutTooltip { get; set; }


//
// Threads
//
Expand All @@ -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);

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -486,6 +496,7 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
Hide();
e.Cancel = true;
Opacity = 0;
ShowInTaskbar = false;
}
else
Expand Down
2 changes: 1 addition & 1 deletion YTMusicUploader/YTMusicUploader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
</Compile>
<Compile Include="Dialogues\ManageYTMusic.Events.TextBox.cs">
<SubType>Form</SubType>
<DependentUpon>ManageYTMusic.cs</DependentUpon>
<DependentUpon>ManageYTMusic.cs</DependentUpon>
</Compile>
<Compile Include="Dialogues\ManageYTMusic.Events.TreeView.cs">
<SubType>Form</SubType>
Expand Down

0 comments on commit 4be34d7

Please sign in to comment.