Compare commits

...

7 Commits

Author SHA1 Message Date
Andrea
903e0b934d Fixed thread not closing issue 2025-10-02 09:00:35 +02:00
Andrea
9a005c15f2 Fixed client form size issues 2025-10-02 08:55:57 +02:00
Andrea
c52c9266af Client log horizontal scrollbar 2025-10-02 08:54:27 +02:00
Andrea
036ea0ed6a Added client commands backend 2025-10-02 08:53:03 +02:00
Andrea
cb74dd00d3 semifix 2025-10-02 08:51:48 +02:00
Andrea
f97f1a7bcb Command support improvements 2025-10-02 08:50:08 +02:00
Andrea
8bea85a5b1 commands overhaul 2025-10-02 08:34:35 +02:00
9 changed files with 115 additions and 127 deletions

View File

@@ -5,6 +5,7 @@ using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
namespace SamaPager_Client namespace SamaPager_Client
{ {
@@ -41,6 +42,23 @@ namespace SamaPager_Client
UdpStack.Send(msgData, msgData.Length, serverEndPoint); UdpStack.Send(msgData, msgData.Length, serverEndPoint);
} }
internal string SendCommand(string command)
{
byte[] msgData = Encoding.UTF8.GetBytes(command);
UdpStack.Send(msgData, msgData.Length, serverEndPoint);
try
{
UdpStack.Client.ReceiveTimeout = 5000;
IPEndPoint receiveEndPoint = serverEndPoint;
byte[] receivedBytes = UdpStack.Receive(ref receiveEndPoint);
return $"Server replied: {Encoding.UTF8.GetString(receivedBytes)}";
}
catch(Exception ex)
{
return $"ERROR: {ex.Message}";
}
}
internal void KillClient() internal void KillClient()
{ {
this.UdpStack.Close(); this.UdpStack.Close();

View File

@@ -31,9 +31,8 @@
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.kryptonPanel1 = new Krypton.Toolkit.KryptonPanel(); this.kryptonPanel1 = new Krypton.Toolkit.KryptonPanel();
this.getDateBtn = new Krypton.Toolkit.KryptonButton(); this.cmdLst = new Krypton.Toolkit.KryptonComboBox();
this.getTimeBtn = new Krypton.Toolkit.KryptonButton(); this.logLst = new Krypton.Toolkit.KryptonListBox();
this.kryptonListBox1 = new Krypton.Toolkit.KryptonListBox();
this.kryptonPictureBox1 = new Krypton.Toolkit.KryptonPictureBox(); this.kryptonPictureBox1 = new Krypton.Toolkit.KryptonPictureBox();
this.sendBtn = new Krypton.Toolkit.KryptonButton(); this.sendBtn = new Krypton.Toolkit.KryptonButton();
this.kryptonStatusStrip1 = new Krypton.Toolkit.KryptonStatusStrip(); this.kryptonStatusStrip1 = new Krypton.Toolkit.KryptonStatusStrip();
@@ -46,6 +45,7 @@
this.kryptonManager2 = new Krypton.Toolkit.KryptonManager(this.components); this.kryptonManager2 = new Krypton.Toolkit.KryptonManager(this.components);
((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).BeginInit();
this.kryptonPanel1.SuspendLayout(); this.kryptonPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.cmdLst)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.kryptonPictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.kryptonPictureBox1)).BeginInit();
this.kryptonStatusStrip1.SuspendLayout(); this.kryptonStatusStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
@@ -53,9 +53,8 @@
// //
// kryptonPanel1 // kryptonPanel1
// //
this.kryptonPanel1.Controls.Add(this.getDateBtn); this.kryptonPanel1.Controls.Add(this.cmdLst);
this.kryptonPanel1.Controls.Add(this.getTimeBtn); this.kryptonPanel1.Controls.Add(this.logLst);
this.kryptonPanel1.Controls.Add(this.kryptonListBox1);
this.kryptonPanel1.Controls.Add(this.kryptonPictureBox1); this.kryptonPanel1.Controls.Add(this.kryptonPictureBox1);
this.kryptonPanel1.Controls.Add(this.sendBtn); this.kryptonPanel1.Controls.Add(this.sendBtn);
this.kryptonPanel1.Controls.Add(this.kryptonStatusStrip1); this.kryptonPanel1.Controls.Add(this.kryptonStatusStrip1);
@@ -64,26 +63,22 @@
resources.ApplyResources(this.kryptonPanel1, "kryptonPanel1"); resources.ApplyResources(this.kryptonPanel1, "kryptonPanel1");
this.kryptonPanel1.Name = "kryptonPanel1"; this.kryptonPanel1.Name = "kryptonPanel1";
// //
// getDateBtn // cmdLst
// //
resources.ApplyResources(this.getDateBtn, "getDateBtn"); this.cmdLst.DropDownWidth = 318;
this.getDateBtn.Name = "getDateBtn"; this.cmdLst.Items.AddRange(new object[] {
this.getDateBtn.Values.DropDownArrowColor = System.Drawing.Color.Empty; resources.GetString("cmdLst.Items"),
this.getDateBtn.Values.Text = resources.GetString("getDateBtn.Values.Text"); resources.GetString("cmdLst.Items1"),
this.getDateBtn.Click += new System.EventHandler(this.getDateBtn_Click); resources.GetString("cmdLst.Items2")});
resources.ApplyResources(this.cmdLst, "cmdLst");
this.cmdLst.Name = "cmdLst";
this.cmdLst.StateCommon.ComboBox.Content.TextH = Krypton.Toolkit.PaletteRelativeAlign.Near;
this.cmdLst.SelectedIndexChanged += new System.EventHandler(this.cmdLst_SelectedIndexChanged);
// //
// getTimeBtn // logLst
// //
resources.ApplyResources(this.getTimeBtn, "getTimeBtn"); resources.ApplyResources(this.logLst, "logLst");
this.getTimeBtn.Name = "getTimeBtn"; this.logLst.Name = "logLst";
this.getTimeBtn.Values.DropDownArrowColor = System.Drawing.Color.Empty;
this.getTimeBtn.Values.Text = resources.GetString("getTimeBtn.Values.Text");
this.getTimeBtn.Click += new System.EventHandler(this.getTimeBtn_Click);
//
// kryptonListBox1
//
resources.ApplyResources(this.kryptonListBox1, "kryptonListBox1");
this.kryptonListBox1.Name = "kryptonListBox1";
// //
// kryptonPictureBox1 // kryptonPictureBox1
// //
@@ -163,6 +158,7 @@
((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).EndInit();
this.kryptonPanel1.ResumeLayout(false); this.kryptonPanel1.ResumeLayout(false);
this.kryptonPanel1.PerformLayout(); this.kryptonPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.cmdLst)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.kryptonPictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.kryptonPictureBox1)).EndInit();
this.kryptonStatusStrip1.ResumeLayout(false); this.kryptonStatusStrip1.ResumeLayout(false);
this.kryptonStatusStrip1.PerformLayout(); this.kryptonStatusStrip1.PerformLayout();
@@ -185,9 +181,8 @@
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem changeDestinationAddressToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem changeDestinationAddressToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem restartUDPClientToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem restartUDPClientToolStripMenuItem;
private Krypton.Toolkit.KryptonButton getDateBtn; private Krypton.Toolkit.KryptonListBox logLst;
private Krypton.Toolkit.KryptonButton getTimeBtn; private Krypton.Toolkit.KryptonComboBox cmdLst;
private Krypton.Toolkit.KryptonListBox kryptonListBox1;
} }
} }

