mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
Merge branch 'dev/feature/projects' of https://github.com/microsoft/PowerToys into dev/feature/projects
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]
|
[JsonIgnore]
|
||||||
public bool IsHighlighted { get; set; }
|
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; }
|
public List<MonitorSetup> Monitors { get; set; }
|
||||||
|
|
||||||
private BitmapImage _previewIcons;
|
private BitmapImage _previewIcons;
|
||||||
@@ -220,7 +218,6 @@ namespace ProjectsEditor.Models
|
|||||||
PackageFullName = item.PackageFullName,
|
PackageFullName = item.PackageFullName,
|
||||||
Minimized = item.Minimized,
|
Minimized = item.Minimized,
|
||||||
Maximized = item.Maximized,
|
Maximized = item.Maximized,
|
||||||
IsSelected = false,
|
|
||||||
MonitorNumber = item.MonitorNumber,
|
MonitorNumber = item.MonitorNumber,
|
||||||
IsNotFound = item.IsNotFound,
|
IsNotFound = item.IsNotFound,
|
||||||
Position = new Application.WindowPosition() { X = item.Position.X, Y = item.Position.Y, Height = item.Position.Height, Width = item.Position.Width },
|
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">
|
<DataTemplate x:Key="headerTemplate">
|
||||||
<Border
|
<Border
|
||||||
HorizontalAlignment="Stretch">
|
HorizontalAlignment="Stretch">
|
||||||
<DockPanel
|
<TextBlock
|
||||||
HorizontalAlignment="Stretch"
|
DockPanel.Dock="Left"
|
||||||
>
|
Text="{Binding MonitorName}"
|
||||||
<TextBlock
|
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
||||||
DockPanel.Dock="Left"
|
FontSize="14"
|
||||||
Text="{Binding MonitorName}"
|
FontWeight="Normal"
|
||||||
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
Margin="0,0,20,0"
|
||||||
FontSize="14"
|
VerticalAlignment="Center"/>
|
||||||
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>
|
|
||||||
</Border>
|
</Border>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<DataTemplate x:Key="appTemplate">
|
<DataTemplate x:Key="appTemplate">
|
||||||
@@ -117,12 +103,6 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</TextBlock.Style>
|
</TextBlock.Style>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<CheckBox
|
|
||||||
Grid.Column="5"
|
|
||||||
IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
|
||||||
Checked="CheckBox_Checked"
|
|
||||||
Unchecked="CheckBox_Checked"
|
|
||||||
Margin="10"/>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
@@ -167,41 +147,21 @@
|
|||||||
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<DockPanel Grid.Row="1">
|
<StackPanel Grid.Row="1" Orientation="Vertical">
|
||||||
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" >
|
<TextBlock Text="{x:Static props:Resources.ProjectName}" FontSize="14" FontWeight="Normal" Foreground="{DynamicResource PrimaryForegroundBrush}"/>
|
||||||
<Button x:Name="DeleteButton"
|
<TextBox
|
||||||
Margin="10,0,0,0"
|
x:Name="EditNameTextBox"
|
||||||
Height="36"
|
Width="320"
|
||||||
Padding="24,0,24,0"
|
Text="{Binding Name, Mode=TwoWay}"
|
||||||
Content="{x:Static props:Resources.DeleteSelected}"
|
Background="{DynamicResource SecondaryBackgroundBrush}"
|
||||||
Background="{DynamicResource SecondaryBackgroundBrush}"
|
BorderBrush="{DynamicResource PrimaryBorderBrush}"
|
||||||
AutomationProperties.Name="{x:Static props:Resources.Cancel}"
|
BorderThickness="2"
|
||||||
IsEnabled="{Binding IsAnySelected, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
|
Margin="0,6,0,6"
|
||||||
Click="RemoveSelectedButtonClicked"/>
|
HorizontalAlignment="Left"
|
||||||
<CheckBox
|
GotFocus="EditNameTextBox_GotFocus"
|
||||||
x:Name="SelectAllCheckBox"
|
TextChanged="EditNameTextBox_TextChanged"
|
||||||
Margin="10,0,0,0"
|
KeyDown="EditNameTextBoxKeyDown" />
|
||||||
FontSize="14"
|
</StackPanel>
|
||||||
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>
|
|
||||||
<Border
|
<Border
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
|
|||||||
@@ -25,16 +25,6 @@ namespace ProjectsEditor
|
|||||||
InitializeComponent();
|
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)
|
private void SaveButtonClicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Project projectToSave = this.DataContext as Project;
|
Project projectToSave = this.DataContext as Project;
|
||||||
@@ -50,12 +40,6 @@ namespace ProjectsEditor
|
|||||||
_mainViewModel.SwitchToMainView();
|
_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)
|
private void CancelButtonClicked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// delete the temp file created by the snapshot tool
|
// delete the temp file created by the snapshot tool
|
||||||
@@ -110,21 +94,5 @@ namespace ProjectsEditor
|
|||||||
project.Name = EditNameTextBox.Text;
|
project.Name = EditNameTextBox.Text;
|
||||||
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.CanBeSaved)));
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ namespace ProjectsEditor.Utils
|
|||||||
CommandLineArguments = app.CommandLineArguments,
|
CommandLineArguments = app.CommandLineArguments,
|
||||||
Maximized = app.Maximized,
|
Maximized = app.Maximized,
|
||||||
Minimized = app.Minimized,
|
Minimized = app.Minimized,
|
||||||
IsSelected = false,
|
|
||||||
IsNotFound = false,
|
IsNotFound = false,
|
||||||
Position = new Models.Application.WindowPosition()
|
Position = new Models.Application.WindowPosition()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -370,46 +370,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()
|
internal void EnterSnapshotMode()
|
||||||
{
|
{
|
||||||
_mainWindow.WindowState = System.Windows.WindowState.Minimized;
|
_mainWindow.WindowState = System.Windows.WindowState.Minimized;
|
||||||
|
|||||||
Reference in New Issue
Block a user