You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Cigarette/WindowsFormsApp2/DialogLogin.cs

155 lines
4.0 KiB
C#

2 years ago
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.Net;
using System.Net.Sockets;
using System.Threading;
namespace WindowsFormsApp2
{
public partial class DialogLogin : Form
{
string pwd;
public static byte[] clientIP = new byte[] { 192, 168, 10, 127 };
public static byte[] localIP = new byte[] { 192, 168, 10, 127 };
public static int ordPort = 3333;
public static int feedPort = 2999;
public bool IsAdmin = false;
public void SendMsg(string obj)
{
try
{
UdpClient udpcSend = new UdpClient(0);
byte[] sendbytes = Encoding.UTF8.GetBytes(obj);
// IPEndPoint remoteIpep = new IPEndPoint(IPAddress.Parse("192.168.31.243"), 3333);
IPEndPoint remoteIpep = new IPEndPoint(new IPAddress(clientIP), ordPort);
udpcSend.Send(sendbytes, sendbytes.Length, remoteIpep);
udpcSend.Close();
}
catch (Exception ex)
2 years ago
{
System.Diagnostics.Debug.WriteLine(ex.Message);
2 years ago
}
}
public DialogLogin()
{
InitializeComponent();
pwd = null;
}
private void button1_Click(object sender, EventArgs e)
{
this.textBox1.AppendText("*");
if (pwd == null)
pwd = "1";
else
pwd += ('1');
}
private void button2_Click(object sender, EventArgs e)
{
this.textBox1.AppendText("*");
if (pwd == null)
pwd = "2";
else
pwd += ('2');
}
private void button3_Click(object sender, EventArgs e)
{
this.textBox1.AppendText("*");
if (pwd == null)
pwd = "3";
else
pwd += ('3');
}
private void button4_Click(object sender, EventArgs e)
{
this.textBox1.AppendText("*");
if (pwd == null)
pwd = "4";
else
pwd += ('4');
}
private void button5_Click(object sender, EventArgs e)
{
this.textBox1.AppendText("*");
if (pwd == null)
pwd = "5";
else
pwd += ('5');
}
private void button6_Click(object sender, EventArgs e)
{
this.textBox1.AppendText("*");
if (pwd == null)
pwd = "6";
else
pwd += ('6');
}
private void button7_Click(object sender, EventArgs e)
{
this.textBox1.AppendText("*");
if (pwd == null)
pwd = "7";
else
pwd += ('7');
}
private void button8_Click(object sender, EventArgs e)
{
this.textBox1.AppendText("*");
if (pwd == null)
pwd = "8";
else
pwd += ('8');
}
private void button9_Click(object sender, EventArgs e)
{
this.textBox1.AppendText("*");
if (pwd == null)
pwd = "9";
else
pwd += ('9');
}
private void button11_Click(object sender, EventArgs e)
{
this.textBox1.AppendText("*");
if (pwd == null)
pwd = "0";
else
pwd += ('0');
}
private void button12_Click(object sender, EventArgs e)
{
string msg;
if(IsAdmin)msg = "ADMINLOGIN:" + pwd;
else msg = "OPLOGIN:" + pwd;
SendMsg(msg);
pwd = null;
this.Close();
}
private void button10_Click(object sender, EventArgs e)
{
pwd = null;
}
}
}