예제 #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();
        }
예제 #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;
        }
예제 #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");
        }
예제 #4
0
        public async void RefreshList()
        {
            MyAzureClass myAzureClass = new MyAzureClass();

            list = await myAzureClass.GetDevices();

            DeviceList.ItemsSource = null;
            DeviceList.ItemsSource = list;
        }
예제 #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;
        }
예제 #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;
        }
예제 #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;
        }