From 0cea0f6473a97402477c7f32a412758159a5010c Mon Sep 17 00:00:00 2001 From: Anime4000 Date: Mon, 8 Jun 2020 01:43:54 +0800 Subject: [PATCH] larger & file calc --- IFME.OSManager/OS.cs | 28 +++++++ IFME/frmMain.Designer.cs | 44 +++++------ IFME/frmMain.Function.cs | 2 +- IFME/frmMain.cs | 1 + IFME/frmMain.resx | 153 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 205 insertions(+), 23 deletions(-) diff --git a/IFME.OSManager/OS.cs b/IFME.OSManager/OS.cs index e109990..07349c8 100644 --- a/IFME.OSManager/OS.cs +++ b/IFME.OSManager/OS.cs @@ -97,5 +97,33 @@ public static void PowerOff(int delay = 0) else if (IsLinux) Process.Start("bash", "-c 'poweroff'"); } + + public static string PrintFileSize(ulong value) + { + if (IsWindows) + { + string[] IEC = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" }; + + if (value == 0) + return $"0{IEC[0]}"; + + long bytes = Math.Abs((long)value); + int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024))); + double num = Math.Round(bytes / Math.Pow(1024, place), 1); + return $"{(Math.Sign((long)value) * num)} {IEC[place]}"; + } + else + { + string[] DEC = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; + + if (value == 0) + return $"0{DEC[0]}"; + + long bytes = Math.Abs((long)value); + int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1000))); + double num = Math.Round(bytes / Math.Pow(1000, place), 1); + return $"{(Math.Sign((long)value) * num)} {DEC[place]}"; + } + } } } diff --git a/IFME/frmMain.Designer.cs b/IFME/frmMain.Designer.cs index 204a289..61cd73a 100644 --- a/IFME/frmMain.Designer.cs +++ b/IFME/frmMain.Designer.cs @@ -404,7 +404,7 @@ private void InitializeComponent() // btnOutputBrowse // this.btnOutputBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnOutputBrowse.Location = new System.Drawing.Point(764, 564); + this.btnOutputBrowse.Location = new System.Drawing.Point(988, 564); this.btnOutputBrowse.Name = "btnOutputBrowse"; this.btnOutputBrowse.Size = new System.Drawing.Size(24, 24); this.btnOutputBrowse.TabIndex = 18; @@ -789,7 +789,7 @@ private void InitializeComponent() // btnProfileSaveLoad // this.btnProfileSaveLoad.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnProfileSaveLoad.Location = new System.Drawing.Point(764, 534); + this.btnProfileSaveLoad.Location = new System.Drawing.Point(988, 534); this.btnProfileSaveLoad.Name = "btnProfileSaveLoad"; this.btnProfileSaveLoad.Size = new System.Drawing.Size(24, 24); this.btnProfileSaveLoad.TabIndex = 15; @@ -806,7 +806,7 @@ private void InitializeComponent() this.cboProfile.FormattingEnabled = true; this.cboProfile.Location = new System.Drawing.Point(274, 534); this.cboProfile.Name = "cboProfile"; - this.cboProfile.Size = new System.Drawing.Size(484, 24); + this.cboProfile.Size = new System.Drawing.Size(708, 24); this.cboProfile.TabIndex = 14; this.cboProfile.SelectedIndexChanged += new System.EventHandler(this.cboProfile_SelectedIndexChanged); // @@ -829,7 +829,7 @@ private void InitializeComponent() this.txtOutputPath.Font = new System.Drawing.Font("Tahoma", 10F); this.txtOutputPath.Location = new System.Drawing.Point(148, 564); this.txtOutputPath.Name = "txtOutputPath"; - this.txtOutputPath.Size = new System.Drawing.Size(610, 24); + this.txtOutputPath.Size = new System.Drawing.Size(834, 24); this.txtOutputPath.TabIndex = 17; this.txtOutputPath.TextChanged += new System.EventHandler(this.txtOutputPath_TextChanged); // @@ -860,7 +860,7 @@ private void InitializeComponent() this.PbxBanner.BackColor = System.Drawing.Color.Black; this.PbxBanner.Location = new System.Drawing.Point(0, 0); this.PbxBanner.Name = "PbxBanner"; - this.PbxBanner.Size = new System.Drawing.Size(800, 64); + this.PbxBanner.Size = new System.Drawing.Size(1024, 64); this.PbxBanner.TabIndex = 27; this.PbxBanner.TabStop = false; // @@ -1531,7 +1531,7 @@ private void InitializeComponent() this.tabConfig.Name = "tabConfig"; this.tabConfig.Padding = new System.Drawing.Point(16, 4); this.tabConfig.SelectedIndex = 0; - this.tabConfig.Size = new System.Drawing.Size(776, 292); + this.tabConfig.Size = new System.Drawing.Size(1000, 292); this.tabConfig.TabIndex = 11; // // tabConfigMediaInfo @@ -1539,7 +1539,7 @@ private void InitializeComponent() this.tabConfigMediaInfo.Controls.Add(this.txtMediaInfo); this.tabConfigMediaInfo.Location = new System.Drawing.Point(4, 24); this.tabConfigMediaInfo.Name = "tabConfigMediaInfo"; - this.tabConfigMediaInfo.Size = new System.Drawing.Size(768, 264); + this.tabConfigMediaInfo.Size = new System.Drawing.Size(992, 264); this.tabConfigMediaInfo.TabIndex = 6; this.tabConfigMediaInfo.Text = "Media Info"; this.tabConfigMediaInfo.UseVisualStyleBackColor = true; @@ -1552,7 +1552,7 @@ private void InitializeComponent() this.txtMediaInfo.Name = "txtMediaInfo"; this.txtMediaInfo.ReadOnly = true; this.txtMediaInfo.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtMediaInfo.Size = new System.Drawing.Size(768, 264); + this.txtMediaInfo.Size = new System.Drawing.Size(992, 264); this.txtMediaInfo.TabIndex = 0; this.txtMediaInfo.WordWrap = false; // @@ -1575,7 +1575,7 @@ private void InitializeComponent() this.lstFile.HideSelection = false; this.lstFile.Location = new System.Drawing.Point(12, 114); this.lstFile.Name = "lstFile"; - this.lstFile.Size = new System.Drawing.Size(776, 116); + this.lstFile.Size = new System.Drawing.Size(1000, 116); this.lstFile.TabIndex = 10; this.lstFile.UseCompatibleStateImageBehavior = false; this.lstFile.View = System.Windows.Forms.View.Details; @@ -1587,38 +1587,38 @@ private void InitializeComponent() // colFileName // this.colFileName.Text = "Name"; - this.colFileName.Width = 260; + this.colFileName.Width = 250; // // colFileType // this.colFileType.Text = "Type"; - this.colFileType.Width = 70; + this.colFileType.Width = 80; // // colFileDuration // this.colFileDuration.Text = "Duration"; - this.colFileDuration.Width = 70; + this.colFileDuration.Width = 80; // // colFileSize // this.colFileSize.Text = "Size"; - this.colFileSize.Width = 70; + this.colFileSize.Width = 80; // // colFileStatus // this.colFileStatus.Text = "Status"; - this.colFileStatus.Width = 80; + this.colFileStatus.Width = 130; // // colFileProgress // this.colFileProgress.Text = "Progress"; - this.colFileProgress.Width = 200; + this.colFileProgress.Width = 354; // // btnDonate // this.btnDonate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnDonate.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; - this.btnDonate.Location = new System.Drawing.Point(584, 76); + this.btnDonate.Location = new System.Drawing.Point(808, 76); this.btnDonate.Name = "btnDonate"; this.btnDonate.Size = new System.Drawing.Size(120, 32); this.btnDonate.TabIndex = 6; @@ -1630,7 +1630,7 @@ private void InitializeComponent() // this.Seperator2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.Seperator2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.Seperator2.Location = new System.Drawing.Point(710, 76); + this.Seperator2.Location = new System.Drawing.Point(934, 76); this.Seperator2.Name = "Seperator2"; this.Seperator2.Size = new System.Drawing.Size(2, 32); this.Seperator2.TabIndex = 7; @@ -1638,7 +1638,7 @@ private void InitializeComponent() // btnStart // this.btnStart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnStart.Location = new System.Drawing.Point(718, 76); + this.btnStart.Location = new System.Drawing.Point(942, 76); this.btnStart.Name = "btnStart"; this.btnStart.Size = new System.Drawing.Size(32, 32); this.btnStart.TabIndex = 8; @@ -1649,7 +1649,7 @@ private void InitializeComponent() // btnStop // this.btnStop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnStop.Location = new System.Drawing.Point(756, 76); + this.btnStop.Location = new System.Drawing.Point(980, 76); this.btnStop.Name = "btnStop"; this.btnStop.Size = new System.Drawing.Size(32, 32); this.btnStop.TabIndex = 9; @@ -1659,7 +1659,7 @@ private void InitializeComponent() // btnFileDown // this.btnFileDown.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.btnFileDown.Location = new System.Drawing.Point(403, 76); + this.btnFileDown.Location = new System.Drawing.Point(515, 76); this.btnFileDown.Name = "btnFileDown"; this.btnFileDown.Size = new System.Drawing.Size(32, 32); this.btnFileDown.TabIndex = 5; @@ -1669,7 +1669,7 @@ private void InitializeComponent() // btnFileUp // this.btnFileUp.Anchor = System.Windows.Forms.AnchorStyles.Top; - this.btnFileUp.Location = new System.Drawing.Point(365, 76); + this.btnFileUp.Location = new System.Drawing.Point(477, 76); this.btnFileUp.Name = "btnFileUp"; this.btnFileUp.Size = new System.Drawing.Size(32, 32); this.btnFileUp.TabIndex = 4; @@ -1855,7 +1855,7 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.ClientSize = new System.Drawing.Size(800, 600); + this.ClientSize = new System.Drawing.Size(1024, 600); this.Controls.Add(this.btnOutputBrowse); this.Controls.Add(this.btnProfileSaveLoad); this.Controls.Add(this.cboProfile); diff --git a/IFME/frmMain.Function.cs b/IFME/frmMain.Function.cs index 21c9597..165a010 100644 --- a/IFME/frmMain.Function.cs +++ b/IFME/frmMain.Function.cs @@ -192,7 +192,7 @@ private void MediaFileListAdd(string path) Path.GetFileName(path), Path.GetExtension(path).Substring(1).ToUpperInvariant(), TimeSpan.FromSeconds(fileData.Duration).ToString("hh\\:mm\\:ss"), - $"{fileData.FileSize}", + OS.PrintFileSize(fileData.FileSize), fileQueue.Enable ? "Ready" : "Done", "" }) diff --git a/IFME/frmMain.cs b/IFME/frmMain.cs index 5ede7b2..73ff06b 100644 --- a/IFME/frmMain.cs +++ b/IFME/frmMain.cs @@ -404,6 +404,7 @@ private void lstFile_SelectedIndexChanged(object sender, EventArgs e) lstAudio.Items.Clear(); lstSub.Items.Clear(); lstAttach.Items.Clear(); + txtMediaInfo.Text = "FFmpeg Media Info ♥"; } // Check queue consistency diff --git a/IFME/frmMain.resx b/IFME/frmMain.resx index bcba6c5..6be8197 100644 --- a/IFME/frmMain.resx +++ b/IFME/frmMain.resx @@ -147,6 +147,9 @@ True + + True + True @@ -219,12 +222,57 @@ True + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + True True + + True + True @@ -246,6 +294,21 @@ True + + True + + + True + + + True + + + True + + + True + True @@ -273,6 +336,9 @@ True + + True + True @@ -291,6 +357,24 @@ True + + True + + + True + + + True + + + True + + + True + + + True + True @@ -336,6 +420,12 @@ True + + True + + + True + True @@ -363,6 +453,69 @@ True + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + True