Skip to content

Code Quality: Reorganze namespaces #11552

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
wants to merge 12 commits into from
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
2 changes: 1 addition & 1 deletion src/Files.App/Actions/Show/TogglePreviewPaneAction.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Files.App.Commands;
using Files.App.Extensions;
using Files.App.ViewModels;
using Files.App.ViewModels.UserControls;
using System.ComponentModel;
using System.Threading.Tasks;
using Windows.System;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Files.App.Storage.NativeStorage;
using Files.App.UserControls.MultitaskingControl;
using Files.App.ViewModels;
using Files.App.ViewModels.UserControls;
using Files.App.Views;
using Files.Backend.Services;
using Files.Backend.Services.Settings;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Files.App.UserControls;
using Files.App.UserControls.Menus;
using Files.App.ViewModels;
using Files.App.ViewModels.UserControls;
using Files.App.Views;
using Files.Backend.Services.Settings;
using Files.Shared.Enums;
Expand Down
8 changes: 0 additions & 8 deletions src/Files.App/CommandLine/ParsedCommands.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/Files.App/Contexts/ContentPage/ContentPageContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Files.App.Filesystem;
using Files.App.ViewModels;
using Files.App.ViewModels.UserControls;
using Files.App.Views;
using System.Collections.Generic;
using System.Collections.Immutable;
Expand Down
9 changes: 0 additions & 9 deletions src/Files.App/Controllers/IJson.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.UI.Xaml.Data;
using System;

