7
7
using System . Linq ;
8
8
using System . Net ;
9
9
using System . Text ;
10
+ using System . Text . RegularExpressions ;
10
11
using System . Windows . Forms ;
11
12
12
13
// TODO: FindNearestBestVersion(), so that no need to be exact match
@@ -31,23 +32,28 @@ private void Form1_Load(object sender, EventArgs e)
31
32
{
32
33
SetStatus ( "Initializing.." ) ;
33
34
35
+ // check installations folder
34
36
var root = GetRootFolder ( ) ;
35
-
36
37
if ( string . IsNullOrEmpty ( root ) == true )
37
38
{
38
39
SetStatus ( "Missing root folder.." ) ;
39
40
SetRootFolder ( ) ;
40
41
SetStatus ( "Ready" ) ;
41
42
}
42
43
43
- // update listbox
44
+ // update settings window
45
+ chkMinimizeToTaskbar . Checked = Properties . Settings . Default . minimizeToTaskbar ;
46
+
47
+ // update installations folder listbox
44
48
lstRootFolders . Items . AddRange ( Properties . Settings . Default . rootFolders . Cast < string > ( ) . ToArray ( ) ) ;
45
49
46
50
// scan installed unitys, TODO: could cache results, at least fileinfo's
47
51
bool foundedUnitys = ScanUnityInstallations ( ) ;
48
52
if ( foundedUnitys == false )
49
53
{
50
54
SetStatus ( "Error> Did not found any Unity installations, try setting correct root folder.." ) ;
55
+ UpdateRecentProjectsList ( ) ;
56
+ tabControl1 . SelectedIndex = 2 ; // settings tab
51
57
return ;
52
58
}
53
59
@@ -73,7 +79,6 @@ private void Form1_Load(object sender, EventArgs e)
73
79
74
80
}
75
81
76
- // this could be delayed, if it affects unity starting?
77
82
UpdateRecentProjectsList ( ) ;
78
83
}
79
84
@@ -317,20 +322,8 @@ void LaunchProject(string pathArg = null)
317
322
else
318
323
{
319
324
var yesno = MessageBox . Show ( "Unity version " + version + " is not installed! Yes = Download, No = Open Webpage" , "UnityLauncher" , MessageBoxButtons . YesNoCancel ) ;
320
- string url = "" ;
321
325
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 ) ;
334
327
335
328
// download file
336
329
if ( yesno == DialogResult . Yes )
@@ -496,14 +489,17 @@ void SetStatus(string msg)
496
489
497
490
private void Form1_Resize ( object sender , EventArgs e )
498
491
{
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 )
505
493
{
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
+ }
507
503
}
508
504
}
509
505
@@ -656,5 +652,44 @@ private void btnExploreUnity_Click(object sender, EventArgs e)
656
652
LaunchExplorer ( unityPath ) ;
657
653
}
658
654
}
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
+ }
659
694
}
660
695
}
0 commit comments