Skip to content

Commit d0ceaa8

Browse files
committed
new project: add warning if projectname starts or ends with Space character
1 parent 227eac3 commit d0ceaa8

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Diff for: UnityLauncherPro/NewProject.xaml

+11-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:UnityLauncherPro"
77
mc:Ignorable="d"
8-
Title="Create New Project" Height="460" Width="450" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True">
8+
Title="Create New Project" Height="480" Width="450" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True">
99

1010
<Grid>
1111
<StackPanel Margin="10,3">
@@ -24,7 +24,7 @@
2424
<ColumnDefinition Width="20*"/>
2525
<ColumnDefinition Width="40*"/>
2626
</Grid.ColumnDefinitions>
27-
<Label Grid.Column="0" Content="Project Name:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,5,0" />
27+
<Label x:Name="lblNewProjectNameLabel" Grid.Column="0" Content="Project Name:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,5,0" />
2828
<Label Grid.Column="1" Content="Platform:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,0,0" />
2929
<Label x:Name="lblTemplateTitleAndCount" Grid.Column="2" Content="Templates:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="5,5,5,0" />
3030
</Grid>
@@ -53,6 +53,15 @@
5353
<Label Content="_Create" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"/>
5454
</Button>
5555
</Grid>
56+
57+
<Grid Grid.Row="2" UseLayoutRounding="False">
58+
<StatusBar VerticalAlignment="Center" Background="{x:Null}" Foreground="{DynamicResource ThemeStatusText}">
59+
<StatusBarItem>
60+
<TextBlock x:Name="txtNewProjectStatus" VerticalAlignment="Center" Text=""/>
61+
</StatusBarItem>
62+
</StatusBar>
63+
</Grid>
64+
5665
</StackPanel>
5766
</Grid>
5867
</Window>

Diff for: UnityLauncherPro/NewProject.xaml.cs

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using System.Windows;
45
using System.Windows.Controls;
@@ -217,6 +218,22 @@ private void TxtNewProjectName_TextChanged(object sender, TextChangedEventArgs e
217218
{
218219
if (isInitializing == true) return;
219220

221+
// warning yellow if contains space at start or end
222+
if (txtNewProjectName.Text.StartsWith(" ") || txtNewProjectName.Text.EndsWith(" "))
223+
{
224+
// NOTE txtbox outline didnt work
225+
txtNewProjectName.Background = Brushes.Yellow;
226+
txtNewProjectStatus.Text = "Warning: Project name starts or ends with SPACE character";
227+
txtNewProjectStatus.Foreground = Brushes.Orange;
228+
}
229+
else
230+
{
231+
// NOTE this element is not using themes yet, so can set white
232+
txtNewProjectName.Background = Brushes.White;
233+
txtNewProjectStatus.Foreground = Brushes.White;
234+
txtNewProjectStatus.Text = "";
235+
}
236+
220237
// validate new projectname that it doesnt exists already
221238
var targetPath = Path.Combine(targetFolder, txtNewProjectName.Text);
222239
if (Directory.Exists(targetPath) == true)

0 commit comments

Comments
 (0)