namespace Files.App.ValueConverters.EnumConverters
namespace Files.App.Converters.EnumConverters
{
internal sealed class ConflictResolveOptionToIndexConverter : IValueConverter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Collections.Generic;
using System.Linq;

namespace Files.App.ValueConverters
namespace Files.App.Converters
{
internal sealed class GenericEnumConverter : IValueConverter
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Files.App.AppModels;
using Files.App.DataModels;
using Microsoft.UI.Xaml.Data;
using System;

namespace Files.App.ValueConverters
namespace Files.App.Converters
{
internal sealed class ImageModelToImageConverter : IValueConverter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.UI.Xaml.Media;
using System;

namespace Files.App.ValueConverters
namespace Files.App.Converters
{
internal sealed class StringToBrushConverter : IValueConverter
{
Expand All @@ -12,7 +12,7 @@ internal sealed class StringToBrushConverter : IValueConverter
if (value is not string strValue)
return null;

return new SolidColorBrush(ColorHelper.ToColor(strValue));
return new SolidColorBrush(strValue.ToColor());
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Files.Backend.Models;
using Microsoft.UI.Xaml.Media.Imaging;

namespace Files.App.AppModels
namespace Files.App.DataModels
{
/// <inheritdoc cref="IImageModel"/>
internal sealed class BitmapImageModel : IImageModel
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Dialogs/AddItemDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:helpers="using:Files.App.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vc="using:Files.App.ValueConverters"
xmlns:vc="using:Files.App.Converters"
xmlns:vm="using:Files.Backend.ViewModels.Dialogs.AddItemDialog"
x:Name="AddDialog"
Title="{helpers:ResourceString Name=AddDialog/Title}"
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Dialogs/CreateShortcutDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

namespace Files.App.Dialogs
{
public sealed partial class CreateShortcutDialog : ContentDialog, IDialog<CreateShortcutDialogViewModel>
public sealed partial class CreateShortcutDialog : ContentDialog, IDialog<CreateShortcutViewModel>
{
public CreateShortcutDialogViewModel ViewModel
public CreateShortcutViewModel ViewModel
{
get => (CreateShortcutDialogViewModel)DataContext;
get => (CreateShortcutViewModel)DataContext;
set => DataContext = value;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Dialogs/DecompressArchiveDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace Files.App.Dialogs
{
public sealed partial class DecompressArchiveDialog : ContentDialog
{
public DecompressArchiveDialogViewModel ViewModel
public DecompressArchiveViewModel ViewModel
{
get => (DecompressArchiveDialogViewModel)DataContext;
get => (DecompressArchiveViewModel)DataContext;
set => DataContext = value;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Dialogs/DynamicDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace Files.App.Dialogs
{
public sealed partial class DynamicDialog : ContentDialog, IDisposable
{
public DynamicDialogViewModel ViewModel
public DynamicViewModel ViewModel
{
get => (DynamicDialogViewModel)DataContext;
get => (DynamicViewModel)DataContext;
private set => DataContext = value;
}

Expand All @@ -33,7 +33,7 @@ private ContentDialog SetContentDialogRoot(ContentDialog contentDialog)
return contentDialog;
}

public DynamicDialog(DynamicDialogViewModel dynamicDialogViewModel)
public DynamicDialog(DynamicViewModel dynamicDialogViewModel)
{
InitializeComponent();

Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Dialogs/FilesystemOperationDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ts="using:Files.App.TemplateSelectors"
xmlns:tvc="using:CommunityToolkit.WinUI.UI.Converters"
xmlns:vc="using:Files.App.ValueConverters"
xmlns:vc2="using:Files.App.ValueConverters.EnumConverters"
xmlns:vc="using:Files.App.Converters"
xmlns:vc2="using:Files.App.Converters.EnumConverters"
xmlns:vc3="using:Files.App.Converters"
xmlns:vm="using:Files.Backend.ViewModels.Dialogs.FileSystemDialog"
x:Name="RootDialog"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Files.App.Filesystem.StorageItems;
using Files.App.Helpers;
using Files.App.Shell;
using Files.Backend.CommandLine;
using Files.Backend.Services;
using Files.Backend.ViewModels.Dialogs.FileSystemDialog;
using Files.Shared;
Expand Down Expand Up @@ -197,7 +198,7 @@ await sourceMatch.Select(x => x.dest).ToListAsync(),
var newEntryInfo = await ShellNewEntryExtensions.GetNewContextMenuEntryForType(Path.GetExtension(source.Path));
if (newEntryInfo?.Command is not null)
{
var args = CommandLine.CommandLineParser.SplitArguments(newEntryInfo.Command);
var args = CommandLineParser.SplitArguments(newEntryInfo.Command);
if (args.Any())
{
if (await LaunchHelper.LaunchAppAsync(args[0].Replace("\"", "", StringComparison.Ordinal),
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Filesystem/LibraryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public async Task<LibraryLocationItem> UpdateLibrary(string libraryPath, string

public static async void ShowRestoreDefaultLibrariesDialog()
{
var dialog = new DynamicDialog(new DynamicDialogViewModel
var dialog = new DynamicDialog(new DynamicViewModel
{
TitleText = "DialogRestoreLibrariesTitleText".GetLocalizedResource(),
SubtitleText = "DialogRestoreLibrariesSubtitleText".GetLocalizedResource(),
Expand Down Expand Up @@ -334,7 +334,7 @@ public static async void ShowCreateNewLibraryDialog()
Visibility = Visibility.Collapsed
};

var dialog = new DynamicDialog(new DynamicDialogViewModel
var dialog = new DynamicDialog(new DynamicViewModel
{
DisplayControl = new Grid
{
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Helpers/AdaptiveLayoutHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using CommunityToolkit.Mvvm.DependencyInjection;
using Files.App.Filesystem;
using Files.App.ViewModels;
using Files.App.ViewModels.Previews;
using Files.App.ViewModels.UserControls.Previews;
using Files.Backend.Services.Settings;
using IniParser.Model;
using System;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/Helpers/ArchiveHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Files.App.Filesystem;
using Files.App.Filesystem.Archive;
using Files.App.ViewModels;
using Files.App.ViewModels.UserControls;
using Files.Backend.Helpers;
using Files.Shared.Enums;
using System;
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Helpers/DialogDisplayHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal class DialogDisplayHelper
/// </param>
public static async Task<bool> ShowDialogAsync(string title, string message, string primaryText = "OK", string secondaryText = null)
{
DynamicDialog dialog = new DynamicDialog(new DynamicDialogViewModel()
DynamicDialog dialog = new DynamicDialog(new DynamicViewModel()
{
TitleText = title,
SubtitleText = message, // We can use subtitle here as our actual message and skip DisplayControl
Expand Down
12 changes: 6 additions & 6 deletions src/Files.App/Helpers/DynamicDialogFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static class DynamicDialogFactory
{
public static DynamicDialog GetFor_PropertySaveErrorDialog()
{
DynamicDialog dialog = new DynamicDialog(new DynamicDialogViewModel()
DynamicDialog dialog = new DynamicDialog(new DynamicViewModel()
{
TitleText = "PropertySaveErrorDialog/Title".GetLocalizedResource(),
SubtitleText = "PropertySaveErrorMessage/Text".GetLocalizedResource(), // We can use subtitle here as our content
Expand All @@ -31,7 +31,7 @@ public static DynamicDialog GetFor_PropertySaveErrorDialog()

public static DynamicDialog GetFor_ConsentDialog()
{
DynamicDialog dialog = new DynamicDialog(new DynamicDialogViewModel()
DynamicDialog dialog = new DynamicDialog(new DynamicViewModel()
{
TitleText = "WelcomeDialog/Title".GetLocalizedResource(),
SubtitleText = "WelcomeDialogTextBlock/Text".GetLocalizedResource(), // We can use subtitle here as our content
Expand All @@ -44,7 +44,7 @@ public static DynamicDialog GetFor_ConsentDialog()

public static DynamicDialog GetFor_ShortcutNotFound(string targetPath)
{
DynamicDialog dialog = new(new DynamicDialogViewModel
DynamicDialog dialog = new(new DynamicViewModel
{
TitleText = "ShortcutCannotBeOpened".GetLocalizedResource(),
SubtitleText = string.Format("DeleteShortcutDescription".GetLocalizedResource(), targetPath),
Expand Down Expand Up @@ -88,7 +88,7 @@ public static DynamicDialog GetFor_RenameDialog()
_ = inputText.DispatcherQueue.EnqueueAsync(() => inputText.Focus(Microsoft.UI.Xaml.FocusState.Programmatic));
};

dialog = new DynamicDialog(new DynamicDialogViewModel()
dialog = new DynamicDialog(new DynamicViewModel()
{
TitleText = "EnterAnItemName".GetLocalizedResource(),
SubtitleText = null,
Expand Down Expand Up @@ -123,7 +123,7 @@ public static DynamicDialog GetFor_RenameDialog()

public static DynamicDialog GetFor_FileInUseDialog(List<Shared.Win32Process> lockingProcess = null)
{
DynamicDialog dialog = new DynamicDialog(new DynamicDialogViewModel()
DynamicDialog dialog = new DynamicDialog(new DynamicViewModel()
{
TitleText = "FileInUseDialog/Title".GetLocalizedResource(),
SubtitleText = lockingProcess.IsEmpty() ? "FileInUseDialog/Text".GetLocalizedResource() :
Expand Down Expand Up @@ -178,7 +178,7 @@ public static DynamicDialog GetFor_CredentialEntryDialog(string path)
dialog.ViewModel.AdditionalData = userAndPass;
};

dialog = new DynamicDialog(new DynamicDialogViewModel()
dialog = new DynamicDialog(new DynamicViewModel()
{
TitleText = "NetworkAuthenticationDialogTitle".GetLocalizedResource(),
PrimaryButtonText = "OK".GetLocalizedResource(),
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Helpers/FilePropertiesHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static async Task OpenPropertiesWindowAsync(object item, IShellPage assoc

if (true) // WINUI3: move window to cursor position
{
UWPToWinAppSDKUpgradeHelpers.InteropHelpers.GetCursorPos(out var pointerPosition);
InteropHelpers.GetCursorPos(out var pointerPosition);
var displayArea = DisplayArea.GetFromPoint(new PointInt32(pointerPosition.X, pointerPosition.Y), DisplayAreaFallback.Nearest);
var appWindowPos = new PointInt32
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
using System.Reflection;
using System.Runtime.InteropServices;

namespace UWPToWinAppSDKUpgradeHelpers
namespace Files.App.Helpers
{
[ComImport]
[Guid("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8")]
[InterfaceType(
ComInterfaceType.InterfaceIsIUnknown)]
interface IDataTransferManagerInterop
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDataTransferManagerInterop
{
IntPtr GetForWindow([In] IntPtr appWindow, [In] ref Guid riid);

Expand All @@ -20,24 +19,20 @@ interface IDataTransferManagerInterop
public static class InteropHelpers
{
public static readonly Guid DataTransferManagerInteropIID =
new Guid(0xa5caee9b, 0x8708, 0x49d1, 0x8d, 0x36, 0x67, 0xd2, 0x5a, 0x8d, 0xa0, 0x0c);
new(0xa5caee9b, 0x8708, 0x49d1, 0x8d, 0x36, 0x67, 0xd2, 0x5a, 0x8d, 0xa0, 0x0c);

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCursorPos(out POINT point);

[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr CreateEvent(
IntPtr lpEventAttributes, bool bManualReset,
bool bInitialState, string lpName);
public static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);

[DllImport("kernel32.dll")]
public static extern bool SetEvent(IntPtr hEvent);

[DllImport("ole32.dll")]
public static extern uint CoWaitForMultipleObjects(
uint dwFlags, uint dwMilliseconds, ulong nHandles,
IntPtr[] pHandles, out uint dwIndex);
public static extern uint CoWaitForMultipleObjects(uint dwFlags, uint dwMilliseconds, ulong nHandles, IntPtr[] pHandles, out uint dwIndex);

[StructLayout(LayoutKind.Sequential)]
public struct POINT
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Helpers/PostBannerHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Files.App.Extensions;
using Files.App.Filesystem;
using Files.App.ViewModels;
using Files.App.ViewModels.UserControls;
using Files.Shared.Enums;
using System.Collections.Generic;
using System.Linq;
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Helpers/UIFilesystemHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using Files.App.Filesystem;
using Files.App.Filesystem.StorageItems;
using Files.App.Interacts;
using Files.App.ViewModels;
using Files.App.ViewModels.Dialogs;
using Files.App.ViewModels.UserControls;
using Files.Backend.Enums;
using Files.Backend.Extensions;
using Files.Backend.Services;
Expand Down Expand Up @@ -390,7 +390,7 @@ public static async Task CreateShortcutFromDialogAsync(IShellPage associatedInst
currentPath = library.DefaultSaveFolder;
}

var viewModel = new CreateShortcutDialogViewModel(currentPath);
var viewModel = new CreateShortcutViewModel(currentPath);
var dialogService = Ioc.Default.GetRequiredService<IDialogService>();
var result = await dialogService.ShowDialogAsync(viewModel);

Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Helpers/WidgetsHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Files.App.UserControls.Widgets;
using Files.App.ViewModels.Widgets;
using Files.App.ViewModels.UserControls.Widgets;
using Files.Backend.Services.Settings;
using System.Collections.Generic;

Expand Down
1 change: 1 addition & 0 deletions src/Files.App/IBaseLayout.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Files.App.Filesystem;
using Files.App.Interacts;
using Files.App.ViewModels;
using Files.App.ViewModels.UserControls;
using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.Generic;
Expand Down
1 change: 1 addition & 0 deletions src/Files.App/IShellPage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Files.App.Filesystem;
using Files.App.UserControls.MultitaskingControl;
using Files.App.ViewModels;
using Files.App.ViewModels.UserControls;
using Files.App.Views;
using System;
using System.ComponentModel;
Expand Down
Loading