Example #1
0
 public async Task <UrlDataPackage> GetRawDataAsync()
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         return(await GetRawDataAsync(Exclusive.Controller));
     }
 }
Example #2
0
 public async Task <bool> UnlockAsync(string Password)
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         return(await Exclusive.Controller.RunAsync("powershell.exe", string.Empty, WindowState.Normal, true, true, true, "-Command", $"$BitlockerSecureString = ConvertTo-SecureString '{Password}' -AsPlainText -Force;", $"Unlock-BitLocker -MountPoint '{DriveFolder.Path}' -Password $BitlockerSecureString"));
     }
 }
Example #3
0
 public async Task <LinkDataPackage> GetLinkDataAsync()
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         return(await Exclusive.Controller.GetLnkDataAsync(Path).ConfigureAwait(true));
     }
 }
Example #4
0
 public virtual async Task CopyAsync(string DirectoryPath, ProgressChangedEventHandler ProgressHandler = null)
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         await Exclusive.Controller.CopyAsync(Path, DirectoryPath, false, ProgressHandler);
     }
 }
Example #5
0
        public static async Task <string> ReplaceVariableAndGetActualPath(string PathWithVariable)
        {
            if (string.IsNullOrWhiteSpace(PathWithVariable))
            {
                return(string.Empty);
            }
            else
            {
                using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
                {
                    string TempString = PathWithVariable;

                    foreach (string Var in Regex.Matches(PathWithVariable, @"(?<=(%))[\s\S]+(?=(%))").Select((Item) => Item.Value).Distinct())
                    {
                        string ActualPath = await Exclusive.Controller.GetVariablePathAsync(Var).ConfigureAwait(false);

                        if (string.IsNullOrWhiteSpace(ActualPath))
                        {
                            throw new System.Exception("ActualPath which get from variable is empty");
                        }
                        else
                        {
                            TempString = TempString.Replace($"%{Var}%", ActualPath);
                        }
                    }

                    return(TempString);
                }
            }
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            ListViewControl.AddHandler(PointerPressedEvent, PointerPressedHandler, true);
            CoreWindow.GetForCurrentThread().KeyDown += RecycleBin_KeyDown;
            SelectionExtention = new ListViewBaseSelectionExtention(ListViewControl, DrawRectangle);

            await ActivateLoading(true, Globalization.GetString("Progress_Tip_Loading"));

            using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
            {
                IReadOnlyList <IRecycleStorageItem> Result = await Exclusive.Controller.GetRecycleBinItemsAsync();

                FileCollection.AddRange(SortCollectionGenerator.GetSortedCollection(Result, SortTarget.Name, SortDirection.Ascending));
            }

            if (FileCollection.Count == 0)
            {
                HasFile.Visibility        = Visibility.Visible;
                ClearRecycleBin.IsEnabled = false;
            }
            else
            {
                HasFile.Visibility        = Visibility.Collapsed;
                ClearRecycleBin.IsEnabled = true;
            }

            await ActivateLoading(false);
        }
Example #7
0
 public virtual async Task DeleteAsync(bool PermanentDelete, ProgressChangedEventHandler ProgressHandler = null)
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         await Exclusive.Controller.DeleteAsync(Path, PermanentDelete, ProgressHandler);
     }
 }
Example #8
0
        public async Task RefreshAsync()
        {
            try
            {
                if (await CheckExistAsync(Path))
                {
                    if (LoadMorePropertiesWithFullTrustProcess())
                    {
                        using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
                        {
                            await LoadMorePropertiesCoreAsync(Exclusive.Controller, true);
                        }
                    }
                    else
                    {
                        await LoadMorePropertiesCoreAsync(true);
                    }

                    OnPropertyChanged(nameof(Size));
                    OnPropertyChanged(nameof(Name));
                    OnPropertyChanged(nameof(ModifiedTime));
                    OnPropertyChanged(nameof(Thumbnail));
                    OnPropertyChanged(nameof(DisplayType));
                }
                else
                {
                    LogTracer.Log($"File/Folder not found or access deny when executing FileSystemStorageItemBase.Update, path: {Path}");
                }
            }
            catch (Exception ex)
            {
                LogTracer.Log(ex, $"An exception was threw when executing FileSystemStorageItemBase.Update, path: {Path}");
            }
        }
