private void SetDefault(Directory directory, DirectoryInfo directoryInfo) { labelName.Text = directory.Name; labelType.Text = "File folder"; icon.Image = new Icon(Properties.Resources.Folder, new Size(64, 64)).ToBitmap(); StringBuilder sb = new StringBuilder(); if (UserSettings.Mode != Mode.BASIC) { sb.AppendLine($"Path: {directory.Path}"); } if (directoryInfo != null) { if (directoryInfo.ItemCount > 0) { sb.AppendLine($"Items: {directoryInfo.ItemCount}"); } if (directoryInfo.TotalByteSize > 0) { if (UserSettings.Mode == Mode.BASIC) { sb.AppendLine($"Size: {DirectoryContent.ToFileSize(directoryInfo.TotalByteSize)}"); } else { sb.AppendLine($"Size: {DirectoryContent.ToByteFileSize(directoryInfo.TotalByteSize)}"); } } } textBoxInfo.Text = sb.ToString(); }
public async Task Set(File file) { Clear(); labelName.Text = file.FileName; labelType.Text = DirectoryContent.ToString(file.Type); string additionalInfo = null; switch (file.Type) { case FileType.TextFile: { icon.Image = new Icon(Properties.Resources.Rtf, new Size(64, 64)).ToBitmap(); previewContent.Text = await((TextFile)file).DownloadAsString(); previewContent.Visible = true; break; } case FileType.SoundFile: { icon.Image = new Icon(Properties.Resources.Rsf, new Size(64, 64)).ToBitmap(); break; } case FileType.GraphicFile: { icon.Image = new Icon(Properties.Resources.Rgf, new Size(64, 64)).ToBitmap(); byte[] data = await file.Download(); Bitmap bitmap = FileConverter.RGFtoBitmap(data, Color.FromArgb(73, 74, 75)); int width = data[0]; int height = data[1]; previewImage.Image = bitmap; additionalInfo = $"Dimension: {width} x {height} px"; previewImage.Visible = true; break; } default: { icon.Image = new Icon(Properties.Resources.File, new Size(64, 64)).ToBitmap(); break; } } StringBuilder sb = new StringBuilder(); if (UserSettings.Mode == Mode.BASIC) { sb.AppendLine($"Size: {DirectoryContent.ToFileSize(file.Size)}"); } else { sb.AppendLine($"Path: {file.Path}"); sb.AppendLine($"Size: {DirectoryContent.ToByteFileSize(file.Size)}"); sb.AppendLine($"Md5sum: {file.MD5SUM}"); } if (additionalInfo != null) { sb.Append(additionalInfo); } textBoxInfo.Text = sb.ToString(); }