Пример #1
0
 private void MPButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         TableHost host = new TableHost("1.1.1.1", 9, "NaN", MacTextBox.Text);
         Dispatcher.Invoke(new Action(() =>
         {
             MagicLabel.Text = BitConverter.ToString(WOL.MagicPacket(host.preparedMac));
         }));
     }
     catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error); }
 }
        private void WakeButton_Click(object sender, RoutedEventArgs e)
        {
            TableHost HostToWake = NewHost();

            if (HostToWake == null)
            {
                return;
            }
            try
            {
                WOL.WakeFunction(HostToWake);
                MessageBox.Show("Magic packet send!", "Ok", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch { MessageBox.Show("Magic packet sending error!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error); }
        }
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            TableHost HostToAdd = NewHost();

            if (HostToAdd == null)
            {
                return;
            }

            Dispatcher.Invoke(new Action(() =>
            {
                _hosts.Add(HostToAdd);
                IPlistView.ItemsSource = null;
                IPlistView.ItemsSource = _hosts;
            }));
        }
Пример #4
0
        public static void WakeFunction(TableHost HostToWake)
        {
            WOLClass client = new WOLClass();

            client.Connect(
                HostToWake.netipAdress, //255.255.255.255 broadcast
                HostToWake.port);       // port=9 is default

            //client.SetClientToBrodcastMode();

            //now send wake up packet
            byte[] packet         = MagicPacket(HostToWake.preparedMac);
            int    reterned_value = client.Send(packet, packet.Length);

            client.Close();
        }