base code commit

remotes/origin/master
syneffort 3 years ago
parent b8081b48ea
commit 2e2d2b7487
  1. BIN
      Resource/Designcontest-Ecommerce-Business-Idea.ico
  2. 113
      WoL/Waker/MainForm.Designer.cs
  3. 71
      WoL/Waker/MainForm.cs
  4. 3476
      WoL/Waker/MainForm.resx
  5. 23
      WoL/Waker/Program.cs
  6. 50
      WoL/Waker/Settings.Designer.cs
  7. 12
      WoL/Waker/Settings.settings
  8. 28
      WoL/Waker/Waker.csproj
  9. 31
      WoL/WoL.sln
  10. 7
      WoL/WoL/WakeOnLan.csproj
  11. 62
      WoL/WoL/WoL.cs

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 KiB

@ -0,0 +1,113 @@

namespace Waker
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.AddressTextBox = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.MacTextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.WakeButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// AddressTextBox
//
this.AddressTextBox.Location = new System.Drawing.Point(67, 14);
this.AddressTextBox.Name = "AddressTextBox";
this.AddressTextBox.Size = new System.Drawing.Size(198, 23);
this.AddressTextBox.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 18);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(49, 15);
this.label1.TabIndex = 1;
this.label1.Text = "Address";
//
// MacTextBox
//
this.MacTextBox.Location = new System.Drawing.Point(67, 43);
this.MacTextBox.Name = "MacTextBox";
this.MacTextBox.Size = new System.Drawing.Size(198, 23);
this.MacTextBox.TabIndex = 1;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(21, 47);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(30, 15);
this.label2.TabIndex = 1;
this.label2.Text = "mac";
//
// WakeButton
//
this.WakeButton.Location = new System.Drawing.Point(271, 12);
this.WakeButton.Name = "WakeButton";
this.WakeButton.Size = new System.Drawing.Size(102, 54);
this.WakeButton.TabIndex = 2;
this.WakeButton.Text = "WoL";
this.WakeButton.UseVisualStyleBackColor = true;
this.WakeButton.Click += new System.EventHandler(this.WakeButton_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(383, 79);
this.Controls.Add(this.WakeButton);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.MacTextBox);
this.Controls.Add(this.AddressTextBox);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximumSize = new System.Drawing.Size(399, 118);
this.MinimumSize = new System.Drawing.Size(399, 118);
this.Name = "MainForm";
this.Text = "Waker";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox AddressTextBox;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox MacTextBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button WakeButton;
}
}

@ -0,0 +1,71 @@
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);
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Waker
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}

@ -0,0 +1,50 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 이 코드는 도구를 사용하여 생성되었습니다.
// 런타임 버전:4.0.30319.42000
//
// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
// 이러한 변경 내용이 손실됩니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Waker {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ip {
get {
return ((string)(this["ip"]));
}
set {
this["ip"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string mac {
get {
return ((string)(this["mac"]));
}
set {
this["mac"] = value;
}
}
}
}

@ -0,0 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Waker" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ip" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="mac" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\WoL\WakeOnLan.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32630.194
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WakeOnLan", "WoL\WakeOnLan.csproj", "{F5680AB7-3CE1-432F-9316-62E379C1B01B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Waker", "Waker\Waker.csproj", "{FF6DB830-A614-465D-94F0-789CBF19A65C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F5680AB7-3CE1-432F-9316-62E379C1B01B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5680AB7-3CE1-432F-9316-62E379C1B01B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5680AB7-3CE1-432F-9316-62E379C1B01B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5680AB7-3CE1-432F-9316-62E379C1B01B}.Release|Any CPU.Build.0 = Release|Any CPU
{FF6DB830-A614-465D-94F0-789CBF19A65C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF6DB830-A614-465D-94F0-789CBF19A65C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF6DB830-A614-465D-94F0-789CBF19A65C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FF6DB830-A614-465D-94F0-789CBF19A65C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B9EB3848-310E-46C7-9926-A311F0DFCDA3}
EndGlobalSection
EndGlobal

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>

@ -0,0 +1,62 @@
using System;
using System.Globalization;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text.RegularExpressions;
namespace WakeOnLan
{
public class WoL
{
private const int WOL_PACKET_LEN = 102;
public static void Wake(string ip, string macAddress)
{
byte[] wolBuffer = GetWolPacket(macAddress);
UdpClient udp = new UdpClient();
udp.EnableBroadcast = true;
IPAddress ipAddress = IPAddress.Parse(ip);
udp.Send(wolBuffer, wolBuffer.Length, ipAddress.ToString(), 7);
udp.Send(wolBuffer, wolBuffer.Length, ipAddress.ToString(), 9);
}
private static byte[] GetWolPacket(string macAddress)
{
byte[] datagram = new byte[WOL_PACKET_LEN];
byte[] macBuffer = StringToBytes(macAddress);
using (MemoryStream ms = new MemoryStream(datagram))
{
BinaryWriter bw = new BinaryWriter(ms);
for (int i = 0; i < 6; i++)
{
bw.Write((byte)0xff);
}
for (int i = 0; i < 16; i++)
{
bw.Write(macBuffer, 0, macBuffer.Length);
}
}
return datagram;
}
private static byte[] StringToBytes(string macAddress)
{
macAddress = Regex.Replace(macAddress, "[-|:]", "");
byte[] buffer = new byte[macAddress.Length / 2];
for (int i = 0; i < macAddress.Length; i += 2)
{
string digit = macAddress.Substring(i, 2);
buffer[i / 2] = byte.Parse(digit, NumberStyles.HexNumber);
}
return buffer;
}
}
}
Loading…
Cancel
Save