Do not allow saving project if name or applist is empty. Also minor UI changes

This commit is contained in:
donlaci
2024-06-17 15:21:13 +02:00
parent 28bf6de36c
commit bfb569e894
4 changed files with 18 additions and 6 deletions

View File

@@ -13,7 +13,7 @@
ui:TitleBar.IsIconVisible="True"
ui:WindowHelper.UseModernWindowStyle="True"
MinWidth="700"
MinHeight="480"
MinHeight="680"
AutomationProperties.Name="Projects Editor"
Closing="OnClosing"
ContentRendered="OnContentRendered"

View File

@@ -21,11 +21,6 @@ namespace ProjectsEditor.Models
{
public class Project : INotifyPropertyChanged
{
public class ScreenHeader : Application
{
public string Title { get; set; }
}
[JsonIgnore]
public string EditorWindowTitle { get; set; }
@@ -44,6 +39,7 @@ namespace ProjectsEditor.Models
{
_name = value;
OnPropertyChanged(new PropertyChangedEventArgs(nameof(Name)));
OnPropertyChanged(new PropertyChangedEventArgs(nameof(CanBeSaved)));
}
}
@@ -123,6 +119,11 @@ namespace ProjectsEditor.Models
}
}
public bool CanBeSaved
{
get => Name.Length > 0 && Applications.Where(x => x.IsSelected).Any();
}
private bool _isPopupVisible;
[JsonIgnore]

View File

@@ -145,6 +145,7 @@
Margin="0,6,0,6"
HorizontalAlignment="Left"
GotFocus="EditNameTextBox_GotFocus"
TextChanged="EditNameTextBox_TextChanged"
KeyDown="EditNameTextBoxKeyDown" />
</StackPanel>
<Border
@@ -235,6 +236,7 @@
Margin="20,0,0,0"
Padding="24,0,24,0"
Height="36"
IsEnabled="{Binding CanBeSaved, UpdateSourceTrigger=PropertyChanged}"
Content="{x:Static props:Resources.Save_project}"
AutomationProperties.Name="{x:Static props:Resources.Save_project}"
Click="SaveButtonClicked"

View File

@@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -28,6 +29,7 @@ namespace ProjectsEditor
CheckBox checkBox = sender as CheckBox;
Models.Application application = checkBox.DataContext as Models.Application;
Models.Project project = application.Parent;
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.CanBeSaved)));
project.Initialize();
}
@@ -82,5 +84,12 @@ namespace ProjectsEditor
Project project = app.Parent;
project.Initialize();
}
private void EditNameTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
Project project = this.DataContext as Project;
project.Name = EditNameTextBox.Text;
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.CanBeSaved)));
}
}
}