Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workspaces] implement the move feature #35480

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d478306
[Workspaces] Add move functionality
donlaci Oct 3, 2024
d660dc4
spell checker
donlaci Oct 3, 2024
8a2d20a
[Workspaces] Modify Arranger to move apps without launch
donlaci Oct 7, 2024
fa7a83c
moved ipc helper
SeraphimaZykova Oct 4, 2024
8a030e4
removed callback
SeraphimaZykova Oct 4, 2024
2d4c9a5
use LauncherStatus in WindowArranger
SeraphimaZykova Oct 7, 2024
d0b349a
wait for launching next app
SeraphimaZykova Oct 4, 2024
f822001
launch in a separate thread and protect by mutexes
SeraphimaZykova Oct 7, 2024
9a3873e
update app version in advance
SeraphimaZykova Oct 7, 2024
c034206
changed canceling launch
SeraphimaZykova Oct 7, 2024
9ecb50c
increased waiting time
SeraphimaZykova Oct 7, 2024
1fb4189
Fix optional parameter load from json
donlaci Oct 8, 2024
8449a4f
changed arranger waiting time
SeraphimaZykova Oct 9, 2024
5f3233f
additional waiting time for Outlook
SeraphimaZykova Oct 9, 2024
c811754
added app id
SeraphimaZykova Oct 9, 2024
e77db91
ensure ids before launch
SeraphimaZykova Oct 9, 2024
ccfaeb2
set id in editor
SeraphimaZykova Oct 9, 2024
fbd1313
minor updates
donlaci Oct 10, 2024
21d9e30
Merge remote-tracking branch 'origin/dev/seraphima/workspaces-sequent…
donlaci Oct 10, 2024
e4f64ac
Merge branch 'main' into Workspaces_Move
Oct 15, 2024
bf800cc
[Workspaces] Move: Get the nearest window when moving a window
donlaci Oct 15, 2024
add003b
[Workspaces] convert optional boolean to enum to avoid json problems
donlaci Oct 16, 2024
fd4d042
Handle case when the new Application Property "moveIfExists" does not…
donlaci Oct 17, 2024
5cfcd00
Re-implementing app-window pairing for moving feature.
donlaci Oct 18, 2024
a4793f0
spell checker
donlaci Oct 18, 2024
a822eca
XAML formatting
donlaci Oct 18, 2024
839c841
Fixing bug: IPC message not arriving
Oct 24, 2024
4351a41
spell checker
donlaci Oct 24, 2024
71209cf
Merge branch 'main' into Workspaces_Move
donlaci Nov 20, 2024
648df8a
Removing app-level-setting for move app. Also fixed compiler errors d…
donlaci Nov 21, 2024
b10e36b
Updating editor window layout
donlaci Nov 21, 2024
f0916a4
Re-implementing window positioning UI elements
donlaci Nov 21, 2024
1ded280
XAML formatting
donlaci Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/modules/Workspaces/WorkspacesEditor/Data/ProjectData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;

using Workspaces.Data;

using static WorkspacesEditor.Data.ProjectData;

