Merge branch 'dev/feature/projects' of https://github.com/microsoft/PowerToys into dev/feature/projects

This commit is contained in:
seraphima
2024-06-17 19:57:14 +02:00
4 changed files with 18 additions and 6 deletions

View File

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

View File

@@ -21,11 +21,6 @@ namespace ProjectsEditor.Models
{ {
public class Project : INotifyPropertyChanged public class Project : INotifyPropertyChanged
{ {
public class ScreenHeader : Application
{
public string Title { get; set; }
}
[JsonIgnore] [JsonIgnore]
public string EditorWindowTitle { get; set; } public string EditorWindowTitle { get; set; }
@@ -44,6 +39,7 @@ namespace ProjectsEditor.Models
{ {
_name = value; _name = value;
OnPropertyChanged(new PropertyChangedEventArgs(nameof(Name))); 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; private bool _isPopupVisible;
[JsonIgnore] [JsonIgnore]

View File

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

View File

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