Exemplo n.º 1
0
        private async void UnlockBitlocker_Click(object sender, RoutedEventArgs e)
        {
            if (DeviceGrid.SelectedItem is HardDeviceInfo Device)
            {
Retry:
                BitlockerPasswordDialog Dialog = new BitlockerPasswordDialog();

                if (await Dialog.ShowAsync().ConfigureAwait(true) == ContentDialogResult.Primary)
                {
                    await FullTrustProcessController.Current.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;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private async void DeleteFile_Click(object sender, RoutedEventArgs e)
        {
            if (SecureGridView.SelectedItem is FileSystemStorageItem Item)
            {
                QueueContentDialog Dialog = new QueueContentDialog
                {
                    Title             = Globalization.GetString("Common_Dialog_WarningTitle"),
                    PrimaryButtonText = Globalization.GetString("Common_Dialog_ContinueButton"),
                    Content           = Globalization.GetString("QueueDialog_DeleteFile_Content"),
                    CloseButtonText   = Globalization.GetString("Common_Dialog_CancelButton")
                };

                if ((await Dialog.ShowAsync().ConfigureAwait(true)) == ContentDialogResult.Primary)
                {
                    await(await Item.GetStorageItem().ConfigureAwait(true)).DeleteAsync(StorageDeleteOption.PermanentDelete);
                    SecureCollection.Remove(Item);
                }
            }
        }
Exemplo n.º 3
0
        public VideoMergeDialog(StorageFile SourceFile)
        {
            InitializeComponent();
            this.SourceFile = SourceFile;

            EncodingProfile.Items.Add($"MP4(.mp4) {Globalization.GetString("Video_Dialog_Encoding_Text")}");
            EncodingProfile.Items.Add($"WMV(.wmv) {Globalization.GetString("Video_Dialog_Encoding_Text")}");
            EncodingProfile.Items.Add($"MKV(.mkv) {Globalization.GetString("Video_Dialog_Encoding_Text")}");

            EncodingQuality.Items.Add("2160p");
            EncodingQuality.Items.Add("1080p");
            EncodingQuality.Items.Add("720p");
            EncodingQuality.Items.Add("480p");

            EncodingProfile.SelectedIndex = 0;
            EncodingQuality.SelectedIndex = 0;

            Loading += VideoMergeDialog_Loading;
        }
Exemplo n.º 4
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 in TabViewContainer.ThisPage.TabCollection.Where((Tab) => (Tab.Content as Frame).CurrentSourcePageType != typeof(ThisPC) && Tab.Tag is FileControl Control && Path.GetPathRoot(Control.CurrentPresenter.CurrentFolder?.Path).Equals(Item.Path, StringComparison.OrdinalIgnoreCase)).ToArray())
                    {
                        await TabViewContainer.ThisPage.CleanUpAndRemoveTabItem(Tab);
                    }

                    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);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void Initialize(bool ShouldDisplayGzip)
        {
            CType.Items.Add("Zip");
            CType.Items.Add("Tar");

            if (ShouldDisplayGzip)
            {
                CType.Items.Add("GZip");
                CType.Items.Add("BZip2");
            }

            CType.SelectedIndex = 0;

            CompressLevel.Items.Add(Globalization.GetString("Compression_Dialog_Level_1"));
            CompressLevel.Items.Add(Globalization.GetString("Compression_Dialog_Level_2"));
            CompressLevel.Items.Add(Globalization.GetString("Compression_Dialog_Level_3"));

            CompressLevel.SelectedIndex = 1;
        }
Exemplo n.º 6
0
        private async void PermanentDelete_Click(object sender, RoutedEventArgs e)
        {
            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>();

                foreach (RecycleStorageItem Item in ListViewControl.SelectedItems)
                {
                    if (await FullTrustExcutorController.Current.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);
        }
Exemplo n.º 7
0
 private async void Delete_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         PhotoDisplaySupport Item = PhotoCollection[Flip.SelectedIndex];
         Item.PhotoFile.PermanentDelete();
         PhotoCollection.Remove(Item);
         Behavior.InitAnimation(InitOption.Full);
     }
     catch (Exception)
     {
         QueueContentDialog dialog = new QueueContentDialog
         {
             Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
             Content         = Globalization.GetString("QueueDialog_DeleteItemError_Content"),
             CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
         };
         _ = await dialog.ShowAsync().ConfigureAwait(true);
     }
 }
