[Workspaces] Saving app properties on launch and recapture (#36751)

* [Workspaces] Implementing set and get GUID to/from HWND to distinguish windows moved by the Workspaces tool

* After launch and capture copy the CLI args from the "original" project

* Fix getting GUID

* spell check

* modification to be able to handle different data sizes on different systems

* code optimisation

* Replacing string parameter by InvokePoint

* renaming variable
This commit is contained in:
Laszlo Nemeth
2025-01-16 10:56:38 +01:00
committed by GitHub
parent 603379a1ad
commit f5f332cbba
11 changed files with 107 additions and 26 deletions

View File

@@ -342,12 +342,22 @@ namespace WorkspacesEditor.Models
return new Rectangle((int)minX, (int)minY, (int)(maxX - minX), (int)(maxY - minY));
}
public void UpdateAfterLaunchAndEdit(Project other)
public void UpdateAfterLaunchAndEdit(Project projectBeforeLaunch)
{
Id = other.Id;
Name = other.Name;
Id = projectBeforeLaunch.Id;
Name = projectBeforeLaunch.Name;
IsRevertEnabled = true;
MoveExistingWindows = other.MoveExistingWindows;
MoveExistingWindows = projectBeforeLaunch.MoveExistingWindows;
foreach (Application app in Applications)
{
var sameAppBefore = projectBeforeLaunch.Applications.Where(x => x.Id.Equals(app.Id, StringComparison.OrdinalIgnoreCase));
if (sameAppBefore.Any())
{
var appBefore = sameAppBefore.FirstOrDefault();
app.CommandLineArguments = appBefore.CommandLineArguments;
app.IsElevated = appBefore.IsElevated;
}
}
}
internal void CloseExpanders()

View File

@@ -40,6 +40,7 @@ namespace WorkspacesEditor.ViewModels
private Timer lastUpdatedTimer;
private WorkspacesSettings settings;
private PwaHelper _pwaHelper;
private bool _isExistingProjectLaunched;
public ObservableCollection<Project> Workspaces { get; set; } = new ObservableCollection<Project>();
@@ -256,12 +257,12 @@ namespace WorkspacesEditor.ViewModels
{
CancelSnapshot();
await Task.Run(() => RunSnapshotTool());
await Task.Run(() => RunSnapshotTool(_isExistingProjectLaunched));
Project project = _workspacesEditorIO.ParseTempProject();
if (project != null)
{
if (editedProject != null)
if (_isExistingProjectLaunched)
{
project.UpdateAfterLaunchAndEdit(projectBeforeLaunch);
project.EditorWindowTitle = Properties.Resources.EditWorkspace;
@@ -431,15 +432,12 @@ namespace WorkspacesEditor.ViewModels
}
}
private void RunSnapshotTool(string filename = null)
private void RunSnapshotTool(bool isExistingProjectLaunched)
{
Process process = new Process();
process.StartInfo = new ProcessStartInfo(@".\PowerToys.WorkspacesSnapshotTool.exe");
process.StartInfo.CreateNoWindow = true;
if (!string.IsNullOrEmpty(filename))
{
process.StartInfo.Arguments = filename;
}
process.StartInfo.Arguments = isExistingProjectLaunched ? $"{(int)InvokePoint.LaunchAndEdit}" : string.Empty;
try
{
@@ -484,6 +482,7 @@ namespace WorkspacesEditor.ViewModels
internal void EnterSnapshotMode(bool isExistingProjectLaunched)
{
_isExistingProjectLaunched = isExistingProjectLaunched;
_mainWindow.WindowState = System.Windows.WindowState.Minimized;
_overlayWindows.Clear();
foreach (var screen in MonitorHelper.GetDpiUnawareScreens())