Initial commit
This commit is contained in:
Executable
+99
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WoL_Manager
|
||||
{
|
||||
class EditHostWindow : NewHostWindow
|
||||
{
|
||||
private Host host;
|
||||
|
||||
public EditHostWindow(Host h) : base()
|
||||
{
|
||||
host = h;
|
||||
this.Text = "Edit Host";
|
||||
InputName.Text = host.Name;
|
||||
InputIP.Text = host.IP.ToString();
|
||||
InputBroadcast.Text = host.Broadcast.ToString();
|
||||
InputMAC.Text = host.MAC;
|
||||
InputDescription.Text = host.Description;
|
||||
}
|
||||
|
||||
protected override void NewHostWindow_Load(object sender, EventArgs e)
|
||||
{
|
||||
OkButton1.Click += new System.EventHandler(this.buttonEventHandler);
|
||||
CancelButton1.Click += new System.EventHandler(this.buttonEventHandler);
|
||||
}
|
||||
|
||||
protected override void buttonEventHandler(object sender, EventArgs e)
|
||||
{
|
||||
if (sender == OkButton1)
|
||||
{
|
||||
string name = InputName.Text.Trim();
|
||||
if (name.Length < 1)
|
||||
{
|
||||
MessageBox.Show("There is no name given!", "ERROR", MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
string mac = InputMAC.Text.Trim().ToUpper();
|
||||
if (!MainWindow.checkMAC(mac))
|
||||
{
|
||||
MessageBox.Show("Wasn't able to parse MAC-Address!\nShould be like this: 00AF2C4323D3",
|
||||
"ERROR", MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
string description = InputDescription.Text;
|
||||
System.Net.IPAddress ip_addr;
|
||||
System.Net.IPAddress bc_addr;
|
||||
try
|
||||
{
|
||||
ip_addr = System.Net.IPAddress.Parse(InputIP.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Wasn't able to parse IP-Address!\nShould be like this: 192.168.0.1",
|
||||
"ERROR", MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
bc_addr = System.Net.IPAddress.Parse(InputBroadcast.Text);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Wasn't able to parse Broadcast-Address!\nShould be like this: 192.168.0.255",
|
||||
"ERROR", MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
|
||||
host.Name = name;
|
||||
host.IP = ip_addr;
|
||||
host.Broadcast = bc_addr;
|
||||
host.MAC = mac;
|
||||
host.Description = description;
|
||||
host.pingThread.stopThread();
|
||||
host.pingThread = null;
|
||||
}
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// EditHostWindow
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(355, 257);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Name = "EditHostWindow";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user