Skip to content

Commit 1fcff23

Browse files
committed
Merge remote-tracking branch 'origin/main' into issue_4028
2 parents 7f4b83e + 7df5ef0 commit 1fcff23

15 files changed

+94
-98
lines changed

Files/App.xaml.cs

-14
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,6 @@ private void OnLeavingBackground(object sender, LeavingBackgroundEventArgs e)
141141
DrivesManager?.ResumeDeviceWatcher();
142142
}
143143

144-
public static INavigationControlItem RightClickedItem;
145-
146-
public static void UnpinItem_Click(object sender, RoutedEventArgs e)
147-
{
148-
if (RightClickedItem.Path.Equals(AppSettings.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
149-
{
150-
AppSettings.PinRecycleBinToSideBar = false;
151-
}
152-
else if (RightClickedItem.Section == SectionType.Favorites)
153-
{
154-
SidebarPinnedController.Model.RemoveItem(RightClickedItem.Path.ToString());
155-
}
156-
}
157-
158144
public static Windows.UI.Xaml.UnhandledExceptionEventArgs ExceptionInfo { get; set; }
159145
public static string ExceptionStackTrace { get; set; }
160146
public static List<string> pathsToDeleteAfterPaste = new List<string>();

Files/BaseLayout.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ internal set
150150

151151
private List<ShellNewEntry> cachedNewContextMenuEntries { get; set; }
152152

153-
private DispatcherQueueController timerQueueController;
154-
155-
private DispatcherQueue timerQueue;
156-
157153
private DispatcherQueueTimer dragOverTimer;
158154

159155
public BaseLayout()
@@ -170,9 +166,7 @@ public BaseLayout()
170166
IsQuickLookEnabled = true;
171167
}
172168

173-
timerQueueController = DispatcherQueueController.CreateOnDedicatedThread();
174-
timerQueue = timerQueueController.DispatcherQueue;
175-
dragOverTimer = timerQueue.CreateTimer();
169+
dragOverTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
176170
}
177171

178172
protected abstract void InitializeCommandsViewModel();

Files/Filesystem/Drives.cs

+9
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
154154
}
155155
}
156156

157+
foreach (DriveItem drive in section.ChildItems.ToList())
158+
{
159+
if (!Drives.Contains(drive))
160+
{
161+
section.ChildItems.Remove(drive);
162+
DrivesWidget.ItemsAdded.Remove(drive);
163+
}
164+
}
165+
157166
MainPage.SideBarItems.EndBulkOperation();
158167
}
159168
finally

Files/Filesystem/WSLDistroManager.cs

+19-14
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,18 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
5151
if ((await distroFolder.GetFoldersAsync()).Count != 0)
5252
{
5353
var section = MainPage.SideBarItems.FirstOrDefault(x => x.Text == "WSL") as LocationItem;
54-
55-
section = new LocationItem()
54+
if (section == null)
5655
{
57-
Text = "WSL",
58-
Section = SectionType.WSL,
59-
Glyph = "\uEC7A",
60-
SelectsOnInvoked = false,
61-
ChildItems = new ObservableCollection<INavigationControlItem>()
62-
};
63-
MainPage.SideBarItems.Add(section);
56+
section = new LocationItem()
57+
{
58+
Text = "WSL",
59+
Section = SectionType.WSL,
60+
Glyph = "\uEC7A",
61+
SelectsOnInvoked = false,
62+
ChildItems = new ObservableCollection<INavigationControlItem>()
63+
};
64+
MainPage.SideBarItems.Add(section);
65+
}
6466

6567
foreach (StorageFolder folder in await distroFolder.GetFoldersAsync())
6668
{
@@ -90,12 +92,15 @@ await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPrio
9092
logoURI = new Uri("ms-appx:///Assets/WSL/genericpng.png");
9193
}
9294

93-
section.ChildItems.Add(new WSLDistroItem()
95+
if (!section.ChildItems.Any(x => x.Path == folder.Path))
9496
{
95-
Text = folder.DisplayName,
96-
Path = folder.Path,
97-
Logo = logoURI
98-
});
97+
section.ChildItems.Add(new WSLDistroItem()
98+
{
99+
Text = folder.DisplayName,
100+
Path = folder.Path,
101+
Logo = logoURI
102+
});
103+
}
99104
}
100105
}
101106
}