Exemplo n.º 8
0
        private async void Attribute_Click(object sender, RoutedEventArgs e)
        {
            if (SearchResultList.SelectedItem is FileSystemStorageItemBase Item)
            {
                AppWindow NewWindow = await AppWindow.TryCreateAsync();

                NewWindow.RequestSize(new Size(420, 600));
                NewWindow.RequestMoveRelativeToCurrentViewContent(new Point(Window.Current.Bounds.Width / 2 - 200, Window.Current.Bounds.Height / 2 - 300));
                NewWindow.PersistedStateId = "Properties";
                NewWindow.Title            = Globalization.GetString("Properties_Window_Title");
                NewWindow.TitleBar.ExtendsContentIntoTitleBar    = true;
                NewWindow.TitleBar.ButtonBackgroundColor         = Colors.Transparent;
                NewWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

                ElementCompositionPreview.SetAppWindowContent(NewWindow, new PropertyBase(NewWindow, Item));
                WindowManagementPreview.SetPreferredMinSize(NewWindow, new Size(420, 600));

                await NewWindow.TryShowAsync();
            }
        }
Exemplo n.º 9
0
        private void ShowEjectNotification()
        {
            try
            {
                ToastNotificationManager.History.Remove("MergeVideoNotification");

                ToastContentBuilder Builder = new ToastContentBuilder()
                                              .SetToastScenario(ToastScenario.Default)
                                              .AddToastActivationInfo("Transcode", ToastActivationType.Foreground)
                                              .AddText(Globalization.GetString("Eject_Toast_Text_1"))
                                              .AddText(Globalization.GetString("Eject_Toast_Text_2"))
                                              .AddText(Globalization.GetString("Eject_Toast_Text_3"));

                ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(Builder.GetToastContent().GetXml()));
            }
            catch (Exception ex)
            {
                LogTracer.Log(ex, "Toast notification could not be sent");
            }
        }
Exemplo n.º 10
0
        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;
        }
Exemplo n.º 11
0
        public async Task OpenTargetFolder(StorageFolder Folder)
        {
            if (Folder == null)
            {
                throw new ArgumentNullException(nameof(Folder), "Argument could not be null");
            }

            try
            {
                if (string.IsNullOrEmpty(Folder.Path))
                {
                    QueueContentDialog Dialog = new QueueContentDialog
                    {
                        Title             = Globalization.GetString("Common_Dialog_TipTitle"),
                        Content           = Globalization.GetString("QueueDialog_MTP_CouldNotAccess_Content"),
                        PrimaryButtonText = Globalization.GetString("Common_Dialog_ContinueButton"),
                        CloseButtonText   = Globalization.GetString("Common_Dialog_CancelButton")
                    };

                    if ((await Dialog.ShowAsync().ConfigureAwait(true)) == ContentDialogResult.Primary)
                    {
                        await Launcher.LaunchFolderAsync(Folder);
                    }
                }
                else
                {
                    if (AnimationController.Current.IsEnableAnimation)
                    {
                        Frame.Navigate(typeof(FileControl), new Tuple <WeakReference <TabViewItem>, StorageFolder>(WeakToTabItem, Folder), new DrillInNavigationTransitionInfo());
                    }
                    else
                    {
                        Frame.Navigate(typeof(FileControl), new Tuple <WeakReference <TabViewItem>, StorageFolder>(WeakToTabItem, Folder), new SuppressNavigationTransitionInfo());
                    }
                }
            }
            catch (Exception ex)
            {
                LogTracer.Log(ex, "An error was threw when entering device");
            }
        }
Exemplo n.º 12
0
        private async void ClearRecycleBin_Click(object sender, RoutedEventArgs e)
        {
            QueueContentDialog Dialog = new QueueContentDialog
            {
                Title             = Globalization.GetString("Common_Dialog_WarningTitle"),
                Content           = Globalization.GetString("QueueDialog_EmptyRecycleBin_Content"),
                PrimaryButtonText = Globalization.GetString("Common_Dialog_ContinueButton"),
                CloseButtonText   = Globalization.GetString("Common_Dialog_CancelButton")
            };

            if (await Dialog.ShowAsync().ConfigureAwait(true) == ContentDialogResult.Primary)
            {
                await ActivateLoading(true, Globalization.GetString("RecycleBinEmptyingText")).ConfigureAwait(true);

                using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
                {
                    if (await Exclusive.Controller.EmptyRecycleBinAsync().ConfigureAwait(true))
                    {
                        await ActivateLoading(false).ConfigureAwait(true);

                        FileCollection.Clear();

                        HasFile.Visibility        = Visibility.Visible;
                        ClearRecycleBin.IsEnabled = false;
                    }
                    else
                    {
                        QueueContentDialog dialog = new QueueContentDialog
                        {
                            Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
                            Content         = Globalization.GetString("QueueDialog_RecycleBinEmptyError_Content"),
                            CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
                        };

                        _ = await dialog.ShowAsync().ConfigureAwait(true);

                        await ActivateLoading(false).ConfigureAwait(true);
                    }
                }
            }
        }
