mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Add Checkbox for per monitor selection
This commit is contained in:
@@ -18,7 +18,7 @@ namespace ProjectsEditor.Models
|
|||||||
|
|
||||||
public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
|
public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
|
||||||
{
|
{
|
||||||
if (item is string)
|
if (item is MonitorHeaderRow)
|
||||||
{
|
{
|
||||||
return HeaderTemplate;
|
return HeaderTemplate;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) Microsoft Corporation
|
||||||
|
// 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;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectsEditor.Models
|
||||||
|
{
|
||||||
|
internal sealed class MonitorHeaderRow
|
||||||
|
{
|
||||||
|
public string MonitorName { get; set; }
|
||||||
|
|
||||||
|
public string SelectString { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -151,7 +151,8 @@ namespace ProjectsEditor.Models
|
|||||||
ILookup<MonitorSetup, Application> apps = Applications.Where(x => !x.Minimized).ToLookup(x => x.MonitorSetup);
|
ILookup<MonitorSetup, Application> apps = Applications.Where(x => !x.Minimized).ToLookup(x => x.MonitorSetup);
|
||||||
foreach (var appItem in apps.OrderBy(x => x.Key.MonitorDpiUnawareBounds.Left).ThenBy(x => x.Key.MonitorDpiUnawareBounds.Top))
|
foreach (var appItem in apps.OrderBy(x => x.Key.MonitorDpiUnawareBounds.Left).ThenBy(x => x.Key.MonitorDpiUnawareBounds.Top))
|
||||||
{
|
{
|
||||||
applicationsListed.Add(appItem.Key.MonitorInfo);
|
MonitorHeaderRow mhr = new MonitorHeaderRow { MonitorName = appItem.Key.MonitorInfo, SelectString = Properties.Resources.SelectAllAppsOnMonitor + " " + appItem.Key.MonitorInfo };
|
||||||
|
applicationsListed.Add(mhr);
|
||||||
foreach (Application app in appItem)
|
foreach (Application app in appItem)
|
||||||
{
|
{
|
||||||
applicationsListed.Add(app);
|
applicationsListed.Add(app);
|
||||||
@@ -161,7 +162,8 @@ namespace ProjectsEditor.Models
|
|||||||
var minimizedApps = Applications.Where(x => x.Minimized);
|
var minimizedApps = Applications.Where(x => x.Minimized);
|
||||||
if (minimizedApps.Any())
|
if (minimizedApps.Any())
|
||||||
{
|
{
|
||||||
applicationsListed.Add("Minimized Apps");
|
MonitorHeaderRow mhr = new MonitorHeaderRow { MonitorName = Properties.Resources.Minimized_Apps, SelectString = Properties.Resources.SelectAllMinimizedApps };
|
||||||
|
applicationsListed.Add(mhr);
|
||||||
foreach (Application app in minimizedApps)
|
foreach (Application app in minimizedApps)
|
||||||
{
|
{
|
||||||
applicationsListed.Add(app);
|
applicationsListed.Add(app);
|
||||||
|
|||||||
@@ -13,14 +13,30 @@
|
|||||||
<BooleanToVisibilityConverter x:Key="BoolToVis" />
|
<BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||||
|
|
||||||
<DataTemplate x:Key="headerTemplate">
|
<DataTemplate x:Key="headerTemplate">
|
||||||
<Border>
|
<Border
|
||||||
|
HorizontalAlignment="Stretch">
|
||||||
|
<DockPanel
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Text="{Binding .}"
|
DockPanel.Dock="Left"
|
||||||
|
Text="{Binding MonitorName}"
|
||||||
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
FontWeight="Normal"
|
FontWeight="Normal"
|
||||||
Margin="0,20,20,5"
|
Margin="0,0,20,0"
|
||||||
VerticalAlignment="Center"/>
|
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">
|
||||||
|
|||||||
@@ -105,5 +105,14 @@ namespace ProjectsEditor
|
|||||||
bool newValue = SelectAllCheckBox.IsChecked == true;
|
bool newValue = SelectAllCheckBox.IsChecked == true;
|
||||||
_mainViewModel.UpdateIsSelectedStates(project, newValue);
|
_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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,6 +258,15 @@ namespace ProjectsEditor.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Minimized Apps.
|
||||||
|
/// </summary>
|
||||||
|
public static string Minimized_Apps {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("Minimized_Apps", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to minutes ago.
|
/// Looks up a localized string similar to minutes ago.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -447,6 +456,24 @@ namespace ProjectsEditor.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Select All Apps on.
|
||||||
|
/// </summary>
|
||||||
|
public static string SelectAllAppsOnMonitor {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SelectAllAppsOnMonitor", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Select All Minimized Apps.
|
||||||
|
/// </summary>
|
||||||
|
public static string SelectAllMinimizedApps {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SelectAllMinimizedApps", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Select All Apps in Project.
|
/// Looks up a localized string similar to Select All Apps in Project.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -183,6 +183,9 @@
|
|||||||
<data name="MainTitle" xml:space="preserve">
|
<data name="MainTitle" xml:space="preserve">
|
||||||
<value>Projects demo app</value>
|
<value>Projects demo app</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Minimized_Apps" xml:space="preserve">
|
||||||
|
<value>Minimized Apps</value>
|
||||||
|
</data>
|
||||||
<data name="MinutesAgo" xml:space="preserve">
|
<data name="MinutesAgo" xml:space="preserve">
|
||||||
<value>minutes ago</value>
|
<value>minutes ago</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -246,6 +249,12 @@
|
|||||||
<data name="SecondsAgo" xml:space="preserve">
|
<data name="SecondsAgo" xml:space="preserve">
|
||||||
<value>seconds ago</value>
|
<value>seconds ago</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="SelectAllAppsOnMonitor" xml:space="preserve">
|
||||||
|
<value>Select All Apps on</value>
|
||||||
|
</data>
|
||||||
|
<data name="SelectAllMinimizedApps" xml:space="preserve">
|
||||||
|
<value>Select All Minimized Apps</value>
|
||||||
|
</data>
|
||||||
<data name="SelectedAllInProject" xml:space="preserve">
|
<data name="SelectedAllInProject" xml:space="preserve">
|
||||||
<value>Select All Apps in Project</value>
|
<value>Select All Apps in Project</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -367,5 +367,26 @@ namespace ProjectsEditor.ViewModels
|
|||||||
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.IsAnySelected)));
|
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.IsAnySelected)));
|
||||||
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.CanBeSaved)));
|
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.CanBeSaved)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user