Files/UserControls/MultitaskingControl/HorizontalMultitaskingControl.xaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@
4949
</MenuFlyoutItem.Icon>
5050
</MenuFlyoutItem>
5151
<MenuFlyoutItem
52+
x:Name="MenuItemCloseTabsToTheRight"
5253
x:Uid="HorizontalMultitaskingControlCloseTabsToTheRight"
5354
Click="{x:Bind views:MainPage.CloseTabsToTheRight}"
5455
Text="Close tabs to the right"
55-
IsEnabled="{x:Bind CloseTabsToTheRightEnabled, Mode=OneWay}"/>
56+
DataContextChanged="MenuItemCloseTabsToTheRight_DataContextChanged" />
5657
</MenuFlyout>
5758
</ResourceDictionary>
5859
<ResourceDictionary>

Files/UserControls/MultitaskingControl/HorizontalMultitaskingControl.xaml.cs

+11-22
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,6 @@ public sealed partial class HorizontalMultitaskingControl : BaseMultitaskingCont
2121

2222
private SettingsViewModel AppSettings => App.AppSettings;
2323

24-
private bool closeTabsToTheRightEnabled = true;
25-
public bool CloseTabsToTheRightEnabled
26-
{
27-
get => closeTabsToTheRightEnabled;
28-
private set
29-
{
30-
if (value != closeTabsToTheRightEnabled)
31-
{
32-
closeTabsToTheRightEnabled = value;
33-
OnPropertyChanged();
34-
}
35-
}
36-
}
37-
3824
public HorizontalMultitaskingControl()
3925
{
4026
InitializeComponent();
@@ -187,24 +173,27 @@ private async void TabStrip_TabDroppedOutside(TabView sender, TabViewTabDroppedO
187173

188174
private void TabItemContextMenu_Opening(object sender, object e)
189175
{
190-
TabItem tabItem = (((MenuFlyout)sender).Items.First()).DataContext as TabItem;
191-
192-
if (MainPage.AppInstances.IndexOf(tabItem) == MainPage.AppInstances.Count - 1)
176+
if (MainPage.MultitaskingControl.Items.Count == 1)
193177
{
194-
CloseTabsToTheRightEnabled = false;
178+
MenuItemMoveTabToNewWindow.IsEnabled = false;
195179
}
196180
else
197181
{
198-
CloseTabsToTheRightEnabled = true;
182+
MenuItemMoveTabToNewWindow.IsEnabled = true;
199183
}
184+
}
200185

201-
if (MainPage.MultitaskingControl.Items.Count == 1)
186+
private void MenuItemCloseTabsToTheRight_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
187+
{
188+
TabItem tabItem = args.NewValue as TabItem;
189+
190+
if (MainPage.AppInstances.IndexOf(tabItem) == MainPage.AppInstances.Count - 1)
202191
{
203-
MenuItemMoveTabToNewWindow.IsEnabled = false;
192+
MenuItemCloseTabsToTheRight.IsEnabled = false;
204193
}
205194
else
206195
{
207-
MenuItemMoveTabToNewWindow.IsEnabled = true;
196+
MenuItemCloseTabsToTheRight.IsEnabled = true;
208197
}
209198
}
210199
}

Files/UserControls/NavigationToolbar.xaml.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -555,20 +555,14 @@ public bool PreviewPaneEnabled
555555

556556
private List<ShellNewEntry> cachedNewContextMenuEntries { get; set; }
557557

558-
private DispatcherQueueController timerQueueController;
559-
560-
private DispatcherQueue timerQueue;
561-
562558
private DispatcherQueueTimer dragOverTimer;
563559

564560
public NavigationToolbar()
565561
{
566562
this.InitializeComponent();
567563
this.Loading += NavigationToolbar_Loading;
568564

569-
timerQueueController = DispatcherQueueController.CreateOnDedicatedThread();
570-
timerQueue = timerQueueController.DispatcherQueue;
571-
dragOverTimer = timerQueue.CreateTimer();
565+
dragOverTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
572566
}
573567

574568
private async void NavigationToolbar_Loading(FrameworkElement sender, object args)

Files/UserControls/SidebarControl.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
x:Name="UnpinItem"
187187
x:Uid="SideBarUnpinFromSideBar"
188188
x:Load="{x:Bind ShowUnpinItem, Mode=OneWay}"
189-
Click="{x:Bind local1:App.UnpinItem_Click}"
189+
Click="{x:Bind UnpinItem_Click}"
190190
Text="Unpin from Sidebar">
191191
<MenuFlyoutItem.Icon>
192192
<FontIcon Glyph="&#xE77A;" />

Files/UserControls/SidebarControl.xaml.cs

+21-13
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,14 @@ public ICommand EmptyRecycleBinCommand
7373
set => SetValue(EmptyRecycleBinCommandProperty, value);
7474
}
7575

