diff --git a/src/Pixeval.Controls/Attributes/LocalizationMetadataAttribute.cs b/src/Pixeval.Controls/Attributes/LocalizationMetadataAttribute.cs index 58800919..c3164904 100644 --- a/src/Pixeval.Controls/Attributes/LocalizationMetadataAttribute.cs +++ b/src/Pixeval.Controls/Attributes/LocalizationMetadataAttribute.cs @@ -30,7 +30,6 @@ public class LocalizationMetadataAttribute(Type resourceType) : Attribute public bool IsPartial { get; init; } } - [AttributeUsage(AttributeTargets.Class)] public class AttachedLocalizationMetadataAttribute(Type resourceType) : Attribute { diff --git a/src/Pixeval.Controls/Timeline/TimelineUnit.cs b/src/Pixeval.Controls/Timeline/TimelineUnit.cs index ae441b24..1c36b6c7 100644 --- a/src/Pixeval.Controls/Timeline/TimelineUnit.cs +++ b/src/Pixeval.Controls/Timeline/TimelineUnit.cs @@ -1,5 +1,3 @@ -using Windows.UI; -using Microsoft.UI; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media; @@ -72,7 +70,6 @@ public sealed partial class TimelineUnit : ContentControl return FoldThreshold is not -1 && ActualWidth < FoldThreshold; } - private void OnSizeChanged(object sender, SizeChangedEventArgs e) { if (FoldCriteria()) diff --git a/src/Pixeval.Utilities/IFactory.cs b/src/Pixeval.Utilities/IFactory.cs index 17aef0d6..104c0f2a 100644 --- a/src/Pixeval.Utilities/IFactory.cs +++ b/src/Pixeval.Utilities/IFactory.cs @@ -24,5 +24,5 @@ namespace Pixeval.Controls; public interface IFactory { - static abstract TSelf CreateInstance(T entry, int index); + static abstract TSelf CreateInstance(T entry); } diff --git a/src/Pixeval.Utilities/ObservableCollectionAdapter.cs b/src/Pixeval.Utilities/ObservableCollectionAdapter.cs index e5af58df..6c30e08e 100644 --- a/src/Pixeval.Utilities/ObservableCollectionAdapter.cs +++ b/src/Pixeval.Utilities/ObservableCollectionAdapter.cs @@ -75,7 +75,7 @@ public class ObservableCollectionAdapter : ObservableCollection for (var index = 0; index < _sourceCollection.Count; index++) { var element = _sourceCollection[index]; - var item = TOutput.CreateInstance(element, index); + var item = TOutput.CreateInstance(element); Add(item); } } @@ -93,7 +93,7 @@ public class ObservableCollectionAdapter : ObservableCollection var input = (TInput)args.NewItems[i]!; if (_filter?.Invoke(input) is false) continue; - var item = TOutput.CreateInstance(input, i); + var item = TOutput.CreateInstance(input); Insert(args.NewStartingIndex + i, item); } break; @@ -117,7 +117,7 @@ public class ObservableCollectionAdapter : ObservableCollection } else { - var item = TOutput.CreateInstance(input, i); + var item = TOutput.CreateInstance(input); this[args.OldStartingIndex + i - removedCount] = item; } } @@ -135,7 +135,7 @@ public class ObservableCollectionAdapter : ObservableCollection var element = SourceCollection[index]; if (_filter?.Invoke(element) is false) continue; - var item = TOutput.CreateInstance(element, index); + var item = TOutput.CreateInstance(element); Add(item); } diff --git a/src/Pixeval/AppManagement/AppInfo.cs b/src/Pixeval/AppManagement/AppInfo.cs index 75566d64..f92e625c 100644 --- a/src/Pixeval/AppManagement/AppInfo.cs +++ b/src/Pixeval/AppManagement/AppInfo.cs @@ -20,7 +20,6 @@ using System; using System.IO; -using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Threading.Tasks; using Windows.Storage; @@ -28,7 +27,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.UI.Xaml.Media.Imaging; using Pixeval.Controls.Windowing; using Pixeval.Database.Managers; -using Pixeval.Download; using Pixeval.Util.IO; using Pixeval.Utilities; using WinUI3Utilities; @@ -93,7 +91,6 @@ public static partial class AppInfo public static Uri NavigationIconUri(string name) => new Uri($"ms-appx:///Assets/Images/Icons/{name}.png"); - public static string ApplicationUriToPath(Uri uri) { if (uri.Scheme is not "ms-appx") diff --git a/src/Pixeval/AppManagement/AppSettings.cs b/src/Pixeval/AppManagement/AppSettings.cs index 9a2f9d61..abf3ab5f 100644 --- a/src/Pixeval/AppManagement/AppSettings.cs +++ b/src/Pixeval/AppManagement/AppSettings.cs @@ -130,7 +130,7 @@ public partial record AppSettings() : IWindowSettings public string ReverseSearchApiKey { get; set; } = ""; [SettingsEntry(Symbol.Cookies, nameof(WebCookieEntryHeader), nameof(WebCookieEntryDescription))] - public string? WebCookie { get; set; } + public string WebCookie { get; set; } = ""; [SettingsEntry(Symbol.TargetArrow, nameof(ReverseSearchResultSimilarityThresholdEntryHeader), nameof(ReverseSearchResultSimilarityThresholdEntryDescription))] public int ReverseSearchResultSimilarityThreshold { get; set; } = 80; diff --git a/src/Pixeval/AppViewModel.cs b/src/Pixeval/AppViewModel.cs index 4e3c441e..7e546494 100644 --- a/src/Pixeval/AppViewModel.cs +++ b/src/Pixeval/AppViewModel.cs @@ -23,13 +23,11 @@ using System.Threading.Tasks; using LiteDB; using Microsoft.Extensions.DependencyInjection; using Pixeval.AppManagement; -using Pixeval.Controls; using Pixeval.Controls.Windowing; using Pixeval.CoreApi; using Pixeval.CoreApi.Net; using Pixeval.Database.Managers; using Pixeval.Download; -using Pixeval.Download.Models; using Pixeval.Logging; using Pixeval.Util.IO; using Pixeval.Util.UI; diff --git a/src/Pixeval/Assets/Images/Icons/recommendations-128x128.png b/src/Pixeval/Assets/Images/Icons/recommendations-128x128.png index b060e8d3..fe34b826 100644 Binary files a/src/Pixeval/Assets/Images/Icons/recommendations-128x128.png and b/src/Pixeval/Assets/Images/Icons/recommendations-128x128.png differ diff --git a/src/Pixeval/Assets/Images/Icons/recommendations-64x64.png b/src/Pixeval/Assets/Images/Icons/recommendations-64x64.png index 9a740475..fe34b826 100644 Binary files a/src/Pixeval/Assets/Images/Icons/recommendations-64x64.png and b/src/Pixeval/Assets/Images/Icons/recommendations-64x64.png differ diff --git a/src/Pixeval/Assets/Images/Icons/recommendations.png b/src/Pixeval/Assets/Images/Icons/recommendations.png index bdcdc85c..fe34b826 100644 Binary files a/src/Pixeval/Assets/Images/Icons/recommendations.png and b/src/Pixeval/Assets/Images/Icons/recommendations.png differ diff --git a/src/Pixeval/Assets/Images/Icons/settings-128x128.png b/src/Pixeval/Assets/Images/Icons/settings-128x128.png index 319e9798..486f1690 100644 Binary files a/src/Pixeval/Assets/Images/Icons/settings-128x128.png and b/src/Pixeval/Assets/Images/Icons/settings-128x128.png differ diff --git a/src/Pixeval/Assets/Images/Icons/settings-64x64.png b/src/Pixeval/Assets/Images/Icons/settings-64x64.png index 56562986..131c5f02 100644 Binary files a/src/Pixeval/Assets/Images/Icons/settings-64x64.png and b/src/Pixeval/Assets/Images/Icons/settings-64x64.png differ diff --git a/src/Pixeval/Assets/Images/Icons/settings.png b/src/Pixeval/Assets/Images/Icons/settings.png index 05515c92..7cc85326 100644 Binary files a/src/Pixeval/Assets/Images/Icons/settings.png and b/src/Pixeval/Assets/Images/Icons/settings.png differ diff --git a/src/Pixeval/Assets/Images/Icons/spotlight-128x128.png b/src/Pixeval/Assets/Images/Icons/spotlight-128x128.png index 9c21fa8c..b517c7ec 100644 Binary files a/src/Pixeval/Assets/Images/Icons/spotlight-128x128.png and b/src/Pixeval/Assets/Images/Icons/spotlight-128x128.png differ diff --git a/src/Pixeval/Assets/Images/Icons/spotlight-64x64.png b/src/Pixeval/Assets/Images/Icons/spotlight-64x64.png index 06e16561..b517c7ec 100644 Binary files a/src/Pixeval/Assets/Images/Icons/spotlight-64x64.png and b/src/Pixeval/Assets/Images/Icons/spotlight-64x64.png differ diff --git a/src/Pixeval/Assets/Images/Icons/spotlight.png b/src/Pixeval/Assets/Images/Icons/spotlight.png index 983e6b24..b517c7ec 100644 Binary files a/src/Pixeval/Assets/Images/Icons/spotlight.png and b/src/Pixeval/Assets/Images/Icons/spotlight.png differ diff --git a/src/Pixeval/Assets/Images/Icons/tag-128x128.png b/src/Pixeval/Assets/Images/Icons/tag-128x128.png index cf798ec1..cf476d7c 100644 Binary files a/src/Pixeval/Assets/Images/Icons/tag-128x128.png and b/src/Pixeval/Assets/Images/Icons/tag-128x128.png differ diff --git a/src/Pixeval/Assets/Images/Icons/tag-64x64.png b/src/Pixeval/Assets/Images/Icons/tag-64x64.png index d67a8494..cf476d7c 100644 Binary files a/src/Pixeval/Assets/Images/Icons/tag-64x64.png and b/src/Pixeval/Assets/Images/Icons/tag-64x64.png differ diff --git a/src/Pixeval/Assets/Images/Icons/tag.png b/src/Pixeval/Assets/Images/Icons/tag.png index 9fd5ebd2..cf476d7c 100644 Binary files a/src/Pixeval/Assets/Images/Icons/tag.png and b/src/Pixeval/Assets/Images/Icons/tag.png differ diff --git a/src/Pixeval/Controls/Download/DownloadItem.xaml b/src/Pixeval/Controls/Download/DownloadItem.xaml index 94f6069e..2260015d 100644 --- a/src/Pixeval/Controls/Download/DownloadItem.xaml +++ b/src/Pixeval/Controls/Download/DownloadItem.xaml @@ -33,7 +33,7 @@ TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" /> new(entry); + public static DownloadItemViewModel CreateInstance(IDownloadTaskGroup entry) => new(entry); #pragma warning disable CA1822 diff --git a/src/Pixeval/Controls/Entry/EntryViewModel.cs b/src/Pixeval/Controls/Entry/EntryViewModel.cs index afefecc9..0960110f 100644 --- a/src/Pixeval/Controls/Entry/EntryViewModel.cs +++ b/src/Pixeval/Controls/Entry/EntryViewModel.cs @@ -33,7 +33,6 @@ using Symbol = FluentIcons.Common.Symbol; namespace Pixeval.Controls; - [DebuggerDisplay("{Entry}")] public abstract class EntryViewModel(T entry) : ObservableObject, IDisposable where T : IEntry { diff --git a/src/Pixeval/Controls/Entry/FetchEngineIncrementalSource.cs b/src/Pixeval/Controls/Entry/FetchEngineIncrementalSource.cs index e2d6d71b..7ee67c55 100644 --- a/src/Pixeval/Controls/Entry/FetchEngineIncrementalSource.cs +++ b/src/Pixeval/Controls/Entry/FetchEngineIncrementalSource.cs @@ -75,5 +75,5 @@ public class FetchEngineIncrementalSource(IAsyncEnumerable as protected virtual long Identifier(T entity) => entity.Id; - protected TViewModel Select(T entity, int index) => TViewModel.CreateInstance(entity, index); + protected TViewModel Select(T entity, int index) => TViewModel.CreateInstance(entity); } diff --git a/src/Pixeval/Controls/EnumComboBox.cs b/src/Pixeval/Controls/EnumComboBox.cs index 4358f547..8faf631a 100644 --- a/src/Pixeval/Controls/EnumComboBox.cs +++ b/src/Pixeval/Controls/EnumComboBox.cs @@ -85,7 +85,7 @@ public sealed partial class EnumValuesExtension : MarkupExtension EnumValuesEnum.WorkSortOption => WorkSortOptionExtension.GetItems(), EnumValuesEnum.PrivacyPolicy => PrivacyPolicyExtension.GetItems(), EnumValuesEnum.DownloadListOption => DownloadListOptionExtension.GetItems(), - _ => throw new ArgumentOutOfRangeException() + _ => ThrowHelper.ArgumentOutOfRange(Type) }; } } diff --git a/src/Pixeval/Controls/Illustration/IllustrationItemViewModel.Commands.cs b/src/Pixeval/Controls/Illustration/IllustrationItemViewModel.Commands.cs index 22745464..6f9b41f1 100644 --- a/src/Pixeval/Controls/Illustration/IllustrationItemViewModel.Commands.cs +++ b/src/Pixeval/Controls/Illustration/IllustrationItemViewModel.Commands.cs @@ -30,7 +30,6 @@ using System.IO; using System.Linq; using Pixeval.Download; using Microsoft.Extensions.DependencyInjection; -using Pixeval.Download.Models; using Pixeval.Util.IO; using Symbol = FluentIcons.Common.Symbol; diff --git a/src/Pixeval/Controls/Illustration/IllustrationItemViewModel.cs b/src/Pixeval/Controls/Illustration/IllustrationItemViewModel.cs index 40a2991b..6f401a04 100644 --- a/src/Pixeval/Controls/Illustration/IllustrationItemViewModel.cs +++ b/src/Pixeval/Controls/Illustration/IllustrationItemViewModel.cs @@ -35,7 +35,7 @@ namespace Pixeval.Controls; /// public partial class IllustrationItemViewModel : WorkEntryViewModel, IFactory { - public static IllustrationItemViewModel CreateInstance(Illustration entry, int _) => new(entry); + public static IllustrationItemViewModel CreateInstance(Illustration entry) => new(entry); public IllustrationItemViewModel(Illustration illustration) : base(illustration) { diff --git a/src/Pixeval/Controls/Illustrator/IllustratorItemViewModel.cs b/src/Pixeval/Controls/Illustrator/IllustratorItemViewModel.cs index c49a8c61..862431e3 100644 --- a/src/Pixeval/Controls/Illustrator/IllustratorItemViewModel.cs +++ b/src/Pixeval/Controls/Illustrator/IllustratorItemViewModel.cs @@ -26,7 +26,7 @@ namespace Pixeval.Controls; public sealed partial class IllustratorItemViewModel : EntryViewModel, IFactory { - public static IllustratorItemViewModel CreateInstance(User entry, int _) => new(entry); + public static IllustratorItemViewModel CreateInstance(User entry) => new(entry); [ObservableProperty] private bool _isFollowed; diff --git a/src/Pixeval/Controls/Novel/NovelItemViewModel.Commands.cs b/src/Pixeval/Controls/Novel/NovelItemViewModel.Commands.cs index 9445bafa..79ed7d0c 100644 --- a/src/Pixeval/Controls/Novel/NovelItemViewModel.Commands.cs +++ b/src/Pixeval/Controls/Novel/NovelItemViewModel.Commands.cs @@ -28,7 +28,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.UI.Xaml.Controls; using Pixeval.CoreApi.Model; using Pixeval.Download; -using Pixeval.Download.Models; using Pixeval.Util.UI; namespace Pixeval.Controls; diff --git a/src/Pixeval/Controls/Novel/NovelItemViewModel.cs b/src/Pixeval/Controls/Novel/NovelItemViewModel.cs index 6ec6a3a3..cedd7a1f 100644 --- a/src/Pixeval/Controls/Novel/NovelItemViewModel.cs +++ b/src/Pixeval/Controls/Novel/NovelItemViewModel.cs @@ -27,7 +27,7 @@ namespace Pixeval.Controls; public partial class NovelItemViewModel(Novel novel) : WorkEntryViewModel(novel), IFactory { - public static NovelItemViewModel CreateInstance(Novel entry, int _) => new(entry); + public static NovelItemViewModel CreateInstance(Novel entry) => new(entry); public int TextLength => Entry.TextLength; diff --git a/src/Pixeval/Controls/Spotlight/SpotlightItemViewModel.cs b/src/Pixeval/Controls/Spotlight/SpotlightItemViewModel.cs index bcf13fdf..d58e822b 100644 --- a/src/Pixeval/Controls/Spotlight/SpotlightItemViewModel.cs +++ b/src/Pixeval/Controls/Spotlight/SpotlightItemViewModel.cs @@ -26,7 +26,7 @@ namespace Pixeval.Controls; public partial class SpotlightItemViewModel : ThumbnailEntryViewModel, IFactory { - public static SpotlightItemViewModel CreateInstance(Spotlight entry, int _) => new(entry); + public static SpotlightItemViewModel CreateInstance(Spotlight entry) => new(entry); public SpotlightItemViewModel(Spotlight spotlight) : base(spotlight) => InitializeCommandsBase(); diff --git a/src/Pixeval/Controls/Work/WorkEntryViewModel.Commands.cs b/src/Pixeval/Controls/Work/WorkEntryViewModel.Commands.cs index b2f00233..cfc4027e 100644 --- a/src/Pixeval/Controls/Work/WorkEntryViewModel.Commands.cs +++ b/src/Pixeval/Controls/Work/WorkEntryViewModel.Commands.cs @@ -23,18 +23,14 @@ using Windows.System; using Microsoft.UI.Xaml.Input; using Pixeval.Util.UI; using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; using FluentIcons.Common; using Pixeval.CoreApi.Model; -using Pixeval.Utilities; namespace Pixeval.Controls; public partial class WorkEntryViewModel { - - /// /// Parameter: /// @@ -125,7 +121,6 @@ public partial class WorkEntryViewModel private void AddToBookmarkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { - if (args.Parameter is not (IEnumerable userTags, bool isPrivate, var parameter)) return; IsBookmarked = true; diff --git a/src/Pixeval/Controls/Work/WorkEntryViewModel.Debounce.cs b/src/Pixeval/Controls/Work/WorkEntryViewModel.Debounce.cs index c5db189e..c9bce1d0 100644 --- a/src/Pixeval/Controls/Work/WorkEntryViewModel.Debounce.cs +++ b/src/Pixeval/Controls/Work/WorkEntryViewModel.Debounce.cs @@ -20,12 +20,10 @@ using Pixeval.Utilities; using System.Threading.Tasks; -using System; using System.Collections.Generic; namespace Pixeval.Controls; - public partial class WorkEntryViewModel { private readonly Debounce _bookmarkDebounce = new(); diff --git a/src/Pixeval/Controls/Work/WorkView.xaml.cs b/src/Pixeval/Controls/Work/WorkView.xaml.cs index ad167ef1..f714a93a 100644 --- a/src/Pixeval/Controls/Work/WorkView.xaml.cs +++ b/src/Pixeval/Controls/Work/WorkView.xaml.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; using System.Linq; using Windows.Foundation; diff --git a/src/Pixeval/Download/Models/NovelDownloadTaskGroup.cs b/src/Pixeval/Download/Models/NovelDownloadTaskGroup.cs index 35e8019a..3a92d4d3 100644 --- a/src/Pixeval/Download/Models/NovelDownloadTaskGroup.cs +++ b/src/Pixeval/Download/Models/NovelDownloadTaskGroup.cs @@ -27,7 +27,6 @@ using System.Threading.Tasks; using Pixeval.Controls; using Pixeval.CoreApi.Model; using Pixeval.Database; -using Pixeval.Download.Macros; using Pixeval.Options; using Pixeval.Util; using Pixeval.Util.IO; diff --git a/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.Condensed.cs b/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.Condensed.cs index 64ec983e..63b3e1d6 100644 --- a/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.Condensed.cs +++ b/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.Condensed.cs @@ -26,6 +26,7 @@ using System.Threading.Tasks; using System; using Microsoft.UI; using Pixeval.AppManagement; +using WinUI3Utilities; namespace Pixeval.Pages.Capability.Feeds; @@ -36,11 +37,11 @@ public class FeedItemCondensedViewModel(List entries) : AbstractFeedItemV GC.SuppressFinalize(this); } - public override Uri AppUri => throw new NotSupportedException("AppUri is not supported for condensed feeds"); + public override Uri AppUri => ThrowHelper.NotSupported("AppUri is not supported for condensed feeds"); - public override Uri WebUri => throw new NotSupportedException("WebUri is not supported for condensed feeds"); + public override Uri WebUri => ThrowHelper.NotSupported("WebUri is not supported for condensed feeds"); - public override Uri PixEzUri => throw new NotSupportedException("PixEzUri is not supported for condensed feeds"); + public override Uri PixEzUri => ThrowHelper.NotSupported("PixEzUri is not supported for condensed feeds"); private ImageSource? _userAvatar; diff --git a/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.Sparse.cs b/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.Sparse.cs index b41584d9..db11fabe 100644 --- a/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.Sparse.cs +++ b/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.Sparse.cs @@ -29,11 +29,10 @@ using System.Threading.Tasks; using System; using Microsoft.UI; using Pixeval.AppManagement; +using WinUI3Utilities; namespace Pixeval.Pages.Capability.Feeds; - - public partial class FeedItemSparseViewModel(Feed entry) : AbstractFeedItemViewModel(new IFeedEntry.SparseFeedEntry(entry)), IFactory { [ObservableProperty] @@ -67,7 +66,7 @@ public partial class FeedItemSparseViewModel(Feed entry) : AbstractFeedItemViewM set => SetProperty(ref _itemBackground, value); } - public static FeedItemSparseViewModel CreateInstance(Feed entry, int index) + public static FeedItemSparseViewModel CreateInstance(Feed entry) { return new FeedItemSparseViewModel(entry); } @@ -103,7 +102,7 @@ public partial class FeedItemSparseViewModel(Feed entry) : AbstractFeedItemViewM FeedType.AddBookmark or FeedType.PostIllust => MakoHelper.GenerateIllustrationAppUri(entry.Id), FeedType.AddFavorite => MakoHelper.GenerateUserAppUri(entry.Id), FeedType.AddNovelBookmark => MakoHelper.GenerateNovelAppUri(entry.Id), - _ => throw new ArgumentOutOfRangeException() + _ => ThrowHelper.ArgumentOutOfRange(entry.Type) }; public override Uri WebUri => entry.Type switch @@ -111,7 +110,7 @@ public partial class FeedItemSparseViewModel(Feed entry) : AbstractFeedItemViewM FeedType.AddBookmark or FeedType.PostIllust => MakoHelper.GenerateIllustrationWebUri(entry.Id), FeedType.AddFavorite => MakoHelper.GenerateUserWebUri(entry.Id), FeedType.AddNovelBookmark => MakoHelper.GenerateNovelWebUri(entry.Id), - _ => throw new ArgumentOutOfRangeException() + _ => ThrowHelper.ArgumentOutOfRange(entry.Type) }; public override Uri PixEzUri => entry.Type switch @@ -119,6 +118,6 @@ public partial class FeedItemSparseViewModel(Feed entry) : AbstractFeedItemViewM FeedType.AddBookmark or FeedType.PostIllust => MakoHelper.GenerateIllustrationPixEzUri(entry.Id), FeedType.AddFavorite => MakoHelper.GenerateUserPixEzUri(entry.Id), FeedType.AddNovelBookmark => MakoHelper.GenerateNovelPixEzUri(entry.Id), - _ => throw new ArgumentOutOfRangeException() + _ => ThrowHelper.ArgumentOutOfRange(entry.Type) }; } diff --git a/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.cs b/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.cs index a494bc2b..76f85904 100644 --- a/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.cs +++ b/src/Pixeval/Pages/Capability/Feeds/FeedItemViewModel.cs @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion -using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -29,6 +28,7 @@ using Microsoft.UI.Xaml.Media; using Pixeval.Controls; using Pixeval.CoreApi.Model; using Pixeval.Util.UI; +using WinUI3Utilities; #pragma warning disable CS9107 // Parameter is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well. @@ -51,7 +51,7 @@ public interface IFeedEntry : IIdEntry public record CondensedFeedEntry(List Entries) : IFeedEntry { - public long Id => Entries.First()?.Id ?? 0; + public long Id => Entries[0]?.Id ?? 0; } } @@ -63,7 +63,7 @@ public abstract class AbstractFeedItemViewModel(IFeedEntry entry) : EntryViewMod FeedType.AddFavorite => FeedItemColors.AddFavorite, FeedType.PostIllust => FeedItemColors.PostIllust, FeedType.AddNovelBookmark => FeedItemColors.AddNovelBookmark, - _ => throw new ArgumentOutOfRangeException() + _ => ThrowHelper.ArgumentOutOfRange(default) }; public abstract ImageSource UserAvatar { get; protected set; } @@ -86,24 +86,27 @@ public abstract class AbstractFeedItemViewModel(IFeedEntry entry) : EntryViewMod ItemBackground = value ? new SolidColorBrush(selectedBackground) : new SolidColorBrush(Colors.Transparent); } - public static AbstractFeedItemViewModel CreateInstance(IFeedEntry entry, int index) + public static AbstractFeedItemViewModel CreateInstance(IFeedEntry entry) { return entry switch { IFeedEntry.SparseFeedEntry(var feed) => new FeedItemSparseViewModel(feed), IFeedEntry.CondensedFeedEntry condensed => new FeedItemCondensedViewModel(condensed.Entries), - _ => throw new ArgumentOutOfRangeException() + _ => ThrowHelper.ArgumentOutOfRange(entry) }; } - // Reify the entry from IFeedEntry. + /// + /// Reify the entry from IFeedEntry. + /// + /// public Feed? GetMostSignificantEntry() { return Entry switch { IFeedEntry.SparseFeedEntry(var feed) => feed, IFeedEntry.CondensedFeedEntry condensed => condensed.Entries.First(), - _ => throw new ArgumentOutOfRangeException() + _ => ThrowHelper.ArgumentOutOfRange(Entry) }; } } diff --git a/src/Pixeval/Pages/Capability/Feeds/FeedPageViewModel.cs b/src/Pixeval/Pages/Capability/Feeds/FeedPageViewModel.cs index fcb110d9..e999534d 100644 --- a/src/Pixeval/Pages/Capability/Feeds/FeedPageViewModel.cs +++ b/src/Pixeval/Pages/Capability/Feeds/FeedPageViewModel.cs @@ -23,7 +23,6 @@ using System.Threading; using System.Threading.Tasks; using CommunityToolkit.Mvvm.ComponentModel; using Pixeval.Controls; -using Pixeval.CoreApi.Model; namespace Pixeval.Pages.Capability.Feeds; @@ -42,7 +41,6 @@ public partial class FeedPageViewModel : EntryViewViewModel()) { - } public override IDataProvider DataProvider { get; } diff --git a/src/Pixeval/Pages/Capability/RecommendationPage.xaml.cs b/src/Pixeval/Pages/Capability/RecommendationPage.xaml.cs index a33f8b01..118711c7 100644 --- a/src/Pixeval/Pages/Capability/RecommendationPage.xaml.cs +++ b/src/Pixeval/Pages/Capability/RecommendationPage.xaml.cs @@ -18,8 +18,6 @@ // along with this program. If not, see . #endregion -using System; -using System.Diagnostics; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Pixeval.CoreApi.Global.Enum; diff --git a/src/Pixeval/Pages/MainPage.xaml.cs b/src/Pixeval/Pages/MainPage.xaml.cs index 2b88179d..bf280df8 100644 --- a/src/Pixeval/Pages/MainPage.xaml.cs +++ b/src/Pixeval/Pages/MainPage.xaml.cs @@ -125,7 +125,7 @@ public sealed partial class MainPage // args.SelectedItem may be null here if (sender.SelectedItem is NavigationViewItem { Tag: NavigationViewTag tag } selectedItem) { - if (Equals(selectedItem, FeedTab) && App.AppViewModel.AppSettings.WebCookie.IsNullOrBlank()) + if (Equals(selectedItem, FeedTab) && App.AppViewModel.AppSettings.WebCookie is "") { _ = this.CreateAcknowledgementAsync(MainPageResources.FeedTabCannotBeOpenedTitle, MainPageResources.FeedTabCannotBeOpenedContent); sender.SelectedItem = _lastSelected; diff --git a/src/Pixeval/Pages/NovelViewer/NovelViewerPage.xaml.cs b/src/Pixeval/Pages/NovelViewer/NovelViewerPage.xaml.cs index 85bc9937..66c36339 100644 --- a/src/Pixeval/Pages/NovelViewer/NovelViewerPage.xaml.cs +++ b/src/Pixeval/Pages/NovelViewer/NovelViewerPage.xaml.cs @@ -64,7 +64,6 @@ public sealed partial class NovelViewerPage ThumbnailItemsView.StartBringItemIntoView(vm.CurrentNovelIndex, new BringIntoViewOptions { AnimationDesired = true }); }; - _viewModel.PropertyChanged += (sender, args) => { var vm = sender.To(); diff --git a/src/Pixeval/Pages/Tags/TagsEntryViewModel.cs b/src/Pixeval/Pages/Tags/TagsEntryViewModel.cs index 095c03d5..58b315bc 100644 --- a/src/Pixeval/Pages/Tags/TagsEntryViewModel.cs +++ b/src/Pixeval/Pages/Tags/TagsEntryViewModel.cs @@ -129,5 +129,9 @@ public partial class TagsEntryViewModel : ObservableObject, IEntry, IDisposable entry.Thumbnail = await (await IoHelper.GetFileThumbnailAsync(path)).GetSoftwareBitmapSourceAsync(true); } - public void Dispose() => Thumbnail?.Dispose(); + public void Dispose() + { + GC.SuppressFinalize(this); + Thumbnail?.Dispose(); + } } diff --git a/src/Pixeval/Util/RankOptionExtension.cs b/src/Pixeval/Util/RankOptionExtension.cs index bbcefc06..dea5b3f4 100644 --- a/src/Pixeval/Util/RankOptionExtension.cs +++ b/src/Pixeval/Util/RankOptionExtension.cs @@ -84,7 +84,6 @@ public static partial class NovelRankOptionExtension ]; } - [AttachedLocalizationMetadata(typeof(MiscResources))] [AttachedLocalizedResource(nameof(TargetFilter.ForAndroid), nameof(MiscResources.TargetFilterForAndroid))] [AttachedLocalizedResource(nameof(TargetFilter.ForIos), nameof(MiscResources.TargetFilterForIOS))] diff --git a/src/Pixeval/Util/UI/Animating/DoubleValueAnimation.cs b/src/Pixeval/Util/UI/Animating/DoubleValueAnimation.cs index 80b4e096..5cc02da2 100644 --- a/src/Pixeval/Util/UI/Animating/DoubleValueAnimation.cs +++ b/src/Pixeval/Util/UI/Animating/DoubleValueAnimation.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval +#region Copyright (c) Pixeval/Pixeval // GPL v3 License // // Pixeval/Pixeval @@ -35,7 +35,6 @@ public class DoubleValueAnimation(TimeSpan duration, double to, IEasingFunction? easingFunction = null) : this(duration, TimeSpan.FromMilliseconds(10), from, to, easingFunction) { - } public override TimeSpan Duration { get; } = duration; @@ -47,4 +46,4 @@ public class DoubleValueAnimation(TimeSpan duration, public override double To { get; } = to; public override IEasingFunction? EasingFunction { get; } = easingFunction; -} \ No newline at end of file +}