mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 03:07:56 +01:00
Merge branch 'dev/feature/projects' of https://github.com/microsoft/PowerToys into dev/feature/projects
This commit is contained in:
@@ -18,7 +18,7 @@ namespace ProjectsEditor.Models
|
||||
|
||||
public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
|
||||
{
|
||||
if (item is string)
|
||||
if (item is MonitorHeaderRow)
|
||||
{
|
||||
return HeaderTemplate;
|
||||
}
|
||||
|
||||
@@ -71,8 +71,21 @@ namespace ProjectsEditor.Models
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isSelected;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsSelected { get; set; }
|
||||
public bool IsSelected
|
||||
{
|
||||
get => _isSelected;
|
||||
set
|
||||
{
|
||||
if (_isSelected != value)
|
||||
{
|
||||
_isSelected = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsSelected)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool IsHighlighted { get; set; }
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ namespace ProjectsEditor.Models
|
||||
|
||||
public bool CanBeSaved
|
||||
{
|
||||
get => Name.Length > 0 && Applications.Where(x => x.IsSelected).Any();
|
||||
get => Name.Length > 0 && Applications.Count > 0;
|
||||
}
|
||||
|
||||
private bool _isPopupVisible;
|
||||
@@ -151,7 +151,8 @@ namespace ProjectsEditor.Models
|
||||
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))
|
||||
{
|
||||
applicationsListed.Add(appItem.Key.MonitorInfo);
|
||||
MonitorHeaderRow headerRow = new MonitorHeaderRow { MonitorName = appItem.Key.MonitorInfo, SelectString = Properties.Resources.SelectAllAppsOnMonitor + " " + appItem.Key.MonitorInfo };
|
||||
applicationsListed.Add(headerRow);
|
||||
foreach (Application app in appItem)
|
||||
{
|
||||
applicationsListed.Add(app);
|
||||
@@ -161,7 +162,8 @@ namespace ProjectsEditor.Models
|
||||
var minimizedApps = Applications.Where(x => x.Minimized);
|
||||
if (minimizedApps.Any())
|
||||
{
|
||||
applicationsListed.Add("Minimized Apps");
|
||||
MonitorHeaderRow headerRow = new MonitorHeaderRow { MonitorName = Properties.Resources.Minimized_Apps, SelectString = Properties.Resources.SelectAllMinimizedApps };
|
||||
applicationsListed.Add(headerRow);
|
||||
foreach (Application app in minimizedApps)
|
||||
{
|
||||
applicationsListed.Add(app);
|
||||
@@ -177,11 +179,13 @@ namespace ProjectsEditor.Models
|
||||
{
|
||||
get
|
||||
{
|
||||
int count = Applications.Where(x => x.IsSelected).Count();
|
||||
int count = Applications.Count;
|
||||
return count.ToString(CultureInfo.InvariantCulture) + " " + (count == 1 ? Properties.Resources.App : Properties.Resources.Apps);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAnySelected { get => Applications?.Any(x => x.IsSelected) == true; }
|
||||
|
||||
public List<MonitorSetup> Monitors { get; set; }
|
||||
|
||||
private BitmapImage _previewIcons;
|
||||
@@ -216,7 +220,7 @@ namespace ProjectsEditor.Models
|
||||
PackageFullName = item.PackageFullName,
|
||||
Minimized = item.Minimized,
|
||||
Maximized = item.Maximized,
|
||||
IsSelected = item.IsSelected,
|
||||
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 },
|
||||
|
||||
@@ -13,14 +13,30 @@
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||
|
||||
<DataTemplate x:Key="headerTemplate">
|
||||
<Border>
|
||||
<TextBlock
|
||||
Text="{Binding .}"
|
||||
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
||||
FontSize="14"
|
||||
FontWeight="Normal"
|
||||
Margin="0,20,20,5"
|
||||
VerticalAlignment="Center"/>
|
||||
<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>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="appTemplate">
|
||||
@@ -103,7 +119,7 @@
|
||||
</TextBlock>
|
||||
<CheckBox
|
||||
Grid.Column="5"
|
||||
IsChecked="{Binding IsSelected, Mode=TwoWay}"
|
||||
IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Checked="CheckBox_Checked"
|
||||
Unchecked="CheckBox_Checked"
|
||||
Margin="10"/>
|
||||
@@ -151,21 +167,41 @@
|
||||
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
||||
VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<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>
|
||||
<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>
|
||||
<Border
|
||||
Grid.Row="2"
|
||||
HorizontalAlignment="Stretch"
|
||||
@@ -189,7 +225,7 @@
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ItemsControl
|
||||
ItemsSource="{Binding ApplicationsListed, Mode=OneWay}"
|
||||
ItemsSource="{Binding ApplicationsListed, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
ItemTemplateSelector="{StaticResource AppListDataTemplateSelector}">
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace ProjectsEditor
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -40,6 +41,12 @@ 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();
|
||||
@@ -91,5 +98,21 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +168,15 @@ namespace ProjectsEditor.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Remove Selected Apps.
|
||||
/// </summary>
|
||||
public static string DeleteSelected {
|
||||
get {
|
||||
return ResourceManager.GetString("DeleteSelected", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Edit.
|
||||
/// </summary>
|
||||
@@ -249,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>
|
||||
/// Looks up a localized string similar to minutes ago.
|
||||
/// </summary>
|
||||
@@ -438,6 +456,33 @@ 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>
|
||||
/// Looks up a localized string similar to Select All Apps in Project.
|
||||
/// </summary>
|
||||
public static string SelectedAllInProject {
|
||||
get {
|
||||
return ResourceManager.GetString("SelectedAllInProject", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Sort by.
|
||||
/// </summary>
|
||||
|
||||
@@ -150,6 +150,9 @@
|
||||
<data name="Delete" xml:space="preserve">
|
||||
<value>Remove</value>
|
||||
</data>
|
||||
<data name="DeleteSelected" xml:space="preserve">
|
||||
<value>Remove Selected Apps</value>
|
||||
</data>
|
||||
<data name="Delete_Project_Dialog_Announce" xml:space="preserve">
|
||||
<value>Delete project dialog.</value>
|
||||
</data>
|
||||
@@ -180,6 +183,9 @@
|
||||
<data name="MainTitle" xml:space="preserve">
|
||||
<value>Projects demo app</value>
|
||||
</data>
|
||||
<data name="Minimized_Apps" xml:space="preserve">
|
||||
<value>Minimized Apps</value>
|
||||
</data>
|
||||
<data name="MinutesAgo" xml:space="preserve">
|
||||
<value>minutes ago</value>
|
||||
</data>
|
||||
@@ -243,6 +249,15 @@
|
||||
<data name="SecondsAgo" xml:space="preserve">
|
||||
<value>seconds ago</value>
|
||||
</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">
|
||||
<value>Select All Apps in Project</value>
|
||||
</data>
|
||||
<data name="SortBy" xml:space="preserve">
|
||||
<value>Sort by</value>
|
||||
</data>
|
||||
|
||||
@@ -48,8 +48,7 @@ namespace ProjectsEditor.Utils
|
||||
|
||||
Dictionary<string, int> repeatCounter = new Dictionary<string, int>();
|
||||
|
||||
var selectedApps = project.Applications.Where(x => x.IsSelected);
|
||||
foreach (Application app in selectedApps)
|
||||
foreach (Application app in project.Applications)
|
||||
{
|
||||
if (repeatCounter.TryGetValue(app.AppPath, out int value))
|
||||
{
|
||||
@@ -64,12 +63,12 @@ namespace ProjectsEditor.Utils
|
||||
}
|
||||
|
||||
// remove those repeatIndexes, which are single 1-es (no repetitions) by setting them to 0
|
||||
foreach (Application app in selectedApps.Where(x => repeatCounter[x.AppPath] == 1))
|
||||
foreach (Application app in project.Applications.Where(x => repeatCounter[x.AppPath] == 1))
|
||||
{
|
||||
app.RepeatIndex = 0;
|
||||
}
|
||||
|
||||
foreach (Application app in project.Applications.Where(x => !x.IsSelected))
|
||||
foreach (Application app in project.Applications)
|
||||
{
|
||||
app.RepeatIndex = 0;
|
||||
}
|
||||
@@ -96,7 +95,7 @@ namespace ProjectsEditor.Utils
|
||||
}
|
||||
|
||||
Bitmap previewBitmap = new Bitmap(Scaled(bounds.Width + (verticalGaps.Count * gapWidth)), Scaled((bounds.Height * 1.2) + (horizontalGaps.Count * gapHeight)));
|
||||
double desiredIconSize = Scaled(Math.Min(bounds.Width, bounds.Height)) * 0.3;
|
||||
double desiredIconSize = Scaled(Math.Min(bounds.Width, bounds.Height)) * 0.25;
|
||||
using (Graphics g = Graphics.FromImage(previewBitmap))
|
||||
{
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
@@ -112,7 +111,7 @@ namespace ProjectsEditor.Utils
|
||||
g.FillRectangle(monitorBrush, new Rectangle(TransformX(monitor.MonitorDpiAwareBounds.Left), TransformY(monitor.MonitorDpiAwareBounds.Top), Scaled(monitor.MonitorDpiAwareBounds.Width), Scaled(monitor.MonitorDpiAwareBounds.Height)));
|
||||
}
|
||||
|
||||
var appsToDraw = project.Applications.Where(x => x.IsSelected && !x.Minimized);
|
||||
var appsToDraw = project.Applications.Where(x => !x.Minimized);
|
||||
|
||||
// draw the highlighted app at the end to have its icon in the foreground for the case there are overlapping icons
|
||||
foreach (Application app in appsToDraw.Where(x => !x.IsHighlighted))
|
||||
@@ -124,12 +123,13 @@ namespace ProjectsEditor.Utils
|
||||
foreach (Application app in appsToDraw.Where(x => x.IsHighlighted))
|
||||
{
|
||||
Rectangle rect = new Rectangle(TransformX(app.ScaledPosition.X), TransformY(app.ScaledPosition.Y), Scaled(app.ScaledPosition.Width), Scaled(app.ScaledPosition.Height));
|
||||
DrawWindow(g, brush, rect, app, desiredIconSize);
|
||||
Brush brushForHighlight = new SolidBrush(Common.ThemeManager.GetCurrentTheme() == Common.Theme.Dark ? Color.FromArgb(192, 255, 255, 255) : Color.FromArgb(192, 0, 0, 0));
|
||||
DrawWindow(g, brushForHighlight, rect, app, desiredIconSize);
|
||||
}
|
||||
|
||||
// draw the minimized windows
|
||||
Rectangle rectMinimized = new Rectangle(0, Scaled((bounds.Height * 1.02) + (horizontalGaps.Count * gapHeight)), Scaled(bounds.Width + (verticalGaps.Count * gapWidth)), Scaled(bounds.Height * 0.18));
|
||||
DrawWindow(g, brush, rectMinimized, project.Applications.Where(x => x.IsSelected && x.Minimized));
|
||||
DrawWindow(g, brush, rectMinimized, project.Applications.Where(x => x.Minimized));
|
||||
}
|
||||
|
||||
using (var memory = new MemoryStream())
|
||||
@@ -264,8 +264,7 @@ namespace ProjectsEditor.Utils
|
||||
|
||||
public static BitmapImage DrawPreviewIcons(Project project)
|
||||
{
|
||||
var selectedApps = project.Applications.Where(x => x.IsSelected);
|
||||
int appsCount = selectedApps.Count();
|
||||
int appsCount = project.Applications.Count;
|
||||
if (appsCount == 0)
|
||||
{
|
||||
return null;
|
||||
@@ -278,7 +277,7 @@ namespace ProjectsEditor.Utils
|
||||
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
int appIndex = 0;
|
||||
foreach (var app in selectedApps)
|
||||
foreach (var app in project.Applications)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace ProjectsEditor.Utils
|
||||
CommandLineArguments = app.CommandLineArguments,
|
||||
Maximized = app.Maximized,
|
||||
Minimized = app.Minimized,
|
||||
IsSelected = true,
|
||||
IsSelected = false,
|
||||
IsNotFound = false,
|
||||
Position = new Models.Application.WindowPosition()
|
||||
{
|
||||
@@ -161,27 +161,24 @@ namespace ProjectsEditor.Utils
|
||||
|
||||
foreach (var app in project.Applications)
|
||||
{
|
||||
if (app.IsSelected)
|
||||
wrapper.Applications.Add(new ProjectsData.ApplicationWrapper
|
||||
{
|
||||
wrapper.Applications.Add(new ProjectsData.ApplicationWrapper
|
||||
Application = app.AppName,
|
||||
ApplicationPath = app.AppPath,
|
||||
Title = app.AppTitle,
|
||||
PackageFullName = app.PackageFullName,
|
||||
CommandLineArguments = app.CommandLineArguments,
|
||||
Maximized = app.Maximized,
|
||||
Minimized = app.Minimized,
|
||||
Position = new ProjectsData.ApplicationWrapper.WindowPositionWrapper
|
||||
{
|
||||
Application = app.AppName,
|
||||
ApplicationPath = app.AppPath,
|
||||
Title = app.AppTitle,
|
||||
PackageFullName = app.PackageFullName,
|
||||
CommandLineArguments = app.CommandLineArguments,
|
||||
Maximized = app.Maximized,
|
||||
Minimized = app.Minimized,
|
||||
Position = new ProjectsData.ApplicationWrapper.WindowPositionWrapper
|
||||
{
|
||||
X = app.Position.X,
|
||||
Y = app.Position.Y,
|
||||
Height = app.Position.Height,
|
||||
Width = app.Position.Width,
|
||||
},
|
||||
Monitor = app.MonitorNumber,
|
||||
});
|
||||
}
|
||||
X = app.Position.X,
|
||||
Y = app.Position.Y,
|
||||
Height = app.Position.Height,
|
||||
Width = app.Position.Width,
|
||||
},
|
||||
Monitor = app.MonitorNumber,
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var monitor in project.Monitors)
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace ProjectsEditor.ViewModels
|
||||
return false;
|
||||
}
|
||||
|
||||
return x.Applications.Any(app => app.IsSelected && app.AppName.Contains(_searchTerm, StringComparison.InvariantCultureIgnoreCase));
|
||||
return x.Applications.Any(app => app.AppName.Contains(_searchTerm, StringComparison.InvariantCultureIgnoreCase));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -159,18 +159,7 @@ namespace ProjectsEditor.ViewModels
|
||||
editedProject.IsShortcutNeeded = projectToSave.IsShortcutNeeded;
|
||||
editedProject.PreviewIcons = projectToSave.PreviewIcons;
|
||||
editedProject.PreviewImage = projectToSave.PreviewImage;
|
||||
for (int appIndex = editedProject.Applications.Count - 1; appIndex >= 0; appIndex--)
|
||||
{
|
||||
if (!projectToSave.Applications[appIndex].IsSelected)
|
||||
{
|
||||
editedProject.Applications.RemoveAt(appIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
editedProject.Applications[appIndex].IsSelected = true;
|
||||
editedProject.Applications[appIndex].CommandLineArguments = projectToSave.Applications[appIndex].CommandLineArguments;
|
||||
}
|
||||
}
|
||||
editedProject.Applications = projectToSave.Applications;
|
||||
|
||||
editedProject.OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs("AppsCountString"));
|
||||
editedProject.Initialize();
|
||||
@@ -360,5 +349,44 @@ namespace ProjectsEditor.ViewModels
|
||||
project.IsPopupVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
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