This repository has been archived on 2025-12-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
SamaPager/SamaPager_Client/Form1.cs
Andrea 7994f3d066 Fix revert errato
revert Revert to 19a5a08f04

revert First experimental encryption implementation (not working)
2025-12-03 09:20:35 +00:00

89 lines
2.5 KiB
C#

using Krypton.Toolkit;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SamaPager_Client
{
public partial class Form1 : Krypton.Toolkit.KryptonForm
{
IPAddress DestinationIP = IPAddress.Loopback;
Client pageClient { get; set; }
public Form1()
{
InitializeComponent();
}
public void StartClient()
{
pageClient = new Client(DestinationIP, 2000);
statusTxt.Text = "STATUS: " + pageClient.StartClient();
}
private void Form1_Load(object sender, EventArgs e)
{
StartClient();
}
private void changeDestinationAddressToolStripMenuItem_Click(object sender, EventArgs e)
{
KryptonMessageBox.Show("WIP");
}
private void restartUDPClientToolStripMenuItem_Click(object sender, EventArgs e)
{
statusTxt.Text = "STATUS: Restarting UdpClient";
StartClient();
}
private void cmdLst_SelectedIndexChanged(object sender, EventArgs e)
{
logLst.Items.Add(pageClient.SendCommand(cmdLst.Text));
cmdLst.Text = String.Empty;
}
private void sendBtn_Click_1(object sender, EventArgs e)
{
if(keyTxt.Text == string.Empty)
{
KryptonMessageBox.Show("Inserire una chiave");
}
else if (messageTxt.Text == string.Empty)
{
KryptonMessageBox.Show("Inserire un messaggio");
}
else
{
pageClient.SendEncryptedMessage(messageTxt.Text, keyTxt.Text);
logLst.Items.Add($"Sent: {messageTxt.Text}");
messageTxt.Text = String.Empty;
}
}
private void sendWithoutEncryptionToolStripMenuItem_Click(object sender, EventArgs e)
{
if (messageTxt.Text == string.Empty)
{
KryptonMessageBox.Show("Inserire un messaggio");
}
else
{
pageClient.SendMessage(messageTxt.Text);
logLst.Items.Add($"Sent: {messageTxt.Text}");
messageTxt.Text = String.Empty;
}
}
}
}