View File

@@ -55,19 +55,16 @@ namespace SamaPager_Client
else else
{ {
pageClient.SendMessage(messageTxt.Text); pageClient.SendMessage(messageTxt.Text);
logLst.Items.Add($"Sent: {messageTxt.Text}");
messageTxt.Text = String.Empty; messageTxt.Text = String.Empty;
} }
} }
private void getTimeBtn_Click(object sender, EventArgs e) private void cmdLst_SelectedIndexChanged(object sender, EventArgs e)
{ {
pageClient.SendMessage("!time"); logLst.Items.Add(pageClient.SendCommand(cmdLst.Text));
} cmdLst.Text = String.Empty;
private void getDateBtn_Click(object sender, EventArgs e)
{
pageClient.SendMessage("!date");
} }
} }
} }

View File

@@ -117,27 +117,21 @@
<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="getDateBtn.Values.Text" xml:space="preserve">
<value>Ottieni Data</value>
</data>
<data name="getTimeBtn.Values.Text" xml:space="preserve">
<value>Ottieni Ora</value>
</data>
<data name="sendBtn.Values.Text" xml:space="preserve"> <data name="sendBtn.Values.Text" xml:space="preserve">
<value>INVIA</value> <value>INVIA</value>
</data> </data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="kryptonStatusStrip1.Location" type="System.Drawing.Point, System.Drawing"> <data name="kryptonStatusStrip1.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 328</value> <value>0, 555</value>
</data> </data>
<data name="kryptonStatusStrip1.Size" type="System.Drawing.Size, System.Drawing"> <data name="kryptonStatusStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>650, 22</value> <value>342, 22</value>
</data> </data>
<data name="menuStrip1.Size" type="System.Drawing.Size, System.Drawing"> <data name="menuStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>650, 24</value> <value>342, 24</value>
</data> </data>
<data name="kryptonPanel1.Size" type="System.Drawing.Size, System.Drawing"> <data name="kryptonPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>650, 350</value> <value>342, 577</value>
</data> </data>
<data name="fileToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> <data name="fileToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>42, 20</value> <value>42, 20</value>
@@ -158,10 +152,6 @@
<value>Riavvia il socket UDP</value> <value>Riavvia il socket UDP</value>
</data> </data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing"> <data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>650, 350</value> <value>342, 577</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="$this.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>Inherit</value>
</data> </data>
</root> </root>

