77using System . Linq ;
88using System . Net ;
99using System . Text ;
10+ using System . Text . RegularExpressions ;
1011using System . Windows . Forms ;
1112
1213// TODO: FindNearestBestVersion(), so that no need to be exact match
@@ -31,23 +32,28 @@ private void Form1_Load(object sender, EventArgs e)
3132 {
3233 SetStatus ( "Initializing.." ) ;
3334
35+ // check installations folder
3436 var root = GetRootFolder ( ) ;
35-
3637 if ( string . IsNullOrEmpty ( root ) == true )
3738 {
3839 SetStatus ( "Missing root folder.." ) ;
3940 SetRootFolder ( ) ;
4041 SetStatus ( "Ready" ) ;
4142 }
4243
43- // update listbox
44+ // update settings window
45+ chkMinimizeToTaskbar . Checked = Properties . Settings . Default . minimizeToTaskbar ;
46+
47+ // update installations folder listbox
4448 lstRootFolders . Items . AddRange ( Properties . Settings . Default . rootFolders . Cast < string > ( ) . ToArray ( ) ) ;
4549
4650 // scan installed unitys, TODO: could cache results, at least fileinfo's
4751 bool foundedUnitys = ScanUnityInstallations ( ) ;
4852 if ( foundedUnitys == false )
4953 {
5054 SetStatus ( "Error> Did not found any Unity installations, try setting correct root folder.." ) ;
55+ UpdateRecentProjectsList ( ) ;
56+ tabControl1 . SelectedIndex = 2 ; // settings tab
5157 return ;
5258 }
5359
@@ -73,7 +79,6 @@ private void Form1_Load(object sender, EventArgs e)
7379
7480 }
7581
76- // this could be delayed, if it affects unity starting?
7782 UpdateRecentProjectsList ( ) ;
7883 }
7984
@@ -317,20 +322,8 @@ void LaunchProject(string pathArg = null)
317322 else
318323 {
319324 var yesno = MessageBox . Show ( "Unity version " + version + " is not installed! Yes = Download, No = Open Webpage" , "UnityLauncher" , MessageBoxButtons . YesNoCancel ) ;
320- string url = "" ;
321325
322- if ( version . Contains ( "f" ) ) // archived
323- {
324- url = "https://unity3d.com/unity/whats-new/unity-" + version . Replace ( "f1" , "" ) ;
325- }
326- if ( version . Contains ( "p" ) ) // patch version
327- {
328- url = "https://unity3d.com/unity/qa/patch-releases/" + version ;
329- }
330- if ( version . Contains ( "b" ) ) // beta version
331- {
332- url = "https://unity3d.com/unity/beta/unity" + version ;
333- }
326+ string url = GetUnityReleaseURL ( version ) ;
334327
335328 // download file
336329 if ( yesno == DialogResult . Yes )
@@ -496,14 +489,17 @@ void SetStatus(string msg)
496489
497490 private void Form1_Resize ( object sender , EventArgs e )
498491 {
499- if ( FormWindowState . Minimized == this . WindowState )
500- {
501- notifyIcon . Visible = true ;
502- this . Hide ( ) ;
503- }
504- else if ( FormWindowState . Normal == this . WindowState )
492+ if ( chkMinimizeToTaskbar . Checked == true )
505493 {
506- notifyIcon . Visible = false ;
494+ if ( FormWindowState . Minimized == this . WindowState )
495+ {
496+ notifyIcon . Visible = true ;
497+ this . Hide ( ) ;
498+ }
499+ else if ( FormWindowState . Normal == this . WindowState )
500+ {
501+ notifyIcon . Visible = false ;
502+ }
507503 }
508504 }
509505
@@ -656,5 +652,44 @@ private void btnExploreUnity_Click(object sender, EventArgs e)
656652 LaunchExplorer ( unityPath ) ;
657653 }
658654 }
655+
656+ string GetUnityReleaseURL ( string version )
657+ {
658+ string url = "" ;
659+ if ( version . Contains ( "f" ) ) // archived
660+ {
661+ version = Regex . Replace ( version , @"f." , "" , RegexOptions . IgnoreCase ) ;
662+ url = "https://unity3d.com/unity/whats-new/unity-" + version ;
663+ }
664+ if ( version . Contains ( "p" ) ) // patch version
665+ {
666+ url = "https://unity3d.com/unity/qa/patch-releases/" + version ;
667+ }
668+ if ( version . Contains ( "b" ) ) // beta version
669+ {
670+ url = "https://unity3d.com/unity/beta/unity" + version ;
671+ }
672+ return url ;
673+ }
674+
675+ private void btnOpenReleasePage_Click ( object sender , EventArgs e )
676+ {
677+ var selected = gridUnityList . CurrentCell . RowIndex ;
678+ if ( selected > - 1 )
679+ {
680+ var version = gridUnityList . Rows [ selected ] . Cells [ "_unityVersion" ] . Value . ToString ( ) ;
681+ var url = GetUnityReleaseURL ( version ) ;
682+ if ( string . IsNullOrEmpty ( url ) == false )
683+ {
684+ Process . Start ( url ) ;
685+ }
686+ }
687+ }
688+
689+ private void chkMinimizeToTaskbar_CheckedChanged ( object sender , EventArgs e )
690+ {
691+ Properties . Settings . Default . minimizeToTaskbar = chkMinimizeToTaskbar . Checked ;
692+ Properties . Settings . Default . Save ( ) ;
693+ }
659694 }
660695}
0 commit comments