76-
private DispatcherQueueController timerQueueController;
77-
78-
private DispatcherQueue timerQueue;
79-
8076
private DispatcherQueueTimer dragOverTimer;
8177

8278
public SidebarControl()
8379
{
8480
this.InitializeComponent();
8581
SidebarNavView.Loaded += SidebarNavView_Loaded;
8682

87-
timerQueueController = DispatcherQueueController.CreateOnDedicatedThread();
88-
timerQueue = timerQueueController.DispatcherQueue;
89-
dragOverTimer = timerQueue.CreateTimer();
83+
dragOverTimer = DispatcherQueue.GetForCurrentThread().CreateTimer();
9084
}
9185

9286
private INavigationControlItem selectedSidebarItem;
@@ -200,13 +194,27 @@ public bool RecycleBinHasItems
200194
}
201195
}
202196

197+
public INavigationControlItem RightClickedItem;
198+
203199
public event PropertyChangedEventHandler PropertyChanged;
204200

205201
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
206202
{
207203
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
208204
}
209205

206+
public void UnpinItem_Click(object sender, RoutedEventArgs e)
207+
{
208+
if (RightClickedItem.Path.Equals(AppSettings.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
209+
{
210+
AppSettings.PinRecycleBinToSideBar = false;
211+
}
212+
else if (RightClickedItem.Section == SectionType.Favorites)
213+
{
214+
App.SidebarPinnedController.Model.RemoveItem(RightClickedItem.Path.ToString());
215+
}
216+
}
217+
210218
private void Sidebar_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args)
211219
{
212220
if (args.InvokedItem == null || args.InvokedItemContainer == null)
@@ -251,8 +259,8 @@ private void NavigationViewLocationItem_RightTapped(object sender, RightTappedRo
251259
}
252260
}
253261

262+
RightClickedItem = item;
254263
SideBarItemContextFlyout.ShowAt(sidebarItem, e.GetPosition(sidebarItem));
255-
App.RightClickedItem = item;
256264
}
257265

258266
e.Handled = true;
@@ -270,7 +278,7 @@ private void NavigationViewDriveItem_RightTapped(object sender, RightTappedRoute
270278

271279
SideBarItemContextFlyout.ShowAt(sidebarItem, e.GetPosition(sidebarItem));
272280

273-
App.RightClickedItem = item;
281+
RightClickedItem = item;
274282

275283
e.Handled = true;
276284
}
@@ -287,19 +295,19 @@ private void NavigationViewWSLItem_RightTapped(object sender, RightTappedRoutedE
287295

288296
SideBarItemContextFlyout.ShowAt(sidebarItem, e.GetPosition(sidebarItem));
289297

290-
App.RightClickedItem = item;
298+
RightClickedItem = item;
291299

292300
e.Handled = true;
293301
}
294302

295303
private void OpenInNewTab_Click(object sender, RoutedEventArgs e)
296304
{
297-
Interaction.OpenPathInNewTab(App.RightClickedItem.Path);
305+
Interaction.OpenPathInNewTab(RightClickedItem.Path);
298306
}
299307

300308
private async void OpenInNewWindow_Click(object sender, RoutedEventArgs e)
301309
{
302-
await Interaction.OpenPathInNewWindowAsync(App.RightClickedItem.Path);
310+
await Interaction.OpenPathInNewWindowAsync(RightClickedItem.Path);
303311
}
304312

305313
private void NavigationViewItem_DragStarting(UIElement sender, DragStartingEventArgs args)
@@ -561,7 +569,7 @@ private void SettingsButton_Tapped(object sender, TappedRoutedEventArgs e)
561569

