コード例 #1
0
        private async void PropertyDialog_Loading(FrameworkElement sender, object args)
        {
            if (SItem is StorageFile || Item?.StorageType == StorageItemTypes.File)
            {
                IncludeArea.Visibility = Visibility.Collapsed;

                StorageFile file;

                if (Item != null)
                {
                    FileName = Item.Name;
                    Path     = Item.Path;
                    FileType = $"{Item.DisplayType} ({Item.Type})";

                    file = (StorageFile)await Item.GetStorageItem().ConfigureAwait(true);

                    if (Item is HyperlinkStorageItem LinkItem)
                    {
                        LinkTargetArea.Visibility = Visibility.Visible;
                        TargetPath = LinkItem.TargetPath;
                    }
                }
                else
                {
                    file     = (StorageFile)SItem;
                    FileType = $"{file.DisplayType} ({file.FileType})";
                }

                CreateTime = file.DateCreated.ToString("F");

                if (file.ContentType.StartsWith("video"))
                {
                    VideoProperties Video = await file.Properties.GetVideoPropertiesAsync();

                    ExtraData.Text = $"{Globalization.GetString("FileProperty_Resolution")}: {((Video.Width == 0 && Video.Height == 0) ? "Unknown" : $"{Video.Width}×{Video.Height}")}{Environment.NewLine}{Globalization.GetString("FileProperty_Bitrate")}: {(Video.Bitrate == 0 ? "Unknown" : (Video.Bitrate / 1024f < 1024 ? Math.Round(Video.Bitrate / 1024f, 2).ToString("0.00") + " Kbps" : Math.Round(Video.Bitrate / 1048576f, 2).ToString("0.00") + " Mbps"))}{Environment.NewLine}{Globalization.GetString("FileProperty_Duration")}: {ConvertTimsSpanToString(Video.Duration)}";
コード例 #2
0
        private async void PropertyDialog_Loading(FrameworkElement sender, object args)
        {
            if (Item.StorageType == StorageItemTypes.File)
            {
                IncludeArea.Visibility = Visibility.Collapsed;

                FileName   = Item.Name;
                Path       = Item.Path;
                FileType   = $"{Item.DisplayType} ({Item.Type})";
                CreateTime = Item.CreationTimeRaw.ToString("F");
                ChangeTime = Item.ModifiedTimeRaw.ToString("F");
                FileSize   = Item.Size + " (" + Item.SizeRaw.ToString("N0") + $" {Globalization.GetString("Device_Capacity_Unit")})";

                if (Item is HyperlinkStorageItem LinkItem)
                {
                    LinkTargetArea.Visibility = Visibility.Visible;
                    ExtraDataArea.Visibility  = Visibility.Collapsed;

                    TargetPath = LinkItem.LinkTargetPath;
                }
                else
                {
                    if (await Item.GetStorageItem().ConfigureAwait(true) is StorageFile File)
                    {
                        if (File.ContentType.StartsWith("video", StringComparison.OrdinalIgnoreCase))
                        {
                            VideoProperties Video = await File.Properties.GetVideoPropertiesAsync();

                            ExtraData.Text = $"{Globalization.GetString("FileProperty_Resolution")}: {((Video.Width == 0 && Video.Height == 0) ? Globalization.GetString("UnknownText") : $"{Video.Width}×{Video.Height}")}{Environment.NewLine}{Globalization.GetString("FileProperty_Bitrate")}: {(Video.Bitrate == 0 ? Globalization.GetString("UnknownText") : (Video.Bitrate / 1024f < 1024 ? Math.Round(Video.Bitrate / 1024f, 2).ToString("0.00") + " Kbps" : Math.Round(Video.Bitrate / 1048576f, 2).ToString("0.00") + " Mbps"))}{Environment.NewLine}{Globalization.GetString("FileProperty_Duration")}: {ConvertTimsSpanToString(Video.Duration)}";
コード例 #3
0
        private async Task Initialize()
        {
            LoadingControl.IsLoading           = true;
            MainPage.ThisPage.IsAnyTaskRunning = true;

            IStorageItem Item = await SFile.GetStorageItem().ConfigureAwait(true);

            try
            {
                string FileText = await FileIO.ReadTextAsync(Item as StorageFile);

                Text.Text = FileText;

                await Task.Delay(500).ConfigureAwait(true);
            }
            catch (ArgumentOutOfRangeException)
            {
                IBuffer buffer = await FileIO.ReadBufferAsync(Item as StorageFile);

                DataReader reader      = DataReader.FromBuffer(buffer);
                byte[]     fileContent = new byte[reader.UnconsumedBufferLength];
                reader.ReadBytes(fileContent);
                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
                Encoding GBKEncoding = Encoding.GetEncoding("GBK");

                string FileText = GBKEncoding.GetString(fileContent);

                Text.Text = FileText;

                await Task.Delay(500).ConfigureAwait(true);
            }
            finally
            {
                LoadingControl.IsLoading           = false;
                MainPage.ThisPage.IsAnyTaskRunning = false;
            }
        }
コード例 #4
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)));
        }