private async void DeviceGrid_ItemClick(object sender, ItemClickEventArgs e) { LibraryGrid.SelectedIndex = -1; if (!SettingControl.IsDoubleClickEnable && e.ClickedItem is HardDeviceInfo Device) { if (Device.IsLockedByBitlocker) { Retry: BitlockerPasswordDialog Dialog = new BitlockerPasswordDialog(); if (await Dialog.ShowAsync().ConfigureAwait(true) == ContentDialogResult.Primary) { using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController()) { await Exclusive.Controller.RunAsync("powershell.exe", true, true, true, "-Command", $"$BitlockerSecureString = ConvertTo-SecureString '{Dialog.Password}' -AsPlainText -Force;", $"Unlock-BitLocker -MountPoint '{Device.Folder.Path}' -Password $BitlockerSecureString").ConfigureAwait(true); } StorageFolder DeviceFolder = await StorageFolder.GetFolderFromPathAsync(Device.Folder.Path); BasicProperties Properties = await DeviceFolder.GetBasicPropertiesAsync(); IDictionary <string, object> PropertiesRetrieve = await Properties.RetrievePropertiesAsync(new string[] { "System.Capacity", "System.FreeSpace", "System.Volume.FileSystem", "System.Volume.BitLockerProtection" }); HardDeviceInfo NewDevice = new HardDeviceInfo(DeviceFolder, await DeviceFolder.GetThumbnailBitmapAsync().ConfigureAwait(true), PropertiesRetrieve, Device.DriveType); if (!NewDevice.IsLockedByBitlocker) { int Index = CommonAccessCollection.HardDeviceList.IndexOf(Device); CommonAccessCollection.HardDeviceList.Remove(Device); CommonAccessCollection.HardDeviceList.Insert(Index, NewDevice); } else { QueueContentDialog UnlockFailedDialog = new QueueContentDialog { Title = Globalization.GetString("Common_Dialog_ErrorTitle"), Content = Globalization.GetString("QueueDialog_UnlockBitlockerFailed_Content"), PrimaryButtonText = Globalization.GetString("Common_Dialog_RetryButton"), CloseButtonText = Globalization.GetString("Common_Dialog_CancelButton") }; if (await UnlockFailedDialog.ShowAsync().ConfigureAwait(true) == ContentDialogResult.Primary) { goto Retry; } } } } else { await OpenTargetFolder(Device.Folder).ConfigureAwait(false); } } }
public DeviceInfoDialog(HardDeviceInfo Device) { InitializeComponent(); this.Device = Device ?? throw new ArgumentNullException(nameof(Device), "Parameter could not be null"); DeviceName.Text = Device.Name; Thumbnail.Source = Device.Thumbnail; FreeByte.Text = $"{Device.FreeByte:N0} {Globalization.GetString("Device_Capacity_Unit")}"; TotalByte.Text = $"{Device.TotalByte:N0} {Globalization.GetString("Device_Capacity_Unit")}"; UsedByte.Text = $"{Device.TotalByte - Device.FreeByte:N0} {Globalization.GetString("Device_Capacity_Unit")}"; FreeSpace.Text = Device.FreeSpace; TotalSpace.Text = Device.Capacity; UsedSpace.Text = (Device.TotalByte - Device.FreeByte).ToFileSizeDescription(); switch (Device.DriveType) { case DriveType.Fixed: { DeviceType.Text = Globalization.GetString("Device_Type_1"); break; } case DriveType.Removable: { DeviceType.Text = Globalization.GetString("Device_Type_3"); break; } case DriveType.Ram: { DeviceType.Text = Globalization.GetString("Device_Type_4"); break; } default: { DeviceType.Text = Globalization.GetString("Device_Type_5"); break; } } FileSystem.Text = Device.FileSystem; Loaded += DeviceInfoDialog_Loaded; }
public DeviceInfoDialog(HardDeviceInfo Device) { InitializeComponent(); this.Device = Device ?? throw new ArgumentNullException(nameof(Device), "Parameter could not be null"); DeviceName.Text = Device.Name; Thumbnail.Source = Device.Thumbnail; string Unit = Globalization.GetString("Device_Capacity_Unit"); FreeByte.Text = $"{Device.FreeByte:N0} {Unit}"; TotalByte.Text = $"{Device.TotalByte:N0} {Unit}"; UsedByte.Text = $"{Device.TotalByte - Device.FreeByte:N0} {Unit}"; FreeSpace.Text = Device.FreeSpace; TotalSpace.Text = Device.Capacity; UsedSpace.Text = GetSizeDescription(Device.TotalByte - Device.FreeByte); Loaded += DeviceInfoDialog_Loaded; }