Skip to content

Commit

Permalink
new project: add warning if projectname starts or ends with Space cha…
Browse files Browse the repository at this point in the history
…racter
  • Loading branch information
unitycoder committed Jan 19, 2024
1 parent 227eac3 commit d0ceaa8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
13 changes: 11 additions & 2 deletions UnityLauncherPro/NewProject.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:UnityLauncherPro"
mc:Ignorable="d"
Title="Create New Project" Height="460" Width="450" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True">
Title="Create New Project" Height="480" Width="450" Background="{DynamicResource ThemeDarkestBackground}" PreviewKeyDown="Window_PreviewKeyDown" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="True">

<Grid>
<StackPanel Margin="10,3">
Expand All @@ -24,7 +24,7 @@
<ColumnDefinition Width="20*"/>
<ColumnDefinition Width="40*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="Project Name:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,5,0" />
<Label x:Name="lblNewProjectNameLabel" Grid.Column="0" Content="Project Name:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,5,0" />
<Label Grid.Column="1" Content="Platform:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="0,5,0,0" />
<Label x:Name="lblTemplateTitleAndCount" Grid.Column="2" Content="Templates:" Foreground="{DynamicResource ThemeButtonForeground}" Margin="0" Padding="5,5,5,0" />
</Grid>
Expand Down Expand Up @@ -53,6 +53,15 @@
<Label Content="_Create" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"/>
</Button>
</Grid>

<Grid Grid.Row="2" UseLayoutRounding="False">
<StatusBar VerticalAlignment="Center" Background="{x:Null}" Foreground="{DynamicResource ThemeStatusText}">
<StatusBarItem>
<TextBlock x:Name="txtNewProjectStatus" VerticalAlignment="Center" Text=""/>
</StatusBarItem>
</StatusBar>
</Grid>

</StackPanel>
</Grid>
</Window>
19 changes: 18 additions & 1 deletion UnityLauncherPro/NewProject.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -217,6 +218,22 @@ private void TxtNewProjectName_TextChanged(object sender, TextChangedEventArgs e
{
if (isInitializing == true) return;

// warning yellow if contains space at start or end
if (txtNewProjectName.Text.StartsWith(" ") || txtNewProjectName.Text.EndsWith(" "))
{
// NOTE txtbox outline didnt work
txtNewProjectName.Background = Brushes.Yellow;
txtNewProjectStatus.Text = "Warning: Project name starts or ends with SPACE character";
txtNewProjectStatus.Foreground = Brushes.Orange;
}
else
{
// NOTE this element is not using themes yet, so can set white
txtNewProjectName.Background = Brushes.White;
txtNewProjectStatus.Foreground = Brushes.White;
txtNewProjectStatus.Text = "";
}

// validate new projectname that it doesnt exists already
var targetPath = Path.Combine(targetFolder, txtNewProjectName.Text);
if (Directory.Exists(targetPath) == true)
Expand Down

0 comments on commit d0ceaa8

Please sign in to comment.