private void WakeUp(WakeOnLANInfo info)
        {
            DisplayStatusMessage = false;
            IsSending            = true;

            try
            {
                WakeOnLAN.Send(info);

                // DEBUG
                //await Task.Delay(5000);

                StatusMessage        = LocalizationManager.GetStringByKey("String_MagicPacketSuccessfulSended");
                DisplayStatusMessage = true;
            }
            catch (Exception ex)
            {
                StatusMessage        = ex.Message;
                DisplayStatusMessage = true;
            }
            finally
            {
                IsSending = false;
            }
        }
示例#2
0
        private void WakeUpAction()
        {
            DisplayStatusMessage = false;
            StatusMessage        = string.Empty;

            try
            {
                WakeOnLANInfo info = new WakeOnLANInfo
                {
                    MagicPacket = MagicPacketHelper.Create(MACAddress),
                    Broadcast   = IPAddress.Parse(Broadcast),
                    Port        = Port
                };

                WakeOnLAN.Send(info);

                StatusMessage        = Application.Current.Resources["String_MagicPacketSuccessfulSended"] as string;
                DisplayStatusMessage = true;
            }
            catch (Exception ex)
            {
                StatusMessage        = ex.Message;
                DisplayStatusMessage = true;
            }
        }
        public void WakeUpSelectedClientsAction()
        {
            DisplayStatusMessage = false;
            StatusMessage        = string.Empty;

            int errorCount = 0;

            foreach (WakeOnLANClientInfo template in SelectedWakeOnLANClients)
            {
                try
                {
                    WakeOnLANInfo info = new WakeOnLANInfo
                    {
                        MagicPacket = MagicPacketHelper.Create(template.MACAddress),
                        Broadcast   = IPAddress.Parse(template.Broadcast),
                        Port        = template.Port
                    };

                    WakeOnLAN.Send(info);
                }
                catch (Exception ex)
                {
                    errorCount++;

                    if (!string.IsNullOrEmpty(StatusMessage))
                    {
                        StatusMessage += Environment.NewLine;
                    }

                    StatusMessage       += ex.Message;
                    DisplayStatusMessage = true;
                }
            }

            if (SelectedWakeOnLANClients.Count == 1)
            {
                StatusMessage        = Application.Current.Resources["String_MagicPacketSuccessfulSended"] as string;
                DisplayStatusMessage = true;
            }

            if (SelectedWakeOnLANClients.Count > 1 && SelectedWakeOnLANClients.Count != errorCount)
            {
                StatusMessage        = string.Format(Application.Current.Resources["String_MagicPacketSuccessfulSendedToClients"] as string, SelectedWakeOnLANClients.Count - errorCount);
                DisplayStatusMessage = true;
            }
        }
        private void WakeUp(WakeOnLANInfo info)
        {
            DisplayStatusMessage = false;
            StatusMessage        = string.Empty;

            try
            {
                WakeOnLAN.Send(info);

                StatusMessage        = Application.Current.Resources["String_MagicPacketSuccessfulSended"] as string;
                DisplayStatusMessage = true;
            }
            catch (Exception ex)
            {
                StatusMessage        = ex.Message;
                DisplayStatusMessage = true;
            }
        }
        private async void WakeUp(WakeOnLANInfo info)
        {
            DisplayStatusMessage = false;
            IsSending            = true;

            try
            {
                WakeOnLAN.Send(info);

                await Task.Delay(2000); // Make the user happy, let him see a reload animation (and he cannot spam the send command)

                StatusMessage        = LocalizationManager.GetStringByKey("String_MagicPacketSuccessfulSended");
                DisplayStatusMessage = true;
            }
            catch (Exception ex)
            {
                StatusMessage        = ex.Message;
                DisplayStatusMessage = true;
            }
            finally
            {
                IsSending = false;
            }
        }