Example #1
0
        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();
        }
Example #2
0
        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;
        }
Example #3
0
        private void DeviceStatusButton_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            MainDevice.Status = true;
            MyAzureClass myAzureClass = new MyAzureClass();

            myAzureClass.UpdateRecordInTable(MainDevice);
            AzureIoTHub.SendDeviceToCloudMessageAsync();
            Debug.WriteLine("Button Pressed");
        }
Example #4
0
        public async void RefreshList()
        {
            MyAzureClass myAzureClass = new MyAzureClass();

            list = await myAzureClass.GetDevices();

            DeviceList.ItemsSource = null;
            DeviceList.ItemsSource = list;
        }
Example #5
0
        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;
        }
Example #6
0
        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;
        }
Example #7
0
        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;
        }