private void UpdateDevice_Click(object sender, RoutedEventArgs e) { AzureDevices SelectedDevice = (AzureDevices)DeviceList.SelectedItems[0]; if (TrueRadio.IsChecked.Value) { SelectedDevice.Status = true; } else { SelectedDevice.Status = false; } var index = DeviceList.Items.IndexOf(DeviceList.SelectedItem); list.RemoveAt(index); list.Insert(index, SelectedDevice); /* DeviceList.ItemsSource = null; * DeviceList.ItemsSource = list;*/ MyAzureClass myAzureClass = new MyAzureClass(); myAzureClass.UpdateRecordInTable(SelectedDevice); AzureIoTHub.SendDeviceToCloudMessageAsync(); }
private async void AddDeviceBtn_Click(object sender, RoutedEventArgs e) { MyAzureClass myAzureClass = new MyAzureClass(); var AddedDevice = await myAzureClass.AddDeviceToCloud(AddDeviceBox.Text, StatusCheck.IsChecked.Value); list.Add(AddedDevice); DeviceList.ItemsSource = null; DeviceList.ItemsSource = list; }
private void DeviceStatusButton_PointerPressed(object sender, PointerRoutedEventArgs e) { MainDevice.Status = true; MyAzureClass myAzureClass = new MyAzureClass(); myAzureClass.UpdateRecordInTable(MainDevice); AzureIoTHub.SendDeviceToCloudMessageAsync(); Debug.WriteLine("Button Pressed"); }
public async void RefreshList() { MyAzureClass myAzureClass = new MyAzureClass(); list = await myAzureClass.GetDevices(); DeviceList.ItemsSource = null; DeviceList.ItemsSource = list; }
private async void GetDevicesButton_Click(object sender, RoutedEventArgs e) { MyAzureClass myAzureClass = new MyAzureClass(); list = await myAzureClass.GetDevices(); foreach (AzureDevices device in list) { Debug.WriteLine("Device ID: " + device.DeviceId); } DeviceList.ItemsSource = list; }
private void DeleteDeviceButton_Click(object sender, RoutedEventArgs e) { //int Index = DeviceList.SelectedIndex; AzureDevices SelectedDevice = (AzureDevices)DeviceList.SelectedItems[0]; MyAzureClass myAzureClass = new MyAzureClass(); myAzureClass.DeleteRecordinTable(SelectedDevice.DeviceId); var index = DeviceList.Items.IndexOf(DeviceList.SelectedItem); list.RemoveAt(index); DeviceList.ItemsSource = null; DeviceList.ItemsSource = list; }
public MainPage() { this.InitializeComponent(); var sender = new object(); var e = new RoutedEventArgs(); GetDevicesButton_Click(sender, e); ListenForMessages(); MyAzureClass myAzureClass = new MyAzureClass(); Task.Run(async() => { MainDevice = await myAzureClass.AddDeviceToCloud(MainDevice.DeviceId, MainDevice.Status); }).GetAwaiter().GetResult(); //AsyncContext.Run(() => ); while (MainDevice.PartitionKey == null) { } DeviceStatusButton.IsEnabled = true; }