mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 03:07:56 +01:00
Remove checkboxes, delete feature
This commit is contained in:
@@ -71,22 +71,6 @@ namespace ProjectsEditor.Models
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isSelected;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
set
|
||||
{
|
||||
if (_isSelected != value)
|
||||
{
|
||||
_isSelected = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelected)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsHighlighted { get; set; }
|
||||
|
||||
|
||||
@@ -184,8 +184,6 @@ namespace ProjectsEditor.Models
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAnySelected { get => Applications?.Any(x => x.IsSelected) == true; }
|
||||
|
||||
public List<MonitorSetup> Monitors { get; set; }
|
||||
|
||||
private BitmapImage _previewIcons;
|
||||
@@ -220,7 +218,6 @@ namespace ProjectsEditor.Models
|
||||
PackageFullName = item.PackageFullName,
|
||||
Minimized = item.Minimized,
|
||||
Maximized = item.Maximized,
|
||||
IsSelected = false,
|
||||
MonitorNumber = item.MonitorNumber,
|
||||
IsNotFound = item.IsNotFound,
|
||||
Position = new Application.WindowPosition() { X = item.Position.X, Y = item.Position.Y, Height = item.Position.Height, Width = item.Position.Width },
|
||||
|
||||
@@ -15,28 +15,14 @@
|
||||
<DataTemplate x:Key="headerTemplate">
|
||||
<Border
|
||||
HorizontalAlignment="Stretch">
|
||||
<DockPanel
|
||||
HorizontalAlignment="Stretch"
|
||||
>
|
||||
<TextBlock
|
||||
DockPanel.Dock="Left"
|
||||
Text="{Binding MonitorName}"
|
||||
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
||||
FontSize="14"
|
||||
FontWeight="Normal"
|
||||
Margin="0,0,20,0"
|
||||
VerticalAlignment="Center"/>
|
||||
<CheckBox
|
||||
DockPanel.Dock="Right"
|
||||
HorizontalAlignment="Right"
|
||||
x:Name="SelectAllOnMonitorCheckBox"
|
||||
Tag="{Binding MonitorName}"
|
||||
Margin="10,0,0,0"
|
||||
FontSize="14"
|
||||
Content="{Binding SelectString}"
|
||||
Checked="SelectAllOnMonitorCheckBox_Modified"
|
||||
Unchecked="SelectAllOnMonitorCheckBox_Modified"/>
|
||||
</DockPanel>
|
||||
<TextBlock
|
||||
DockPanel.Dock="Left"
|
||||
Text="{Binding MonitorName}"
|
||||
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
||||
FontSize="14"
|
||||
FontWeight="Normal"
|
||||
Margin="0,0,20,0"
|
||||
VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="appTemplate">
|
||||
@@ -117,12 +103,6 @@
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
<CheckBox
|
||||
Grid.Column="5"
|
||||
IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Checked="CheckBox_Checked"
|
||||
Unchecked="CheckBox_Checked"
|
||||
Margin="10"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
@@ -167,41 +147,21 @@
|
||||
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
||||
VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<DockPanel Grid.Row="1">
|
||||
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" >
|
||||
<Button x:Name="DeleteButton"
|
||||
Margin="10,0,0,0"
|
||||
Height="36"
|
||||
Padding="24,0,24,0"
|
||||
Content="{x:Static props:Resources.DeleteSelected}"
|
||||
Background="{DynamicResource SecondaryBackgroundBrush}"
|
||||
AutomationProperties.Name="{x:Static props:Resources.Cancel}"
|
||||
IsEnabled="{Binding IsAnySelected, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Click="RemoveSelectedButtonClicked"/>
|
||||
<CheckBox
|
||||
x:Name="SelectAllCheckBox"
|
||||
Margin="10,0,0,0"
|
||||
FontSize="14"
|
||||
Content="{x:Static props:Resources.SelectedAllInProject}"
|
||||
Checked="SelectAllCheckBox_Modified"
|
||||
Unchecked="SelectAllCheckBox_Modified"/>
|
||||
</StackPanel>
|
||||
<StackPanel DockPanel.Dock="Left" Orientation="Vertical">
|
||||
<TextBlock Text="{x:Static props:Resources.ProjectName}" FontSize="14" FontWeight="Normal" Foreground="{DynamicResource PrimaryForegroundBrush}"/>
|
||||
<TextBox
|
||||
x:Name="EditNameTextBox"
|
||||
Width="320"
|
||||
Text="{Binding Name, Mode=TwoWay}"
|
||||
Background="{DynamicResource SecondaryBackgroundBrush}"
|
||||
BorderBrush="{DynamicResource PrimaryBorderBrush}"
|
||||
BorderThickness="2"
|
||||
Margin="0,6,0,6"
|
||||
HorizontalAlignment="Left"
|
||||
GotFocus="EditNameTextBox_GotFocus"
|
||||
TextChanged="EditNameTextBox_TextChanged"
|
||||
KeyDown="EditNameTextBoxKeyDown" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
<StackPanel Grid.Row="1" Orientation="Vertical">
|
||||
<TextBlock Text="{x:Static props:Resources.ProjectName}" FontSize="14" FontWeight="Normal" Foreground="{DynamicResource PrimaryForegroundBrush}"/>
|
||||
<TextBox
|
||||
x:Name="EditNameTextBox"
|
||||
Width="320"
|
||||
Text="{Binding Name, Mode=TwoWay}"
|
||||
Background="{DynamicResource SecondaryBackgroundBrush}"
|
||||
BorderBrush="{DynamicResource PrimaryBorderBrush}"
|
||||
BorderThickness="2"
|
||||
Margin="0,6,0,6"
|
||||
HorizontalAlignment="Left"
|
||||
GotFocus="EditNameTextBox_GotFocus"
|
||||
TextChanged="EditNameTextBox_TextChanged"
|
||||
KeyDown="EditNameTextBoxKeyDown" />
|
||||
</StackPanel>
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
HorizontalAlignment="Stretch"
|
||||
|
||||
@@ -24,16 +24,6 @@ namespace ProjectsEditor
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void CheckBox_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
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.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.IsAnySelected)));
|
||||
project.Initialize();
|
||||
}
|
||||
|
||||
private void SaveButtonClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Project projectToSave = this.DataContext as Project;
|
||||
@@ -41,12 +31,6 @@ namespace ProjectsEditor
|
||||
_mainViewModel.SwitchToMainView();
|
||||
}
|
||||
|
||||
private void RemoveSelectedButtonClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Project projectToSave = this.DataContext as Project;
|
||||
_mainViewModel.RemoveSelectedApps(projectToSave);
|
||||
}
|
||||
|
||||
private void CancelButtonClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_mainViewModel.CancelLastEdit();
|
||||
@@ -98,21 +82,5 @@ namespace ProjectsEditor
|
||||
project.Name = EditNameTextBox.Text;
|
||||
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.CanBeSaved)));
|
||||
}
|
||||
|
||||
private void SelectAllCheckBox_Modified(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Project project = this.DataContext as Project;
|
||||
bool newValue = SelectAllCheckBox.IsChecked == true;
|
||||
_mainViewModel.UpdateIsSelectedStates(project, newValue);
|
||||
}
|
||||
|
||||
private void SelectAllOnMonitorCheckBox_Modified(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Project project = this.DataContext as Project;
|
||||
CheckBox checkBox = (CheckBox)sender;
|
||||
string monitorInfo = (string)checkBox.Tag;
|
||||
bool newValue = checkBox.IsChecked == true;
|
||||
_mainViewModel.UpdateIsSelectedStates(project, monitorInfo, newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,6 @@ namespace ProjectsEditor.Utils
|
||||
CommandLineArguments = app.CommandLineArguments,
|
||||
Maximized = app.Maximized,
|
||||
Minimized = app.Minimized,
|
||||
IsSelected = false,
|
||||
IsNotFound = false,
|
||||
Position = new Models.Application.WindowPosition()
|
||||
{
|
||||
|
||||
@@ -354,46 +354,6 @@ namespace ProjectsEditor.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
internal void UpdateIsSelectedStates(Project project, bool newValue)
|
||||
{
|
||||
foreach (Application app in project.Applications)
|
||||
{
|
||||
app.IsSelected = newValue;
|
||||
}
|
||||
|
||||
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.IsAnySelected)));
|
||||
}
|
||||
|
||||
internal void RemoveSelectedApps(Project project)
|
||||
{
|
||||
project.Applications.RemoveAll(app => app.IsSelected);
|
||||
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.ApplicationsListed)));
|
||||
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.IsAnySelected)));
|
||||
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.CanBeSaved)));
|
||||
project.Initialize();
|
||||
}
|
||||
|
||||
internal void UpdateIsSelectedStates(Project project, string monitorInfo, bool newValue)
|
||||
{
|
||||
IEnumerable<Application> apps;
|
||||
if (monitorInfo == Properties.Resources.Minimized_Apps)
|
||||
{
|
||||
apps = project.Applications.Where(app => app.Minimized);
|
||||
}
|
||||
else
|
||||
{
|
||||
Monitor monitor = project.Monitors.Where(x => x.MonitorInfo == monitorInfo).Single();
|
||||
apps = project.Applications.Where(app => !app.Minimized && app.MonitorNumber == monitor.MonitorNumber);
|
||||
}
|
||||
|
||||
foreach (Application app in apps)
|
||||
{
|
||||
app.IsSelected = newValue;
|
||||
}
|
||||
|
||||
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.IsAnySelected)));
|
||||
}
|
||||
|
||||
internal void EnterSnapshotMode()
|
||||
{
|
||||
_mainWindow.WindowState = System.Windows.WindowState.Minimized;
|
||||
|
||||
Reference in New Issue
Block a user