@@ -15,7 +15,7 @@ class MainWindow : Window
15
15
{
16
16
private const string InstallUnityUrl = "https://unity.com/releases/editor/archive" ;
17
17
18
- private static MainWindow s_instance ;
18
+ public static MainWindow Instance { get ; private set ; }
19
19
private static ListBox s_unityInstallationsParent ;
20
20
21
21
private static ListBox s_unityInstalltionSearchPathsParent ;
@@ -30,14 +30,16 @@ class MainWindow : Window
30
30
private static MenuItem s_removeFromListMenuItem ;
31
31
private static MenuItem s_revealInFileExplorerMenuItem ;
32
32
private static MenuItem s_openInDifferentVersionMenuItem ;
33
- private static CheckBox s_transparentCheckbox ;
33
+
34
34
private static CheckBox s_acrylicCheckbox ;
35
+ private static CheckBox s_transparentCheckbox ;
35
36
private static DockPanel s_transparentPanel ;
36
37
private static Slider s_backgroundBlurIntensitySlider ;
38
+ private static CheckBox s_closeAfterOpenProjectCheckbox ;
37
39
38
40
public MainWindow ( object data )
39
41
{
40
- s_instance = this ;
42
+ Instance = this ;
41
43
DataContext = data ;
42
44
Title = "UnityHubNative.Net" ;
43
45
Content = CreateContent ( ) ;
@@ -179,7 +181,7 @@ private static void ReloadEverything()
179
181
Header = "_Close Window" ,
180
182
HotKey = new ( Key . W , KeyModifiers . Control ) ,
181
183
InputGesture = new ( Key . W , KeyModifiers . Control )
182
- } . OnClick ( static ( ) => s_instance . Close ( ) ) ,
184
+ } . OnClick ( static ( ) => Instance . Close ( ) ) ,
183
185
new MenuItem
184
186
{
185
187
Header = "_About UnityHubNative.Net" ,
@@ -436,17 +438,58 @@ private static void ReloadEverything()
436
438
} . OnValueChanged ( OnAcrylicIntensitySliderValueChanged ) . SetDock ( Dock . Right )
437
439
] ) . SetDock ( Dock . Top )
438
440
}
441
+ ] ) ,
442
+ new SettingsExpander
443
+ {
444
+ Header = new DockPanel
445
+ {
446
+ LastChildFill = false
447
+ } . AddChildren
448
+ ( [
449
+ new TextBlock
450
+ {
451
+ Text = "Behaviour" ,
452
+ VerticalAlignment = VerticalAlignment . Center ,
453
+ } . SetDock ( Dock . Left )
454
+ ] ) ,
455
+ } . SetDock ( Dock . Top ) . AddItems
456
+ ( [
457
+ new SettingsExpanderItem
458
+ {
459
+ Content = new DockPanel
460
+ {
461
+ LastChildFill = false
462
+ } . AddChildren
463
+ ( [
464
+ new TextBlock
465
+ {
466
+ Text = "Close after opening a project" ,
467
+ VerticalAlignment = VerticalAlignment . Center ,
468
+ } . SetDock ( Dock . Left ) ,
469
+ s_closeAfterOpenProjectCheckbox = new CheckBox
470
+ {
471
+ IsChecked = UnityHubNativeNetApp . Config . closeAfterProjectOpen ,
472
+ VerticalAlignment = VerticalAlignment . Center ,
473
+ } . OnCheckChanged ( OnCloseAfterOpenProjectCheckboxChanged ) . SetDock ( Dock . Right )
474
+ ] )
475
+ } . SetTooltip ( "If checked, the app will close after opening a project" )
439
476
] )
440
477
] )
441
478
}
442
479
] )
443
480
] )
444
481
] ) ;
445
482
483
+ private static void OnCloseAfterOpenProjectCheckboxChanged ( )
484
+ {
485
+ UnityHubNativeNetApp . Config . closeAfterProjectOpen = ! UnityHubNativeNetApp . Config . closeAfterProjectOpen ;
486
+ UnityHubNativeNetApp . SaveConfig ( UnityHubNativeNetApp . Config ) ;
487
+ }
488
+
446
489
private static void OnAcrylicIntensitySliderValueChanged ( )
447
490
{
448
491
UnityHubNativeNetApp . Config . blurIntensity = ( float ) s_backgroundBlurIntensitySlider . Value ;
449
- s_instance . SetupBackground ( ) ;
492
+ Instance . SetupBackground ( ) ;
450
493
UnityHubNativeNetApp . SaveConfig ( UnityHubNativeNetApp . Config ) ;
451
494
}
452
495
@@ -487,8 +530,7 @@ private static void OnUnityProjectListSubmitted()
487
530
{
488
531
if ( ! IsAnyProjectSelected ( ) )
489
532
return ;
490
- UnityHubUtils . UnityProjects [ GetUnityProjectSelectedIndex ( ) ] . OpenProject ( ) ;
491
-
533
+ ( ( UnityProjectView ) s_unityProjectsParent . Items [ GetUnityProjectSelectedIndex ( ) ] ! ) . OpenProject ( ) ;
492
534
}
493
535
494
536
private static void RemoveSelectedUnitySearchPath ( Button button , RoutedEventArgs args )
@@ -532,7 +574,7 @@ private static async void AddNewUnitySearchPath()
532
574
{
533
575
try
534
576
{
535
- var paths = await s_instance . StorageProvider . OpenFolderPickerAsync ( new FolderPickerOpenOptions
577
+ var paths = await Instance . StorageProvider . OpenFolderPickerAsync ( new FolderPickerOpenOptions
536
578
{
537
579
AllowMultiple = true ,
538
580
Title = "Pick Folder to search for Unity Installations"
@@ -560,7 +602,7 @@ private static async void AddNewUnitySearchPath()
560
602
catch ( Exception ex )
561
603
{
562
604
Debug . WriteLine ( $ "{ ex . Message } \n { ex . StackTrace } ") ;
563
- _ = MessageBoxManager . GetMessageBoxStandard ( "Error" , ex . Message , MsBox . Avalonia . Enums . ButtonEnum . Ok , MsBox . Avalonia . Enums . Icon . Error ) . ShowWindowDialogAsync ( s_instance ) ;
605
+ _ = MessageBoxManager . GetMessageBoxStandard ( "Error" , ex . Message , MsBox . Avalonia . Enums . ButtonEnum . Ok , MsBox . Avalonia . Enums . Icon . Error ) . ShowWindowDialogAsync ( Instance ) ;
564
606
}
565
607
}
566
608
@@ -578,7 +620,7 @@ private static async void OnAddExistingProjectClicked()
578
620
{
579
621
try
580
622
{
581
- var paths = await s_instance . StorageProvider . OpenFolderPickerAsync ( new ( )
623
+ var paths = await Instance . StorageProvider . OpenFolderPickerAsync ( new ( )
582
624
{
583
625
AllowMultiple = true ,
584
626
Title = "Select the folder(s) containing the Unity Project"
@@ -592,7 +634,7 @@ private static async void OnAddExistingProjectClicked()
592
634
continue ;
593
635
if ( UnityHubUtils . UnityProjects . Any ( p => p . path == folder ) )
594
636
{
595
- _ = MessageBoxManager . GetMessageBoxStandard ( $ "Project \" { folder } \" has already been added.", "Cannot add project" , MsBox . Avalonia . Enums . ButtonEnum . Ok , MsBox . Avalonia . Enums . Icon . Info ) . ShowWindowDialogAsync ( s_instance ) ;
637
+ _ = MessageBoxManager . GetMessageBoxStandard ( $ "Project \" { folder } \" has already been added.", "Cannot add project" , MsBox . Avalonia . Enums . ButtonEnum . Ok , MsBox . Avalonia . Enums . Icon . Info ) . ShowWindowDialogAsync ( Instance ) ;
596
638
continue ;
597
639
}
598
640
bool dirty = false ;
@@ -611,15 +653,15 @@ private static async void OnAddExistingProjectClicked()
611
653
}
612
654
catch ( Exception ex )
613
655
{
614
- _ = MessageBoxManager . GetMessageBoxStandard ( "Error" , ex . Message , MsBox . Avalonia . Enums . ButtonEnum . Ok , MsBox . Avalonia . Enums . Icon . Error ) . ShowWindowDialogAsync ( s_instance ) ;
656
+ _ = MessageBoxManager . GetMessageBoxStandard ( "Error" , ex . Message , MsBox . Avalonia . Enums . ButtonEnum . Ok , MsBox . Avalonia . Enums . Icon . Error ) . ShowWindowDialogAsync ( Instance ) ;
615
657
Debug . WriteLine ( $ "{ ex . Message } \n { ex . StackTrace } ") ;
616
658
}
617
659
}
618
660
619
661
private static void OnOpenWithClicked ( )
620
662
{
621
663
var dialogue = new OpenWithDialogue ( UnityHubUtils . UnityProjects [ GetUnityProjectSelectedIndex ( ) ] ) ;
622
- dialogue . ShowDialog ( s_instance ) ;
664
+ dialogue . ShowDialog ( Instance ) ;
623
665
}
624
666
625
667
private static void OnCreateNewProjectClicked ( ) => ShowTbiDialogue ( ) ;
@@ -634,7 +676,7 @@ private static void OnRemoveProjectFromListClicked()
634
676
635
677
private static void OnRevealProjectClicked ( ) => OsUtils . OpenExplorer ( UnityHubUtils . UnityProjects [ GetUnityProjectSelectedIndex ( ) ] . path ) ;
636
678
637
- private static void OnAboutClicked ( MenuItem item , RoutedEventArgs args ) => new AboutDialogue ( ) . ShowDialog ( s_instance ) ;
679
+ private static void OnAboutClicked ( MenuItem item , RoutedEventArgs args ) => new AboutDialogue ( ) . ShowDialog ( Instance ) ;
638
680
639
681
private static void UpdateUnityVersionViews ( )
640
682
{
@@ -679,7 +721,7 @@ private static void UpdateUnityProjectViews()
679
721
680
722
private static void ShowTbiDialogue ( )
681
723
{
682
- _ = MessageBoxManager . GetMessageBoxStandard ( "To be implemented" , "Not implemented yet" , MsBox . Avalonia . Enums . ButtonEnum . Ok , MsBox . Avalonia . Enums . Icon . Warning ) . ShowWindowDialogAsync ( s_instance ) ;
724
+ _ = MessageBoxManager . GetMessageBoxStandard ( "To be implemented" , "Not implemented yet" , MsBox . Avalonia . Enums . ButtonEnum . Ok , MsBox . Avalonia . Enums . Icon . Warning ) . ShowWindowDialogAsync ( Instance ) ;
683
725
}
684
726
}
685
727
0 commit comments