diff --git a/src/RayCarrot.RCP.Metro/AppData/AppUserData.Aliases.v14.0.0.cs b/src/RayCarrot.RCP.Metro/AppData/AppUserData.Aliases.v14.0.0.cs index b9ec313a0..4e7ccb81e 100644 --- a/src/RayCarrot.RCP.Metro/AppData/AppUserData.Aliases.v14.0.0.cs +++ b/src/RayCarrot.RCP.Metro/AppData/AppUserData.Aliases.v14.0.0.cs @@ -1,5 +1,4 @@ -#nullable disable -using Newtonsoft.Json; +using Newtonsoft.Json; namespace RayCarrot.RCP.Metro; diff --git a/src/RayCarrot.RCP.Metro/Helpers/Extensions/EnumExtensions.cs b/src/RayCarrot.RCP.Metro/Helpers/Extensions/EnumExtensions.cs index e5dc64975..c45f92108 100644 --- a/src/RayCarrot.RCP.Metro/Helpers/Extensions/EnumExtensions.cs +++ b/src/RayCarrot.RCP.Metro/Helpers/Extensions/EnumExtensions.cs @@ -1,5 +1,4 @@ -#nullable disable -using System.Reflection; +using System.Reflection; namespace RayCarrot.RCP.Metro; @@ -91,8 +90,6 @@ public static T[] GetValues(this T input) return EnumHelpers.GetValues(); } -#nullable enable - /// /// Gets the first attribute of specified type for the enum value /// diff --git a/src/RayCarrot.RCP.Metro/Helpers/Extensions/EnumerableExtensions.cs b/src/RayCarrot.RCP.Metro/Helpers/Extensions/EnumerableExtensions.cs index cf940ccbd..3e1e39eeb 100644 --- a/src/RayCarrot.RCP.Metro/Helpers/Extensions/EnumerableExtensions.cs +++ b/src/RayCarrot.RCP.Metro/Helpers/Extensions/EnumerableExtensions.cs @@ -1,5 +1,4 @@ -#nullable disable -namespace RayCarrot.RCP.Metro; +namespace RayCarrot.RCP.Metro; /// /// Extension methods for an @@ -116,7 +115,7 @@ public static int FindItemIndex(this IList list, Predicate match) /// Disposes all items in the collection /// /// The collection of disposable items - public static void DisposeAll(this IEnumerable disposables) + public static void DisposeAll(this IEnumerable? disposables) { disposables?.ForEach(x => x?.Dispose()); } diff --git a/src/RayCarrot.RCP.Metro/Helpers/Extensions/TaskExtensions.cs b/src/RayCarrot.RCP.Metro/Helpers/Extensions/TaskExtensions.cs index 40dbb9853..5e9c1f527 100644 --- a/src/RayCarrot.RCP.Metro/Helpers/Extensions/TaskExtensions.cs +++ b/src/RayCarrot.RCP.Metro/Helpers/Extensions/TaskExtensions.cs @@ -1,5 +1,4 @@ -#nullable disable -namespace RayCarrot.RCP.Metro; +namespace RayCarrot.RCP.Metro; public static class TaskExtensions { diff --git a/src/RayCarrot.RCP.Metro/Helpers/Extensions/VisualExtensions.cs b/src/RayCarrot.RCP.Metro/Helpers/Extensions/VisualExtensions.cs index 3391db4ec..11a88d203 100644 --- a/src/RayCarrot.RCP.Metro/Helpers/Extensions/VisualExtensions.cs +++ b/src/RayCarrot.RCP.Metro/Helpers/Extensions/VisualExtensions.cs @@ -1,4 +1,5 @@ -#nullable disable +//#nullable disable +using System.Diagnostics.CodeAnalysis; using System.Windows; using System.Windows.Media; @@ -15,7 +16,7 @@ public static class VisualExtensions /// The type of element to get /// The element to get the type from /// The element - public static T GetDescendantByType(this Visual element) + public static T? GetDescendantByType(this Visual element) where T : class { return element.GetDescendantByType(typeof(T)) as T; @@ -27,7 +28,7 @@ public static T GetDescendantByType(this Visual element) /// The element to get the type from /// The type of element to get /// The element - public static object GetDescendantByType(this Visual element, Type descendantType) + public static object? GetDescendantByType(this Visual? element, Type descendantType) { if (element == null) return default; @@ -38,7 +39,7 @@ public static object GetDescendantByType(this Visual element, Type descendantTyp if (element is FrameworkElement frameworkElement) frameworkElement.ApplyTemplate(); - object foundElement = null; + object? foundElement = null; for (var i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++) { diff --git a/src/RayCarrot.RCP.Metro/Helpers/Extensions/WindowExtensions.cs b/src/RayCarrot.RCP.Metro/Helpers/Extensions/WindowExtensions.cs index 92ce3d13f..8ac6e4f70 100644 --- a/src/RayCarrot.RCP.Metro/Helpers/Extensions/WindowExtensions.cs +++ b/src/RayCarrot.RCP.Metro/Helpers/Extensions/WindowExtensions.cs @@ -1,5 +1,4 @@ -#nullable disable -using System.Reflection; +using System.Reflection; using System.Windows; namespace RayCarrot.RCP.Metro; @@ -8,6 +7,11 @@ public static class WindowExtensions { public static bool IsModal(this Window window) { - return (bool)typeof(Window).GetField("_showingAsDialog", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(window); + FieldInfo? fieldInfo = typeof(Window).GetField("_showingAsDialog", BindingFlags.Instance | BindingFlags.NonPublic); + + if (fieldInfo == null) + throw new Exception("Unable to get field info for '_showingAsDialog'"); + + return (bool)fieldInfo.GetValue(window); } } \ No newline at end of file diff --git a/src/RayCarrot.RCP.Metro/Helpers/OperationStatus/IStatusUpdated.cs b/src/RayCarrot.RCP.Metro/Helpers/OperationStatus/IStatusUpdated.cs index d2528d885..ba8805061 100644 --- a/src/RayCarrot.RCP.Metro/Helpers/OperationStatus/IStatusUpdated.cs +++ b/src/RayCarrot.RCP.Metro/Helpers/OperationStatus/IStatusUpdated.cs @@ -1,5 +1,4 @@ -#nullable disable -namespace RayCarrot.RCP.Metro; +namespace RayCarrot.RCP.Metro; /// /// Contains information for keeping track of the status of a running operation diff --git a/src/RayCarrot.RCP.Metro/Helpers/OperationStatus/ItemsOperationProgress.cs b/src/RayCarrot.RCP.Metro/Helpers/OperationStatus/ItemsOperationProgress.cs index 23ef0467e..a9093dbb0 100644 --- a/src/RayCarrot.RCP.Metro/Helpers/OperationStatus/ItemsOperationProgress.cs +++ b/src/RayCarrot.RCP.Metro/Helpers/OperationStatus/ItemsOperationProgress.cs @@ -1,29 +1,40 @@ -#nullable disable -namespace RayCarrot.RCP.Metro; +namespace RayCarrot.RCP.Metro; /// /// Contains information for an item during an ongoing operation /// public class ItemsOperationProgress { + public ItemsOperationProgress( + Progress totalProgress, + Progress itemProgress, + object currentItem, + string operationName) + { + TotalProgress = totalProgress; + ItemProgress = itemProgress; + CurrentItem = currentItem; + OperationName = operationName; + } + /// /// The total progress of the operation /// - public Progress TotalProgress { get; set; } + public Progress TotalProgress { get; } /// /// The item progress for the currently processed item in the operation /// - public Progress ItemProgress { get; set; } + public Progress ItemProgress { get; } /// /// The current item being processed in the operation /// - public object CurrentItem { get; set; } + public object CurrentItem { get; } /// /// The name of the current operation, /// usually the name of the method /// - public string OperationName { get; set; } + public string OperationName { get; } } \ No newline at end of file diff --git a/src/RayCarrot.RCP.Metro/IO/FileSystemPath/FileSystemPathConverter.cs b/src/RayCarrot.RCP.Metro/IO/FileSystemPath/FileSystemPathConverter.cs index ec81af004..c007838e3 100644 --- a/src/RayCarrot.RCP.Metro/IO/FileSystemPath/FileSystemPathConverter.cs +++ b/src/RayCarrot.RCP.Metro/IO/FileSystemPath/FileSystemPathConverter.cs @@ -1,5 +1,4 @@ -#nullable disable -using System.ComponentModel; +using System.ComponentModel; using System.Globalization; using System.IO; @@ -70,7 +69,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c /// An that represents the converted value. /// The destinationType parameter is null. /// The conversion cannot be performed. - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + public override object? ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (!(value is FileSystemPath path)) return base.ConvertTo(context, culture, value, destinationType); diff --git a/src/RayCarrot.RCP.Metro/IO/FileSystemPath/FileSystemPathExtensions.cs b/src/RayCarrot.RCP.Metro/IO/FileSystemPath/FileSystemPathExtensions.cs index d65c54c8f..e10057f84 100644 --- a/src/RayCarrot.RCP.Metro/IO/FileSystemPath/FileSystemPathExtensions.cs +++ b/src/RayCarrot.RCP.Metro/IO/FileSystemPath/FileSystemPathExtensions.cs @@ -1,5 +1,4 @@ -#nullable disable -using System.IO; +using System.IO; using System.Security.Cryptography; namespace RayCarrot.RCP.Metro; @@ -21,7 +20,7 @@ public static class FileSystemPathExtensions /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// The path contains a colon (:) in the middle of the string - public static FileSystemInfo GetFileSystemInfo(this FileSystemPath path) + public static FileSystemInfo? GetFileSystemInfo(this FileSystemPath path) { switch (path.FileSystemType) { diff --git a/src/RayCarrot.RCP.Metro/Installer/GameInstaller.cs b/src/RayCarrot.RCP.Metro/Installer/GameInstaller.cs index 94a1fab47..ead7f4d64 100644 --- a/src/RayCarrot.RCP.Metro/Installer/GameInstaller.cs +++ b/src/RayCarrot.RCP.Metro/Installer/GameInstaller.cs @@ -111,20 +111,13 @@ protected int TotalItems /// The item progress private void OnStatusUpdated(OperationState operationState = OperationState.Running, Progress? itemProgress = null) { - OnStatusUpdated(new OperationProgressEventArgs(new ItemsOperationProgress() - { - // Set the name to the install method - OperationName = nameof(InstallAsync), - - // Set the item progress - ItemProgress = itemProgress ?? new Progress(0), - - // Set the total progress - TotalProgress = new Progress((CurrentItem * 100) + (itemProgress?.Percentage_100 ?? 0), TotalPercentage), - - // Set the current item - CurrentItem = CurrentObject - }, operationState)); + // Set the total progress, item progress, current item and name to the install method + OnStatusUpdated(new OperationProgressEventArgs(new ItemsOperationProgress( + new Progress((CurrentItem * 100) + (itemProgress?.Percentage_100 ?? 0), TotalPercentage), + itemProgress ?? new Progress(0), + CurrentObject, + nameof(InstallAsync) + ), operationState)); } #endregion diff --git a/src/RayCarrot.RCP.Metro/Localization/LocString/ConstLocString.cs b/src/RayCarrot.RCP.Metro/Localization/LocString/ConstLocString.cs index b343fcea6..ad96236de 100644 --- a/src/RayCarrot.RCP.Metro/Localization/LocString/ConstLocString.cs +++ b/src/RayCarrot.RCP.Metro/Localization/LocString/ConstLocString.cs @@ -1,5 +1,4 @@ -#nullable disable -namespace RayCarrot.RCP.Metro; +namespace RayCarrot.RCP.Metro; public class ConstLocString : LocalizedString { diff --git a/src/RayCarrot.RCP.Metro/Localization/LocString/GeneratedLocString.cs b/src/RayCarrot.RCP.Metro/Localization/LocString/GeneratedLocString.cs index a8647671a..9faf2ac48 100644 --- a/src/RayCarrot.RCP.Metro/Localization/LocString/GeneratedLocString.cs +++ b/src/RayCarrot.RCP.Metro/Localization/LocString/GeneratedLocString.cs @@ -1,5 +1,4 @@ -#nullable disable -namespace RayCarrot.RCP.Metro; +namespace RayCarrot.RCP.Metro; /// /// A localized string which gets generated from a func when the culture changes diff --git a/src/RayCarrot.RCP.Metro/Localization/LocString/LocalizedString.cs b/src/RayCarrot.RCP.Metro/Localization/LocString/LocalizedString.cs index 29c14989d..5e9ad5f32 100644 --- a/src/RayCarrot.RCP.Metro/Localization/LocString/LocalizedString.cs +++ b/src/RayCarrot.RCP.Metro/Localization/LocString/LocalizedString.cs @@ -1,5 +1,4 @@ -#nullable disable -using System.Globalization; +using System.Globalization; namespace RayCarrot.RCP.Metro; @@ -24,7 +23,7 @@ protected LocalizedString(bool refreshOnCultureChanged = true) /// /// The current string value /// - public string Value { get; protected set; } + public string Value { get; protected set; } = null!; #endregion diff --git a/src/RayCarrot.RCP.Metro/Pages/Progression/GameViewModel.cs b/src/RayCarrot.RCP.Metro/Pages/Progression/GameViewModel.cs index 7e89b2ce3..98d1b32f3 100644 --- a/src/RayCarrot.RCP.Metro/Pages/Progression/GameViewModel.cs +++ b/src/RayCarrot.RCP.Metro/Pages/Progression/GameViewModel.cs @@ -151,12 +151,12 @@ private async Task LoadBackupInfoAsync(GameBackups_ExistingBackup? backup) text: backup.IsCompressed.ToString(), minUserLevel: UserLevel.Debug)); - DateTime lastWriteTime = backup.Path.GetFileSystemInfo().LastWriteTime; + DateTime backupDate = backup.Path.GetFileSystemInfo()?.LastWriteTime ?? throw new Exception("Can't get backup info"); // Get the backup date BackupInfoItems.Add(new DuoGridItemViewModel( - header: new ResourceLocString(nameof(Resources.Backup_LastBackupDate)), - text: new GeneratedLocString(() => lastWriteTime.ToShortDateString()))); + header: new ResourceLocString(nameof(Resources.Backup_LastBackupDate)), + text: new GeneratedLocString(() => backupDate.ToShortDateString()))); // Get the backup size BackupInfoItems.Add(new DuoGridItemViewModel( @@ -242,7 +242,7 @@ private async Task GetBackupStatusAsync(GameBackups_ExistingBackup if (backup.IsCompressed) compressedBackup = new ZipArchive(File.OpenRead(backup.Path)); - DateTime backupDate = backup.Path.GetFileSystemInfo().LastWriteTime; + DateTime backupDate = backup.Path.GetFileSystemInfo()?.LastWriteTime ?? throw new Exception("Can't get backup info"); BackupSearchPattern[] backupDirs = BackupInfo.BackupDirectories!; // Get the current progress files diff --git a/src/RayCarrot.RCP.Metro/Services/AppUI/AppUIManager.cs b/src/RayCarrot.RCP.Metro/Services/AppUI/AppUIManager.cs index 497a1dbc7..6f60a70bc 100644 --- a/src/RayCarrot.RCP.Metro/Services/AppUI/AppUIManager.cs +++ b/src/RayCarrot.RCP.Metro/Services/AppUI/AppUIManager.cs @@ -5,6 +5,7 @@ using System.Windows; using System.Windows.Media; using System.Windows.Threading; + using RayCarrot.RCP.Metro.Archive; using RayCarrot.RCP.Metro.Games.Clients; using RayCarrot.RCP.Metro.Games.Components; @@ -79,7 +80,7 @@ private async Task ShowDialogAsync(Func createWindowFunc, + Func createWindowFunc, ShowWindowFlags flags = ShowWindowFlags.None, string[] typeGroupNames = null, string[] globalGroupNames = null) @@ -119,7 +120,7 @@ public async Task SelectItemAsync(ItemSelectionDialog public Task GetProgramAsync(ProgramSelectionViewModel programSelectionViewModel) => ShowDialogAsync(() => new ProgramSelectionDialog(programSelectionViewModel)); - public Task SelectGamesAsync(GamesSelectionViewModel gamesSelectionViewModel) => + public Task SelectGamesAsync(GamesSelectionViewModel gamesSelectionViewModel) => ShowDialogAsync(() => new GamesSelectionDialog(gamesSelectionViewModel)); /// @@ -131,7 +132,7 @@ public Task SelectGamesAsync(GamesSelectionViewModel games public Task DownloadAsync(DownloaderViewModel viewModel) => ShowDialogAsync(() => new Downloader(viewModel)); - public Task InstallGameAsync(GameDescriptor gameDescriptor, GameInstallerInfo info) => + public Task InstallGameAsync(GameDescriptor gameDescriptor, GameInstallerInfo info) => ShowDialogAsync(() => new GameInstallerDialog(gameDescriptor, info)); /// @@ -213,14 +214,11 @@ static string GetImgSource(MessageType mt) return await Application.Current.Dispatcher.Invoke(async () => { // Create the view model - var vm = new DialogMessageViewModel() + var vm = new DialogMessageViewModel(message, messageType, actions, + new UserInputResult(), + (ImageSource)new ImageSourceConverter().ConvertFromString(GetImgSource(messageType))) { - MessageText = message, Title = headerMessage, - MessageType = messageType, - DialogImageSource = (ImageSource)new ImageSourceConverter().ConvertFromString(GetImgSource(messageType)), - DialogActions = actions, - DefaultActionResult = new UserInputResult(), }; // Create the message box @@ -271,7 +269,7 @@ await ShowWindowAsync( public async Task ShowGameClientGameOptionsAsync(GameInstallation gameInstallation) { await ShowWindowAsync( - () => new GameSettingsDialog(gameInstallation.GetRequiredComponent().CreateObject()), + () => new GameSettingsDialog(gameInstallation.GetRequiredComponent().CreateObject()), // Only allow one settings window per installation typeGroupNames: new[] { gameInstallation.InstallationId }); } @@ -351,7 +349,7 @@ public async Task ShowModLoaderAsync(GameInstallation gameInstallation, long gam if (validFiles.Count > 1) { ItemSelectionDialogResult result = await Services.UI.SelectItemAsync(new ItemSelectionDialogViewModel(validFiles. - Select(x => x.Description.IsNullOrWhiteSpace() + Select(x => x.Description.IsNullOrWhiteSpace() ? x.File : $"{x.File}{Environment.NewLine}{x.Description}"). ToArray(), @@ -453,9 +451,9 @@ public async Task ShowModLoaderAsync(GameInstallation? gameInstallation, params await Services.MessageUI.DisplayExceptionMessageAsync(ex, Resources.ModLoader_ErrorOpening); - return; + return; } - + if (viewModel == null) return; @@ -469,7 +467,7 @@ public async Task ShowModLoaderAsync(GameInstallation? gameInstallation, params /// /// The game installation the mod should be created for /// The task - public async Task ShowModCreatorAsync(GameInstallation gameInstallation) => + public async Task ShowModCreatorAsync(GameInstallation gameInstallation) => await ShowWindowAsync(() => new ModCreatorDialog(new ModCreatorViewModel(gameInstallation))); /// @@ -477,7 +475,7 @@ public async Task ShowModCreatorAsync(GameInstallation gameInstallation) => /// /// The task public async Task ShowPrototypeRestorationAsync(GameInstallation gameInstallation) => - await ShowWindowAsync(() => new PrototypeRestorationDialog(new PrototypeRestorationViewModel(gameInstallation)), + await ShowWindowAsync(() => new PrototypeRestorationDialog(new PrototypeRestorationViewModel(gameInstallation)), typeGroupNames: new[] { gameInstallation.InstallationId }); /// @@ -485,28 +483,28 @@ public async Task ShowPrototypeRestorationAsync(GameInstallation gameInstallatio /// /// The task public async Task ShowRuntimeModificationsAsync(GameInstallation gameInstallation) => - await ShowWindowAsync(() => new RuntimeModificationsDialog(new RuntimeModificationsViewModel(gameInstallation, Services.MessageUI)), + await ShowWindowAsync(() => new RuntimeModificationsDialog(new RuntimeModificationsViewModel(gameInstallation, Services.MessageUI)), typeGroupNames: new[] { gameInstallation.InstallationId }); /// /// Shows a new instance of the add games dialog /// /// The task - public async Task ShowAddGamesAsync() => + public async Task ShowAddGamesAsync() => await ShowWindowAsync(() => new AddGamesDialog(), ShowWindowFlags.DuplicateTypesNotAllowed); /// /// Shows a new instance of the game clients setup dialog /// /// The task - public async Task ShowGameClientsSetupAsync() => + public async Task ShowGameClientsSetupAsync() => await ShowWindowAsync(() => new GameClientsSetupDialog(), ShowWindowFlags.DuplicateTypesNotAllowed); /// /// Shows a new instance of the anniversary update dialog /// /// The task - public async Task ShowAnniversaryUpdateAsync() => + public async Task ShowAnniversaryUpdateAsync() => await ShowWindowAsync(() => new AnniversaryUpdateDialog(), ShowWindowFlags.Modal); #endregion diff --git a/src/RayCarrot.RCP.Metro/Services/Browse/Directory/DirectoryBrowserViewModel.cs b/src/RayCarrot.RCP.Metro/Services/Browse/Directory/DirectoryBrowserViewModel.cs index 6a2f9f3f5..dca5896a8 100644 --- a/src/RayCarrot.RCP.Metro/Services/Browse/Directory/DirectoryBrowserViewModel.cs +++ b/src/RayCarrot.RCP.Metro/Services/Browse/Directory/DirectoryBrowserViewModel.cs @@ -1,5 +1,4 @@ -#nullable disable -namespace RayCarrot.RCP.Metro; +namespace RayCarrot.RCP.Metro; /// /// A model to use when browsing for a directory diff --git a/src/RayCarrot.RCP.Metro/Services/Browse/SaveFile/SaveFileViewModel.cs b/src/RayCarrot.RCP.Metro/Services/Browse/SaveFile/SaveFileViewModel.cs index e77c42182..2e2294141 100644 --- a/src/RayCarrot.RCP.Metro/Services/Browse/SaveFile/SaveFileViewModel.cs +++ b/src/RayCarrot.RCP.Metro/Services/Browse/SaveFile/SaveFileViewModel.cs @@ -1,5 +1,4 @@ -#nullable disable -namespace RayCarrot.RCP.Metro; +namespace RayCarrot.RCP.Metro; /// /// The model to use when saving a file @@ -9,5 +8,5 @@ public class SaveFileViewModel : BaseBrowseViewModel /// /// The available extensions to save the file to /// - public string Extensions { get; set; } + public string? Extensions { get; set; } } \ No newline at end of file diff --git a/src/RayCarrot.RCP.Metro/Services/WindowDialog/Control/IWindowControl.cs b/src/RayCarrot.RCP.Metro/Services/WindowDialog/Control/IWindowControl.cs index 23d09f361..099baf635 100644 --- a/src/RayCarrot.RCP.Metro/Services/WindowDialog/Control/IWindowControl.cs +++ b/src/RayCarrot.RCP.Metro/Services/WindowDialog/Control/IWindowControl.cs @@ -1,5 +1,4 @@ -#nullable disable -namespace RayCarrot.RCP.Metro; +namespace RayCarrot.RCP.Metro; /// /// An abstract window control diff --git a/src/RayCarrot.RCP.Metro/Services/WindowDialog/Control/WindowContentControl.cs b/src/RayCarrot.RCP.Metro/Services/WindowDialog/Control/WindowContentControl.cs index 7dc0ad92a..b79406503 100644 --- a/src/RayCarrot.RCP.Metro/Services/WindowDialog/Control/WindowContentControl.cs +++ b/src/RayCarrot.RCP.Metro/Services/WindowDialog/Control/WindowContentControl.cs @@ -74,7 +74,7 @@ private async void WindowInstance_WindowClosing(object sender, CancelEventArgs e try { // Check if the window can be closed - var canClose = await ClosingAsync(); + bool canClose = await ClosingAsync(); // If we can close we flag to force close and then close the window again if (canClose) diff --git a/src/RayCarrot.RCP.Metro/UI/BindingProxy.cs b/src/RayCarrot.RCP.Metro/UI/BindingProxy.cs index 5c7b6a7c7..2ac34eb06 100644 --- a/src/RayCarrot.RCP.Metro/UI/BindingProxy.cs +++ b/src/RayCarrot.RCP.Metro/UI/BindingProxy.cs @@ -1,5 +1,4 @@ -#nullable disable -using System.Windows; +using System.Windows; namespace RayCarrot.RCP.Metro; @@ -16,7 +15,7 @@ protected override Freezable CreateInstanceCore() /// /// The data context to bind to /// - public object Data + public object? Data { get => GetValue(DataProperty); set => SetValue(DataProperty, value); diff --git a/src/RayCarrot.RCP.Metro/UI/Dialogs/Message/DialogMessageViewModel.cs b/src/RayCarrot.RCP.Metro/UI/Dialogs/Message/DialogMessageViewModel.cs index 5d1d792f1..ba94539ca 100644 --- a/src/RayCarrot.RCP.Metro/UI/Dialogs/Message/DialogMessageViewModel.cs +++ b/src/RayCarrot.RCP.Metro/UI/Dialogs/Message/DialogMessageViewModel.cs @@ -1,5 +1,4 @@ -#nullable disable -using System.Windows.Media; +using System.Windows.Media; namespace RayCarrot.RCP.Metro; @@ -8,28 +7,42 @@ namespace RayCarrot.RCP.Metro; /// public class DialogMessageViewModel : UserInputViewModel { + public DialogMessageViewModel( + string messageText, + MessageType messageType, + IList dialogActions, + UserInputResult defaultActionResult, + ImageSource dialogImageSource) + { + MessageText = messageText; + MessageType = messageType; + DialogActions = dialogActions; + DefaultActionResult = defaultActionResult; + DialogImageSource = dialogImageSource; + } + /// /// The message text /// - public string MessageText { get; set; } + public string MessageText { get; } /// /// The message type /// - public MessageType MessageType { get; set; } + public MessageType MessageType { get; } /// /// The dialog actions /// - public IList DialogActions { get; set; } + public IList DialogActions { get; } /// /// The default action result /// - public UserInputResult DefaultActionResult { get; set; } + public UserInputResult DefaultActionResult { get; } /// /// The dialog image source /// - public ImageSource DialogImageSource { get; set; } + public ImageSource DialogImageSource { get; } } \ No newline at end of file diff --git a/src/RayCarrot.RCP.Metro/UI/Dialogs/Message/MessageType.cs b/src/RayCarrot.RCP.Metro/UI/Dialogs/Message/MessageType.cs index f11942891..122748ff9 100644 --- a/src/RayCarrot.RCP.Metro/UI/Dialogs/Message/MessageType.cs +++ b/src/RayCarrot.RCP.Metro/UI/Dialogs/Message/MessageType.cs @@ -1,5 +1,4 @@ -#nullable disable -namespace RayCarrot.RCP.Metro; +namespace RayCarrot.RCP.Metro; /// /// The types of messages to display