You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
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 WakeOnLan;
|
|
|
|
|
|
|
|
|
|
namespace Waker
|
|
|
|
|
{
|
|
|
|
|
public partial class MainForm : Form
|
|
|
|
|
{
|
|
|
|
|
private string ip;
|
|
|
|
|
private string mac;
|
|
|
|
|
|
|
|
|
|
public MainForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
InitInstance();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitInstance()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(Settings.Default.ip))
|
|
|
|
|
ip = Settings.Default.ip;
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(Settings.Default.mac))
|
|
|
|
|
mac = Settings.Default.mac;
|
|
|
|
|
|
|
|
|
|
AddressTextBox.KeyUp += TextBox_KeyUp;
|
|
|
|
|
MacTextBox.KeyUp += TextBox_KeyUp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TextBox_KeyUp(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.KeyCode != Keys.Enter)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
WakeButton_Click(sender, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool GetInformation()
|
|
|
|
|
{
|
|
|
|
|
ip = AddressTextBox.Text;
|
|
|
|
|
mac = MacTextBox.Text;
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(ip) || string.IsNullOrEmpty(mac))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
Settings.Default.ip = ip;
|
|
|
|
|
Settings.Default.mac = mac;
|
|
|
|
|
Settings.Default.Save();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void WakeButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!GetInformation())
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Invalid information");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WoL.Wake(ip, mac);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|