View File

@@ -117,83 +117,71 @@
<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>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <data name="cmdLst.Items" xml:space="preserve">
<data name="getDateBtn.Location" type="System.Drawing.Point, System.Drawing"> <value>!getDateTime</value>
<value>349, 78</value>
</data> </data>
<data name="getDateBtn.Size" type="System.Drawing.Size, System.Drawing"> <data name="cmdLst.Items1" xml:space="preserve">
<value>278, 43</value> <value>!getCurrentDir</value>
</data>
<data name="cmdLst.Items2" xml:space="preserve">
<value>!getCurrentUser</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="cmdLst.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 524</value>
</data>
<data name="cmdLst.Size" type="System.Drawing.Size, System.Drawing">
<value>318, 22</value>
</data> </data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="getDateBtn.TabIndex" type="System.Int32, mscorlib"> <data name="cmdLst.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="getDateBtn.Values.Text" xml:space="preserve">
<value>Get Date</value>
</data>
<data name="&gt;&gt;getDateBtn.Name" xml:space="preserve">
<value>getDateBtn</value>
</data>
<data name="&gt;&gt;getDateBtn.Type" xml:space="preserve">
<value>Krypton.Toolkit.KryptonButton, Krypton.Toolkit, Version=95.25.8.235, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e</value>
</data>
<data name="&gt;&gt;getDateBtn.Parent" xml:space="preserve">
<value>kryptonPanel1</value>
</data>
<data name="&gt;&gt;getDateBtn.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="getTimeBtn.Location" type="System.Drawing.Point, System.Drawing">
<value>349, 27</value>
</data>
<data name="getTimeBtn.Size" type="System.Drawing.Size, System.Drawing">
<value>278, 45</value>
</data>
<data name="getTimeBtn.TabIndex" type="System.Int32, mscorlib">
<value>6</value> <value>6</value>
</data> </data>
<data name="getTimeBtn.Values.Text" xml:space="preserve"> <data name="&gt;&gt;cmdLst.Name" xml:space="preserve">
<value>Get Time</value> <value>cmdLst</value>
</data> </data>
<data name="&gt;&gt;getTimeBtn.Name" xml:space="preserve"> <data name="&gt;&gt;cmdLst.Type" xml:space="preserve">
<value>getTimeBtn</value> <value>Krypton.Toolkit.KryptonComboBox, Krypton.Toolkit, Version=95.25.8.235, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e</value>
</data> </data>
<data name="&gt;&gt;getTimeBtn.Type" xml:space="preserve"> <data name="&gt;&gt;cmdLst.Parent" xml:space="preserve">
<value>Krypton.Toolkit.KryptonButton, Krypton.Toolkit, Version=95.25.8.235, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e</value>
</data>
<data name="&gt;&gt;getTimeBtn.Parent" xml:space="preserve">
<value>kryptonPanel1</value> <value>kryptonPanel1</value>
</data> </data>
<data name="&gt;&gt;getTimeBtn.ZOrder" xml:space="preserve"> <data name="&gt;&gt;cmdLst.ZOrder" xml:space="preserve">
<value>1</value> <value>0</value>
</data> </data>
<data name="kryptonListBox1.Location" type="System.Drawing.Point, System.Drawing"> <data name="logLst.HorizontalExtent" type="System.Int32, mscorlib">
<value>12, 27</value> <value>4000</value>
</data> </data>
<data name="kryptonListBox1.Size" type="System.Drawing.Size, System.Drawing"> <data name="logLst.HorizontalScrollbar" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="logLst.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 230</value>
</data>
<data name="logLst.Size" type="System.Drawing.Size, System.Drawing">
<value>318, 215</value> <value>318, 215</value>
</data> </data>
<data name="kryptonListBox1.TabIndex" type="System.Int32, mscorlib"> <data name="logLst.TabIndex" type="System.Int32, mscorlib">
<value>5</value> <value>5</value>
</data> </data>
<data name="&gt;&gt;kryptonListBox1.Name" xml:space="preserve"> <data name="&gt;&gt;logLst.Name" xml:space="preserve">
<value>kryptonListBox1</value> <value>logLst</value>
</data> </data>
<data name="&gt;&gt;kryptonListBox1.Type" xml:space="preserve"> <data name="&gt;&gt;logLst.Type" xml:space="preserve">
<value>Krypton.Toolkit.KryptonListBox, Krypton.Toolkit, Version=95.25.8.235, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e</value> <value>Krypton.Toolkit.KryptonListBox, Krypton.Toolkit, Version=95.25.8.235, Culture=neutral, PublicKeyToken=a87e673e9ecb6e8e</value>
</data> </data>
<data name="&gt;&gt;kryptonListBox1.Parent" xml:space="preserve"> <data name="&gt;&gt;logLst.Parent" xml:space="preserve">
<value>kryptonPanel1</value> <value>kryptonPanel1</value>
</data> </data>
<data name="&gt;&gt;kryptonListBox1.ZOrder" xml:space="preserve"> <data name="&gt;&gt;logLst.ZOrder" xml:space="preserve">
<value>2</value> <value>1</value>
</data> </data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="kryptonPictureBox1.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms"> <data name="kryptonPictureBox1.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value> <value>NoControl</value>
</data> </data>
<data name="kryptonPictureBox1.Location" type="System.Drawing.Point, System.Drawing"> <data name="kryptonPictureBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>349, 134</value> <value>31, 38</value>
</data> </data>
<data name="kryptonPictureBox1.Size" type="System.Drawing.Size, System.Drawing"> <data name="kryptonPictureBox1.Size" type="System.Drawing.Size, System.Drawing">
<value>278, 181</value> <value>278, 181</value>
@@ -214,10 +202,10 @@
<value>kryptonPanel1</value> <value>kryptonPanel1</value>
</data> </data>
<data name="&gt;&gt;kryptonPictureBox1.ZOrder" xml:space="preserve"> <data name="&gt;&gt;kryptonPictureBox1.ZOrder" xml:space="preserve">
<value>3</value> <value>2</value>
</data> </data>
<data name="sendBtn.Location" type="System.Drawing.Point, System.Drawing"> <data name="sendBtn.Location" type="System.Drawing.Point, System.Drawing">
<value>250, 248</value> <value>250, 451</value>
</data> </data>
<data name="sendBtn.Size" type="System.Drawing.Size, System.Drawing"> <data name="sendBtn.Size" type="System.Drawing.Size, System.Drawing">
<value>80, 67</value> <value>80, 67</value>
@@ -238,7 +226,7 @@
<value>kryptonPanel1</value> <value>kryptonPanel1</value>
</data> </data>
<data name="&gt;&gt;sendBtn.ZOrder" xml:space="preserve"> <data name="&gt;&gt;sendBtn.ZOrder" xml:space="preserve">
<value>4</value> <value>3</value>
</data> </data>
<metadata name="kryptonStatusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="kryptonStatusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>165, 17</value> <value>165, 17</value>
@@ -247,16 +235,16 @@
<value>Segoe UI, 9pt</value> <value>Segoe UI, 9pt</value>
</data> </data>
<data name="statusTxt.Size" type="System.Drawing.Size, System.Drawing"> <data name="statusTxt.Size" type="System.Drawing.Size, System.Drawing">
<value>68, 17</value> <value>70, 17</value>
</data> </data>
<data name="statusTxt.Text" xml:space="preserve"> <data name="statusTxt.Text" xml:space="preserve">
<value>STATUS: Off</value> <value>STATUS: Off</value>
</data> </data>
<data name="kryptonStatusStrip1.Location" type="System.Drawing.Point, System.Drawing"> <data name="kryptonStatusStrip1.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 326</value> <value>0, 555</value>
</data> </data>
<data name="kryptonStatusStrip1.Size" type="System.Drawing.Size, System.Drawing"> <data name="kryptonStatusStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>652, 22</value> <value>345, 22</value>
</data> </data>
<data name="kryptonStatusStrip1.TabIndex" type="System.Int32, mscorlib"> <data name="kryptonStatusStrip1.TabIndex" type="System.Int32, mscorlib">
<value>1</value> <value>1</value>
@@ -274,7 +262,7 @@
<value>kryptonPanel1</value> <value>kryptonPanel1</value>
</data> </data>
<data name="&gt;&gt;kryptonStatusStrip1.ZOrder" xml:space="preserve"> <data name="&gt;&gt;kryptonStatusStrip1.ZOrder" xml:space="preserve">
<value>5</value> <value>4</value>
</data> </data>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>322, 17</value> <value>322, 17</value>
@@ -304,7 +292,7 @@
<value>0, 0</value> <value>0, 0</value>
</data> </data>
<data name="menuStrip1.Size" type="System.Drawing.Size, System.Drawing"> <data name="menuStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>652, 24</value> <value>345, 24</value>
</data> </data>
<data name="menuStrip1.TabIndex" type="System.Int32, mscorlib"> <data name="menuStrip1.TabIndex" type="System.Int32, mscorlib">
<value>4</value> <value>4</value>
@@ -322,10 +310,10 @@
<value>kryptonPanel1</value> <value>kryptonPanel1</value>
</data> </data>
<data name="&gt;&gt;menuStrip1.ZOrder" xml:space="preserve"> <data name="&gt;&gt;menuStrip1.ZOrder" xml:space="preserve">
<value>6</value> <value>5</value>
</data> </data>
<data name="messageTxt.Location" type="System.Drawing.Point, System.Drawing"> <data name="messageTxt.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 248</value> <value>12, 451</value>
</data> </data>
<data name="messageTxt.Multiline" type="System.Boolean, mscorlib"> <data name="messageTxt.Multiline" type="System.Boolean, mscorlib">
<value>True</value> <value>True</value>
@@ -346,7 +334,7 @@
<value>kryptonPanel1</value> <value>kryptonPanel1</value>
</data> </data>
<data name="&gt;&gt;messageTxt.ZOrder" xml:space="preserve"> <data name="&gt;&gt;messageTxt.ZOrder" xml:space="preserve">
<value>7</value> <value>6</value>
</data> </data>
<data name="kryptonPanel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms"> <data name="kryptonPanel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value> <value>Fill</value>
@@ -355,7 +343,7 @@
<value>0, 0</value> <value>0, 0</value>
</data> </data>
<data name="kryptonPanel1.Size" type="System.Drawing.Size, System.Drawing"> <data name="kryptonPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>652, 348</value> <value>345, 577</value>
</data> </data>
<data name="kryptonPanel1.TabIndex" type="System.Int32, mscorlib"> <data name="kryptonPanel1.TabIndex" type="System.Int32, mscorlib">
<value>0</value> <value>0</value>
@@ -382,7 +370,7 @@
<value>6, 13</value> <value>6, 13</value>
</data> </data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing"> <data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>652, 348</value> <value>345, 577</value>
</data> </data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms"> <data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterScreen</value> <value>CenterScreen</value>

