示例#1
0
        private async void btn_add_Click(object sender, RoutedEventArgs e)
        {
            AddDeviceDialog     dialog       = new AddDeviceDialog(false);
            ContentDialogResult dialogResult = await dialog.ShowAsync();

            if (dialogResult == ContentDialogResult.Primary)
            {
                currentAppState.Devices.Add(dialog.ViewModel.Device);
                await Startup.StoreAppState(currentAppState);
            }
        }
示例#2
0
        private async void btn_editDevice_Click(object sender, RoutedEventArgs e)
        {
            AddDeviceDialog dialog               = new AddDeviceDialog(true);
            var             selectedDevice       = GetSelectedDevice();
            var             clonedDeviceForEdits = selectedDevice.CloneJson();

            dialog.ViewModel.Device = clonedDeviceForEdits;

            ContentDialogResult dialogResult = await dialog.ShowAsync();

            if (dialogResult == ContentDialogResult.Primary)
            {
                var index = currentAppState.Devices.IndexOf(selectedDevice);
                currentAppState.Devices.Remove(selectedDevice);
                currentAppState.Devices.Insert(index, clonedDeviceForEdits);

                await Startup.StoreAppState(currentAppState);
            }
        }