Example #9
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            ListViewControl.AddHandler(PointerPressedEvent, PointerPressedHandler, true);
            CoreWindow.GetForCurrentThread().KeyDown += RecycleBin_KeyDown;
            SelectionExtention = new ListViewBaseSelectionExtention(ListViewControl, DrawRectangle);

            using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
            {
                List <IRecycleStorageItem> Result = await Exclusive.Controller.GetRecycleBinItemsAsync().ConfigureAwait(true);

                foreach (IRecycleStorageItem Item in SortCollectionGenerator.Current.GetSortedCollection(Result, SortTarget.Name, SortDirection.Ascending))
                {
                    FileCollection.Add(Item);
                }
            }

            if (FileCollection.Count == 0)
            {
                HasFile.Visibility        = Visibility.Visible;
                ClearRecycleBin.IsEnabled = false;
            }
            else
            {
                HasFile.Visibility        = Visibility.Collapsed;
                ClearRecycleBin.IsEnabled = true;
            }
        }
 public async Task <bool> InvokeAsync()
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         return(await Exclusive.Controller.InvokeContextMenuItemAsync(DataPackage).ConfigureAwait(false));
     }
 }
Example #11
0
 public virtual async Task MoveAsync(string DirectoryPath, ProgressChangedEventHandler ProgressHandler = null, bool IsUndoOperation = false)
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         await Exclusive.Controller.MoveAsync(Path, DirectoryPath, IsUndoOperation, ProgressHandler);
     }
 }
 public static async Task DeleteAsync(IEnumerable <string> SourcePathList, bool PermanentDelete, ProgressChangedEventHandler ProgressHandler = null, bool IsUndoOperation = false)
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         await Exclusive.Controller.DeleteAsync(SourcePathList, PermanentDelete, IsUndoOperation, ProgressHandler).ConfigureAwait(false);
     }
 }
        private async void PickUWP_Click(object sender, RoutedEventArgs e)
        {
            UWPPickerTip.IsOpen        = true;
            UWPLoadingTip.Visibility   = Visibility.Visible;
            PackageListView.Visibility = Visibility.Collapsed;

            using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
            {
                foreach (InstalledApplication Pack in await Exclusive.Controller.GetAllInstalledApplicationAsync())
                {
                    if (!UWPPickerTip.IsOpen)
                    {
                        break;
                    }

                    PackageListViewSource.Add(Pack);
                }
            }

            if (UWPPickerTip.IsOpen)
            {
                await Task.Delay(500);

                UWPLoadingTip.Visibility   = Visibility.Collapsed;
                PackageListView.Visibility = Visibility.Visible;
            }
            else
            {
                PackageListViewSource.Clear();
            }
        }
 public static async Task <string> RenameAsync(string Path, string DesireName)
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         return(await Exclusive.Controller.RenameAsync(Path, DesireName).ConfigureAwait(false));
     }
 }
 public static async Task CopyAsync(string SourcePath, string DirectoryPath, ProgressChangedEventHandler ProgressHandler = null, bool IsUndoOperation = false)
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         await Exclusive.Controller.CopyAsync(SourcePath, DirectoryPath, IsUndoOperation, ProgressHandler).ConfigureAwait(false);
     }
 }
 public async Task <HiddenDataPackage> GetRawDataAsync()
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         return(await Exclusive.Controller.GetHiddenItemDataAsync(Path));
     }
 }
Example #17
0
 public async Task <bool> RestoreAsync()
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         return(await Exclusive.Controller.RestoreItemInRecycleBinAsync(OriginPath).ConfigureAwait(true));
     }
 }
 public virtual async Task MoveAsync(string DirectoryPath, CollisionOptions Option = CollisionOptions.None, ProgressChangedEventHandler ProgressHandler = null)
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         await Exclusive.Controller.MoveAsync(Path, DirectoryPath, Option, false, ProgressHandler);
     }
 }
