@@ -1167,14 +1167,14 @@ public static bool SaveCustomProjectData(string projectPath, string customFile,
11671167
11681168 public static bool HasFocus ( DependencyObject obj , Control control , bool checkChildren )
11691169 {
1170- var oFocused = System . Windows . Input . FocusManager . GetFocusedElement ( obj ) as DependencyObject ;
1170+ var oFocused = FocusManager . GetFocusedElement ( obj ) as DependencyObject ;
11711171 if ( ! checkChildren )
11721172 return oFocused == control ;
11731173 while ( oFocused != null )
11741174 {
11751175 if ( oFocused == control )
11761176 return true ;
1177- oFocused = System . Windows . Media . VisualTreeHelper . GetParent ( oFocused ) ;
1177+ oFocused = VisualTreeHelper . GetParent ( oFocused ) ;
11781178 }
11791179 return false ;
11801180 }
@@ -1201,23 +1201,32 @@ public static void SetFocusToGrid(DataGrid targetGrid, int index = -1)
12011201 if ( row == null )
12021202 {
12031203 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+ }
12071214 }
12081215 // NOTE does this causes move below?
12091216 //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+ }
12141223 }
12151224
12161225 public static string BrowseForOutputFolder ( string title , string initialDirectory = null )
12171226 {
12181227 // https://stackoverflow.com/a/50261723/5452781
12191228 // Create a "Save As" dialog for selecting a directory (HACK)
1220- var dialog = new Microsoft . Win32 . SaveFileDialog ( ) ;
1229+ var dialog = new SaveFileDialog ( ) ;
12211230 if ( initialDirectory != null ) dialog . InitialDirectory = initialDirectory ;
12221231 dialog . Title = title ;
12231232 dialog . Filter = "Project Folder|*.Folder" ; // Prevents displaying files
@@ -1297,11 +1306,12 @@ public static Project FastCreateProject(string version, string baseFolder, strin
12971306 // launch empty project
12981307 var proj = new Project ( ) ;
12991308 proj . Title = projectName ;
1300- proj . Path = Path . Combine ( baseFolder , newPath ) ;
1309+ proj . Path = Path . Combine ( baseFolder , newPath ) . Replace ( " \\ " , "/" ) ;
13011310 proj . Version = version ;
13021311 proj . TargetPlatforms = platformsForThisUnity ;
13031312 proj . TargetPlatform = platform ;
13041313 proj . Modified = DateTime . Now ;
1314+ proj . folderExists = true ; // have to set this value, so item is green on list
13051315
13061316 var proc = LaunchProject ( proj , null , useInitScript ) ;
13071317 ProcessHandler . Add ( proj , proc ) ;
0 commit comments