Skip to content

Commit f5f31c0

Browse files
committed
new project: Add "Create missing folder" button to create folders from your given path input field #201
1 parent d1e709d commit f5f31c0

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

UnityLauncherPro/NewProject.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@
4949
<Grid.ColumnDefinitions>
5050
<ColumnDefinition Width="18*"/>
5151
<ColumnDefinition Width="*"/>
52+
<ColumnDefinition Width="*"/>
5253
</Grid.ColumnDefinitions>
5354
<TextBox Grid.Column="0" x:Name="txtNewProjectFolder" VerticalAlignment="Center" IsUndoEnabled="True" TextChanged="txtNewProjectFolder_TextChanged" PreviewKeyDown="TxtNewProjectName_PreviewKeyDown" TabIndex="0" Margin="0,2,6,2" />
5455
<Button Grid.Column="1" x:Name="btnBrowseForProjectFolder" Style="{StaticResource CustomButton}" ToolTip="Browse for New Project folder" Content="..." Height="22" Width="22" HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="16" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="btnBrowseForProjectFolder_Click"/>
56+
<Button Grid.Column="2" x:Name="btnCreateMissingFolder" Style="{StaticResource CustomButton}" ToolTip="Create Missing Folder from your path" Content="+" Height="22" Width="22" HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="16" Padding="1,-2,1,1" BorderBrush="{x:Null}" Click="btnCreateMissingFolder_Click"/>
5557
</Grid>
5658

5759
<!--<Label x:Name="lblNewProjectFolder" Content="(folder)" Foreground="{DynamicResource ThemeButtonForegroundDisabled}" Margin="0" FontSize="10" Padding="5,0,5,3" />-->
@@ -64,7 +66,7 @@
6466
<Label Content="Cancel" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"/>
6567
</Button>
6668
<Button Grid.Column="1" Style="{StaticResource CustomButton}" x:Name="btnCreateNewProject" Margin="3,0,0,3" BorderBrush="{x:Null}" VerticalAlignment="Top" Height="35" Click="BtnCreateNewProject_Click" TabIndex="3">
67-
<Label Content="_Create" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"/>
69+
<Label Content="_Create Project" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"/>
6870
</Button>
6971
</Grid>
7072

UnityLauncherPro/NewProject.xaml.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,29 @@ private void txtNewProjectFolder_TextChanged(object sender, TextChangedEventArgs
373373
{
374374
txtNewProjectFolder.BorderBrush = Brushes.Red; // not visible if focused
375375
btnCreateNewProject.IsEnabled = false;
376+
btnCreateMissingFolder.IsEnabled = true;
376377
}
377378
else
378379
{
379380
txtNewProjectFolder.BorderBrush = null;
380381
btnCreateNewProject.IsEnabled = true;
381382
targetFolder = txtNewProjectFolder.Text;
383+
btnCreateMissingFolder.IsEnabled = false;
384+
}
385+
}
386+
387+
private void btnCreateMissingFolder_Click(object sender, RoutedEventArgs e)
388+
{
389+
try
390+
{
391+
Directory.CreateDirectory(txtNewProjectFolder.Text);
392+
txtNewProjectFolder.BorderBrush = null;
393+
btnCreateNewProject.IsEnabled = true;
394+
targetFolder = txtNewProjectFolder.Text;
395+
}
396+
catch (Exception ex)
397+
{
398+
Tools.SetStatus("Failed to create folder: " + ex.Message);
382399
}
383400
}
384401
}

0 commit comments

Comments
 (0)