Exemplo n.º 13
0
        private async void EjectButton_Click(object sender, RoutedEventArgs e)
        {
            if (DeviceGrid.SelectedItem is HardDeviceInfo Item)
            {
                if (string.IsNullOrEmpty(Item.Folder.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 in TabViewContainer.ThisPage.TabViewControl.TabItems.OfType <TabViewItem>().Where((Tab) => Tab.Content is Frame frame && CommonAccessCollection.FrameFileControlDic.TryGetValue(frame, out FileControl Control) && Path.GetPathRoot(Control.CurrentPresenter.CurrentFolder?.Path) == Item.Folder.Path).ToArray())
                    {
                        await TabViewContainer.ThisPage.CleanUpAndRemoveTabItem(Tab).ConfigureAwait(true);
                    }

                    using (FullTrustProcessController.ExclusiveUsage Exclusive = await FullTrustProcessController.GetAvailableController())
                    {
                        if (await Exclusive.Controller.EjectPortableDevice(Item.Folder.Path).ConfigureAwait(true))
                        {
                            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);
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        private async void ResetDialog_Loading(FrameworkElement sender, object args)
        {
            StorageFolder SecureFolder = await ApplicationData.Current.LocalCacheFolder.CreateFolderAsync("SecureFolder", CreationCollisionOption.OpenIfExists);

            QueryOptions Options = new QueryOptions
            {
                FolderDepth   = FolderDepth.Shallow,
                IndexerOption = IndexerOption.DoNotUseIndexer
            };

            StorageItemQueryResult ItemQuery = SecureFolder.CreateItemQueryWithOptions(Options);

            uint Count = await ItemQuery.GetItemCountAsync();

            if (Count == 0)
            {
                ClearSecure.IsEnabled = false;
            }

            ClearSecure.Content += $"({Globalization.GetString("Reset_Dialog_TotalFile")}: {Count})";
        }
Exemplo n.º 15
0
        private async void PairOrCancelButton_Click(object sender, RoutedEventArgs e)
        {
            Button Btn = sender as Button;

            if (Btn.DataContext is BluetoothDeivceData Device)
            {
                if (Btn.Content.ToString() == Globalization.GetString("PairText"))
                {
                    await PairAsync(Device).ConfigureAwait(false);
                }
                else
                {
                    DeviceUnpairingResult UnPairResult = await Device.DeviceInfo.Pairing.UnpairAsync();

                    if (UnPairResult.Status == DeviceUnpairingResultStatus.Unpaired || UnPairResult.Status == DeviceUnpairingResultStatus.AlreadyUnpaired)
                    {
                        BluetoothDeviceCollection.Remove(Device);
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void Current_EnteredBackground(object sender, EnteredBackgroundEventArgs e)
        {
            if (IsAnyTaskRunning || GeneralTransformer.IsAnyTransformTaskRunning)
            {
                ToastNotificationManager.History.Remove("EnterBackgroundTips");

                ToastContent Content = new ToastContent()
                {
                    Scenario = ToastScenario.Alarm,
                    Launch   = "EnterBackgroundTips",
                    Visual   = new ToastVisual()
                    {
                        BindingGeneric = new ToastBindingGeneric()
                        {
                            Children =
                            {
                                new AdaptiveText()
                                {
                                    Text = Globalization.GetString("Toast_EnterBackground_Text_1")
                                },

                                new AdaptiveText()
                                {
                                    Text = Globalization.GetString("Toast_EnterBackground_Text_2")
                                },

                                new AdaptiveText()
                                {
                                    Text = Globalization.GetString("Toast_EnterBackground_Text_3")
                                }
                            }
                        }
                    },
                };
                ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(Content.GetXml())
                {
                    Tag = "EnterBackgroundTips", Priority = ToastNotificationPriority.High
                });
            }
        }
Exemplo n.º 17
0
        private async void RestoreRecycle_Click(object sender, RoutedEventArgs e)
        {
            if (ListViewControl.SelectedItems.Count > 0)
            {
                await ActivateLoading(true, Globalization.GetString("RecycleBinRestoreText")).ConfigureAwait(true);

                List <string> ErrorList = new List <string>();

                foreach (RecycleStorageItem Item in ListViewControl.SelectedItems.ToList())
                {
                    if (await FullTrustProcessController.Current.RestoreItemInRecycleBinAsync(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_RecycleBinRestoreError_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;
                }
            }
        }
Exemplo n.º 18
0
        public VideoEditDialog(StorageFile VideoFile)
        {
            InitializeComponent();
            this.VideoFile = VideoFile;
            Loaded        += VideoEditDialog_Loaded;

            EncodingProfile.Items.Add($"MP4(.mp4) {Globalization.GetString("Video_Dialog_Encoding_Text")}");
            EncodingProfile.Items.Add($"WMV(.wmv) {Globalization.GetString("Video_Dialog_Encoding_Text")}");
            EncodingProfile.Items.Add($"MKV(.mkv) {Globalization.GetString("Video_Dialog_Encoding_Text")}");

            EncodingQuality.Items.Add("2160p");
            EncodingQuality.Items.Add("1080p");
            EncodingQuality.Items.Add("720p");
            EncodingQuality.Items.Add("480p");

            TrimmingProfile.Items.Add(Globalization.GetString("VideoEdit_Dialog_Crop_Precision_Level_1"));
            TrimmingProfile.Items.Add(Globalization.GetString("VideoEdit_Dialog_Crop_Precision_Level_2"));

            EncodingProfile.SelectedIndex = 0;
            EncodingQuality.SelectedIndex = 0;
            TrimmingProfile.SelectedIndex = 0;
        }
Exemplo n.º 19
0
        private async void MainPage_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral Deferral = e.GetDeferral();

            if (IsAnyTaskRunning || GeneralTransformer.IsAnyTransformTaskRunning || FullTrustExcutorController.Current.IsNowHasAnyActionExcuting)
            {
                QueueContentDialog Dialog = new QueueContentDialog
                {
                    Title             = Globalization.GetString("Common_Dialog_WarningTitle"),
                    Content           = Globalization.GetString("QueueDialog_WaitUntilFinish_Content"),
                    PrimaryButtonText = Globalization.GetString("QueueDialog_WaitUntilFinish_PrimaryButton"),
                    CloseButtonText   = Globalization.GetString("QueueDialog_WaitUntilFinish_CloseButton")
                };

                if ((await Dialog.ShowAsync().ConfigureAwait(true)) != ContentDialogResult.Primary)
                {
                    e.Handled = true;
                }
                else
                {
                    IsAnyTaskRunning = false;
                    GeneralTransformer.IsAnyTransformTaskRunning = false;
                    ToastNotificationManager.History.Clear();
                }
            }

            try
            {
                if (!e.Handled && Clipboard.GetContent().Contains(StandardDataFormats.StorageItems))
                {
                    Clipboard.Flush();
                }
            }
            catch
            {
            }

            Deferral.Complete();
        }
Exemplo n.º 20
0
        private async void LibraryProperties_Click(object sender, RoutedEventArgs e)
        {
            if (LibraryGrid.SelectedItem is LibraryFolder Library)
            {
                FileSystemStorageFolder Folder = new FileSystemStorageFolder(Library.Folder, await Library.Folder.GetThumbnailBitmapAsync(), await Library.Folder.GetModifiedTimeAsync());

                AppWindow NewWindow = await AppWindow.TryCreateAsync();

                NewWindow.RequestSize(new Size(420, 600));
                NewWindow.RequestMoveRelativeToCurrentViewContent(new Point(Window.Current.Bounds.Width / 2 - 200, Window.Current.Bounds.Height / 2 - 300));
                NewWindow.PersistedStateId = "Properties";
                NewWindow.Title            = Globalization.GetString("Properties_Window_Title");
                NewWindow.TitleBar.ExtendsContentIntoTitleBar    = true;
                NewWindow.TitleBar.ButtonBackgroundColor         = Colors.Transparent;
                NewWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

                ElementCompositionPreview.SetAppWindowContent(NewWindow, new PropertyBase(NewWindow, Folder));
                WindowManagementPreview.SetPreferredMinSize(NewWindow, new Size(420, 600));

                await NewWindow.TryShowAsync();
            }
        }
Exemplo n.º 21
0
        private async void DeviceGrid_DoubleTapped(object sender, Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs e)
        {
            try
            {
                if (SettingControl.IsInputFromPrimaryButton && (e.OriginalSource as FrameworkElement)?.DataContext is HardDeviceInfo Device)
                {
                    if (string.IsNullOrEmpty(Device.Folder.Path))
                    {
                        QueueContentDialog Dialog = new QueueContentDialog
                        {
                            Title             = Globalization.GetString("Common_Dialog_TipTitle"),
                            Content           = Globalization.GetString("QueueDialog_MTP_CouldNotAccess_Content"),
                            PrimaryButtonText = Globalization.GetString("Common_Dialog_ContinueButton"),
                            CloseButtonText   = Globalization.GetString("Common_Dialog_CancelButton")
                        };

                        if ((await Dialog.ShowAsync().ConfigureAwait(true)) == ContentDialogResult.Primary)
                        {
                            await Launcher.LaunchFolderAsync(Device.Folder);
                        }
                    }
                    else
                    {
                        if (AnimationController.Current.IsEnableAnimation)
                        {
                            Nav.Navigate(typeof(FileControl), new Tuple <TabViewItem, StorageFolder, ThisPC>(TabItem, Device.Folder, this), new DrillInNavigationTransitionInfo());
                        }
                        else
                        {
                            Nav.Navigate(typeof(FileControl), new Tuple <TabViewItem, StorageFolder, ThisPC>(TabItem, Device.Folder, this), new SuppressNavigationTransitionInfo());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionTracer.RequestBlueScreen(ex);
            }
        }
Exemplo n.º 22
0
        private async Task Initialize()
        {
            if (MediaFile.FileType == ".mp3" || MediaFile.FileType == ".flac" || MediaFile.FileType == ".wma" || MediaFile.FileType == ".m4a" || MediaFile.FileType == ".alac")
            {
                MusicCover.Visibility = Visibility.Visible;

                MediaPlaybackItem Item = new MediaPlaybackItem(MediaSource.CreateFromStorageFile(MediaFile));

                MediaItemDisplayProperties Props = Item.GetDisplayProperties();
                Props.Type = Windows.Media.MediaPlaybackType.Music;
                Props.MusicProperties.Title = MediaFile.DisplayName;

                try
                {
                    Props.MusicProperties.AlbumArtist = await GetMusicCoverAsync().ConfigureAwait(true);
                }
                catch (Exception)
                {
                    Cover.Visibility = Visibility.Collapsed;
                }
                Item.ApplyDisplayProperties(Props);

                Display.Text     = $"{Globalization.GetString("Media_Tip_Text")} {MediaFile.DisplayName}";
                MVControl.Source = Item;
            }
            else
            {
                MusicCover.Visibility = Visibility.Collapsed;

                MediaPlaybackItem          Item  = new MediaPlaybackItem(MediaSource.CreateFromStorageFile(MediaFile));
                MediaItemDisplayProperties Props = Item.GetDisplayProperties();
                Props.Type = Windows.Media.MediaPlaybackType.Video;
                Props.VideoProperties.Title = MediaFile.DisplayName;
                Item.ApplyDisplayProperties(Props);

                MVControl.Source = Item;
            }
        }
Exemplo n.º 23
0
        private string GetArtist()
        {
            try
            {
                using (FileStream FileStream = MediaFile.GetFileStreamFromFile(AccessMode.Read))
                    using (var TagFile = TagLib.File.Create(new StreamFileAbstraction(MediaFile.Name, FileStream, FileStream)))
                    {
                        if (TagFile.Tag.AlbumArtists != null && TagFile.Tag.AlbumArtists.Length != 0)
                        {
                            string Artist = "";

                            if (TagFile.Tag.AlbumArtists.Length == 1)
                            {
                                return(TagFile.Tag.AlbumArtists[0]);
                            }
                            else
                            {
                                Artist = TagFile.Tag.AlbumArtists[0];
                            }

                            foreach (var item in TagFile.Tag.AlbumArtists)
                            {
                                Artist = Artist + "/" + item;
                            }

                            return(Artist);
                        }
                        else
                        {
                            return(Globalization.GetString("UnknownText"));
                        }
                    }
            }
            catch
            {
                return(Globalization.GetString("UnknownText"));
            }
        }
Exemplo n.º 24
0
        private async void Location_Click(object sender, RoutedEventArgs e)
        {
            if (SearchResultList.SelectedItem is FileSystemStorageItemBase Item)
            {
                try
                {
                    StorageFolder ParentFolder = await StorageFolder.GetFolderFromPathAsync(Path.GetDirectoryName(Item.Path));

                    if (WeakToFileControl.TryGetTarget(out FileControl Control))
                    {
                        Frame.GoBack();

                        await Control.OpenTargetFolder(ParentFolder).ConfigureAwait(true);

                        await JumpListController.Current.AddItem(JumpListGroup.Recent, ParentFolder).ConfigureAwait(true);

                        if (Control.Presenter.FileCollection.FirstOrDefault((SItem) => SItem.Path == Item.Path) is FileSystemStorageItemBase Target)
                        {
                            Control.Presenter.ItemPresenter.ScrollIntoView(Target);
                            Control.Presenter.SelectedItem = Target;
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogTracer.Log(ex, $"An error was threw in {nameof(Location_Click)}");

                    QueueContentDialog dialog = new QueueContentDialog
                    {
                        Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
                        Content         = Globalization.GetString("QueueDialog_LocateFolderFailure_Content"),
                        CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
                    };

                    _ = await dialog.ShowAsync().ConfigureAwait(true);
                }
            }
        }
Exemplo n.º 25
0
        private async void SearchResultList_DoubleTapped(object sender, Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs e)
        {
            if ((e.OriginalSource as FrameworkElement).DataContext is FileSystemStorageItemBase Item)
            {
                try
                {
                    string ParentFolderPath = Path.GetDirectoryName(Item.Path);

                    if (WeakToFileControl.TryGetTarget(out FileControl Control))
                    {
                        Frame.GoBack();

                        await Control.CurrentPresenter.DisplayItemsInFolder(ParentFolderPath).ConfigureAwait(true);

                        await JumpListController.Current.AddItemAsync(JumpListGroup.Recent, ParentFolderPath).ConfigureAwait(true);

                        if (Control.CurrentPresenter.FileCollection.FirstOrDefault((SItem) => SItem == Item) is FileSystemStorageItemBase Target)
                        {
                            Control.CurrentPresenter.ItemPresenter.ScrollIntoView(Target);
                            Control.CurrentPresenter.SelectedItem = Target;
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogTracer.Log(ex, $"An error was threw in {nameof(Location_Click)}");

                    QueueContentDialog dialog = new QueueContentDialog
                    {
                        Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
                        Content         = Globalization.GetString("QueueDialog_LocateFolderFailure_Content"),
                        CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
                    };

                    _ = await dialog.ShowAsync().ConfigureAwait(true);
                }
            }
        }
Exemplo n.º 26
0
        private async void Save_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (CurrentEncoding != null)
                {
                    try
                    {
                        using (FileStream Stream = FileSystemStorageItemBase.Create(TextFile.Path, StorageItemTypes.File, CreateOption.ReplaceExisting).GetFileStreamFromFile(AccessMode.Write))
                            using (StreamWriter Writer = new StreamWriter(Stream, CurrentEncoding))
                            {
                                await Writer.WriteAsync(Text.Text).ConfigureAwait(true);
                            }
                    }
                    catch
                    {
                        QueueContentDialog Dialog = new QueueContentDialog
                        {
                            Title           = Globalization.GetString("Common_Dialog_ErrorTitle"),
                            Content         = Globalization.GetString("QueueDialog_CouldReadWriteFile_Content"),
                            CloseButtonText = Globalization.GetString("Common_Dialog_CloseButton")
                        };

                        await Dialog.ShowAsync().ConfigureAwait(true);
                    }

                    Frame.GoBack();
                }
                else
                {
                    InvalidTip.IsOpen = true;
                }
            }
            catch
            {
                InvalidTip.IsOpen = true;
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// 异步启动蓝牙的配对过程
        /// </summary>
        /// <param name="DeviceInfo"></param>
        /// <returns></returns>
        private async Task PairAsync(DeviceInformation DeviceInfo)
        {
            DevicePairingKinds PairKinds = DevicePairingKinds.ConfirmOnly | DevicePairingKinds.ConfirmPinMatch;

            DeviceInformationCustomPairing CustomPairing = DeviceInfo.Pairing.Custom;

            CustomPairing.PairingRequested += CustomPairInfo_PairingRequested;

            DevicePairingResult PairResult = await CustomPairing.PairAsync(PairKinds, DevicePairingProtectionLevel.EncryptionAndAuthentication);

            CustomPairing.PairingRequested -= CustomPairInfo_PairingRequested;

            if (PairResult.Status == DevicePairingResultStatus.Paired)
            {
                BluetoothWatcher.Stop();
                BluetoothDeviceCollection.Clear();
                BluetoothWatcher.Start();
            }
            else
            {
                Tips.Text = Globalization.GetString("BluetoothUI_Tips_Text_4");
            }
        }
Exemplo n.º 28
0
        private async void DeleteFile_Click(object sender, RoutedEventArgs e)
        {
            QueueContentDialog Dialog = new QueueContentDialog
            {
                Title             = Globalization.GetString("Common_Dialog_WarningTitle"),
                PrimaryButtonText = Globalization.GetString("Common_Dialog_ContinueButton"),
                Content           = Globalization.GetString("QueueDialog_DeleteFile_Content"),
                CloseButtonText   = Globalization.GetString("Common_Dialog_CancelButton")
            };

            if ((await Dialog.ShowAsync().ConfigureAwait(true)) == ContentDialogResult.Primary)
            {
                foreach (SecureAreaStorageItem Item in SecureGridView.SelectedItems.ToArray())
                {
                    SecureCollection.Remove(Item);

                    if (!Item.PermanentDelete())
                    {
                        LogTracer.Log(new Win32Exception(Marshal.GetLastWin32Error()), "Delete encrypted file failed");
                    }
                }
            }
        }
Exemplo n.º 29
0
        private async void SecureFilePropertyDialog_Loading(Windows.UI.Xaml.FrameworkElement sender, object args)
        {
            StorageFile Item = (await StorageItem.GetStorageItem().ConfigureAwait(true)) as StorageFile;

            FileSize = StorageItem.Size;
            FileName = StorageItem.Name;
            FileType = StorageItem.DisplayType;

            using (Stream EncryptFileStream = await Item.OpenStreamForReadAsync().ConfigureAwait(true))
            {
                byte[] DecryptByteBuffer = new byte[20];

                await EncryptFileStream.ReadAsync(DecryptByteBuffer, 0, DecryptByteBuffer.Length).ConfigureAwait(true);

                if (Encoding.UTF8.GetString(DecryptByteBuffer).Split('$', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault() is string Info)
                {
                    string[] InfoGroup = Info.Split('|');
                    if (InfoGroup.Length == 2)
                    {
                        Level = Convert.ToInt32(InfoGroup[0]) == 128 ? "AES-128bit" : "AES-256bit";
                    }
                    else
                    {
                        Level = Globalization.GetString("UnknownText");
                    }
                }
                else
                {
                    Level = Globalization.GetString("UnknownText");
                }
            }

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FileSize)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FileName)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FileType)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Level)));
        }
Exemplo n.º 30
0
        /// <summary>
        /// 异步启动蓝牙的配对过程
        /// </summary>
        /// <param name="DeviceInfo"></param>
        /// <returns></returns>
        private async Task PairAsync(BluetoothDeivceData Device)
        {
            try
            {
                if (Device.DeviceInfo.Pairing.CanPair)
                {
                    DeviceInformationCustomPairing CustomPairing = Device.DeviceInfo.Pairing.Custom;

                    CustomPairing.PairingRequested += CustomPairInfo_PairingRequested;

                    DevicePairingResult PairResult = await CustomPairing.PairAsync(DevicePairingKinds.ConfirmOnly | DevicePairingKinds.ConfirmPinMatch, DevicePairingProtectionLevel.EncryptionAndAuthentication);

                    CustomPairing.PairingRequested -= CustomPairInfo_PairingRequested;

                    if (PairResult.Status == DevicePairingResultStatus.Paired)
                    {
                        Device.Update();
                    }
                    else
                    {
                        await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                        {
                            Tips.Text       = Globalization.GetString("BluetoothUI_Tips_Text_4");
                            Tips.Visibility = Visibility.Visible;
                        });
                    }
                }
                else
                {
                    LogTracer.Log($"Unable pair with Bluetooth device: \"{Device.Name}\", reason: CanPair property return false");
                }
            }
            catch (Exception ex)
            {
                LogTracer.Log(ex, $"Unable pair with Bluetooth device: \"{Device.Name}\"");
            }
        }