diff --git a/MisskeyLiveCommentViewer/App.config b/MisskeyLiveCommentViewer/App.config index 0630019..35c3c08 100644 --- a/MisskeyLiveCommentViewer/App.config +++ b/MisskeyLiveCommentViewer/App.config @@ -1,5 +1,10 @@  + + +
+ + @@ -15,4 +20,26 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/MisskeyLiveCommentViewer/Misskey.cs b/MisskeyLiveCommentViewer/Misskey.cs index b7e4b42..3fbb380 100644 --- a/MisskeyLiveCommentViewer/Misskey.cs +++ b/MisskeyLiveCommentViewer/Misskey.cs @@ -298,6 +298,19 @@ public async Task PostNote(string Text) var response = await client.PostAsync(instanceurl + "/api/notes/create", content); } } + public void Setting(string AppSecret,string i,string token,string instanceurl,string livetag) + { + this.appSecret = AppSecret; + this.i = i; + this.token = token; + this.instanceurl = instanceurl; + this.livetag = livetag; + } + public string AppSecret { get => appSecret; } + public string I { get => i; } + public string Token { get => token; } + public string Instanceurl { get => instanceurl; } + public string Livetag { get => livetag; } } public class MisskeyConnectObj { diff --git a/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.Designer.cs b/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.Designer.cs index 944bcde..c38608b 100644 --- a/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.Designer.cs +++ b/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.Designer.cs @@ -236,7 +236,7 @@ private void InitializeComponent() this.SendTextBox.Name = "SendTextBox"; this.SendTextBox.Size = new System.Drawing.Size(620, 19); this.SendTextBox.TabIndex = 13; - this.SendTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.SendTextBox_KeyUp); + this.SendTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SendTextBox_KeyDown); // // MisskeyLiveCommentViewer // @@ -262,6 +262,8 @@ private void InitializeComponent() this.Controls.Add(this.listView1); this.Name = "MisskeyLiveCommentViewer"; this.Text = "MisskeyCommentViewer"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MisskeyLiveCommentViewer_FormClosing); + this.Load += new System.EventHandler(this.MisskeyLiveCommentViewer_Load); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); this.ResumeLayout(false); diff --git a/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.cs b/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.cs index 0286c14..a1f04da 100644 --- a/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.cs +++ b/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; @@ -399,10 +399,41 @@ private async void SendButton_Click(object sender, EventArgs e) } } - private async void SendTextBox_KeyUp(object sender, KeyEventArgs e) + private async void MisskeyLiveCommentViewer_Load(object sender, EventArgs e) { - if(e.KeyCode == Keys.Enter&&!LoginButton.Enabled) + misskey.Setting(Properties.Settings.Default.appSecret, + Properties.Settings.Default.i, + Properties.Settings.Default.token, + Properties.Settings.Default.instanceurl, + Properties.Settings.Default.livetag); + MisskeyID.Text = Properties.Settings.Default.livetag; + if (misskey.I == String.Empty) return; + if (await misskey.CheckToken(misskey.I)) { + LoginButton.Enabled = false; + SendTextBox.Enabled = true; + SendButton.Enabled = true; + ConnectButton_Click(sender, e); + } + } + + private void MisskeyLiveCommentViewer_FormClosing(object sender, FormClosingEventArgs e) + { + Properties.Settings.Default.i = misskey.I; + Properties.Settings.Default.appSecret = misskey.AppSecret; + Properties.Settings.Default.token = misskey.Token; + Properties.Settings.Default.instanceurl = misskey.Instanceurl; + Properties.Settings.Default.livetag = misskey.Livetag; + Properties.Settings.Default.Save(); + } + + private async void SendTextBox_KeyDown(object sender, KeyEventArgs e) + { + TextBox textBox = sender as TextBox; + System.Diagnostics.Debug.WriteLine(textBox.ImeMode); + if(textBox.Text == String.Empty) return; + if (e.KeyCode == Keys.Enter && !LoginButton.Enabled) + { SendTextBox.Enabled = false; SendButton.Enabled = false; await misskey.PostNote(SendTextBox.Text); @@ -410,7 +441,7 @@ private async void SendTextBox_KeyUp(object sender, KeyEventArgs e) SendTextBox.Enabled = true; SendButton.Enabled = true; } - } + } } public class MisskeyComment { diff --git a/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.csproj b/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.csproj index 0f45ba8..2373e7c 100644 --- a/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.csproj +++ b/MisskeyLiveCommentViewer/MisskeyLiveCommentViewer.csproj @@ -13,6 +13,7 @@ true true + false publish\ false Disk @@ -25,7 +26,6 @@ true 3 0.0.0.%2a - false false true diff --git a/MisskeyLiveCommentViewer/Properties/Settings.Designer.cs b/MisskeyLiveCommentViewer/Properties/Settings.Designer.cs index 8d65786..05047fe 100644 --- a/MisskeyLiveCommentViewer/Properties/Settings.Designer.cs +++ b/MisskeyLiveCommentViewer/Properties/Settings.Designer.cs @@ -22,5 +22,77 @@ public static Settings Default { return defaultInstance; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string i { + get { + return ((string)(this["i"])); + } + set { + this["i"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string server { + get { + return ((string)(this["server"])); + } + set { + this["server"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string appSecret { + get { + return ((string)(this["appSecret"])); + } + set { + this["appSecret"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string livetag { + get { + return ((string)(this["livetag"])); + } + set { + this["livetag"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string token { + get { + return ((string)(this["token"])); + } + set { + this["token"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string instanceurl { + get { + return ((string)(this["instanceurl"])); + } + set { + this["instanceurl"] = value; + } + } } } diff --git a/MisskeyLiveCommentViewer/Properties/Settings.settings b/MisskeyLiveCommentViewer/Properties/Settings.settings index 3964565..ddc2676 100644 --- a/MisskeyLiveCommentViewer/Properties/Settings.settings +++ b/MisskeyLiveCommentViewer/Properties/Settings.settings @@ -1,7 +1,24 @@  - - - - - - + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file