Example #19
0
 public async Task Invoke()
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         await Exclusive.Controller.InvokeContextMenuItemAsync(this).ConfigureAwait(false);
     }
 }
Example #20
0
 public async Task <bool> DeleteAsync()
 {
     using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
     {
         return(await Exclusive.Controller.DeleteItemInRecycleBinAsync(Path));
     }
 }
Example #21
0
        public async Task LaunchAsync()
        {
            try
            {
                using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
                {
                    if (LinkType == ShellLinkType.Normal)
                    {
                        if (!await Exclusive.Controller.RunAsync(LinkTargetPath, WorkDirectory, WindowState, NeedRunAsAdmin, false, false, Arguments))
                        {
                            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                            {
                                QueueContentDialog Dialog = new QueueContentDialog
                                {
                                    Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
                                    Content         = Globalization.GetString("QueueDialog_LaunchFailed_Content"),
                                    CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
                                };

                                await Dialog.ShowAsync();
                            });
                        }
                    }
                    else
                    {
                        if (!await Exclusive.Controller.LaunchUWPFromPfnAsync(LinkTargetPath))
                        {
                            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                            {
                                QueueContentDialog Dialog = new QueueContentDialog
                                {
                                    Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
                                    Content         = Globalization.GetString("QueueDialog_LaunchFailed_Content"),
                                    CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
                                };

                                await Dialog.ShowAsync();
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogTracer.Log(ex);

                await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    QueueContentDialog Dialog = new QueueContentDialog
                    {
                        Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
                        Content         = Globalization.GetString("QueueDialog_LaunchFailed_Content"),
                        CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
                    };

                    await Dialog.ShowAsync();
                });
            }
        }
Example #22
0
        public async virtual Task <string> RenameAsync(string DesireName)
        {
            using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
            {
                string NewName = await Exclusive.Controller.RenameAsync(Path, DesireName);

                Path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Path), NewName);
                return(NewName);
            }
        }
