Prevent multiple instances, allow starting in tray, documentation edits and priority support #4

Merged
alexhorner merged 9 commits from master into master 2022-12-12 17:01:23 -05:00
22 changed files with 586 additions and 149 deletions

View File

@@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Publish ntfysh_client to folder" type="DotNetFolderPublish" factoryName="Publish to folder">
<riderPublish configuration="Release" delete_existing_files="true" platform="Any CPU" runtime="win-x86" target_folder="./bin/Publish/net6.0-windows" target_framework="net6.0-windows" uuid_high="6492169016564532222" uuid_low="-5168761336838336273" />
<method v="2" />
</configuration>
</component>

View File

@@ -1,7 +1,27 @@
# ntfy.sh Windows # ntfy.sh Windows
![Application screenshot](https://i.imgur.com/C9BFTCJ.png) ntfy.sh Windows is a small lightweight push notification client for notifications sent via https://ntfy.sh compatible servers.
![Notification example screenshot](https://i.imgur.com/ZmfJ8Wm.png) It is capable of receiving notifications from multiple ntfy.sh servers simultaneously via Websocket or HTTP and supports both unauthenticated and authenticated topics.
A [ntfy.sh](https://ntfy.sh/) client for Windows. ## Screenshots
### Main Application
![Application screenshot](https://user-images.githubusercontent.com/33007665/206556170-962fd699-988c-477e-941e-5179b9f4a67c.png)
![Topic Subscribe screenshot](https://user-images.githubusercontent.com/33007665/206556398-5ee95cee-6fc8-4234-b46e-6380cdfc94dd.png)
![Settings screenshot](https://user-images.githubusercontent.com/33007665/207159693-40542c12-1669-4f32-b1c6-4a8542ac1539.png)
### Example Notifications
![Default toast](https://user-images.githubusercontent.com/33007665/206558550-9903b9e3-7f6b-418d-8a46-1311708b5b3e.png)
![High priority toast](https://user-images.githubusercontent.com/33007665/206558687-92a6c6ae-2583-400b-952b-3cdb7fe38c07.png)
![Medium priority toast](https://user-images.githubusercontent.com/33007665/206559209-2f052fc2-4e8a-4ccb-b6cd-4a8066f9c8d7.png)
![image](https://user-images.githubusercontent.com/33007665/206559650-b6b961cc-c764-4d0a-bc49-84e51b23c86f.png)
## Command Line Parameters
### -h and --help
Show the help menu
### -t and --start-in-tray
Start ntfy.sh Windows in the tray, useful for starting with Windows when logging in
### -m and --allow-multiple-instances
Bypass the instance check to allow multiple instances of ntfy.sh Windows to start simultaneously

View File

@@ -29,53 +29,107 @@ namespace ntfysh_client
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutBox));
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.aboutPage = new System.Windows.Forms.TabPage();
this.richTextBox2 = new System.Windows.Forms.RichTextBox();
this.licensePage = new System.Windows.Forms.TabPage();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.tabControl1.SuspendLayout();
this.aboutPage.SuspendLayout();
this.licensePage.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// button1 // button1
// //
this.button1.Location = new System.Drawing.Point(299, 173); this.button1.Location = new System.Drawing.Point(522, 243);
this.button1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23); this.button1.Size = new System.Drawing.Size(88, 27);
this.button1.TabIndex = 0; this.button1.TabIndex = 0;
this.button1.Text = "Close"; this.button1.Text = "Close";
this.button1.UseVisualStyleBackColor = true; this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click); this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 49);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(358, 65);
this.label1.TabIndex = 1;
this.label1.Text = "Copyright © 2022 Lucas Bortoli\r\nAll rights reserved\r\n\r\nThe icons included in this" +
" application are property of Microsoft Corporation.\r\n(Visual Studio Image Librar" +
"y)";
// //
// label2 // label2
// //
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Font = new System.Drawing.Font("Segoe UI", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.label2.Location = new System.Drawing.Point(10, 9); this.label2.Location = new System.Drawing.Point(12, 9);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(166, 30); this.label2.Size = new System.Drawing.Size(166, 30);
this.label2.TabIndex = 2; this.label2.TabIndex = 2;
this.label2.Text = "ntfy.sh Windows"; this.label2.Text = "ntfy.sh Windows";
// //
// tabControl1
//
this.tabControl1.Controls.Add(this.aboutPage);
this.tabControl1.Controls.Add(this.licensePage);
this.tabControl1.Location = new System.Drawing.Point(12, 43);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(598, 194);
this.tabControl1.TabIndex = 3;
//
// aboutPage
//
this.aboutPage.Controls.Add(this.richTextBox2);
this.aboutPage.Location = new System.Drawing.Point(4, 24);
this.aboutPage.Name = "aboutPage";
this.aboutPage.Padding = new System.Windows.Forms.Padding(3);
this.aboutPage.Size = new System.Drawing.Size(590, 166);
this.aboutPage.TabIndex = 0;
this.aboutPage.Text = "About";
this.aboutPage.UseVisualStyleBackColor = true;
//
// richTextBox2
//
this.richTextBox2.BackColor = System.Drawing.SystemColors.Window;
this.richTextBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.richTextBox2.Location = new System.Drawing.Point(6, 6);
this.richTextBox2.Name = "richTextBox2";
this.richTextBox2.ReadOnly = true;
this.richTextBox2.Size = new System.Drawing.Size(578, 154);
this.richTextBox2.TabIndex = 0;
this.richTextBox2.Text = resources.GetString("richTextBox2.Text");
//
// licensePage
//
this.licensePage.Controls.Add(this.richTextBox1);
this.licensePage.Location = new System.Drawing.Point(4, 24);
this.licensePage.Name = "licensePage";
this.licensePage.Padding = new System.Windows.Forms.Padding(3);
this.licensePage.Size = new System.Drawing.Size(590, 166);
this.licensePage.TabIndex = 1;
this.licensePage.Text = "MIT License\n\n";
this.licensePage.UseVisualStyleBackColor = true;
//
// richTextBox1
//
this.richTextBox1.BackColor = System.Drawing.SystemColors.Window;
this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.richTextBox1.Location = new System.Drawing.Point(6, 6);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.ReadOnly = true;
this.richTextBox1.Size = new System.Drawing.Size(578, 154);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = resources.GetString("richTextBox1.Text");
//
// AboutBox // AboutBox
// //
this.AcceptButton = this.button1; this.AcceptButton = this.button1;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White; this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(386, 208); this.ClientSize = new System.Drawing.Size(622, 275);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1); this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "AboutBox"; this.Name = "AboutBox";
@@ -83,6 +137,9 @@ namespace ntfysh_client
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "About"; this.Text = "About";
this.tabControl1.ResumeLayout(false);
this.aboutPage.ResumeLayout(false);
this.licensePage.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -91,7 +148,11 @@ namespace ntfysh_client
#endregion #endregion
private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage aboutPage;
private System.Windows.Forms.TabPage licensePage;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.RichTextBox richTextBox2;
} }
} }

View File

@@ -1,11 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace ntfysh_client namespace ntfysh_client

View File

@@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
@@ -117,4 +57,24 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="richTextBox2.Text" xml:space="preserve">
<value>ntfy.sh Windows by Lucas Bortoli and Contributors
ntfy.sh Windows is a small lightweight push notification client for notifications sent via https://ntfy.sh compatible servers.
It is capable of receiving notifications from multiple ntfy.sh servers simultaneously via Websocket or HTTP and supports both unauthenticated and authenticated topics.
Get the latest release and keep track of updates via GitHub at https://github.com/lucas-bortoli/ntfysh-windows</value>
</data>
<data name="richTextBox1.Text" xml:space="preserve">
<value>Copyright © 2022 Lucas Bortoli
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The icons included in this application are property of Microsoft Corporation (Visual Studio Image Library)</value>
</data>
</root> </root>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@@ -46,6 +46,7 @@ namespace ntfysh_client
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.trayContextMenu.SuspendLayout(); this.trayContextMenu.SuspendLayout();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@@ -138,7 +139,8 @@ namespace ntfysh_client
// fileToolStripMenuItem // fileToolStripMenuItem
// //
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.exitToolStripMenuItem1}); this.exitToolStripMenuItem1,
this.settingsToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "File"; this.fileToolStripMenuItem.Text = "File";
@@ -147,7 +149,7 @@ namespace ntfysh_client
// //
this.exitToolStripMenuItem1.Image = ((System.Drawing.Image)(resources.GetObject("exitToolStripMenuItem1.Image"))); this.exitToolStripMenuItem1.Image = ((System.Drawing.Image)(resources.GetObject("exitToolStripMenuItem1.Image")));
this.exitToolStripMenuItem1.Name = "exitToolStripMenuItem1"; this.exitToolStripMenuItem1.Name = "exitToolStripMenuItem1";
this.exitToolStripMenuItem1.Size = new System.Drawing.Size(93, 22); this.exitToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
this.exitToolStripMenuItem1.Text = "Exit"; this.exitToolStripMenuItem1.Text = "Exit";
this.exitToolStripMenuItem1.Click += new System.EventHandler(this.exitToolStripMenuItem1_Click); this.exitToolStripMenuItem1.Click += new System.EventHandler(this.exitToolStripMenuItem1_Click);
// //
@@ -192,6 +194,14 @@ namespace ntfysh_client
this.label1.TabIndex = 1; this.label1.TabIndex = 1;
this.label1.Text = "Subscribed Notification Topics:"; this.label1.Text = "Subscribed Notification Topics:";
// //
// settingsToolStripMenuItem
//
this.settingsToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("settingsToolStripMenuItem.Image")));
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.settingsToolStripMenuItem.Text = "Settings";
this.settingsToolStripMenuItem.Click += new System.EventHandler(this.settingsToolStripMenuItem_Click);
//
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@@ -240,6 +250,7 @@ namespace ntfysh_client
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ntfyshWebsiteToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem ntfyshWebsiteToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
} }
} }

