1- using System ;
1+ // Unity Project Launcher by https://unitycoder.com
2+ // Sources https://github.com/unitycoder/UnityLauncherPro
3+
4+ using System ;
25using System . Collections . Generic ;
36using System . ComponentModel ;
47using System . Diagnostics ;
@@ -35,9 +38,11 @@ void Start()
3538 {
3639 LoadSettings ( ) ;
3740
41+ // disable accesskeys without alt
42+ CoreCompatibilityPreferences . IsAltKeyRequiredInAccessKeyDefaultScope = true ;
43+
3844 // make window resizable (this didnt work when used pure xaml to do this)
3945 WindowChrome Resizable_BorderLess_Chrome = new WindowChrome ( ) ;
40- //Resizable_BorderLess_Chrome.GlassFrameThickness = new Thickness(0);
4146 Resizable_BorderLess_Chrome . CornerRadius = new CornerRadius ( 0 ) ;
4247 Resizable_BorderLess_Chrome . CaptionHeight = 1.0 ;
4348 WindowChrome . SetWindowChrome ( this , Resizable_BorderLess_Chrome ) ;
@@ -131,20 +136,53 @@ void FilterRecentProjects()
131136 _filterString = txtSearchBox . Text ;
132137 ICollectionView collection = CollectionViewSource . GetDefaultView ( projectsSource ) ;
133138 collection . Filter = ProjectFilter ;
134-
135- // set first row selected (good, especially if only one results)
139+ // set first row selected
136140 if ( gridRecent . Items . Count > 0 )
137141 {
138142 gridRecent . SelectedIndex = 0 ;
139143 }
140144 }
141145
146+ void FilterUpdates ( )
147+ {
148+ _filterString = txtSearchBoxUpdates . Text ;
149+ ICollectionView collection = CollectionViewSource . GetDefaultView ( dataGridUpdates . ItemsSource ) ;
150+ collection . Filter = UpdatesFilter ;
151+ if ( dataGridUpdates . Items . Count > 0 )
152+ {
153+ dataGridUpdates . SelectedIndex = 0 ;
154+ }
155+ }
156+
157+ void FilterUnitys ( )
158+ {
159+ _filterString = txtSearchBoxUnity . Text ;
160+ ICollectionView collection = CollectionViewSource . GetDefaultView ( dataGridUnitys . ItemsSource ) ;
161+ collection . Filter = UnitysFilter ;
162+ if ( dataGridUnitys . Items . Count > 0 )
163+ {
164+ dataGridUnitys . SelectedIndex = 0 ;
165+ }
166+ }
167+
142168 private bool ProjectFilter ( object item )
143169 {
144170 Project proj = item as Project ;
145171 return ( proj . Title . IndexOf ( _filterString , 0 , StringComparison . CurrentCultureIgnoreCase ) != - 1 ) ;
146172 }
147173
174+ private bool UpdatesFilter ( object item )
175+ {
176+ Updates unity = item as Updates ;
177+ return ( unity . Version . IndexOf ( _filterString , 0 , StringComparison . CurrentCultureIgnoreCase ) != - 1 ) ;
178+ }
179+
180+ private bool UnitysFilter ( object item )
181+ {
182+ UnityInstallation unity = item as UnityInstallation ;
183+ return ( unity . Version . IndexOf ( _filterString , 0 , StringComparison . CurrentCultureIgnoreCase ) != - 1 ) ;
184+ }
185+
148186 void LoadSettings ( )
149187 {
150188 // form size
@@ -276,7 +314,6 @@ async void CallGetUnityUpdates()
276314 dataGridUpdates . ItemsSource = null ;
277315 var task = GetUnityUpdates . Scan ( ) ;
278316 var items = await task ;
279- // TODO handle errors?
280317 if ( items == null ) return ;
281318 updatesSource = GetUnityUpdates . Parse ( items ) ;
282319 if ( updatesSource == null ) return ;
@@ -334,7 +371,6 @@ private void OnRectangleMouseDown(object sender, MouseButtonEventArgs e)
334371
335372 private void OnSearchTextChanged ( object sender , TextChangedEventArgs e )
336373 {
337- TextBox textbox = ( TextBox ) sender ;
338374 FilterRecentProjects ( ) ;
339375 }
340376
@@ -383,7 +419,7 @@ private void BtnMinimize_Click(object sender, RoutedEventArgs e)
383419 }
384420 }
385421
386- private async void OnGetUnityUpdatesClick ( object sender , RoutedEventArgs e )
422+ private void OnGetUnityUpdatesClick ( object sender , RoutedEventArgs e )
387423 {
388424 var button = ( Button ) sender ;
389425 button . IsEnabled = false ;
@@ -395,8 +431,12 @@ private async void OnGetUnityUpdatesClick(object sender, RoutedEventArgs e)
395431
396432 private void OnWindowKeyDown ( object sender , KeyEventArgs e )
397433 {
398- // TODO if editing cells, dont focus on search
399- //if (gridRecent.IsCurrentCellInEditMode == true) return;
434+ // disable alt key?
435+ /*
436+ if (Keyboard.Modifiers == ModifierKeys.Alt)
437+ {
438+ e.Handled = true;
439+ }*/
400440
401441 switch ( tabControl . SelectedIndex )
402442 {
@@ -418,6 +458,9 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
418458 IEditableCollectionView itemsView = gridRecent . Items ;
419459 if ( itemsView . IsAddingNew || itemsView . IsEditingItem ) return ;
420460
461+ // skip these keys
462+ if ( Keyboard . Modifiers == ModifierKeys . Alt ) return ;
463+
421464 // activate searchbar if not active and we are in tab#1
422465 if ( txtSearchBox . IsFocused == false )
423466 {
@@ -537,8 +580,10 @@ private void MenuItemCopyVersion_Click(object sender, RoutedEventArgs e)
537580 }
538581 else if ( tabControl . SelectedIndex == 2 )
539582 {
540- //var update = getselect
583+ var unity = GetSelectedUpdate ( ) ;
584+ copy = unity ? . Version ;
541585 }
586+
542587 if ( copy != null ) Clipboard . SetText ( copy ) ;
543588 }
544589
@@ -927,8 +972,17 @@ private void GridRecent_CellEditEnding(object sender, DataGridCellEditEndingEven
927972 //SetStatus("File error: " + exception.Message);
928973 Console . WriteLine ( ex ) ;
929974 }
930-
931975 // TODO select the same row again
932976 }
977+
978+ private void TxtSearchBoxUpdates_TextChanged ( object sender , TextChangedEventArgs e )
979+ {
980+ FilterUpdates ( ) ;
981+ }
982+
983+ private void TxtSearchBoxUnity_TextChanged ( object sender , TextChangedEventArgs e )
984+ {
985+ FilterUnitys ( ) ;
986+ }
933987 } // class
934988} //namespace
0 commit comments