Files
2017-10-26 20:11:00 +02:00

89 lines
2.3 KiB
C#
Executable File

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WoL_Manager
{
public partial class SettingsWindow : Form
{
public SettingsWindow()
{
InitializeComponent();
this.Load += new EventHandler(SettingsWindow_Load);
}
void SettingsWindow_Load(object sender, EventArgs e)
{
OkButton.Click += new EventHandler(OkButton_Click);
ClButton.Click += new EventHandler(CancelButton_Click);
InputPingTimeout.Text = ManagerSettings.PingTimeOut.ToString();
InputPingInterval.Text = ManagerSettings.PingWaitTime.ToString();
InputWakeWaittime.Text = ManagerSettings.WakeWaitTime.ToString();
}
void CancelButton_Click(object sender, EventArgs e)
{
this.Hide();
this.Close();
}
void OkButton_Click(object sender, EventArgs e)
{
int val1, val2, val3;
string temp1 = InputPingTimeout.Text;
string temp2 = InputPingInterval.Text;
string temp3 = InputWakeWaittime.Text;
try
{
val1 = Int32.Parse(temp1);
}
catch (Exception)
{
MessageBox.Show(this, "ERROR: Couldn't parse Ping Timeout!\nShould be a decimal number between 1 and 30000.");
return;
}
try
{
val2 = Int32.Parse(temp2);
}
catch (Exception)
{
MessageBox.Show(this, "ERROR: Couldn't parse Ping Interval!\nShould be a decimal number between 1 and 30000.");
return;
}
try
{
val3 = Int32.Parse(temp3);
}
catch (Exception)
{
MessageBox.Show(this, "ERROR: Couldn't parse Wakeup Waittime!\nShould be a decimal number between 1 and 30000.");
return;
}
if (val1 < 1 || val1 > 30000)
{
MessageBox.Show(this,"Ping Timeout should be between 1 and 30000");
return;
}
if (val2 < 1 || val2 > 30000)
{
MessageBox.Show(this, "Ping Interval should be between 1 and 30000");
return;
}
if (val3 < 1 || val3 > 30000)
{
MessageBox.Show(this, "Wakeup Waittime should be between 1 and 30000");
return;
}
ManagerSettings.PingTimeOut = val1;
ManagerSettings.PingWaitTime = val2;
ManagerSettings.WakeWaitTime = val3;
this.Hide();
this.Close();
}
}
}