View File

@@ -7,27 +7,70 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using Newtonsoft.Json; using Newtonsoft.Json;
using ntfysh_client.Notifications;
namespace ntfysh_client namespace ntfysh_client
{ {
public partial class MainForm : Form public partial class MainForm : Form
{ {
private readonly NotificationListener _notificationListener; private readonly NotificationListener _notificationListener;
private bool _startInTray;
private bool _trueExit; private bool _trueExit;
public MainForm(NotificationListener notificationListener) public MainForm(NotificationListener notificationListener, bool startInTray = false)
{ {
_notificationListener = notificationListener; _notificationListener = notificationListener;
_startInTray = startInTray;
_notificationListener.OnNotificationReceive += OnNotificationReceive; _notificationListener.OnNotificationReceive += OnNotificationReceive;
_notificationListener.OnConnectionMultiAttemptFailure += OnConnectionMultiAttemptFailure; _notificationListener.OnConnectionMultiAttemptFailure += OnConnectionMultiAttemptFailure;
_notificationListener.OnConnectionCredentialsFailure += OnConnectionCredentialsFailure; _notificationListener.OnConnectionCredentialsFailure += OnConnectionCredentialsFailure;
InitializeComponent(); InitializeComponent();
} }
private void MainForm_Load(object sender, EventArgs e)
{
LoadSettings();
LoadTopics();
}
protected override void SetVisibleCore(bool value)
{
if (_startInTray)
{
_startInTray = false;
/*
* TODO This little workaround prevents the window from appearing with a flash, but the taskbar icon appears for a moment.
*
* TODO This is because we must call SetVisibleCore(true) for the initial load events in the MainForm to fire, which is what triggers the listener
*/
Opacity = 0;
base.SetVisibleCore(true);
base.SetVisibleCore(false);
Opacity = 1;
return;
}
base.SetVisibleCore(value);
}
private void OnNotificationReceive(object sender, NotificationReceiveEventArgs e) private void OnNotificationReceive(object sender, NotificationReceiveEventArgs e)
{ {
notifyIcon.ShowBalloonTip(3000, e.Title, e.Message, ToolTipIcon.Info); ToolTipIcon priorityIcon = e.Priority switch
{
NotificationPriority.Max => ToolTipIcon.Error,
NotificationPriority.High => ToolTipIcon.Warning,
NotificationPriority.Default => ToolTipIcon.Info,
NotificationPriority.Low => ToolTipIcon.Info,
NotificationPriority.Min => ToolTipIcon.None,
_ => throw new ArgumentOutOfRangeException("Unknown priority received")
};
string finalTitle = string.IsNullOrWhiteSpace(e.Title) ? $"{e.Sender.TopicId}@{e.Sender.ServerUrl}" : e.Title;
notifyIcon.ShowBalloonTip((int)TimeSpan.FromSeconds((double)Program.Settings.Timeout).TotalMilliseconds, finalTitle, e.Message, priorityIcon);
} }
private void OnConnectionMultiAttemptFailure(NotificationListener sender, SubscribedTopic topic) private void OnConnectionMultiAttemptFailure(NotificationListener sender, SubscribedTopic topic)
@@ -42,8 +85,6 @@ namespace ntfysh_client
MessageBox.Show($"Connecting to topic ID '{topic.TopicId}' on server '{topic.ServerUrl}' failed because {reason}.\n\nThis topic ID will be ignored and you will not receive notifications for it until you correct the credentials.", "Connection Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show($"Connecting to topic ID '{topic.TopicId}' on server '{topic.ServerUrl}' failed because {reason}.\n\nThis topic ID will be ignored and you will not receive notifications for it until you correct the credentials.", "Connection Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
private void MainForm_Load(object sender, EventArgs e) => LoadTopics();
private void subscribeNewTopic_Click(object sender, EventArgs e) private void subscribeNewTopic_Click(object sender, EventArgs e)
{ {
using SubscribeDialog dialog = new SubscribeDialog(notificationTopics); using SubscribeDialog dialog = new SubscribeDialog(notificationTopics);
@@ -81,6 +122,26 @@ namespace ntfysh_client
SaveTopicsToFile(); SaveTopicsToFile();
} }
private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
{
using SettingsDialog dialog = new();
//Load current settings into dialog
dialog.Timeout = Program.Settings.Timeout;
//Show dialog
DialogResult result = dialog.ShowDialog();
//Do not save on cancelled dialog
if (result != DialogResult.OK) return;
//Read new settings from dialog
Program.Settings.Timeout = dialog.Timeout;
//Save new settings persistently
SaveSettingsToFile();
}
private void notificationTopics_SelectedValueChanged(object sender, EventArgs e) private void notificationTopics_SelectedValueChanged(object sender, EventArgs e)
{ {
@@ -95,11 +156,6 @@ namespace ntfysh_client
if (clickedItemIndex == -1) notificationTopics.ClearSelected(); if (clickedItemIndex == -1) notificationTopics.ClearSelected();
} }
private void button1_Click(object sender, EventArgs e)
{
Visible = false;
}
private void notifyIcon_Click(object sender, EventArgs e) private void notifyIcon_Click(object sender, EventArgs e)
{ {
MouseEventArgs mouseEv = (MouseEventArgs)e; MouseEventArgs mouseEv = (MouseEventArgs)e;
@@ -134,6 +190,19 @@ namespace ntfysh_client
File.WriteAllText(GetTopicsFilePath(), topicsSerialised); File.WriteAllText(GetTopicsFilePath(), topicsSerialised);
} }
private string GetSettingsFilePath()
{
string binaryDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? throw new InvalidOperationException("Unable to determine path for application");
return Path.Combine(binaryDirectory ?? throw new InvalidOperationException("Unable to determine path for settings file"), "settings.json");
}
private void SaveSettingsToFile()
{
string settingsSerialised = JsonConvert.SerializeObject(Program.Settings, Formatting.Indented);
File.WriteAllText(GetSettingsFilePath(), settingsSerialised);
}
private void LoadTopics() private void LoadTopics()
{ {
@@ -215,6 +284,54 @@ namespace ntfysh_client
} }
} }
private SettingsModel GetDefaultSettings() => new()
{
Timeout = 5
};
private void LoadSettings()
{
string settingsFilePath = GetSettingsFilePath();
//Check if we have any settings file on disk to load. If we don't, initialise defaults
if (!File.Exists(settingsFilePath))
{
Program.Settings = GetDefaultSettings();
SaveSettingsToFile();
return;
}
//We have a settings file. Load it!
string settingsSerialised = File.ReadAllText(settingsFilePath);
//Check if the file is empty. If it is, initialise default settings
if (string.IsNullOrWhiteSpace(settingsSerialised))
{
Program.Settings = GetDefaultSettings();
SaveSettingsToFile();
return;
}
//Deserialise the settings
SettingsModel? settings = JsonConvert.DeserializeObject<SettingsModel?>(settingsSerialised);
//Check if the deserialise succeeded. If it didn't, initialise default settings
if (settings is null)
{
Program.Settings = GetDefaultSettings();
SaveSettingsToFile();
return;
}
Program.Settings = settings;
}
private void MainForm_FormClosed(object sender, FormClosedEventArgs e) private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{ {
notifyIcon.Dispose(); notifyIcon.Dispose();

View File

@@ -67,7 +67,7 @@
<data name="showControlWindowToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="showControlWindowToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA6+AAAOvgHqQrHAAAAAiklE JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAAAiklE
QVQ4T8WPQQqAIBBFvUOrXIhu3dcZOkqtu5R1ia4SdRDrxyyGGKmBIOGBDL6nmk9WCGE9yUpW0q9Ads7V QVQ4T8WPQQqAIBBFvUOrXIhu3dcZOkqtu5R1ia4SdRDrxyyGGKmBIOGBDL6nmk9WCGE9yUpW0q9Ads7V
GuCQ/kHAe79joAEO6dcLFmttpQEO6c+Bvpm2oZ0zwB4zVQBiF8cIsMdMDPCb+G2vA/wgP/z6C6WAhBgo GuCQ/kHAe79joAEO6dcLFmttpQEO6c+Bvpm2oZ0zwB4zVQBiF8cIsMdMDPCb+G2vA/wgP/z6C6WAhBgo
fUFCDGi4BxIGShLpvy5jDoPes/0oNG3VAAAAAElFTkSuQmCC fUFCDGi4BxIGShLpvy5jDoPes/0oNG3VAAAAAElFTkSuQmCC
@@ -76,7 +76,7 @@
<data name="exitToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="exitToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA6+AAAOvgHqQrHAAAAAgUlE JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAAAgUlE
QVQ4T2OgGjjOLq4AZeIFWNWBBI9yib06zC3uABXCCkDyIHVYDTnMI2pzhEvs5VFucSeoEAo4wiNii08e QVQ4T2OgGjjOLq4AZeIFWNWBBI9yib06zC3uABXCCkDyIHVYDTnMI2pzhEvs5VFucSeoEAo4wiNii08e
DHAZQshwFICumCTNMADyK1gTl2gJiCYUNlgBSDPQ1v8gGipEPKDIBRSFAa6oIsoQQvGM1xCqpESsglgA DHAZQshwFICumCTNMADyK1gTl2gJiCYUNlgBSDPQ1v8gGipEPKDIBRSFAa6oIsoQQvGM1xCqpESsglgA
seroBRgYAOoOWBJbfVcRAAAAAElFTkSuQmCC seroBRgYAOoOWBJbfVcRAAAAAElFTkSuQmCC
@@ -267,16 +267,28 @@
<data name="exitToolStripMenuItem1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="exitToolStripMenuItem1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA6+AAAOvgHqQrHAAAAAgUlE JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAAAgUlE
QVQ4T2OgGjjOLq4AZeIFWNWBBI9yib06zC3uABXCCkDyIHVYDTnMI2pzhEvs5VFucSeoEAo4wiNii08e QVQ4T2OgGjjOLq4AZeIFWNWBBI9yib06zC3uABXCCkDyIHVYDTnMI2pzhEvs5VFucSeoEAo4wiNii08e
DHAZQshwFICumCTNMADyK1gTl2gJiCYUNlgBSDPQ1v8gGipEPKDIBRSFAa6oIsoQQvGM1xCqpESsglgA DHAZQshwFICumCTNMADyK1gTl2gJiCYUNlgBSDPQ1v8gGipEPKDIBRSFAa6oIsoQQvGM1xCqpESsglgA
seroBRgYAOoOWBJbfVcRAAAAAElFTkSuQmCC seroBRgYAOoOWBJbfVcRAAAAAElFTkSuQmCC
</value>
</data>
<data name="settingsToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7CAAAOwgEVKEqAAAABT0lE
QVQ4T7WTzU3DUBCEXQICcSAYx5bdgKkDEuggF37aIJwJVBBfsCsAux+iII6hgvCNM5GV8HeBlUa73tnZ
fe9lE/ybJUlyC5bG2OmfLY7jK1CGYbiLr/v9/kigQeNcqRqXbxrEJXgBBYJX/DviPE3TY8Xk5vgpmIHP
TUhWKoii6AA/RPygWFBMbmCuAKVlnVG0AzHDnzH1iPheJ/HkiXLEp/rWdSxbGckxRTVYeNoEPFF4mGVZ
CC9uYm4BamksbxssIUe6r46pKRKaDjx97uvkqpXGdNdA5G8NNOSrBmPQcDS9fHsFvms1sVjcnTn9Io00
lq8Mcv2I5xK5yVxQrBwnOCF+o/G+ZZ1BaEkKHRM/0DTFgicPzWkXKss6I7lepClT20XyfXPFzmkHdMpr
yzYN8gJUvV5vD/9M4fYqP34r3jZEetj1n+nG6b+2IPgAzHGHcFUSC1YAAAAASUVORK5CYII=
</value> </value>
</data> </data>
<data name="ntfyshWebsiteToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="ntfyshWebsiteToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA6+AAAOvgHqQrHAAAABDElE JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAABDElE
QVQ4T91RO3bCQAzUy3uhChdJnTVlCj5FcMsZsF1jmy4XycPrzl6fBLgEXMFp4srRiF0wcaBP5j0VI2m0 QVQ4T91RO3bCQAzUy3uhChdJnTVlCj5FcMsZsF1jmy4XycPrzl6fBLgEXMFp4srRiF0wcaBP5j0VI2m0
4zH9EwSq8gPP7ELPNFxtpxrbn9vVPkSsykOkqvHi2QxsWwAevhQTzG8eCb1yD7Glv2I5MlM+sLX0GqEq 4zH9EwSq8gPP7ELPNFxtpxrbn9vVPkSsykOkqvHi2QxsWwAevhQTzG8eCb1yD7Glv2I5MlM+sLX0GqEq
6+jVPFl6QZz7lOgdJVnzuMq/sEepbsGln2YnR3AAm0IcIE71geJsTO9mcOWAOa3zicxxxGWApXMGabaH 6+jVPFl6QZz7lOgdJVnzuMq/sEepbsGln2YnR3AAm0IcIE71geJsTO9mcOWAOa3zicxxxGWApXMGabaH
@@ -287,7 +299,7 @@
<data name="aboutToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="aboutToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA6+AAAOvgHqQrHAAAAAwUlE JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAAAwUlE
QVQ4T2OgClBUVHwAxP9JxA+g2sEG/JeTk5MkBYP0QLVTwQAFBYXHIAFSMEgPVDvYBfulpKSEScEgPVDt QVQ4T2OgClBUVHwAxP9JxA+g2sEG/JeTk5MkBYP0QLVTwQAFBYXHIAFSMEgPVDvYBfulpKSEScEgPVDt
dDIA6OTNQHX/YXysBjAxMcUxMjKuBrGB9DIgPxqmARhwOUBD3sD4WA0QERGRBHLvCwoKygLpm6KiohIw dDIA6OTNQHX/YXysBjAxMcUxMjKuBrGB9DIgPxqmARhwOUBD3sD4WA0QERGRBHLvCwoKygLpm6KiohIw
DVBNz5HY2L0AtHkOEE8F4okgvoyMjDSSJsIGsLOzuwKFfnBycppJS0vLAJ39BUQTbQA6RnYBMkY3YAVI DVBNz5HY2L0AtHkOEE8F4okgvoyMjDSSJsIGsLOzuwKFfnBycppJS0vLAJ39BUQTbQA6RnYBMkY3YAVI

View File

@@ -1,16 +0,0 @@
using System;
namespace ntfysh_client
{
public class NotificationReceiveEventArgs : EventArgs
{
public string Title { get; }
public string Message { get; }
public NotificationReceiveEventArgs(string title, string message)
{
Title = title;
Message = message;
}
}
}

View File

@@ -1,5 +1,4 @@
using Newtonsoft.Json; using System;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@@ -12,8 +11,9 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
using Newtonsoft.Json;
namespace ntfysh_client namespace ntfysh_client.Notifications
{ {
public class NotificationListener public class NotificationListener
{ {
@@ -85,7 +85,7 @@ namespace ntfysh_client
lines.RemoveAt(partialLineIndex); lines.RemoveAt(partialLineIndex);
//Process the full lines //Process the full lines
foreach (string line in lines) ProcessMessage(line); foreach (string line in lines) ProcessMessage(topic, line);
//Write back the partial line //Write back the partial line
mainBuffer.Clear(); mainBuffer.Clear();
@@ -189,7 +189,7 @@ namespace ntfysh_client
lines.RemoveAt(partialLineIndex); lines.RemoveAt(partialLineIndex);
//Process the full lines //Process the full lines
foreach (string line in lines) ProcessMessage(line); foreach (string line in lines) ProcessMessage(topic, line);
//Write back the partial line //Write back the partial line
mainBuffer.Clear(); mainBuffer.Clear();
@@ -244,7 +244,7 @@ namespace ntfysh_client
} }
} }
private void ProcessMessage(string message) private void ProcessMessage(SubscribedTopic topic, string message)
{ {
#if DEBUG #if DEBUG
Debug.WriteLine(message); Debug.WriteLine(message);
@@ -257,7 +257,7 @@ namespace ntfysh_client
if (evt.Event == "message") if (evt.Event == "message")
{ {
OnNotificationReceive?.Invoke(this, new NotificationReceiveEventArgs(evt.Title, evt.Message)); OnNotificationReceive?.Invoke(this, new NotificationReceiveEventArgs(topic, evt.Title ?? "", evt.Message, evt.Priority ?? NotificationPriority.Default));
} }
} }

View File

@@ -0,0 +1,11 @@
namespace ntfysh_client.Notifications
{
public enum NotificationPriority
{
Min = 1,
Low = 2,
Default = 3,
High = 4,
Max = 5
}
}

View File

@@ -0,0 +1,20 @@
using System;
namespace ntfysh_client.Notifications
{
public class NotificationReceiveEventArgs : EventArgs
{
public SubscribedTopic Sender { get; }
public string Title { get; }
public string Message { get; }
public NotificationPriority Priority { get; set; }
public NotificationReceiveEventArgs(SubscribedTopic sender, string title, string message, NotificationPriority priority)
{
Sender = sender;
Title = title;
Message = message;
Priority = priority;
}
}
}

View File

@@ -1,6 +1,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace ntfysh_client namespace ntfysh_client.Notifications
{ {
public class NtfyEvent public class NtfyEvent
{ {
@@ -20,6 +20,9 @@ namespace ntfysh_client
public string Message { get; set; } = null!; public string Message { get; set; } = null!;
[JsonProperty("title")] [JsonProperty("title")]
public string Title { get; set; } = null!; public string? Title { get; set; }
[JsonProperty("priority")]
public NotificationPriority? Priority { get; set; }
} }
} }

View File

@@ -3,7 +3,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace ntfysh_client namespace ntfysh_client.Notifications
{ {
public class SubscribedTopic public class SubscribedTopic
{ {

View File

@@ -1,25 +1,48 @@
using System; using System;
using System.Collections.Generic; using System.Diagnostics;
using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using ntfysh_client.Notifications;
namespace ntfysh_client namespace ntfysh_client
{ {
static class Program static class Program
{ {
private static readonly NotificationListener NotificationListener = new NotificationListener(); private static readonly NotificationListener NotificationListener = new();
public static SettingsModel Settings { get; set; } = null!;
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() private static void Main(string[] args)
{ {
args = args.Select(a => a.ToLower()).ToArray();
if (args.Contains("-h") || args.Contains("--help"))
{
MessageBox.Show("Help:\n -h\n --help\n\nStart in tray:\n -t\n --start-in-tray\n\nAllow multiple instances:\n -m\n --allow-multiple-instances", "Help Menu", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
bool startInTray = args.Contains("-t") || args.Contains("--start-in-tray");
bool allowMultipleInstances = args.Contains("-m") || args.Contains("--allow-multiple-instances");
if (Process.GetProcessesByName(Path.GetFileNameWithoutExtension(Assembly.GetEntryAssembly()!.Location)).Length > 1)
{
if (!allowMultipleInstances)
{
MessageBox.Show("Another instance is already running.\n\nUse -m or --allow-multiple-instances if you wish to start a second duplicate instance.\n\nThis instance will now close.", "Multiple Instances", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm(NotificationListener)); Application.Run(new MainForm(NotificationListener, startInTray));
} }
} }
} }

129
ntfysh_client/SettingsDialog.Designer.cs generated Normal file
View File

@@ -0,0 +1,129 @@

namespace ntfysh_client
{
partial class SettingsDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.cancelButton = new System.Windows.Forms.Button();
this.saveButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.timeout = new System.Windows.Forms.NumericUpDown();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.timeout)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.Control;
this.panel1.Controls.Add(this.cancelButton);
this.panel1.Controls.Add(this.saveButton);
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel1.Location = new System.Drawing.Point(0, 61);
this.panel1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(531, 51);
this.panel1.TabIndex = 9;
//
// cancelButton
//
this.cancelButton.Location = new System.Drawing.Point(363, 16);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 1;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// saveButton
//
this.saveButton.Location = new System.Drawing.Point(444, 16);
this.saveButton.Name = "saveButton";
this.saveButton.Size = new System.Drawing.Size(75, 23);
this.saveButton.TabIndex = 0;
this.saveButton.Text = "Save";
this.saveButton.UseVisualStyleBackColor = true;
this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 9);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(488, 15);
this.label1.TabIndex = 11;
this.label1.Text = "Notification Toast Timeout (seconds, may be ignored by OS based on accessibility " +
"settings):";
//
// timeout
//
this.timeout.Location = new System.Drawing.Point(13, 27);
this.timeout.Maximum = new decimal(new int[] {
-1981284353,
-1966660860,
0,
0});
this.timeout.Name = "timeout";
this.timeout.Size = new System.Drawing.Size(506, 23);
this.timeout.TabIndex = 12;
//
// SettingsDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(531, 112);
this.Controls.Add(this.timeout);
this.Controls.Add(this.label1);
this.Controls.Add(this.panel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SettingsDialog";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Settings";
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.timeout)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.NumericUpDown timeout;
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Button saveButton;
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Windows.Forms;
namespace ntfysh_client
{
public partial class SettingsDialog : Form
{
public decimal Timeout
{
get => timeout.Value;
set => timeout.Value = value;
}
public SettingsDialog()
{
InitializeComponent();
}
private void saveButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
}

View File

@@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,7 @@
namespace ntfysh_client
{
public class SettingsModel
{
public decimal Timeout { get; set; }
}
}

View File

@@ -8,6 +8,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ApplicationIcon>NotificationHub.ico</ApplicationIcon> <ApplicationIcon>NotificationHub.ico</ApplicationIcon>
<StartupObject>ntfysh_client.Program</StartupObject> <StartupObject>ntfysh_client.Program</StartupObject>
<AssemblyName>ntfy.sh</AssemblyName>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
</packages>