namespace WorkspacesEditor.Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ namespace WorkspacesEditor.Data
{
public class TempProjectData : ProjectData
{
public static string File
{
get
{
return FolderUtils.DataFolder() + "\\temp-workspaces.json";
}
}
public static string File => FolderUtils.DataFolder() + "\\temp-workspaces.json";

public static void DeleteTempFile()
{
Expand Down
10 changes: 1 addition & 9 deletions src/modules/Workspaces/WorkspacesEditor/Data/WorkspacesData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;

using Workspaces.Data;
using WorkspacesEditor.Utils;

using static WorkspacesEditor.Data.ProjectData;
Expand All @@ -14,13 +12,7 @@ namespace WorkspacesEditor.Data
{
public class WorkspacesData : WorkspacesEditorData<WorkspacesListWrapper>
{
public string File
{
get
{
return FolderUtils.DataFolder() + "\\workspaces.json";
}
}
public string File => FolderUtils.DataFolder() + "\\workspaces.json";

public struct WorkspacesListWrapper
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,24 @@
// See the LICENSE file in the project root for more information.

using System.Text.Json;

using WorkspacesEditor.Utils;

namespace Workspaces.Data
namespace WorkspacesEditor.Data
{
public class WorkspacesEditorData<T>
{
protected JsonSerializerOptions JsonOptions
{
get
get => new()
{
return new JsonSerializerOptions
{
PropertyNamingPolicy = new DashCaseNamingPolicy(),
WriteIndented = true,
};
}
PropertyNamingPolicy = new DashCaseNamingPolicy(),
WriteIndented = true,
};
}

public T Read(string file)
{
IOUtils ioUtils = new IOUtils();
IOUtils ioUtils = new();
string data = ioUtils.ReadFile(file);
return JsonSerializer.Deserialize<T>(data, JsonOptions);
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Workspaces/WorkspacesEditor/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xmlns:ui="http://schemas.modernwpf.com/2019"
x:Name="WorkspacesMainWindow"
Title="{x:Static props:Resources.MainTitle}"
MinWidth="700"
MinWidth="750"
MinHeight="680"
ui:TitleBar.Background="{DynamicResource PrimaryBackgroundBrush}"
ui:TitleBar.InactiveBackground="{DynamicResource TertiaryBackgroundBrush}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ public AppListDataTemplateSelector()

public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
{
if (item is MonitorHeaderRow)
{
return HeaderTemplate;
}
else
{
return AppTemplate;
}
return item is MonitorHeaderRow ? HeaderTemplate : AppTemplate;
}
}
}
76 changes: 21 additions & 55 deletions src/modules/Workspaces/WorkspacesEditor/Models/Application.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
// 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.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Windows.Media.Imaging;
using ManagedCommon;
using Windows.Management.Deployment;
using WorkspacesCsharpLibrary;
using WorkspacesCsharpLibrary.Models;

namespace WorkspacesEditor.Models
{
public enum WindowPositionKind
{
Custom = 0,
Maximized = 1,
Minimized = 2,
}

public class Application : BaseApplication, IDisposable
{
private bool _isInitialized;
Expand Down Expand Up @@ -79,7 +76,7 @@ public struct WindowPosition
return left.X != right.X || left.Y != right.Y || left.Width != right.Width || left.Height != right.Height;
}

public override bool Equals(object obj)
public override readonly bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
Expand All @@ -90,7 +87,7 @@ public override bool Equals(object obj)
return X == pos.X && Y == pos.Y && Width == pos.Width && Height == pos.Height;
}

public override int GetHashCode()
public override readonly int GetHashCode()
{
return base.GetHashCode();
}
Expand Down Expand Up @@ -136,36 +133,24 @@ private void RedrawPreviewImage()
}
}

private bool _minimized;
public bool Minimized { get; set; }

public bool Minimized
{
get => _minimized;
set
{
_minimized = value;
OnPropertyChanged(new PropertyChangedEventArgs(nameof(Minimized)));
OnPropertyChanged(new PropertyChangedEventArgs(nameof(EditPositionEnabled)));
RedrawPreviewImage();
}
}
public bool Maximized { get; set; }

private bool _maximized;
public bool EditPositionEnabled => !Minimized && !Maximized;

public bool Maximized
public int PositionComboboxIndex
{
get => _maximized;
get => Maximized ? (int)WindowPositionKind.Maximized : Minimized ? (int)WindowPositionKind.Minimized : (int)WindowPositionKind.Custom;
set
{
_maximized = value;
OnPropertyChanged(new PropertyChangedEventArgs(nameof(Maximized)));
Maximized = value == (int)WindowPositionKind.Maximized;
Minimized = value == (int)WindowPositionKind.Minimized;
OnPropertyChanged(new PropertyChangedEventArgs(nameof(EditPositionEnabled)));
RedrawPreviewImage();
}
}

public bool EditPositionEnabled { get => !Minimized && !Maximized; }

private string _appMainParams;

public string AppMainParams
Expand All @@ -183,7 +168,7 @@ public string AppMainParams
}
}

public bool IsAppMainParamVisible { get => !string.IsNullOrWhiteSpace(_appMainParams); }
public bool IsAppMainParamVisible => !string.IsNullOrWhiteSpace(_appMainParams);

[JsonIgnore]
public bool IsHighlighted { get; set; }
Expand All @@ -192,13 +177,7 @@ public string AppMainParams
public int RepeatIndex { get; set; }

[JsonIgnore]
public string RepeatIndexString
{
get
{
return RepeatIndex <= 1 ? string.Empty : RepeatIndex.ToString(CultureInfo.InvariantCulture);
}
}
public string RepeatIndexString => RepeatIndex <= 1 ? string.Empty : RepeatIndex.ToString(CultureInfo.InvariantCulture);

private WindowPosition _position;

Expand Down Expand Up @@ -242,10 +221,7 @@ public MonitorSetup MonitorSetup
{
get
{
if (_monitorSetup == null)
{
_monitorSetup = Parent.GetMonitorForApp(this);
}
_monitorSetup ??= Parent.GetMonitorForApp(this);

return _monitorSetup;
}
Expand All @@ -271,7 +247,7 @@ public bool IsExpanded
}
}

