@@ -86,34 +86,88 @@ protected override void OnOpened(EventArgs e)
8686 s_unityProjectsParent . ContainerFromIndex ( 0 ) ! . Focus ( ) ;
8787 }
8888
89- void SetupBackground ( )
89+ public static void ReloadEverything ( )
9090 {
91- if ( UnityHubNativeNetApp . Config . transparent )
92- {
93- TransparencyLevelHint =
94- [
95- UnityHubNativeNetApp . Config . acrylic ? WindowTransparencyLevel . AcrylicBlur : WindowTransparencyLevel . Mica ,
96- WindowTransparencyLevel . Blur ,
97- ] ;
98- #if Windows
91+ UnityHubUtils . LoadAll ( ) ;
92+ UpdateUnityVersionViews ( ) ;
93+ UpdateUnitySearchPathViews ( ) ;
94+ UpdateUnityProjectViews ( ) ;
95+ }
9996
100- Background = UnityHubNativeNetApp . Config . acrylic
101- ? new SolidColorBrush (
102- ActualThemeVariant == Avalonia . Styling . ThemeVariant . Dark ? Colors . Black : Colors . White ,
103- 1 - UnityHubNativeNetApp . Config . blurIntensity )
104- : Brushes . Transparent ;
105- #endif
106- }
97+ public static void OnOpenWithClicked ( )
98+ {
99+ var dialogue = new OpenWithDialogue ( UnityHubUtils . UnityProjects [ GetUnityProjectSelectedIndex ( ) ] ) ;
100+ dialogue . ShowDialog ( Instance ) ;
107101 }
108102
109- static void ReloadEverything ( )
103+ public static void OnRemoveProjectFromListClicked ( )
110104 {
111- UnityHubUtils . LoadAll ( ) ;
112- UpdateUnityVersionViews ( ) ;
113- UpdateUnitySearchPathViews ( ) ;
105+ UnityHubUtils . UnityProjects . RemoveAt ( GetUnityProjectSelectedIndex ( ) ) ;
106+ UnityHubUtils . SaveUnityProjects ( ) ;
107+ UnityHubUtils . LoadUnityProjects ( ) ;
114108 UpdateUnityProjectViews ( ) ;
115109 }
116110
111+ public static void UpdateUnityVersionViews ( )
112+ {
113+ SyncListBoxWithView < UnityInstallation , UnityInstallationView > ( s_unityInstallationsParent , UnityHubUtils . UnityInstallations ) ;
114+
115+ for ( int i = 0 ; i < UnityHubUtils . UnityInstallations . Count ; i ++ )
116+ ( ( UnityInstallationView ) s_unityInstallationsParent . Items [ i ] ! ) . Update ( UnityHubUtils . UnityInstallations [ i ] ) ;
117+ }
118+
119+ public static void UpdateUnitySearchPathViews ( )
120+ {
121+ SyncListBoxWithView < string , UnityInstallationSearchPathView > ( s_unityInstalltionSearchPathsParent , UnityHubUtils . UnityInstallationSearchPaths ) ;
122+
123+ for ( int i = 0 ; i < UnityHubUtils . UnityInstallationSearchPaths . Count ; i ++ )
124+ ( ( UnityInstallationSearchPathView ) s_unityInstalltionSearchPathsParent . Items [ i ] ! ) . Update ( UnityHubUtils . UnityInstallationSearchPaths [ i ] ) ;
125+ }
126+
127+ public static void UpdateUnityProjectViews ( )
128+ {
129+ SyncListBoxWithView < UnityProject , UnityProjectView > ( s_unityProjectsParent , UnityHubUtils . UnityProjects ) ;
130+
131+ for ( int i = 0 ; i < UnityHubUtils . UnityProjects . Count ; i ++ )
132+ ( ( UnityProjectView ) s_unityProjectsParent . Items [ i ] ! ) . Update ( UnityHubUtils . UnityProjects [ i ] ) ;
133+ }
134+
135+ public static void MoveUnityProjectUp ( UnityProject unityProject )
136+ {
137+ if ( unityProject is null )
138+ return ;
139+ var ind = UnityHubUtils . UnityProjects . IndexOf ( unityProject ) ;
140+ if ( ind == - 1 )
141+ return ;
142+ if ( ind == UnityHubUtils . UnityProjects . Count - 1 )
143+ return ;
144+ UnityHubUtils . UnityProjects . RemoveAt ( ind ) ;
145+ UnityHubUtils . UnityProjects . Insert ( ind + 1 , unityProject ) ;
146+ UnityHubUtils . SaveUnityProjects ( ) ;
147+ ( s_unityProjectsParent . Items [ ind ] , s_unityProjectsParent . Items [ ind + 1 ] ) = ( s_unityProjectsParent . Items [ ind + 1 ] , s_unityProjectsParent . Items [ ind ] ) ;
148+ s_unityProjectsParent . SelectedIndex = ind + 1 ;
149+ ( ( UnityProjectView ) s_unityProjectsParent . Items [ ind ] ) . Update ( UnityHubUtils . UnityProjects [ ind ] ) ;
150+ ( ( UnityProjectView ) s_unityProjectsParent . Items [ ind + 1 ] ) . Update ( UnityHubUtils . UnityProjects [ ind + 1 ] ) ;
151+ }
152+
153+ public static void MoveUnityProjectDown ( UnityProject unityProject )
154+ {
155+ if ( unityProject is null )
156+ return ;
157+ var ind = UnityHubUtils . UnityProjects . IndexOf ( unityProject ) ;
158+ if ( ind == - 1 )
159+ return ;
160+ if ( ind == 0 )
161+ return ;
162+ UnityHubUtils . UnityProjects . RemoveAt ( ind ) ;
163+ UnityHubUtils . UnityProjects . Insert ( ind - 1 , unityProject ) ;
164+ UnityHubUtils . SaveUnityProjects ( ) ;
165+ ( s_unityProjectsParent . Items [ ind ] , s_unityProjectsParent . Items [ ind - 1 ] ) = ( s_unityProjectsParent . Items [ ind - 1 ] , s_unityProjectsParent . Items [ ind ] ) ;
166+ s_unityProjectsParent . SelectedIndex = ind - 1 ;
167+ ( ( UnityProjectView ) s_unityProjectsParent . Items [ ind ] ) . Update ( UnityHubUtils . UnityProjects [ ind ] ) ;
168+ ( ( UnityProjectView ) s_unityProjectsParent . Items [ ind - 1 ] ) . Update ( UnityHubUtils . UnityProjects [ ind - 1 ] ) ;
169+ }
170+
117171 static Control CreateContent ( ) => new DockPanel
118172 {
119173 LastChildFill = true ,
@@ -655,50 +709,12 @@ static async void OnAddExistingProjectClicked()
655709 }
656710 }
657711
658- static void OnOpenWithClicked ( )
659- {
660- var dialogue = new OpenWithDialogue ( UnityHubUtils . UnityProjects [ GetUnityProjectSelectedIndex ( ) ] ) ;
661- dialogue . ShowDialog ( Instance ) ;
662- }
663-
664712 static void OnCreateNewProjectClicked ( ) => new CreateNewProjectDialogue ( ) . ShowDialog ( Instance ) ;
665713
666- static void OnRemoveProjectFromListClicked ( )
667- {
668- UnityHubUtils . UnityProjects . RemoveAt ( GetUnityProjectSelectedIndex ( ) ) ;
669- UnityHubUtils . SaveUnityProjects ( ) ;
670- UnityHubUtils . LoadUnityProjects ( ) ;
671- UpdateUnityProjectViews ( ) ;
672- }
673-
674714 static void OnRevealProjectClicked ( ) => OsUtils . OpenExplorer ( UnityHubUtils . UnityProjects [ GetUnityProjectSelectedIndex ( ) ] . path ) ;
675715
676716 static void OnAboutClicked ( MenuItem item , RoutedEventArgs args ) => new AboutDialogue ( ) . ShowDialog ( Instance ) ;
677717
678- static void UpdateUnityVersionViews ( )
679- {
680- SyncListBoxWithView < UnityInstallation , UnityInstallationView > ( s_unityInstallationsParent , UnityHubUtils . UnityInstallations ) ;
681-
682- for ( int i = 0 ; i < UnityHubUtils . UnityInstallations . Count ; i ++ )
683- ( ( UnityInstallationView ) s_unityInstallationsParent . Items [ i ] ! ) . Update ( UnityHubUtils . UnityInstallations [ i ] ) ;
684- }
685-
686- static void UpdateUnitySearchPathViews ( )
687- {
688- SyncListBoxWithView < string , UnityInstallationSearchPathView > ( s_unityInstalltionSearchPathsParent , UnityHubUtils . UnityInstallationSearchPaths ) ;
689-
690- for ( int i = 0 ; i < UnityHubUtils . UnityInstallationSearchPaths . Count ; i ++ )
691- ( ( UnityInstallationSearchPathView ) s_unityInstalltionSearchPathsParent . Items [ i ] ! ) . Update ( UnityHubUtils . UnityInstallationSearchPaths [ i ] ) ;
692- }
693-
694- static void UpdateUnityProjectViews ( )
695- {
696- SyncListBoxWithView < UnityProject , UnityProjectView > ( s_unityProjectsParent , UnityHubUtils . UnityProjects ) ;
697-
698- for ( int i = 0 ; i < UnityHubUtils . UnityProjects . Count ; i ++ )
699- ( ( UnityProjectView ) s_unityProjectsParent . Items [ i ] ! ) . Update ( UnityHubUtils . UnityProjects [ i ] ) ;
700- }
701-
702718 static void SyncListBoxWithView < TItem , TView > ( ListBox parent , List < TItem > items ) where TView : new ( )
703719 {
704720 // update
@@ -720,5 +736,25 @@ static void ShowTbiDialogue()
720736 {
721737 _ = MessageBoxManager . GetMessageBoxStandard ( "To be implemented" , "Not implemented yet" , MsBox . Avalonia . Enums . ButtonEnum . Ok , MsBox . Avalonia . Enums . Icon . Warning ) . ShowWindowDialogAsync ( Instance ) ;
722738 }
739+
740+ void SetupBackground ( )
741+ {
742+ if ( UnityHubNativeNetApp . Config . transparent )
743+ {
744+ TransparencyLevelHint =
745+ [
746+ UnityHubNativeNetApp . Config . acrylic ? WindowTransparencyLevel . AcrylicBlur : WindowTransparencyLevel . Mica ,
747+ WindowTransparencyLevel . Blur ,
748+ ] ;
749+ #if Windows
750+
751+ Background = UnityHubNativeNetApp . Config . acrylic
752+ ? new SolidColorBrush (
753+ ActualThemeVariant == Avalonia . Styling . ThemeVariant . Dark ? Colors . Black : Colors . White ,
754+ 1 - UnityHubNativeNetApp . Config . blurIntensity )
755+ : Brushes . Transparent ;
756+ #endif
757+ }
758+ }
723759}
724760
0 commit comments