Skip to content

Code Quality: WCT Settings Control #13045

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,13 @@ private IHost ConfigureHost()
.AddSingleton<DrivesViewModel>()
.AddSingleton<NetworkDrivesViewModel>()
.AddSingleton<OngoingTasksViewModel>()
.AddSingleton<AppearanceViewModel>()
// Settings ViewModels
.AddTransient<AboutViewModel>()
.AddTransient<AdvancedViewModel>()
.AddTransient<AppearanceViewModel>()
.AddTransient<FoldersViewModel>()
.AddTransient<GeneralViewModel>()
.AddTransient<TagsViewModel>()
).Build();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Files.App.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Copyright (c) 2023 Files Community. Licensed under the MIT License. See the LICENSE. -->
<!-- Copyright (c) 2023 Files Community. Licensed under the MIT License. See the LICENSE. -->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
global using global::Files.App.UserControls;
global using global::Files.App.ViewModels;
global using global::Files.App.ViewModels.UserControls;
global using global::Files.App.ViewModels.Settings;
global using global::Files.App.Views;
global using global::Files.App.Views.LayoutModes;
global using global::Files.App.Views.Shells;
Expand Down
21 changes: 21 additions & 0 deletions src/Files.App/UserControls/Settings/ControlHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Documents;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;

namespace Files.App.UserControls
{
internal static partial class ControlHelpers
{
internal static bool IsXamlRootAvailable { get; } = Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "XamlRoot");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Documents;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;

namespace Files.App.UserControls
{
internal static class ResourceDictionaryExtensions
{
/// <summary>
/// Copies the <see cref="ResourceDictionary"/> provided as a parameter into the calling dictionary, includes overwriting the source location, theme dictionaries, and merged dictionaries.
/// </summary>
/// <param name="destination">ResourceDictionary to copy values to.</param>
/// <param name="source">ResourceDictionary to copy values from.</param>
internal static void CopyFrom(this ResourceDictionary destination, ResourceDictionary source)
{
if (source.Source != null)
{
destination.Source = source.Source;
}
else
{
// Clone theme dictionaries
if (source.ThemeDictionaries != null)
{
foreach (var theme in source.ThemeDictionaries)
{
if (theme.Value is ResourceDictionary themedResource)
{
var themeDictionary = new ResourceDictionary();
themeDictionary.CopyFrom(themedResource);
destination.ThemeDictionaries[theme.Key] = themeDictionary;
}
else
{
destination.ThemeDictionaries[theme.Key] = theme.Value;
}
}
}

// Clone merged dictionaries
if (source.MergedDictionaries != null)
{
foreach (var mergedResource in source.MergedDictionaries)
{
var themeDictionary = new ResourceDictionary();
themeDictionary.CopyFrom(mergedResource);
destination.MergedDictionaries.Add(themeDictionary);
}
}

// Clone all contents
foreach (var item in source)
{
destination[item.Key] = item.Value;
}
}
}
}
}
116 changes: 0 additions & 116 deletions src/Files.App/UserControls/Settings/SettingsBlockControl.xaml

This file was deleted.

146 changes: 0 additions & 146 deletions src/Files.App/UserControls/Settings/SettingsBlockControl.xaml.cs

This file was deleted.

Loading