public string Token { get; set; } = "";\r
}\r
\r
+ public class PushbulletConfig\r
+ {\r
+ public bool On { get; set; }\r
+ public string Token { get; set; } = "";\r
+ }\r
+\r
public class SoundConfig\r
{\r
public int Volume { get; set; } = 100;\r
FlashWindow = 1,\r
ShowBaloonTip = 1 << 1,\r
PlaySound = 1 << 2,\r
- All = (1 << 3) - 1\r
+ Pushbullet = 1 << 3,\r
+ All = (1 << 3) - 1 // Pushbullet以外\r
}\r
\r
public class NotificationConfig\r
public ShipListConfig ShipList { get; set; } = new ShipListConfig();\r
public LogConfig Log { get; set; } = new LogConfig();\r
public KancolleDbConfig KancolleDb { get; set; } = new KancolleDbConfig();\r
+ public PushbulletConfig Pushbullet { get; set; } = new PushbulletConfig();\r
\r
public static readonly string[] NotificationNames =\r
{\r
this.label11 = new System.Windows.Forms.Label();\r
this.buttonOutputDir = new System.Windows.Forms.Button();\r
this.tabPageCollabo = new System.Windows.Forms.TabPage();\r
+ this.groupBoxPushbullet = new System.Windows.Forms.GroupBox();\r
+ this.buttonPushbulletTest = new System.Windows.Forms.Button();\r
+ this.textBoxPushbulletToken = new System.Windows.Forms.TextBox();\r
+ this.label7 = new System.Windows.Forms.Label();\r
+ this.checkBoxPushbulletOn = new System.Windows.Forms.CheckBox();\r
this.groupBoxKancolleDb = new System.Windows.Forms.GroupBox();\r
this.textBoxKancolleDbToken = new System.Windows.Forms.TextBox();\r
this.label8 = new System.Windows.Forms.Label();\r
this.tabPageLog.SuspendLayout();\r
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaterialLogInterval)).BeginInit();\r
this.tabPageCollabo.SuspendLayout();\r
+ this.groupBoxPushbullet.SuspendLayout();\r
this.groupBoxKancolleDb.SuspendLayout();\r
this.tabPageDebug.SuspendLayout();\r
this.SuspendLayout();\r
// \r
// tabPageCollabo\r
// \r
+ this.tabPageCollabo.Controls.Add(this.groupBoxPushbullet);\r
this.tabPageCollabo.Controls.Add(this.groupBoxKancolleDb);\r
this.tabPageCollabo.Location = new System.Drawing.Point(4, 40);\r
this.tabPageCollabo.Name = "tabPageCollabo";\r
this.tabPageCollabo.Text = "連携";\r
this.tabPageCollabo.UseVisualStyleBackColor = true;\r
// \r
+ // groupBoxPushbullet\r
+ // \r
+ this.groupBoxPushbullet.Controls.Add(this.buttonPushbulletTest);\r
+ this.groupBoxPushbullet.Controls.Add(this.textBoxPushbulletToken);\r
+ this.groupBoxPushbullet.Controls.Add(this.label7);\r
+ this.groupBoxPushbullet.Controls.Add(this.checkBoxPushbulletOn);\r
+ this.groupBoxPushbullet.Location = new System.Drawing.Point(11, 66);\r
+ this.groupBoxPushbullet.Name = "groupBoxPushbullet";\r
+ this.groupBoxPushbullet.Size = new System.Drawing.Size(234, 48);\r
+ this.groupBoxPushbullet.TabIndex = 1;\r
+ this.groupBoxPushbullet.TabStop = false;\r
+ this.groupBoxPushbullet.Text = "Pushbullet";\r
+ // \r
+ // buttonPushbulletTest\r
+ // \r
+ this.buttonPushbulletTest.Font = new System.Drawing.Font("MS ゴシック", 9F);\r
+ this.buttonPushbulletTest.Location = new System.Drawing.Point(191, 16);\r
+ this.buttonPushbulletTest.Name = "buttonPushbulletTest";\r
+ this.buttonPushbulletTest.Size = new System.Drawing.Size(37, 23);\r
+ this.buttonPushbulletTest.TabIndex = 3;\r
+ this.buttonPushbulletTest.Text = "Test";\r
+ this.buttonPushbulletTest.UseVisualStyleBackColor = true;\r
+ this.buttonPushbulletTest.Click += new System.EventHandler(this.buttonPushbulletTest_Click);\r
+ // \r
+ // textBoxPushbulletToken\r
+ // \r
+ this.textBoxPushbulletToken.Location = new System.Drawing.Point(99, 18);\r
+ this.textBoxPushbulletToken.Name = "textBoxPushbulletToken";\r
+ this.textBoxPushbulletToken.Size = new System.Drawing.Size(89, 19);\r
+ this.textBoxPushbulletToken.TabIndex = 2;\r
+ // \r
+ // label7\r
+ // \r
+ this.label7.AutoSize = true;\r
+ this.label7.Location = new System.Drawing.Point(57, 21);\r
+ this.label7.Name = "label7";\r
+ this.label7.Size = new System.Drawing.Size(42, 12);\r
+ this.label7.TabIndex = 1;\r
+ this.label7.Text = "トークン:";\r
+ // \r
+ // checkBoxPushbulletOn\r
+ // \r
+ this.checkBoxPushbulletOn.AutoSize = true;\r
+ this.checkBoxPushbulletOn.Location = new System.Drawing.Point(6, 20);\r
+ this.checkBoxPushbulletOn.Name = "checkBoxPushbulletOn";\r
+ this.checkBoxPushbulletOn.Size = new System.Drawing.Size(48, 16);\r
+ this.checkBoxPushbulletOn.TabIndex = 0;\r
+ this.checkBoxPushbulletOn.Text = "有効";\r
+ this.checkBoxPushbulletOn.UseVisualStyleBackColor = true;\r
+ // \r
// groupBoxKancolleDb\r
// \r
this.groupBoxKancolleDb.Controls.Add(this.textBoxKancolleDbToken);\r
// \r
// textBoxKancolleDbToken\r
// \r
- this.textBoxKancolleDbToken.Location = new System.Drawing.Point(135, 18);\r
+ this.textBoxKancolleDbToken.Location = new System.Drawing.Point(121, 18);\r
this.textBoxKancolleDbToken.Name = "textBoxKancolleDbToken";\r
- this.textBoxKancolleDbToken.Size = new System.Drawing.Size(93, 19);\r
+ this.textBoxKancolleDbToken.Size = new System.Drawing.Size(107, 19);\r
this.textBoxKancolleDbToken.TabIndex = 2;\r
// \r
// label8\r
// \r
this.label8.AutoSize = true;\r
- this.label8.Location = new System.Drawing.Point(73, 21);\r
+ this.label8.Location = new System.Drawing.Point(57, 21);\r
this.label8.Name = "label8";\r
this.label8.Size = new System.Drawing.Size(63, 12);\r
this.label8.TabIndex = 1;\r
this.checkBoxKancolleDbOn.AutoSize = true;\r
this.checkBoxKancolleDbOn.Location = new System.Drawing.Point(6, 20);\r
this.checkBoxKancolleDbOn.Name = "checkBoxKancolleDbOn";\r
- this.checkBoxKancolleDbOn.Size = new System.Drawing.Size(67, 16);\r
+ this.checkBoxKancolleDbOn.Size = new System.Drawing.Size(48, 16);\r
this.checkBoxKancolleDbOn.TabIndex = 0;\r
- this.checkBoxKancolleDbOn.Text = "送信する";\r
+ this.checkBoxKancolleDbOn.Text = "有効";\r
this.checkBoxKancolleDbOn.UseVisualStyleBackColor = true;\r
// \r
// tabPageDebug\r
this.tabPageLog.PerformLayout();\r
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaterialLogInterval)).EndInit();\r
this.tabPageCollabo.ResumeLayout(false);\r
+ this.groupBoxPushbullet.ResumeLayout(false);\r
+ this.groupBoxPushbullet.PerformLayout();\r
this.groupBoxKancolleDb.ResumeLayout(false);\r
this.groupBoxKancolleDb.PerformLayout();\r
this.tabPageDebug.ResumeLayout(false);\r
private System.Windows.Forms.Label label14;\r
private System.Windows.Forms.Label label15;\r
private System.Windows.Forms.Button buttonDetailedSettings;\r
+ private System.Windows.Forms.GroupBox groupBoxPushbullet;\r
+ private System.Windows.Forms.TextBox textBoxPushbulletToken;\r
+ private System.Windows.Forms.Label label7;\r
+ private System.Windows.Forms.CheckBox checkBoxPushbulletOn;\r
+ private System.Windows.Forms.Button buttonPushbulletTest;\r
}\r
}
\ No newline at end of file
LoadProxySettings();\r
LoadLogSettings();\r
LoadDebugSettings();\r
+\r
checkBoxKancolleDbOn.Checked = _config.KancolleDb.On;\r
textBoxKancolleDbToken.Text = _config.KancolleDb.Token;\r
+ checkBoxPushbulletOn.Checked = _config.Pushbullet.On;\r
+ textBoxPushbulletToken.Text = _config.Pushbullet.Token;\r
}\r
\r
private void LoadProxySettings()\r
DialogResult = DialogResult.None;\r
ApplyLogSettings();\r
ApplyDebugSettings();\r
+\r
_config.KancolleDb.On = checkBoxKancolleDbOn.Checked;\r
_config.KancolleDb.Token = textBoxKancolleDbToken.Text;\r
+ _config.Pushbullet.On = checkBoxPushbulletOn.Checked;\r
+ _config.Pushbullet.Token = textBoxPushbulletToken.Text;\r
\r
_config.TopMost = checkBoxTopMost.Checked;\r
_config.HideOnMinimized = checkBoxHideOnMinimized.Checked;\r
{\r
_prevPosition = Location;\r
}\r
+\r
+ private void buttonPushbulletTest_Click(object sender, EventArgs e)\r
+ {\r
+ try\r
+ {\r
+ PushBullet.PushNote(textBoxPushbulletToken.Text, "KancolleSniffer", "うまくいったかな?");\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ MessageBox.Show(this, ex.Message, "Pushbulletエラー", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ }\r
+ }\r
}\r
}
\ No newline at end of file
<DependentUpon>NotificationConfigDialog.cs</DependentUpon>\r
</Compile>\r
<Compile Include="PresetDeck.cs" />\r
+ <Compile Include="PushBullet.cs" />\r
<Compile Include="RepairListForMain.cs">\r
<SubType>Component</SubType>\r
</Compile>\r
}\r
}\r
\r
- private void Ring(string baloonTitle, string baloonMessage, string name)\r
+ private void Ring(string balloonTitle, string balloonMessage, string name)\r
{\r
if (_config.FlashWindow && (_config.Notifications[name] & NotificationType.FlashWindow) != 0)\r
Win32API.FlashWindow(Handle);\r
if (_config.ShowBaloonTip && (_config.Notifications[name] & NotificationType.ShowBaloonTip) != 0)\r
- notifyIconMain.ShowBalloonTip(20000, baloonTitle, baloonMessage, ToolTipIcon.Info);\r
+ notifyIconMain.ShowBalloonTip(20000, balloonTitle, balloonMessage, ToolTipIcon.Info);\r
if (_config.PlaySound && (_config.Notifications[name] & NotificationType.PlaySound) != 0)\r
PlaySound(_config.Sounds[name], _config.Sounds.Volume);\r
+ if (_config.Pushbullet.On && (_config.Notifications[name] & NotificationType.Pushbullet) != 0)\r
+ {\r
+ Task.Run(() =>\r
+ {\r
+ PushBullet.PushNote(_config.Pushbullet.Token, balloonTitle, balloonMessage);\r
+ });\r
+ }\r
}\r
\r
[DllImport("winmm.dll")]\r
this.checkBoxShowBaloonTip = new System.Windows.Forms.CheckBox();\r
this.checkBoxPlaySound = new System.Windows.Forms.CheckBox();\r
this.buttonClose = new System.Windows.Forms.Button();\r
+ this.checkBoxPushbullet = new System.Windows.Forms.CheckBox();\r
this.SuspendLayout();\r
// \r
// listBoxNotifications\r
// buttonClose\r
// \r
this.buttonClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;\r
- this.buttonClose.Location = new System.Drawing.Point(141, 134);\r
+ this.buttonClose.Location = new System.Drawing.Point(141, 148);\r
this.buttonClose.Name = "buttonClose";\r
this.buttonClose.Size = new System.Drawing.Size(75, 23);\r
this.buttonClose.TabIndex = 6;\r
this.buttonClose.Text = "閉じる";\r
this.buttonClose.UseVisualStyleBackColor = true;\r
// \r
+ // checkBoxPushbullet\r
+ // \r
+ this.checkBoxPushbullet.AutoSize = true;\r
+ this.checkBoxPushbullet.Location = new System.Drawing.Point(12, 128);\r
+ this.checkBoxPushbullet.Name = "checkBoxPushbullet";\r
+ this.checkBoxPushbullet.Size = new System.Drawing.Size(77, 16);\r
+ this.checkBoxPushbullet.TabIndex = 7;\r
+ this.checkBoxPushbullet.Text = "Pushbullet";\r
+ this.checkBoxPushbullet.UseVisualStyleBackColor = true;\r
+ this.checkBoxPushbullet.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);\r
+ // \r
// NotificationConfigDialog\r
// \r
this.AcceptButton = this.buttonClose;\r
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);\r
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
this.CancelButton = this.buttonClose;\r
- this.ClientSize = new System.Drawing.Size(228, 166);\r
+ this.ClientSize = new System.Drawing.Size(228, 183);\r
+ this.Controls.Add(this.checkBoxPushbullet);\r
this.Controls.Add(this.buttonClose);\r
this.Controls.Add(this.checkBoxPlaySound);\r
this.Controls.Add(this.checkBoxShowBaloonTip);\r
private System.Windows.Forms.CheckBox checkBoxShowBaloonTip;\r
private System.Windows.Forms.CheckBox checkBoxPlaySound;\r
private System.Windows.Forms.Button buttonClose;\r
+ private System.Windows.Forms.CheckBox checkBoxPushbullet;\r
}\r
}
\ No newline at end of file
checkBoxFlashWindow.Tag = NotificationType.FlashWindow;\r
checkBoxShowBaloonTip.Tag = NotificationType.ShowBaloonTip;\r
checkBoxPlaySound.Tag = NotificationType.PlaySound;\r
+ checkBoxPushbullet.Tag = NotificationType.Pushbullet;\r
\r
// ReSharper disable once CoVariantArrayConversion\r
listBoxNotifications.Items.AddRange(Config.NotificationNames);\r
checkBoxFlashWindow.Checked = (notification & NotificationType.FlashWindow) != 0;\r
checkBoxShowBaloonTip.Checked = (notification & NotificationType.ShowBaloonTip) != 0;\r
checkBoxPlaySound.Checked = (notification & NotificationType.PlaySound) != 0;\r
+ checkBoxPushbullet.Checked = (notification & NotificationType.Pushbullet) != 0;\r
}\r
\r
private void checkBox_CheckedChanged(object sender, EventArgs e)\r
--- /dev/null
+// Copyright (C) 2017 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
+// \r
+// Licensed under the Apache License, Version 2.0 (the "License");\r
+// you may not use this file except in compliance with the License.\r
+// You may obtain a copy of the License at\r
+//\r
+// http://www.apache.org/licenses/LICENSE-2.0\r
+//\r
+// Unless required by applicable law or agreed to in writing, software\r
+// distributed under the License is distributed on an "AS IS" BASIS,\r
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+// See the License for the specific language governing permissions and\r
+// limitations under the License.\r
+\r
+using System.Net;\r
+using System.Text;\r
+\r
+namespace KancolleSniffer\r
+{\r
+ public class PushBullet\r
+ {\r
+ public static void PushNote(string token, string title, string body)\r
+ {\r
+ using (var wc = new WebClient())\r
+ {\r
+ wc.Headers[HttpRequestHeader.ContentType] = "application/json";\r
+ wc.Credentials = new NetworkCredential(token, "");\r
+ wc.Encoding = Encoding.UTF8;\r
+ wc.UploadString("https://api.pushbullet.com/v2/pushes",\r
+ $"{{ \"type\": \"note\", \"title\": \"{title}\", \"body\": \"{body}\" }}");\r
+ }\r
+ }\r
+ }\r
+}
\ No newline at end of file