1
- using System ;
1
+ // Unity Project Launcher by https://unitycoder.com
2
+ // Sources https://github.com/unitycoder/UnityLauncherPro
3
+
4
+ using System ;
2
5
using System . Collections . Generic ;
3
6
using System . ComponentModel ;
4
7
using System . Diagnostics ;
@@ -35,9 +38,11 @@ void Start()
35
38
{
36
39
LoadSettings ( ) ;
37
40
41
+ // disable accesskeys without alt
42
+ CoreCompatibilityPreferences . IsAltKeyRequiredInAccessKeyDefaultScope = true ;
43
+
38
44
// make window resizable (this didnt work when used pure xaml to do this)
39
45
WindowChrome Resizable_BorderLess_Chrome = new WindowChrome ( ) ;
40
- //Resizable_BorderLess_Chrome.GlassFrameThickness = new Thickness(0);
41
46
Resizable_BorderLess_Chrome . CornerRadius = new CornerRadius ( 0 ) ;
42
47
Resizable_BorderLess_Chrome . CaptionHeight = 1.0 ;
43
48
WindowChrome . SetWindowChrome ( this , Resizable_BorderLess_Chrome ) ;
@@ -131,20 +136,53 @@ void FilterRecentProjects()
131
136
_filterString = txtSearchBox . Text ;
132
137
ICollectionView collection = CollectionViewSource . GetDefaultView ( projectsSource ) ;
133
138
collection . Filter = ProjectFilter ;
134
-
135
- // set first row selected (good, especially if only one results)
139
+ // set first row selected
136
140
if ( gridRecent . Items . Count > 0 )
137
141
{
138
142
gridRecent . SelectedIndex = 0 ;
139
143
}
140
144
}
141
145
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
+
142
168
private bool ProjectFilter ( object item )
143
169
{
144
170
Project proj = item as Project ;
145
171
return ( proj . Title . IndexOf ( _filterString , 0 , StringComparison . CurrentCultureIgnoreCase ) != - 1 ) ;
146
172
}
147
173
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
+
148
186
void LoadSettings ( )
149
187
{
150
188
// form size
@@ -276,7 +314,6 @@ async void CallGetUnityUpdates()
276
314
dataGridUpdates . ItemsSource = null ;
277
315
var task = GetUnityUpdates . Scan ( ) ;
278
316
var items = await task ;
279
- // TODO handle errors?
280
317
if ( items == null ) return ;
281
318
updatesSource = GetUnityUpdates . Parse ( items ) ;
282
319
if ( updatesSource == null ) return ;
@@ -334,7 +371,6 @@ private void OnRectangleMouseDown(object sender, MouseButtonEventArgs e)
334
371
335
372
private void OnSearchTextChanged ( object sender , TextChangedEventArgs e )
336
373
{
337
- TextBox textbox = ( TextBox ) sender ;
338
374
FilterRecentProjects ( ) ;
339
375
}
340
376
@@ -383,7 +419,7 @@ private void BtnMinimize_Click(object sender, RoutedEventArgs e)
383
419
}
384
420
}
385
421
386
- private async void OnGetUnityUpdatesClick ( object sender , RoutedEventArgs e )
422
+ private void OnGetUnityUpdatesClick ( object sender , RoutedEventArgs e )
387
423
{
388
424
var button = ( Button ) sender ;
389
425
button . IsEnabled = false ;
@@ -395,8 +431,12 @@ private async void OnGetUnityUpdatesClick(object sender, RoutedEventArgs e)
395
431
396
432
private void OnWindowKeyDown ( object sender , KeyEventArgs e )
397
433
{
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
+ }*/
400
440
401
441
switch ( tabControl . SelectedIndex )
402
442
{
@@ -418,6 +458,9 @@ private void OnWindowKeyDown(object sender, KeyEventArgs e)
418
458
IEditableCollectionView itemsView = gridRecent . Items ;
419
459
if ( itemsView . IsAddingNew || itemsView . IsEditingItem ) return ;
420
460
461
+ // skip these keys
462
+ if ( Keyboard . Modifiers == ModifierKeys . Alt ) return ;
463
+
421
464
// activate searchbar if not active and we are in tab#1
422
465
if ( txtSearchBox . IsFocused == false )
423
466
{
@@ -537,8 +580,10 @@ private void MenuItemCopyVersion_Click(object sender, RoutedEventArgs e)
537
580
}
538
581
else if ( tabControl . SelectedIndex == 2 )
539
582
{
540
- //var update = getselect
583
+ var unity = GetSelectedUpdate ( ) ;
584
+ copy = unity ? . Version ;
541
585
}
586
+
542
587
if ( copy != null ) Clipboard . SetText ( copy ) ;
543
588
}
544
589
@@ -927,8 +972,17 @@ private void GridRecent_CellEditEnding(object sender, DataGridCellEditEndingEven
927
972
//SetStatus("File error: " + exception.Message);
928
973
Console . WriteLine ( ex ) ;
929
974
}
930
-
931
975
// TODO select the same row again
932
976
}
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
+ }
933
987
} // class
934
988
} //namespace
0 commit comments