/// <summary> /// Event handler for when a device list item delete button is clicked. /// </summary> private void DeleteDevice_Click(object sender, RoutedEventArgs e) { InitializeDeleteDevicePopup(); Button deleteDeviceButton = sender as Button; Models.DeviceListItem device = deleteDeviceButton.DataContext as Models.DeviceListItem; DeleteDevices.DeviceToDelete = device; DeleteDevices.PopupTitle = Manager.TranslationService.GetString("devices-remove-popup-title"); DeleteDevices.PopupContent = Manager.TranslationService.GetString("devices-remove-popup-content", UI.Resources.Localization.TranslationService.Args("deviceName", device.Name)); OpenDeleteDevicePopup(); ButtonExtensions.SetMarkForDeletion(deleteDeviceButton, true); DisableDeleteDeviceButton(deleteDeviceButton); currentDeleteButton = deleteDeviceButton; }
private void UpdateDeviceListUI(List <JSONStructures.Device> newDevices) { if (newDevices == null) { return; } var currentDevicePubKey = Manager.Account.Config.FxALogin.PublicKey; var newDeviceList = new List <Models.DeviceListItem>(); foreach (var device in newDevices) { var localCreatedDate = device.CreatedAt.ToLocalTime(); var dateAdded = GetDateAdded(device.CreatedAt); var newDevice = new Models.DeviceListItem { Name = device.Name, Pubkey = device.PublicKey, Created = string.Format("{0} ({1})", dateAdded, localCreatedDate), Added = (device.PublicKey == currentDevicePubKey) ? Manager.TranslationService.GetString("devices-current-device") : dateAdded, CurrentDevice = (device.PublicKey == currentDevicePubKey) ? true : false, }; if (newDevice.CurrentDevice) { newDeviceList.Insert(0, newDevice); } else { newDeviceList.Add(newDevice); } } Manager.MainWindowViewModel.DeviceList = newDeviceList; Manager.MainWindowViewModel.UserNumDevices = newDeviceList.Count(); Manager.MainWindowViewModel.MaxNumDevices = Manager.Account.Config.FxALogin.User.MaxDevices; }