From 48446af6027ab947b222fdf709748cc3fae36c2c Mon Sep 17 00:00:00 2001 From: TM0D <37343661+Saeraphinx@users.noreply.github.com> Date: Sun, 23 Jan 2022 10:52:01 -0600 Subject: [PATCH] add in directory saving and also attempt to fix http not working --- NyaDesktop/App.config | 2 +- NyaDesktop/Form1.cs | 6 ++++ NyaDesktop/NyaAPI.cs | 2 +- NyaDesktop/NyaDesktop.csproj | 11 +++++++ NyaDesktop/Properties/Settings.Designer.cs | 38 ++++++++++++++++++++++ NyaDesktop/Properties/Settings.settings | 9 +++++ NyaDesktop/packages.config | 2 +- 7 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 NyaDesktop/Properties/Settings.Designer.cs create mode 100644 NyaDesktop/Properties/Settings.settings diff --git a/NyaDesktop/App.config b/NyaDesktop/App.config index 40df807..0c19d69 100644 --- a/NyaDesktop/App.config +++ b/NyaDesktop/App.config @@ -10,7 +10,7 @@ - + diff --git a/NyaDesktop/Form1.cs b/NyaDesktop/Form1.cs index 60f5257..09b5a10 100644 --- a/NyaDesktop/Form1.cs +++ b/NyaDesktop/Form1.cs @@ -28,6 +28,10 @@ public Form1(DiscordRpcClient client) DiscordClient = client; DiscordClient.Initialize(); updatePrecense(); + if (Properties.Settings.Default.path != "") + { + save_path = Properties.Settings.Default.path; + } } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) @@ -67,6 +71,8 @@ private void button1_Click(object sender, EventArgs e) { save_path = folderBrowserDialog1.SelectedPath; button2.Enabled = true; + Properties.Settings.Default.path = save_path; + Properties.Settings.Default.Save(); } } diff --git a/NyaDesktop/NyaAPI.cs b/NyaDesktop/NyaAPI.cs index 697395e..1f230df 100644 --- a/NyaDesktop/NyaAPI.cs +++ b/NyaDesktop/NyaAPI.cs @@ -9,7 +9,7 @@ namespace NyaDesktop { class NyaAPI { - private static readonly HttpClient client = new HttpClient(); + private static readonly System.Net.Http.HttpClient client = new HttpClient(); // HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks. public static async Task PullNyaImageURL(string type, string endpoint) diff --git a/NyaDesktop/NyaDesktop.csproj b/NyaDesktop/NyaDesktop.csproj index 5eb694e..24b919c 100644 --- a/NyaDesktop/NyaDesktop.csproj +++ b/NyaDesktop/NyaDesktop.csproj @@ -153,12 +153,14 @@ ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + ..\packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll True True True + ..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll True @@ -245,6 +247,11 @@ + + True + True + Settings.settings + Form1.cs @@ -264,6 +271,10 @@ + + SettingsSingleFileGenerator + Settings.Designer.cs + diff --git a/NyaDesktop/Properties/Settings.Designer.cs b/NyaDesktop/Properties/Settings.Designer.cs new file mode 100644 index 0000000..ec18075 --- /dev/null +++ b/NyaDesktop/Properties/Settings.Designer.cs @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace NyaDesktop.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string path { + get { + return ((string)(this["path"])); + } + set { + this["path"] = value; + } + } + } +} diff --git a/NyaDesktop/Properties/Settings.settings b/NyaDesktop/Properties/Settings.settings new file mode 100644 index 0000000..407e398 --- /dev/null +++ b/NyaDesktop/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/NyaDesktop/packages.config b/NyaDesktop/packages.config index b39186b..3865a87 100644 --- a/NyaDesktop/packages.config +++ b/NyaDesktop/packages.config @@ -3,7 +3,7 @@ - +