public string DeleteButtonContent { get => _isIncluded ? Properties.Resources.Delete : Properties.Resources.AddBack; }
public string DeleteButtonContent => _isIncluded ? Properties.Resources.Delete : Properties.Resources.AddBack;

private bool _isIncluded = true;

Expand All @@ -298,15 +274,5 @@ internal void CommandLineTextChanged(string newCommandLineValue)
CommandLineArguments = newCommandLineValue;
OnPropertyChanged(new PropertyChangedEventArgs(nameof(AppMainParams)));
}

internal void MaximizedChecked()
{
Minimized = false;
}

internal void MinimizedChecked()
{
Maximized = false;
}
}
}
24 changes: 7 additions & 17 deletions src/modules/Workspaces/WorkspacesEditor/Models/Monitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,18 @@

namespace WorkspacesEditor.Models
{
public class Monitor
public class Monitor(string monitorName, string monitorInstanceId, int number, int dpi, Rect dpiAwareBounds, Rect dpiUnawareBounds)
{
public string MonitorName { get; private set; }
public string MonitorName { get; private set; } = monitorName;

public string MonitorInstanceId { get; private set; }
public string MonitorInstanceId { get; private set; } = monitorInstanceId;

public int MonitorNumber { get; private set; }
public int MonitorNumber { get; private set; } = number;

public int Dpi { get; private set; }
public int Dpi { get; private set; } = dpi;

public Rect MonitorDpiUnawareBounds { get; private set; }
public Rect MonitorDpiUnawareBounds { get; private set; } = dpiUnawareBounds;

public Rect MonitorDpiAwareBounds { get; private set; }

public Monitor(string monitorName, string monitorInstanceId, int number, int dpi, Rect dpiAwareBounds, Rect dpiUnawareBounds)
{
MonitorName = monitorName;
MonitorInstanceId = monitorInstanceId;
MonitorNumber = number;
Dpi = dpi;
MonitorDpiAwareBounds = dpiAwareBounds;
MonitorDpiUnawareBounds = dpiUnawareBounds;
}
public Rect MonitorDpiAwareBounds { get; private set; } = dpiAwareBounds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public void OnPropertyChanged(PropertyChangedEventArgs e)
PropertyChanged?.Invoke(this, e);
}

public string MonitorInfo { get => MonitorName; }
public string MonitorInfo => MonitorName;

public string MonitorInfoWithResolution { get => $"{MonitorName} {MonitorDpiAwareBounds.Width}x{MonitorDpiAwareBounds.Height}"; }
public string MonitorInfoWithResolution => $"{MonitorName} {MonitorDpiAwareBounds.Width}x{MonitorDpiAwareBounds.Height}";

public MonitorSetup(string monitorName, string monitorInstanceId, int number, int dpi, Rect dpiAwareBounds, Rect dpiUnawareBounds)
: base(monitorName, monitorInstanceId, number, dpi, dpiAwareBounds, dpiUnawareBounds)
Expand Down
Loading
Loading