Example #23
0
        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);
                }
            }
        }
        private async void TabViewContainer_KeyDown(CoreWindow sender, KeyEventArgs args)
        {
            if (!QueueContentDialog.IsRunningOrWaiting)
            {
                CoreVirtualKeyStates CtrlState = sender.GetKeyState(VirtualKey.Control);

                switch (args.VirtualKey)
                {
                case VirtualKey.W when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                {
                    if (TabViewControl.SelectedItem is TabViewItem Tab)
                    {
                        args.Handled = true;

                        await CleanUpAndRemoveTabItem(Tab);
                    }

                    return;
                }
                }

                if (CurrentNavigationControl?.Content is ThisPC PC)
                {
                    switch (args.VirtualKey)
                    {
                    case VirtualKey.T when CtrlState.HasFlag(CoreVirtualKeyStates.Down):
                    {
                        await CreateNewTabAsync();

                        args.Handled = true;

                        break;
                    }

                    case VirtualKey.Space when SettingControl.IsQuicklookEnable:
                    {
                        using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
                        {
                            if (await Exclusive.Controller.CheckIfQuicklookIsAvaliableAsync())
                            {
                                if (PC.DeviceGrid.SelectedItem is DriveRelatedData Device && !string.IsNullOrEmpty(Device.Folder.Path))
                                {
                                    await Exclusive.Controller.ViewWithQuicklookAsync(Device.Folder.Path);
                                }
                                else if (PC.LibraryGrid.SelectedItem is LibraryFolder Library && !string.IsNullOrEmpty(Library.Folder.Path))
                                {
                                    await Exclusive.Controller.ViewWithQuicklookAsync(Library.Folder.Path);
                                }
                            }
                        }

                        args.Handled = true;

                        break;
                    }
Example #25
0
        private async void EjectButton_Click(object sender, RoutedEventArgs e)
        {
            if (DeviceGrid.SelectedItem is DriveDataBase Item)
            {
                if (string.IsNullOrEmpty(Item.Path))
                {
                    QueueContentDialog Dialog = new QueueContentDialog
                    {
                        Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
                        Content         = Globalization.GetString("QueueContentDialog_UnableToEject_Content"),
                        CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
                    };

                    await Dialog.ShowAsync().ConfigureAwait(false);
                }
                else
                {
                    foreach ((TabViewItem Tab, BladeItem[] Blades) in TabViewContainer.ThisPage.TabCollection.Where((Tab) => Tab.Tag is FileControl)
                             .Select((Tab) => (Tab, (Tab.Tag as FileControl).BladeViewer.Items.Cast <BladeItem>().ToArray())).ToArray())
                    {
                        if (Blades.Select((BItem) => (BItem.Content as FilePresenter)?.CurrentFolder?.Path)
                            .All((BladePath) => Item.Path.Equals(Path.GetPathRoot(BladePath), StringComparison.OrdinalIgnoreCase)))
                        {
                            await TabViewContainer.ThisPage.CleanUpAndRemoveTabItem(Tab);
                        }
                        else
                        {
                            foreach (BladeItem BItem in Blades.Where((BItem) => Item.Path.Equals(Path.GetPathRoot((BItem.Content as FilePresenter)?.CurrentFolder?.Path))))
                            {
                                await(Tab.Tag as FileControl).CloseBladeAsync(BItem);
                            }
                        }
                    }

                    using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
                    {
                        if (await Exclusive.Controller.EjectPortableDevice(Item.Path))
                        {
                            ShowEjectNotification();
                        }
                        else
                        {
                            QueueContentDialog Dialog = new QueueContentDialog
                            {
                                Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
                                Content         = Globalization.GetString("QueueContentDialog_UnableToEject_Content"),
                                CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
                            };

                            await Dialog.ShowAsync().ConfigureAwait(false);
                        }
                    }
                }
            }
        }
        private async void PermanentDelete_Click(object sender, RoutedEventArgs e)
        {
            if (ListViewControl.SelectedItems.Count > 0)
            {
                await ActivateLoading(true, Globalization.GetString("RecycleBinDeleteText")).ConfigureAwait(true);

                QueueContentDialog QueueContenDialog = new QueueContentDialog
                {
                    Title             = Globalization.GetString("Common_Dialog_WarningTitle"),
                    Content           = Globalization.GetString("QueueDialog_DeleteFile_Content"),
                    PrimaryButtonText = Globalization.GetString("Common_Dialog_ContinueButton"),
                    CloseButtonText   = Globalization.GetString("Common_Dialog_CancelButton")
                };

                if ((await QueueContenDialog.ShowAsync().ConfigureAwait(true)) == ContentDialogResult.Primary)
                {
                    List <string> ErrorList = new List <string>();

                    using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
                    {
                        foreach (RecycleStorageItem Item in ListViewControl.SelectedItems.ToList())
                        {
                            if (await Exclusive.Controller.DeleteItemInRecycleBinAsync(Item.Path).ConfigureAwait(true))
                            {
                                FileCollection.Remove(Item);
                            }
                            else
                            {
                                ErrorList.Add(Item.Name);
                            }
                        }
                    }

                    if (ErrorList.Count > 0)
                    {
                        QueueContentDialog Dialog = new QueueContentDialog
                        {
                            Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
                            Content         = $"{Globalization.GetString("QueueDialog_RecycleBinDeleteError_Content")} {Environment.NewLine}{string.Join(Environment.NewLine, ErrorList)}",
                            CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
                        };
                        _ = Dialog.ShowAsync().ConfigureAwait(true);
                    }
                }

                await ActivateLoading(false).ConfigureAwait(true);

                if (FileCollection.Count == 0)
                {
                    HasFile.Visibility        = Visibility.Visible;
                    ClearRecycleBin.IsEnabled = false;
                }
            }
        }
Example #27
0
        private async void QuickStartGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (e.ClickedItem is QuickStartItem Item)
            {
                if ((sender as GridView).Name == nameof(QuickStartGridView))
                {
                    Uri Ur = new Uri(Item.Protocol);

                    if (Ur.IsFile)
                    {
                        if (WIN_Native_API.CheckExist(Item.Protocol))
                        {
                            using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
                            {
                                try
                                {
                                    if (Path.GetExtension(Item.Protocol).ToLower() == ".msc")
                                    {
                                        await Exclusive.Controller.RunAsync("powershell.exe", false, true, false, "-Command", Item.Protocol).ConfigureAwait(true);
                                    }
                                    else
                                    {
                                        await Exclusive.Controller.RunAsync(Item.Protocol).ConfigureAwait(true);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    LogTracer.Log(ex, "Could not execute program in quick start");
                                }
                            }
                        }
                        else
                        {
                            QueueContentDialog Dialog = new QueueContentDialog
                            {
                                Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
                                Content         = Globalization.GetString("QueueDialog_ApplicationNotFound_Content"),
                                CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
                            };
                            _ = await Dialog.ShowAsync().ConfigureAwait(true);
                        }
                    }
                    else
                    {
                        await Launcher.LaunchUriAsync(Ur);
                    }
                }
                else
                {
                    await Launcher.LaunchUriAsync(new Uri(Item.Protocol));
                }
            }
        }
Example #28
0
        private async void DeviceGrid_ItemClick(object sender, ItemClickEventArgs e)
        {
            LibraryGrid.SelectedIndex = -1;

            if (!SettingControl.IsDoubleClickEnable && e.ClickedItem is DriveRelatedData Device)
            {
                if (Device.IsLockedByBitlocker)
                {
Retry:
                    BitlockerPasswordDialog Dialog = new BitlockerPasswordDialog();

                    if (await Dialog.ShowAsync() == ContentDialogResult.Primary)
                    {
                        using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
                        {
                            await Exclusive.Controller.RunAsync("powershell.exe", string.Empty, WindowState.Normal, true, true, true, "-Command", $"$BitlockerSecureString = ConvertTo-SecureString '{Dialog.Password}' -AsPlainText -Force;", $"Unlock-BitLocker -MountPoint '{Device.Folder.Path}' -Password $BitlockerSecureString");
                        }

                        StorageFolder DriveFolder = await StorageFolder.GetFolderFromPathAsync(Device.Folder.Path);

                        DriveRelatedData NewDevice = await DriveRelatedData.CreateAsync(DriveFolder, Device.DriveType);

                        if (!NewDevice.IsLockedByBitlocker)
                        {
                            int Index = CommonAccessCollection.DriveList.IndexOf(Device);
                            CommonAccessCollection.DriveList.Remove(Device);
                            CommonAccessCollection.DriveList.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() == ContentDialogResult.Primary)
                            {
                                goto Retry;
                            }
                        }
                    }
                }
                else
                {
                    await OpenTargetFolder(Device.Folder).ConfigureAwait(false);
                }
            }
        }
Example #29
0
 public static async Task <string> TranslateVariable(string Variable)
 {
     if (string.IsNullOrWhiteSpace(Variable))
     {
         return(string.Empty);
     }
     else
     {
         using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
         {
             return(await Exclusive.Controller.GetVariablePathAsync(Variable.Trim('%')).ConfigureAwait(false));
         }
     }
 }
Example #30
0
        protected override async void OnWindowCreated(WindowCreatedEventArgs args)
        {
            MSStoreHelper.Current.PreLoadAppLicense();

            using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
            {
                if (await Exclusive.Controller.CheckIfQuicklookIsAvaliableAsync().ConfigureAwait(true))
                {
                    SettingControl.IsQuicklookAvailable = true;
                }
                else
                {
                    SettingControl.IsQuicklookAvailable = false;
                }
            }
        }