View File

@@ -61,9 +61,11 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.it-IT.resx"> <EmbeddedResource Include="Form1.it-IT.resx">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Form1.resx"> <EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>

View File

@@ -72,7 +72,7 @@
this.kryptonPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.kryptonPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.kryptonPanel1.Location = new System.Drawing.Point(0, 0); this.kryptonPanel1.Location = new System.Drawing.Point(0, 0);
this.kryptonPanel1.Name = "kryptonPanel1"; this.kryptonPanel1.Name = "kryptonPanel1";
this.kryptonPanel1.Size = new System.Drawing.Size(423, 386); this.kryptonPanel1.Size = new System.Drawing.Size(426, 383);
this.kryptonPanel1.TabIndex = 0; this.kryptonPanel1.TabIndex = 0;
// //
// logList // logList
@@ -81,7 +81,7 @@
this.logList.HorizontalScrollbar = true; this.logList.HorizontalScrollbar = true;
this.logList.Location = new System.Drawing.Point(12, 27); this.logList.Location = new System.Drawing.Point(12, 27);
this.logList.Name = "logList"; this.logList.Name = "logList";
this.logList.Size = new System.Drawing.Size(399, 322); this.logList.Size = new System.Drawing.Size(402, 322);
this.logList.TabIndex = 4; this.logList.TabIndex = 4;
// //
// kryptonStatusStrip1 // kryptonStatusStrip1
@@ -89,18 +89,18 @@
this.kryptonStatusStrip1.Font = new System.Drawing.Font("Segoe UI", 9F); this.kryptonStatusStrip1.Font = new System.Drawing.Font("Segoe UI", 9F);
this.kryptonStatusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.kryptonStatusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.statusLabel}); this.statusLabel});
this.kryptonStatusStrip1.Location = new System.Drawing.Point(0, 364); this.kryptonStatusStrip1.Location = new System.Drawing.Point(0, 361);
this.kryptonStatusStrip1.Name = "kryptonStatusStrip1"; this.kryptonStatusStrip1.Name = "kryptonStatusStrip1";
this.kryptonStatusStrip1.ProgressBars = null; this.kryptonStatusStrip1.ProgressBars = null;
this.kryptonStatusStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.ManagerRenderMode; this.kryptonStatusStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.ManagerRenderMode;
this.kryptonStatusStrip1.Size = new System.Drawing.Size(423, 22); this.kryptonStatusStrip1.Size = new System.Drawing.Size(426, 22);
this.kryptonStatusStrip1.TabIndex = 3; this.kryptonStatusStrip1.TabIndex = 3;
this.kryptonStatusStrip1.Text = "kryptonStatusStrip1"; this.kryptonStatusStrip1.Text = "kryptonStatusStrip1";
// //
// statusLabel // statusLabel
// //
this.statusLabel.Name = "statusLabel"; this.statusLabel.Name = "statusLabel";
this.statusLabel.Size = new System.Drawing.Size(103, 17); this.statusLabel.Size = new System.Drawing.Size(105, 17);
this.statusLabel.Text = "STATUS: Server Off"; this.statusLabel.Text = "STATUS: Server Off";
// //
// menuStrip1 // menuStrip1
@@ -111,7 +111,7 @@
this.helpToolStripMenuItem}); this.helpToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(423, 24); this.menuStrip1.Size = new System.Drawing.Size(426, 24);
this.menuStrip1.TabIndex = 0; this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
@@ -126,7 +126,7 @@
// exitToolStripMenuItem // exitToolStripMenuItem
// //
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(93, 22); this.exitToolStripMenuItem.Size = new System.Drawing.Size(92, 22);
this.exitToolStripMenuItem.Text = "Exit"; this.exitToolStripMenuItem.Text = "Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
// //
@@ -141,7 +141,7 @@
// infoToolStripMenuItem2 // infoToolStripMenuItem2
// //
this.infoToolStripMenuItem2.Name = "infoToolStripMenuItem2"; this.infoToolStripMenuItem2.Name = "infoToolStripMenuItem2";
this.infoToolStripMenuItem2.Size = new System.Drawing.Size(180, 22); this.infoToolStripMenuItem2.Size = new System.Drawing.Size(107, 22);
this.infoToolStripMenuItem2.Text = "About"; this.infoToolStripMenuItem2.Text = "About";
this.infoToolStripMenuItem2.Click += new System.EventHandler(this.infoToolStripMenuItem2_Click); this.infoToolStripMenuItem2.Click += new System.EventHandler(this.infoToolStripMenuItem2_Click);
// //
@@ -192,7 +192,7 @@
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(423, 386); this.ClientSize = new System.Drawing.Size(426, 383);
this.Controls.Add(this.kryptonPanel1); this.Controls.Add(this.kryptonPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

View File

@@ -73,6 +73,7 @@ namespace SamaPager_Server
private void Exit() private void Exit()
{ {
srv.KillServer();
this.Stop = true; this.Stop = true;
Application.Exit(); Application.Exit();
} }

View File

@@ -40,16 +40,13 @@ namespace SamaPager_Server
IPEndPoint receiveEndPoint = ServerEndPoint; IPEndPoint receiveEndPoint = ServerEndPoint;
byte[] receivedBytes = UdpServer.Receive(ref receiveEndPoint); byte[] receivedBytes = UdpServer.Receive(ref receiveEndPoint);
string receivedMessage = Encoding.UTF8.GetString(receivedBytes); string receivedMessage = Encoding.UTF8.GetString(receivedBytes);
byte[] bytesToSend;
switch (receivedMessage) switch (receivedMessage)
{ {
case "!time": case "!getDateTime":
byte[] bytesToSend = Encoding.UTF8.GetBytes($"Hi, it's {DateTime.Now.Hour}:{DateTime.Now.Minute}:{DateTime.Now.Second}"); bytesToSend = Encoding.UTF8.GetBytes($"Hi, it's {DateTime.Now}");
this.UdpServer.Send(bytesToSend, bytesToSend.Length, receiveEndPoint); this.UdpServer.Send(bytesToSend, bytesToSend.Length, receiveEndPoint);
return $"Time command received by {receiveEndPoint}, sent local server time"; return $"Time command received by {receiveEndPoint}, sent local server time";
case "!date":
byte[] bytesToSendDate = Encoding.UTF8.GetBytes($"Hi, it's");
this.UdpServer.Send(bytesToSendDate, bytesToSend.Length, receiveEndPoint);
return $"Time command received by {receiveEndPoint}, sent local server time";
default: default:
return $"[{DateTime.Now}] {receiveEndPoint}: {receivedMessage}"; return $"[{DateTime.Now}] {receiveEndPoint}: {receivedMessage}";
} }