@@ -1167,14 +1167,14 @@ public static bool SaveCustomProjectData(string projectPath, string customFile,
1167
1167
1168
1168
public static bool HasFocus ( DependencyObject obj , Control control , bool checkChildren )
1169
1169
{
1170
- var oFocused = System . Windows . Input . FocusManager . GetFocusedElement ( obj ) as DependencyObject ;
1170
+ var oFocused = FocusManager . GetFocusedElement ( obj ) as DependencyObject ;
1171
1171
if ( ! checkChildren )
1172
1172
return oFocused == control ;
1173
1173
while ( oFocused != null )
1174
1174
{
1175
1175
if ( oFocused == control )
1176
1176
return true ;
1177
- oFocused = System . Windows . Media . VisualTreeHelper . GetParent ( oFocused ) ;
1177
+ oFocused = VisualTreeHelper . GetParent ( oFocused ) ;
1178
1178
}
1179
1179
return false ;
1180
1180
}
@@ -1201,23 +1201,32 @@ public static void SetFocusToGrid(DataGrid targetGrid, int index = -1)
1201
1201
if ( row == null )
1202
1202
{
1203
1203
targetGrid . UpdateLayout ( ) ;
1204
- // scroll to view if outside
1205
- targetGrid . ScrollIntoView ( targetGrid . Items [ index ] ) ;
1206
- row = ( DataGridRow ) targetGrid . ItemContainerGenerator . ContainerFromIndex ( index ) ;
1204
+ if ( index < targetGrid . Items . Count )
1205
+ {
1206
+ // scroll selected into view
1207
+ targetGrid . ScrollIntoView ( targetGrid . Items [ index ] ) ;
1208
+ row = ( DataGridRow ) targetGrid . ItemContainerGenerator . ContainerFromIndex ( index ) ;
1209
+ }
1210
+ else
1211
+ {
1212
+ Console . WriteLine ( "selected row out of bounds: " + index ) ;
1213
+ }
1207
1214
}
1208
1215
// NOTE does this causes move below?
1209
1216
//row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
1210
- row . MoveFocus ( new TraversalRequest ( FocusNavigationDirection . Up ) ) ; // works better than Up
1211
-
1212
- row . Focus ( ) ;
1213
- Keyboard . Focus ( row ) ;
1217
+ if ( row != null )
1218
+ {
1219
+ row . MoveFocus ( new TraversalRequest ( FocusNavigationDirection . Up ) ) ; // works better than Up
1220
+ row . Focus ( ) ;
1221
+ Keyboard . Focus ( row ) ;
1222
+ }
1214
1223
}
1215
1224
1216
1225
public static string BrowseForOutputFolder ( string title , string initialDirectory = null )
1217
1226
{
1218
1227
// https://stackoverflow.com/a/50261723/5452781
1219
1228
// Create a "Save As" dialog for selecting a directory (HACK)
1220
- var dialog = new Microsoft . Win32 . SaveFileDialog ( ) ;
1229
+ var dialog = new SaveFileDialog ( ) ;
1221
1230
if ( initialDirectory != null ) dialog . InitialDirectory = initialDirectory ;
1222
1231
dialog . Title = title ;
1223
1232
dialog . Filter = "Project Folder|*.Folder" ; // Prevents displaying files
@@ -1297,11 +1306,12 @@ public static Project FastCreateProject(string version, string baseFolder, strin
1297
1306
// launch empty project
1298
1307
var proj = new Project ( ) ;
1299
1308
proj . Title = projectName ;
1300
- proj . Path = Path . Combine ( baseFolder , newPath ) ;
1309
+ proj . Path = Path . Combine ( baseFolder , newPath ) . Replace ( " \\ " , "/" ) ;
1301
1310
proj . Version = version ;
1302
1311
proj . TargetPlatforms = platformsForThisUnity ;
1303
1312
proj . TargetPlatform = platform ;
1304
1313
proj . Modified = DateTime . Now ;
1314
+ proj . folderExists = true ; // have to set this value, so item is green on list
1305
1315
1306
1316
var proc = LaunchProject ( proj , null , useInitScript ) ;
1307
1317
ProcessHandler . Add ( proj , proc ) ;
0 commit comments