[Workspaces] Handle admin windows repositioning. (#34965)

This commit is contained in:
Seraphima Zykova
2024-09-25 12:13:38 +03:00
committed by GitHub
parent 499dc9bb7a
commit 1e18e83af6
65 changed files with 2531 additions and 891 deletions

View File

@@ -1,33 +1,16 @@
// Copyright (c) Microsoft Corporation
// 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.Text.Json.Serialization;
using System.Threading.Tasks;
using Workspaces.Data;
using WorkspacesLauncherUI.Utils;
using static WorkspacesLauncherUI.Data.AppLaunchData;
using static WorkspacesLauncherUI.Data.AppLaunchInfoData;
using static WorkspacesLauncherUI.Data.AppLaunchInfosData;
namespace WorkspacesLauncherUI.Data
{
internal sealed class AppLaunchData : WorkspacesEditorData<AppLaunchDataWrapper>
public class AppLaunchData : WorkspacesUIData<AppLaunchDataWrapper>
{
public static string File
{
get
{
return FolderUtils.DataFolder() + "\\launch-workspaces.json";
}
}
public struct AppLaunchDataWrapper
{
[JsonPropertyName("apps")]

View File

@@ -1,32 +1,23 @@
// Copyright (c) Microsoft Corporation
// 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.Text.Json.Serialization;
using System.Threading.Tasks;
using Workspaces.Data;
using static WorkspacesLauncherUI.Data.AppLaunchInfoData;
namespace WorkspacesLauncherUI.Data
{
public class AppLaunchInfoData : WorkspacesEditorData<AppLaunchInfoWrapper>
public class AppLaunchInfoData : WorkspacesUIData<AppLaunchInfoWrapper>
{
public struct AppLaunchInfoWrapper
{
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("path")]
public string Path { get; set; }
[JsonPropertyName("application")]
public ApplicationWrapper Application { get; set; }
[JsonPropertyName("state")]
public string State { get; set; }
public LaunchingState State { get; set; }
}
}
}

View File

@@ -2,7 +2,6 @@
// 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.Text.Json.Serialization;
@@ -13,7 +12,7 @@ using static WorkspacesLauncherUI.Data.AppLaunchInfosData;
namespace WorkspacesLauncherUI.Data
{
public class AppLaunchInfosData : WorkspacesEditorData<AppLaunchInfoListWrapper>
public class AppLaunchInfosData : WorkspacesUIData<AppLaunchInfoListWrapper>
{
public struct AppLaunchInfoListWrapper
{

View File

@@ -0,0 +1,33 @@
// 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.
namespace WorkspacesLauncherUI.Data
{
public struct ApplicationWrapper
{
public string Application { get; set; }
public string ApplicationPath { get; set; }
public string Title { get; set; }
public string PackageFullName { get; set; }
public string AppUserModelId { get; set; }
public string CommandLineArguments { get; set; }
public bool IsElevated { get; set; }
public bool CanLaunchElevated { get; set; }
public bool Minimized { get; set; }
public bool Maximized { get; set; }
public PositionWrapper Position { get; set; }
public int Monitor { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
// 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.
namespace WorkspacesLauncherUI.Data
{
// sync with WorkspacesLib : LaunchingStateEnum.h
public enum LaunchingState
{
Waiting = 0,
Launched,
LaunchedAndMoved,
Failed,
}
}

View File

@@ -0,0 +1,43 @@
// 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.
namespace WorkspacesLauncherUI.Data
{
public struct PositionWrapper
{
public int X { get; set; }
public int Y { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public static bool operator ==(PositionWrapper left, PositionWrapper right)
{
return left.X == right.X && left.Y == right.Y && left.Width == right.Width && left.Height == right.Height;
}
public static bool operator !=(PositionWrapper left, PositionWrapper right)
{
return left.X != right.X || left.Y != right.Y || left.Width != right.Width || left.Height != right.Height;
}
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
PositionWrapper pos = (PositionWrapper)obj;
return X == pos.X && Y == pos.Y && Width == pos.Width && Height == pos.Height;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}

View File

@@ -8,7 +8,7 @@ using WorkspacesLauncherUI.Utils;
namespace Workspaces.Data
{
public class WorkspacesEditorData<T>
public class WorkspacesUIData<T>
{
protected JsonSerializerOptions JsonOptions
{
@@ -22,10 +22,8 @@ namespace Workspaces.Data
}
}
public T Read(string file)
public T Deserialize(string data)
{
IOUtils ioUtils = new IOUtils();
string data = ioUtils.ReadFile(file);
return JsonSerializer.Deserialize<T>(data, JsonOptions);
}