Exemplo n.º 1
0
        //Delete a device
        public void deleteDevice(object sender, RoutedEventArgs e)
        {
            Device device = (Device)this.deviceList.SelectedItem;

            if (device != null && device.NAME != "+")
            {
                this.file.deleteAddress(device, this);
                dataRefresh();
            }
            else
            {
                appMessageBox appMessage = new appMessageBox();
                appMessage.Show();

                appMessage.showMsg("Please select a device");
            }
        }
Exemplo n.º 2
0
        //Send the magic packet
        private void WakeUp(object sender, RoutedEventArgs e)
        {
            Device device = (Device)this.deviceList.SelectedItem;

            if (device != null && device.NAME != "+")
            {
                networkControl      nc = new networkControl();
                notificationService ns = new notificationService();

                nc.wakeUp(device.ADDRESS);
                ns.sendNotification(device.NAME);
            }
            else
            {
                appMessageBox appMessage = new appMessageBox();
                appMessage.Show();

                appMessage.showMsg("Please select a device");
            }
        }
Exemplo n.º 3
0
        //Function that add or update device
        private void editDeviceClick(object sender, RoutedEventArgs e)
        {
            fileControl   file       = new fileControl();
            Regex         r          = new Regex("^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$");
            appMessageBox appMessage = new appMessageBox();

            nameTextBox.BorderBrush    = new SolidColorBrush(Colors.Transparent);
            addressTextBox.BorderBrush = new SolidColorBrush(Colors.Transparent);

            if (nameTextBox.Text == "")
            {
                nameTextBox.BorderBrush = new SolidColorBrush(Colors.Red);
            }
            else if (!r.IsMatch(addressTextBox.Text))
            {
                addressTextBox.BorderBrush = new SolidColorBrush(Colors.Red);
            }
            else
            {
                if (editDeviceButton.Content.ToString() == "Add")
                {
                    file.addAddress(new Device()
                    {
                        ID = file.getAllAddresses().Count, NAME = nameTextBox.Text, ADDRESS = addressTextBox.Text
                    });
                }
                else
                {
                    Device updateDevice = (Device)main.deviceList.SelectedItem;
                    file.updateAddress(new Device()
                    {
                        ID = updateDevice.ID, NAME = nameTextBox.Text, ADDRESS = addressTextBox.Text
                    });
                }
                this.main.dataRefresh();

                this.Close();
            }
        }