Пример #1
0
        // Navigate to Characteristic's page, once one has been chosen.
        private void OnCharacteristicSelectionChanged(object sender, RoutedEventArgs e)
        {
            ListBox listBox = (ListBox)sender;

            // Looks like we didn't actually select anything.
            if (listBox.SelectedIndex == -1)
            {
                return;
            }

            // Get the characteristic that we've picked.
            foreach (var listBoxItem in listBox.SelectedItems)
            {
                BECharacteristicVM characteristic = (BECharacteristicVM)listBoxItem;
                GlobalSettings.SelectedCharacteristic = characteristic.CharacteristicM;
            }

            // Go to the characteristic page.
            this.Frame.Navigate(typeof(CharacteristicInfo));

            // Since we're navigating away from a page that may change a service, we should save
            // its dictionary.
            if (ServiceVM.ServiceM.DictionaryModelChanged)
            {
                // This is not critical and doesn't have to block execution
                // Make sure this is done at the end of this function, as it returns
                // once the first blocking call is encountered
                Utilities.RunFuncAsTask(GlobalSettings.ServiceDictionaryUnknown.SaveDictionaryAsync);
            }
        }
        public CharacteristicInfo()
        {
            this.InitializeComponent();   // default init for page object

            // Handle back button press
            this.Loaded += (sender, e) => { HardwareButtons.BackPressed += OnBackPressed; };
            // De-register back button when the page is no longer visible
            this.Unloaded   += (sender, e) => { HardwareButtons.BackPressed -= OnBackPressed; };
            CharacteristicVM = new BECharacteristicVM();
            ServiceVM        = new BEServiceVM();
            DeviceVM         = new BEDeviceVM();
        }
        private async void OnToastSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox listBox = (ListBox)sender;

            if (listBox.SelectedIndex == -1)
            {
                return;
            }

            foreach (var listBoxItem in listBox.SelectedItems)
            {
                BECharacteristicVM characteristicVM = (BECharacteristicVM)listBoxItem;
                await characteristicVM.CharacteristicM.TaskUnregisterForToastAsync();
                ToastListVM.Initialize(GlobalSettings.CharacteristicsWithActiveToast);
            }
        }