562570
private async void EjectDevice_Click(object sender, RoutedEventArgs e)
563571
{
564-
await DeviceHelpers.EjectDeviceAsync(App.RightClickedItem.Path);
572+
await DeviceHelpers.EjectDeviceAsync(RightClickedItem.Path);
565573
}
566574

567575
private void SidebarNavView_Loaded(object sender, RoutedEventArgs e)

Files/UserControls/Widgets/DrivesWidget.xaml

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
1313
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
1414
mc:Ignorable="d">
15+
<UserControl.Resources>
16+
<StaticResource x:Key="ButtonBackground" ResourceKey="ControlFillColorDefaultBrush" />
17+
<StaticResource x:Key="ButtonBackgroundPointerOver" ResourceKey="ControlFillColorSecondaryBrush" />
18+
<StaticResource x:Key="ButtonBackgroundPressed" ResourceKey="ControlFillColorTertiaryBrush" />
19+
<StaticResource x:Key="ButtonBackgroundDisabled" ResourceKey="ControlFillColorDisabledBrush" />
20+
<StaticResource x:Key="ButtonBorderBrush" ResourceKey="ControlElevationBorderBrush" />
21+
<StaticResource x:Key="ButtonBorderBrushPointerOver" ResourceKey="ControlElevationBorderBrush" />
22+
<StaticResource x:Key="ButtonBorderBrushPressed" ResourceKey="ControlStrokeColorDefaultBrush" />
23+
<StaticResource x:Key="ButtonBorderBrushDisabled" ResourceKey="ControlStrokeColorDefaultBrush" />
24+
</UserControl.Resources>
1525
<StackPanel Spacing="12">
1626
<Grid>
1727
<Grid.ColumnDefinitions>

Files/UserControls/Widgets/LibraryCards.xaml

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
1212
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
1313
mc:Ignorable="d">
14+
<UserControl.Resources>
15+
<StaticResource x:Key="ButtonBackground" ResourceKey="ControlFillColorDefaultBrush" />
16+
<StaticResource x:Key="ButtonBackgroundPointerOver" ResourceKey="ControlFillColorSecondaryBrush" />
17+
<StaticResource x:Key="ButtonBackgroundPressed" ResourceKey="ControlFillColorTertiaryBrush" />
18+
<StaticResource x:Key="ButtonBackgroundDisabled" ResourceKey="ControlFillColorDisabledBrush" />
19+
<StaticResource x:Key="ButtonBorderBrush" ResourceKey="ControlElevationBorderBrush" />
20+
<StaticResource x:Key="ButtonBorderBrushPointerOver" ResourceKey="ControlElevationBorderBrush" />
21+
<StaticResource x:Key="ButtonBorderBrushPressed" ResourceKey="ControlStrokeColorDefaultBrush" />
22+
<StaticResource x:Key="ButtonBorderBrushDisabled" ResourceKey="ControlStrokeColorDefaultBrush" />
23+
</UserControl.Resources>
1424
<StackPanel Spacing="12">
1525
<TextBlock
1626
x:Uid="LibraryWidgetDescription"

Files/ViewModels/FolderSettingsViewModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public static LayoutPreferences GetLayoutPreferencesForPath(string folderPath)
416416
if (App.AppSettings.AreLayoutPreferencesPerFolder)
417417
{
418418
var layoutPrefs = ReadLayoutPreferencesFromAds(folderPath.TrimEnd('\\'));
419-
return layoutPrefs ?? ReadLayoutPreferencesFromSettings(folderPath.Replace('\\', '_'));
419+
return layoutPrefs ?? ReadLayoutPreferencesFromSettings(folderPath.TrimEnd('\\').Replace('\\', '_'));
420420
}
421421

422422
return LayoutPreferences.DefaultLayoutPreferences;
@@ -430,7 +430,7 @@ public void UpdateLayoutPreferencesForPath(string folderPath, LayoutPreferences
430430
// include an '\\' at the end (unlike paths to folders)
431431
if (!WriteLayoutPreferencesToAds(folderPath.TrimEnd('\\'), prefs))
432432
{
433-
WriteLayoutPreferencesToSettings(folderPath.Replace('\\', '_'), prefs);
433+
WriteLayoutPreferencesToSettings(folderPath.TrimEnd('\\').Replace('\\', '_'), prefs);
434434
}
435435
}
436436
else

0 commit comments

Comments
 (0)