Skip to content

Commit 28e8805

Browse files
committed
CQ: Updates
1 parent 8d5e95f commit 28e8805

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

src/Files.App/App.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ async Task ActivateAsync()
100100
var userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
101101
var isLeaveAppRunning = userSettingsService.GeneralSettingsService.LeaveAppRunning;
102102

103-
Ioc.Default.GetRequiredService<IRealTimeLayoutService>().UpdateCulture(new(AppLanguageHelper.PreferredLanguage.Code));
103+
var realTimeLayoutService = Ioc.Default.GetRequiredService<IRealTimeLayoutService>();
104+
realTimeLayoutService.UpdateCulture(new(AppLanguageHelper.PreferredLanguage.Code));
105+
104106
MainWindow.Instance.InitializeContentLayout();
105107

106108
if (isStartupTask && !isLeaveAppRunning)

src/Files.App/Data/Contracts/IRealTimeWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ internal interface IRealTimeWindow
1111
/// <summary>
1212
/// Initializes the content layout for the window.
1313
/// </summary>
14-
void InitializeContentLayout() { }
14+
void InitializeContentLayout();
1515

1616
/// <summary>
1717
/// Updates the content layout of the window.
1818
/// </summary>
19-
void UpdateContentLayout() { }
19+
void UpdateContentLayout();
2020
}
2121
}

src/Files.App/UserControls/Sidebar/SidebarView.xaml.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ namespace Files.App.UserControls.Sidebar
1515
[ContentProperty(Name = "InnerContent")]
1616
public sealed partial class SidebarView : UserControl, INotifyPropertyChanged
1717
{
18+
private static readonly IRealTimeLayoutService RealTimeLayoutService = Ioc.Default.GetRequiredService<IRealTimeLayoutService>();
19+
20+
private static readonly int RePos = RealTimeLayoutService.FlowDirection == FlowDirection.LeftToRight ? 1 : -1;
21+
1822
private const double COMPACT_MAX_WIDTH = 200;
1923

2024
public event EventHandler<object>? ItemInvoked;
@@ -130,10 +134,7 @@ private void SidebarResizer_ManipulationStarted(object sender, ManipulationStart
130134

131135
private void SidebarResizer_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
132136
{
133-
var rtls = Ioc.Default.GetRequiredService<IRealTimeLayoutService>();
134-
var rePos = rtls.FlowDirection == FlowDirection.LeftToRight ? 1 : -1;
135-
var newWidth = preManipulationSidebarWidth + (e.Cumulative.Translation.X * rePos);
136-
137+
var newWidth = preManipulationSidebarWidth + (e.Cumulative.Translation.X * RePos);
137138
UpdateDisplayModeForPaneWidth(newWidth);
138139
e.Handled = true;
139140
}

src/Files.App/Utils/Storage/Helpers/FilePropertiesHelpers.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public static class FilePropertiesHelpers
2121
{
2222
private static IAppThemeModeService AppThemeModeService { get; } = Ioc.Default.GetRequiredService<IAppThemeModeService>();
2323

24-
private static IRealTimeLayoutService RealTimeLayoutService { get; } = Ioc.Default.GetRequiredService<IRealTimeLayoutService>();
24+
private static readonly IRealTimeLayoutService RealTimeLayoutService = Ioc.Default.GetRequiredService<IRealTimeLayoutService>();
25+
26+
private static readonly int RePos = RealTimeLayoutService.FlowDirection == FlowDirection.LeftToRight ? 1 : -1;
2527

2628
/// <summary>
2729
/// Get window handle (hWnd) of the given properties window instance
@@ -133,12 +135,11 @@ public static void OpenPropertiesWindow(object item, IShellPage associatedInstan
133135

134136
// WINUI3: Move window to cursor position
135137
PInvoke.GetCursorPos(out var pointerPosition);
136-
var rePos = RealTimeLayoutService.FlowDirection is FlowDirection.LeftToRight ? 1 : -1;
137138
var displayArea = DisplayArea.GetFromPoint(new PointInt32(pointerPosition.X, pointerPosition.Y), DisplayAreaFallback.Nearest);
138139
var appWindowPos = new PointInt32
139140
{
140141
X = displayArea.WorkArea.X
141-
+ Math.Max(0, Math.Min(displayArea.WorkArea.Width - appWindow.Size.Width,( pointerPosition.X * rePos) - displayArea.WorkArea.X)),
142+
+ Math.Max(0, Math.Min(displayArea.WorkArea.Width - appWindow.Size.Width,( pointerPosition.X * RePos) - displayArea.WorkArea.X)),
142143
Y = displayArea.WorkArea.Y
143144
+ Math.Max(0, Math.Min(displayArea.WorkArea.Height - appWindow.Size.Height, pointerPosition.Y - displayArea.WorkArea.Y)),
144145
};

src/Files.App/ViewModels/Settings/GeneralViewModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public sealed class GeneralViewModel : ObservableObject, IDisposable
1818
private IUserSettingsService UserSettingsService { get; } = Ioc.Default.GetRequiredService<IUserSettingsService>();
1919
private ICommonDialogService CommonDialogService { get; } = Ioc.Default.GetRequiredService<ICommonDialogService>();
2020

21+
private static readonly IRealTimeLayoutService RealTimeLayoutService = Ioc.Default.GetRequiredService<IRealTimeLayoutService>();
22+
2123
private bool disposed;
2224

2325
private ReadOnlyCollection<IMenuFlyoutItemViewModel> addFlyoutItemsSource;
@@ -78,8 +80,7 @@ public int SelectedAppLanguageIndex
7880
selectedAppLanguageIndex = value;
7981
OnPropertyChanged(nameof(SelectedAppLanguageIndex));
8082

81-
var RTLayoutService = Ioc.Default.GetRequiredService<IRealTimeLayoutService>();
82-
RTLayoutService.UpdateCulture(new(AppLanguageHelper.PreferredLanguage.Code));
83+
RealTimeLayoutService.UpdateCulture(new(AppLanguageHelper.PreferredLanguage.Code));
8384

8485
ShowRestartControl = true;
8586
}

0 commit comments

Comments
 (0)