diff --git a/EhTagClient/EhTagClient.csproj b/EhTagClient/EhTagClient.csproj index 44a4f348..0020e9c9 100644 --- a/EhTagClient/EhTagClient.csproj +++ b/EhTagClient/EhTagClient.csproj @@ -111,10 +111,10 @@ - 3.1.30 + 3.1.32 - 3.1.30 + 3.1.32 runtime; build; native; contentfiles; analyzers all diff --git a/EhTagTranslatorClient/EhTagTranslatorClient.csproj b/EhTagTranslatorClient/EhTagTranslatorClient.csproj index 2260c1ca..3e6e5f07 100644 --- a/EhTagTranslatorClient/EhTagTranslatorClient.csproj +++ b/EhTagTranslatorClient/EhTagTranslatorClient.csproj @@ -111,10 +111,10 @@ - 3.1.30 + 3.1.32 - 3.1.30 + 3.1.32 runtime; build; native; contentfiles; analyzers all diff --git a/EhWikiClient/EhWikiClient.csproj b/EhWikiClient/EhWikiClient.csproj index 3f58a92c..c1126749 100644 --- a/EhWikiClient/EhWikiClient.csproj +++ b/EhWikiClient/EhWikiClient.csproj @@ -114,10 +114,10 @@ - 3.1.30 + 3.1.32 - 3.1.30 + 3.1.32 runtime; build; native; contentfiles; analyzers all @@ -125,7 +125,7 @@ 6.2.14 - 13.0.1 + 13.0.3 1.3.19 diff --git a/ExClient/ExClient.csproj b/ExClient/ExClient.csproj index 37af45da..8c0705fa 100644 --- a/ExClient/ExClient.csproj +++ b/ExClient/ExClient.csproj @@ -251,13 +251,13 @@ - 1.11.46 + 1.11.70 - 3.1.30 + 3.1.32 - 3.1.30 + 3.1.32 runtime; build; native; contentfiles; analyzers all @@ -265,7 +265,7 @@ 6.2.14 - 13.0.1 + 13.0.3 1.3.19 diff --git a/ExClient/Settings/SettingCollection.cs b/ExClient/Settings/SettingCollection.cs index 0946daf2..0b5fb1e1 100644 --- a/ExClient/Settings/SettingCollection.cs +++ b/ExClient/Settings/SettingCollection.cs @@ -12,10 +12,8 @@ using System.Threading; using System.Threading.Tasks; -namespace ExClient.Settings -{ - public enum ImageSize - { +namespace ExClient.Settings { + public enum ImageSize { Auto = 0, H780 = 1, H980 = 2, @@ -24,31 +22,26 @@ public enum ImageSize H2400 = 5, } - public enum CommentsOrder - { + public enum CommentsOrder { ByTimeAscending = 0, ByTimeDecending = 1, ByScore = 2, } - public enum FavoritesOrder - { + public enum FavoritesOrder { ByLastUpdatedTime = 0, ByFavoritedTime = 1, } - public sealed class SettingCollection : ObservableObject - { + public sealed class SettingCollection : ObservableObject { private static readonly Uri configUriRaletive = new Uri("/uconfig.php", UriKind.Relative); private readonly Uri configUri; private readonly DomainProvider owner; - internal SettingCollection(DomainProvider domain) - { + internal SettingCollection(DomainProvider domain) { owner = domain; configUri = new Uri(domain.RootUri, configUriRaletive); - foreach (var item in items.Values) - { + foreach (var item in items.Values) { item.Owner = this; } loadCache(); @@ -61,124 +54,111 @@ internal SettingCollection(DomainProvider domain) private const string CACHE_NAME = "SettingsCache"; - internal void StoreCache() - { + internal void StoreCache() { var storage = Windows.Storage.ApplicationData.Current.LocalSettings.CreateContainer("ExClient", Windows.Storage.ApplicationDataCreateDisposition.Always); storage.Values[owner.Type + CACHE_NAME] = JsonConvert.SerializeObject(_Settings); } - private void loadCache() - { + private void loadCache() { var storage = Windows.Storage.ApplicationData.Current.LocalSettings.CreateContainer("ExClient", Windows.Storage.ApplicationDataCreateDisposition.Always); storage.Values.TryGetValue(owner.Type + CACHE_NAME, out var r); var value = r + ""; _Settings.Clear(); - if (string.IsNullOrEmpty(value)) - { + if (string.IsNullOrEmpty(value)) { return; } JsonConvert.PopulateObject(value, _Settings); } - private void updateSettingsDic(HtmlDocument doc) - { + private void updateSettingsDic(HtmlDocument doc) { + // Ill formed HTML, can not get inner form var outer = doc.GetElementbyId("outer"); if (outer is null) return; _Settings.Clear(); - foreach (var item in outer.Descendants("input").Concat(outer.Descendants("textarea"))) - { + foreach (var item in outer.Descendants("select")) { var name = item.GetAttribute("name", default(string)); - if (name is null || name.StartsWith("profile")) - { + if (name is null || name.StartsWith("profile_")) continue; + + var selected = item.SelectSingleNode("./option[@selected]"); + if (selected is not null) { + _Settings[name] = selected.GetAttribute("value", ""); } + } + foreach (var item in outer.Descendants("input").Concat(outer.Descendants("textarea"))) { + var name = item.GetAttribute("name", default(string)); + if (name is null || name.StartsWith("profile_")) + continue; - switch (item.GetAttribute("type", default(string))) - { - case "radio": - if (item.GetAttribute("checked", "") == "checked") - { - _Settings[name] = item.GetAttribute("value", ""); - } + switch (item.GetAttribute("type", default(string))) { + case "radio": + if (item.GetAttribute("checked", "") == "checked") { + _Settings[name] = item.GetAttribute("value", "on"); + } - break; - case "checkbox": - if (item.GetAttribute("checked", "") == "checked") - { - _Settings[name] = item.GetAttribute("value", "on"); - } + break; + case "checkbox": + if (item.GetAttribute("checked", "") == "checked") { + _Settings[name] = item.GetAttribute("value", "on"); + } - break; - //case "text": - //case "hidden": - //case "submit": - //textarea - default: - _Settings[name] = item.GetAttribute("value", item.GetInnerText()); - break; + break; + //case "text": + //case "hidden": + //case "submit": + //textarea + default: + _Settings[name] = item.GetAttribute("value", item.GetInnerText()); + break; } } } - public async Task FetchAsync(CancellationToken token = default) - { + public async Task FetchAsync(CancellationToken token = default) { Client.Current.CheckLogOn(); - try - { + try { var getDoc = Client.Current.HttpClient.GetDocumentAsync(configUri); token.Register(getDoc.Cancel); var doc = await getDoc; updateSettingsDic(doc); - } - finally - { + } finally { _LoadSettingsDic(); } } - private void _LoadSettingsDic() - { - foreach (var item in items.Values) - { + private void _LoadSettingsDic() { + foreach (var item in items.Values) { item.DataChanged(_Settings); } StoreCache(); OnPropertyReset(); } - public async Task SendAsync(CancellationToken token = default) - { - try - { + public async Task SendAsync(CancellationToken token = default) { + try { if (_Settings.Count == 0) await FetchAsync(); var postDic = new Dictionary(_Settings); - foreach (var item in items.Values) - { + foreach (var item in items.Values) { item.ApplyChanges(postDic); } var isSame = true; - if (postDic.Count == _Settings.Count) - { - foreach (var item in postDic) - { + if (postDic.Count == _Settings.Count) { + foreach (var item in postDic) { if (_Settings.TryGetValue(item.Key, out var ov) && ov == item.Value) continue; - else - { + else { isSame = false; break; } } - } - else + } else isSame = false; - if (!isSame) - { + if (!isSame) { var postData = Client.Current.HttpClient.PostAsync(configUri, postDic); token.Register(postData.Cancel); var r = await postData; @@ -186,15 +166,12 @@ public async Task SendAsync(CancellationToken token = default) doc.LoadHtml(await r.Content.ReadAsStringAsync()); updateSettingsDic(doc); } - } - finally - { + } finally { _LoadSettingsDic(); } } - private readonly Dictionary items = new Dictionary - { + private readonly Dictionary items = new Dictionary { ["Default"] = new DefaultSettingProvider(), [nameof(ExcludedLanguages)] = new ExcludedLanguagesSettingProvider(), [nameof(ExcludedUploaders)] = new ExcludedUploadersSettingProvider(), @@ -202,68 +179,55 @@ public async Task SendAsync(CancellationToken token = default) [nameof(FavoriteCategoryNames)] = new FavoriteCategoryNamesSettingProvider(), }; - private SettingProvider _GetProvider([System.Runtime.CompilerServices.CallerMemberName] string key = null) - { + private SettingProvider _GetProvider([System.Runtime.CompilerServices.CallerMemberName] string key = null) { return items[key]; } public ExcludedLanguagesSettingProvider ExcludedLanguages => (ExcludedLanguagesSettingProvider)_GetProvider(); public ExcludedUploadersSettingProvider ExcludedUploaders => (ExcludedUploadersSettingProvider)_GetProvider(); - public Tagging.Namespace ExcludedTagNamespaces - { + public Tagging.Namespace ExcludedTagNamespaces { get => ((ExcludedTagNamespacesSettingProvider)_GetProvider()).Value; - set - { + set { ((ExcludedTagNamespacesSettingProvider)_GetProvider()).Value = value; OnPropertyChanged(); } } - public ImageSize ResampledImageSize - { + public ImageSize ResampledImageSize { get => ((DefaultSettingProvider)_GetProvider("Default")).ResampledImageSize; - set - { + set { ((DefaultSettingProvider)_GetProvider("Default")).ResampledImageSize = value; OnPropertyChanged(); } } - public CommentsOrder CommentsOrder - { + public CommentsOrder CommentsOrder { get => ((DefaultSettingProvider)_GetProvider("Default")).CommentsOrder; - set - { + set { ((DefaultSettingProvider)_GetProvider("Default")).CommentsOrder = value; OnPropertyChanged(); } } - public FavoritesOrder FavoritesOrder - { + public FavoritesOrder FavoritesOrder { get => ((DefaultSettingProvider)_GetProvider("Default")).FavoritesOrder; - set - { + set { ((DefaultSettingProvider)_GetProvider("Default")).FavoritesOrder = value; OnPropertyChanged(); } } - public int TagFilteringThreshold - { + public int TagFilteringThreshold { get => ((DefaultSettingProvider)_GetProvider("Default")).TagFilteringThreshold; - set - { + set { ((DefaultSettingProvider)_GetProvider("Default")).TagFilteringThreshold = value; OnPropertyChanged(); } } - public int TagWatchingThreshold - { + public int TagWatchingThreshold { get => ((DefaultSettingProvider)_GetProvider("Default")).TagWatchingThreshold; - set - { + set { ((DefaultSettingProvider)_GetProvider("Default")).TagWatchingThreshold = value; OnPropertyChanged(); } @@ -271,10 +235,8 @@ public int TagWatchingThreshold public FavoriteCategoryNamesSettingProvider FavoriteCategoryNames => (FavoriteCategoryNamesSettingProvider)_GetProvider(); - private sealed class DefaultSettingProvider : SettingProvider - { - internal override void ApplyChanges(Dictionary settings) - { + private sealed class DefaultSettingProvider : SettingProvider { + internal override void ApplyChanges(Dictionary settings) { // Original Images - Nope (Use local setting instead) settings["oi"] = "0"; // Always use the Multi-Page Viewer - Nope @@ -290,11 +252,9 @@ internal override void ApplyChanges(Dictionary settings) settings["ft"] = _Ft.ToString(); } - internal override void DataChanged(Dictionary settings) - { + internal override void DataChanged(Dictionary settings) { void setEnum(ref T field, string key, T def) - where T : struct, Enum - { + where T : struct, Enum { if (!settings.TryGetValue(key, out var value) || !Enum.TryParse(value, true, out field)) field = def; @@ -303,8 +263,7 @@ void setEnum(ref T field, string key, T def) setEnum(ref CommentsOrder, "cs", CommentsOrder.ByTimeAscending); setEnum(ref FavoritesOrder, "fs", FavoritesOrder.ByLastUpdatedTime); - void setInt(ref int field, string key, int def) - { + void setInt(ref int field, string key, int def) { if (!settings.TryGetValue(key, out var value) || !int.TryParse(value, out field)) field = def; @@ -312,8 +271,7 @@ void setInt(ref int field, string key, int def) setInt(ref _Ft, "ft", 0); setInt(ref _Wt, "wt", 0); } - private static int _Clamp(int value, int v1, int v2) - { + private static int _Clamp(int value, int v1, int v2) { if (value < v1) return v1; if (value > v2) @@ -328,14 +286,12 @@ private static int _Clamp(int value, int v1, int v2) public FavoritesOrder FavoritesOrder; private int _Ft, _Wt; - public int TagFilteringThreshold - { + public int TagFilteringThreshold { get => _Ft; set => _Ft = _Clamp(value, -9999, 0); } - public int TagWatchingThreshold - { + public int TagWatchingThreshold { get => _Wt; set => _Wt = _Clamp(value, 0, 9999); } diff --git a/ExViewer/ExViewer.csproj b/ExViewer/ExViewer.csproj index c6298bdb..8c5365a7 100644 --- a/ExViewer/ExViewer.csproj +++ b/ExViewer/ExViewer.csproj @@ -735,7 +735,7 @@ - 1.11.46 + 1.11.70 4.5.3 @@ -744,10 +744,10 @@ 4.5.3 - 3.1.30 + 3.1.32 - 3.1.30 + 3.1.32 runtime; build; native; contentfiles; analyzers all @@ -758,7 +758,7 @@ 4.0.0 - 2.8.1 + 2.8.6 1.3.19 @@ -779,7 +779,7 @@ 4.5.0 - 0.16.8 + 0.16.9