mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 03:07:56 +01:00
Add intermediate step to project creation
This commit is contained in:
@@ -25,7 +25,7 @@ namespace ProjectsEditor
|
||||
|
||||
private /*async*/ void NewProjectButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_mainViewModel.AddNewProject();
|
||||
_mainViewModel.EnterSnapshotMode();
|
||||
}
|
||||
|
||||
private void EditButtonClicked(object sender, RoutedEventArgs e)
|
||||
|
||||
15
src/modules/Projects/ProjectsEditor/OverlayWindow.xaml
Normal file
15
src/modules/Projects/ProjectsEditor/OverlayWindow.xaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<Window x:Class="ProjectsEditor.OverlayWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:ProjectsEditor"
|
||||
mc:Ignorable="d"
|
||||
AllowsTransparency="True"
|
||||
WindowStyle="None"
|
||||
Background="Transparent">
|
||||
<Border
|
||||
Background="Transparent"
|
||||
BorderBrush="Red"
|
||||
BorderThickness="3"/>
|
||||
</Window>
|
||||
31
src/modules/Projects/ProjectsEditor/OverlayWindow.xaml.cs
Normal file
31
src/modules/Projects/ProjectsEditor/OverlayWindow.xaml.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
// 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;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace ProjectsEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for OverlayWindow.xaml
|
||||
/// </summary>
|
||||
public partial class OverlayWindow : Window
|
||||
{
|
||||
public OverlayWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -483,6 +483,24 @@ namespace ProjectsEditor.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Move the windows you want to include to the project into the desired position. There will be later a possibility to deselect the windows you don't want to include to the project..
|
||||
/// </summary>
|
||||
public static string SnapshotDescription {
|
||||
get {
|
||||
return ResourceManager.GetString("SnapshotDescription", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Snapshot Creator.
|
||||
/// </summary>
|
||||
public static string SnapshotWindowTitle {
|
||||
get {
|
||||
return ResourceManager.GetString("SnapshotWindowTitle", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Sort by.
|
||||
/// </summary>
|
||||
@@ -492,6 +510,15 @@ namespace ProjectsEditor.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Take Snapshot.
|
||||
/// </summary>
|
||||
public static string Take_Snapshot {
|
||||
get {
|
||||
return ResourceManager.GetString("Take_Snapshot", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Write arguments here.
|
||||
/// </summary>
|
||||
|
||||
@@ -258,9 +258,18 @@
|
||||
<data name="SelectedAllInProject" xml:space="preserve">
|
||||
<value>Select All Apps in Project</value>
|
||||
</data>
|
||||
<data name="SnapshotDescription" xml:space="preserve">
|
||||
<value>Move the windows you want to include to the project into the desired position. There will be later a possibility to deselect the windows you don't want to include to the project.</value>
|
||||
</data>
|
||||
<data name="SnapshotWindowTitle" xml:space="preserve">
|
||||
<value>Snapshot Creator</value>
|
||||
</data>
|
||||
<data name="SortBy" xml:space="preserve">
|
||||
<value>Sort by</value>
|
||||
</data>
|
||||
<data name="Take_Snapshot" xml:space="preserve">
|
||||
<value>Take Snapshot</value>
|
||||
</data>
|
||||
<data name="WriteArgs" xml:space="preserve">
|
||||
<value>Write arguments here</value>
|
||||
</data>
|
||||
|
||||
58
src/modules/Projects/ProjectsEditor/SnapshotWindow.xaml
Normal file
58
src/modules/Projects/ProjectsEditor/SnapshotWindow.xaml
Normal file
@@ -0,0 +1,58 @@
|
||||
<Window x:Class="ProjectsEditor.SnapshotWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
xmlns:local="clr-namespace:ProjectsEditor"
|
||||
xmlns:props="clr-namespace:ProjectsEditor.Properties"
|
||||
mc:Ignorable="d"
|
||||
Background="{DynamicResource PrimaryBackgroundBrush}"
|
||||
Title="{x:Static props:Resources.SnapshotWindowTitle}"
|
||||
Width="250"
|
||||
Height="200"
|
||||
ResizeMode="NoResize"
|
||||
ui:TitleBar.Background="{DynamicResource PrimaryBackgroundBrush}"
|
||||
ui:TitleBar.InactiveBackground="{DynamicResource TertiaryBackgroundBrush}"
|
||||
ui:WindowHelper.UseModernWindowStyle="True"
|
||||
Closing="Window_Closing">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
<ColumnDefinition Width="1*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
Grid.ColumnSpan="2"
|
||||
TextWrapping="WrapWithOverflow"
|
||||
Margin="5"
|
||||
Foreground="{DynamicResource PrimaryForegroundBrush}"
|
||||
Text="{x:Static props:Resources.SnapshotDescription}" />
|
||||
<Button
|
||||
Grid.Row="1"
|
||||
x:Name="CancelButton"
|
||||
Margin="5,5,5,5"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="36"
|
||||
Content="{x:Static props:Resources.Cancel}"
|
||||
Background="{DynamicResource SecondaryBackgroundBrush}"
|
||||
AutomationProperties.Name="{x:Static props:Resources.Cancel}"
|
||||
Click="CancelButtonClicked">
|
||||
</Button>
|
||||
<Button
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
x:Name="SnapshotButton"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="5,5,5,5"
|
||||
Height="36"
|
||||
Content="{x:Static props:Resources.Take_Snapshot}"
|
||||
AutomationProperties.Name="{x:Static props:Resources.Take_Snapshot}"
|
||||
Click="SnapshotButtonClicked"
|
||||
Style="{StaticResource AccentButtonStyle}">
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
51
src/modules/Projects/ProjectsEditor/SnapshotWindow.xaml.cs
Normal file
51
src/modules/Projects/ProjectsEditor/SnapshotWindow.xaml.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
// 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;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using ProjectsEditor.ViewModels;
|
||||
|
||||
namespace ProjectsEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SnapshotWindow.xaml
|
||||
/// </summary>
|
||||
public partial class SnapshotWindow : Window
|
||||
{
|
||||
private MainViewModel _mainViewModel;
|
||||
|
||||
public SnapshotWindow(MainViewModel mainViewModel)
|
||||
{
|
||||
_mainViewModel = mainViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void CancelButtonClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
_mainViewModel.CancelSnapshot();
|
||||
}
|
||||
|
||||
private void SnapshotButtonClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_mainViewModel.AddNewProject();
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
_mainViewModel.CancelSnapshot();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@ namespace ProjectsEditor.ViewModels
|
||||
public class MainViewModel : INotifyPropertyChanged, IDisposable
|
||||
{
|
||||
private ProjectsEditorIO _projectsEditorIO;
|
||||
private SnapshotWindow _snapshotWindow;
|
||||
private List<OverlayWindow> _overlayWindows = new List<OverlayWindow>();
|
||||
|
||||
public ObservableCollection<Project> Projects { get; set; } = new ObservableCollection<Project>();
|
||||
|
||||
@@ -217,6 +219,7 @@ namespace ProjectsEditor.ViewModels
|
||||
|
||||
public async void AddNewProject()
|
||||
{
|
||||
CancelSnapshot();
|
||||
await Task.Run(() => RunSnapshotTool());
|
||||
if (_projectsEditorIO.ParseProjects(this).Result == true && Projects.Count != 0)
|
||||
{
|
||||
@@ -388,5 +391,39 @@ namespace ProjectsEditor.ViewModels
|
||||
|
||||
project.OnPropertyChanged(new PropertyChangedEventArgs(nameof(Project.IsAnySelected)));
|
||||
}
|
||||
|
||||
internal void EnterSnapshotMode()
|
||||
{
|
||||
_mainWindow.WindowState = System.Windows.WindowState.Minimized;
|
||||
_overlayWindows.Clear();
|
||||
var screens = System.Windows.Forms.Screen.AllScreens;
|
||||
foreach (var screen in screens)
|
||||
{
|
||||
OverlayWindow overlayWindow = new OverlayWindow();
|
||||
overlayWindow.Top = screen.Bounds.Top;
|
||||
overlayWindow.Left = screen.Bounds.Left;
|
||||
overlayWindow.Width = screen.Bounds.Width;
|
||||
overlayWindow.Height = screen.Bounds.Height;
|
||||
overlayWindow.ShowActivated = true;
|
||||
overlayWindow.Topmost = true;
|
||||
overlayWindow.Show();
|
||||
_overlayWindows.Add(overlayWindow);
|
||||
}
|
||||
|
||||
_snapshotWindow = new SnapshotWindow(this);
|
||||
_snapshotWindow.ShowActivated = true;
|
||||
_snapshotWindow.Topmost = true;
|
||||
_snapshotWindow.Show();
|
||||
}
|
||||
|
||||
internal void CancelSnapshot()
|
||||
{
|
||||
foreach (OverlayWindow overlayWindow in _overlayWindows)
|
||||
{
|
||||
overlayWindow.Close();
|
||||
}
|
||||
|
||||
_mainWindow.WindowState = System.Windows.WindowState.Normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user