From dccf7b2d0631d889b31f1b77cd15b339cb178560 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 6 Oct 2021 12:57:50 +0100 Subject: [PATCH] Added: refresh --- .vs/VideoPreview/v16/.suo | Bin 38912 -> 43520 bytes MainForm.Designer.cs | 23 ++++++- MainForm.cs | 58 ++++++++++++++---- Resources/UI/refresh.png | Bin 0 -> 451 bytes Resources/UI/refresh2.png | Bin 0 -> 300 bytes .../ThemedForms/TextBox/TButtonTextBox.cs | 14 ++++- UIResource.Designer.cs | 20 ++++++ UIResource.resx | 6 ++ 8 files changed, 105 insertions(+), 16 deletions(-) create mode 100644 Resources/UI/refresh.png create mode 100644 Resources/UI/refresh2.png diff --git a/.vs/VideoPreview/v16/.suo b/.vs/VideoPreview/v16/.suo index 30cbbf757154a56af70175ceb98a3ec2f40bff94..122de5e0da66e45c217da1d61f9babb9b9a4306f 100644 GIT binary patch delta 3498 zcmc&$dr(y86~EtQcV(BmfUp~03+&3GD6ieS%fl7M1vW$x1i=bah=`!#0}=1?^1+(P zG#N{)-lK_`v@^O%{>VQqvYqK9aoTmbtCz<2bhyCin(n z1$H%vMHE<`WM#Kto^KWysve0^gB0h}-$2D?1c?TiDlOlNyL%n>i&bLq)ujGF9AUo0b2v&JBXBsPKB)&u^f?&h(}P&wjojxIf&@4>DZ?z zP&7;tJw+iO5se_tEr{5#t68+;z!Hv%03lVEwiOi(h&yMu<+FnGwjev8yGfi(|=Pkr_1l{Kbwl@*C5WhjZgZM3C7V$g8?-B1J z-b4HW@jl{@2wM9AWG9@Kbx+@Sit*l4X!cE<{cAbpOBRBKluZI^7Bg@oYKhArrB2C- z9)W^DzJH@noQ2mDi$F@+8oxHiAW+CDH6-6^rCM1D3zi0`Th|R2SG*|jxCfm`6248I zPc5R-_@HT1a-+oT;BA~_Hkil%rQmI97OHSP{Q5q_q&*NYs z{SCOr+vPSDjAc9xD@NP_w<*Zv6p1;&n=+|Bjq{d{9s418QzwNV-~@7wWTr91?z@DR z@}QXE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0O#P zq#2U$yD`puso$;DRft-Jbc0 qLHzP(Y#MGj4{qb>^TrE>$h;q#C*$zyD@S4W^oVxrWxwrz_Ww5(+EXk5 diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 097e825..13c008c 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -41,6 +41,7 @@ namespace VideoPreview this.textBox1 = new RyzStudio.Windows.ThemedForms.TOpenFileTextBox(); this.button2 = new RyzStudio.Windows.ThemedForms.TButton(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.button3 = new RyzStudio.Windows.ThemedForms.TButton(); this.label4 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); @@ -163,7 +164,7 @@ namespace VideoPreview this.textBox1.Name = "textBox1"; this.textBox1.NormalImage = ((System.Drawing.Image)(resources.GetObject("textBox1.NormalImage"))); this.textBox1.Padding = new System.Windows.Forms.Padding(10, 10, 9, 9); - this.textBox1.Size = new System.Drawing.Size(341, 35); + this.textBox1.Size = new System.Drawing.Size(294, 35); this.textBox1.SubmitButton = null; this.textBox1.TabIndex = 16; this.textBox1.UseSystemPasswordChar = false; @@ -186,6 +187,24 @@ namespace VideoPreview this.toolTip1.SetToolTip(this.button2, "Options"); this.button2.MouseClick += new System.Windows.Forms.MouseEventHandler(this.button2_MouseClick); // + // button3 + // + this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button3.BackColor = System.Drawing.Color.Transparent; + this.button3.DefaultImage = null; + this.button3.DownImage = null; + this.button3.IsSelected = false; + this.button3.LabelText = ""; + this.button3.Location = new System.Drawing.Point(410, 9); + this.button3.Margin = new System.Windows.Forms.Padding(10); + this.button3.Name = "button3"; + this.button3.OverImage = null; + this.button3.Padding = new System.Windows.Forms.Padding(4, 4, 3, 3); + this.button3.Size = new System.Drawing.Size(35, 35); + this.button3.TabIndex = 23; + this.toolTip1.SetToolTip(this.button3, "Refresh"); + this.button3.MouseClick += new System.Windows.Forms.MouseEventHandler(this.button3_MouseClick); + // // label4 // this.label4.AutoSize = true; @@ -243,6 +262,7 @@ namespace VideoPreview this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250))))); this.ClientSize = new System.Drawing.Size(464, 761); + this.Controls.Add(this.button3); this.Controls.Add(this.label6); this.Controls.Add(this.label7); this.Controls.Add(this.label3); @@ -284,6 +304,7 @@ namespace VideoPreview private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label7; + private RyzStudio.Windows.ThemedForms.TButton button3; } } diff --git a/MainForm.cs b/MainForm.cs index 5549c14..7d6cd61 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -13,7 +13,6 @@ namespace VideoPreview public partial class MainForm : Form { protected readonly Random randy; - protected readonly string tempPath; protected OptionsForm optionsForm = null; protected bool isBusy = false; @@ -27,16 +26,15 @@ namespace VideoPreview InitializeComponent(); randy = new Random(); - tempPath = Application.StartupPath.TrimEnd('\\') + "\\"; textBox1.InnerTextBox.ReadOnly = true; textBox1.InnerTextBox.BackColor = Color.White; textBox1.InnerTextBox.TextChanged += textBox1_TextChanged; button2.DefaultImage = UIResource.cog2; - button2.DownImage = UIResource.cog; - button2.OverImage = UIResource.cog; - + button2.DownImage = button2.OverImage = UIResource.cog; + button3.DefaultImage = UIResource.refresh2; + button3.DownImage = button3.OverImage = UIResource.refresh; } protected override void OnFormClosing(FormClosingEventArgs e) @@ -229,6 +227,11 @@ namespace VideoPreview } } + private async void button3_MouseClick(object sender, MouseEventArgs e) + { + await ReadVideoFile(textBox1.Text); + } + protected TimeSpan CalcRandomTimeSpan(TimeSpan duration) { @@ -243,7 +246,7 @@ namespace VideoPreview videoFilename = null; videoDuration = TimeSpan.FromSeconds(0); - ThreadControl.SetText(textBox1.InnerTextBox, ""); + textBox1.Text = string.Empty; ThreadControl.SetText(label5, "-"); ThreadControl.SetText(label7, "-"); ThreadControl.SetText(label2, "-"); @@ -288,6 +291,37 @@ namespace VideoPreview } } + //protected string GetTempFolder() + //{ + // string path = Path.Combine(Application.StartupPath, "tmp"); + // if (Directory.Exists(path)) + // { + // return path; + // } + + // try + // { + // Directory.CreateDirectory(path); + // } + // catch + // { + // // do nothing + // } + + // if (Directory.Exists(path)) + // { + // return path; + // } + + // path = Path.GetTempPath(); + // if (Directory.Exists(path)) + // { + // return path; + // } + + // return null; + //} + protected decimal ParseFrameSizeRatio(string videoSize) { if (string.IsNullOrWhiteSpace(videoSize)) @@ -359,7 +393,7 @@ namespace VideoPreview videoFilename = filename; videoDuration = inputFile.Metadata.Duration; - ThreadControl.SetText(textBox1.InnerTextBox, Path.GetFileName(videoFilename)); + textBox1.Text = videoFilename; ThreadControl.SetText(label5, inputFile.Metadata.VideoData.Format ?? string.Empty); ThreadControl.SetText(label7, (inputFile.Metadata.VideoData.FrameSize ?? string.Empty) + " @ " + inputFile.Metadata.VideoData.Fps.ToString() + "FPS"); ThreadControl.SetText(label2, string.Format("{0}h {1}m {2}s", videoDuration.Hours, videoDuration.Minutes, videoDuration.Seconds)); @@ -380,8 +414,7 @@ namespace VideoPreview for (int i = 0; i < this.CurrentSession.NoFrames; i++) { TimeSpan ts = CalcRandomTimeSpan(videoDuration); - - string saveFilename = tempPath + "temp-" + string.Format("{0}h-{1}m-{2}s", ts.Hours, ts.Minutes, ts.Seconds) + ".jpg"; + string thumbnailFilename = Path.ChangeExtension(Path.GetTempFileName(), "jpg"); ConversionOptions options = new ConversionOptions { @@ -389,16 +422,16 @@ namespace VideoPreview CustomWidth = thumbnailWidth, CustomHeight = thumbnailHeight }; - engine.GetThumbnail(inputFile, new MediaFile { Filename = saveFilename }, options); + engine.GetThumbnail(inputFile, new MediaFile { Filename = thumbnailFilename }, options); - PictureBox imageBox = CreatePictureBox(saveFilename, thumbnailWidth, thumbnailHeight); + PictureBox imageBox = CreatePictureBox(thumbnailFilename, thumbnailWidth, thumbnailHeight); ThreadControl.Add(flowLayoutPanel1, imageBox); Label label = CreateLabel(ts); ThreadControl.Add(flowLayoutPanel1, label); // clean-up - DeleteFile(saveFilename); + DeleteFile(thumbnailFilename); } } @@ -406,6 +439,5 @@ namespace VideoPreview }); } - } } diff --git a/Resources/UI/refresh.png b/Resources/UI/refresh.png new file mode 100644 index 0000000000000000000000000000000000000000..6e6d91880fe4e058a81015f3325ee3026759aa14 GIT binary patch literal 451 zcmV;!0X+VRP)Uq zK~yM_g^w|7R6!Jlzk6q%zaT+GB)z&7zaX)&31}AxLI~Jch(E!?DqTd-kj`RJ z&^m>nHp|NHfTge?1X86lyEDh;Ei6mG(_J{(ar@+^o z^OHXC0Kfs7ra1)8QcBAJ0Fu0v@*Q|?X2$>#z|02o`TWf)(C@tO?w|X!0$11h{wteI zCVwSenb{1W*1Fww-M3ZaXf(PVV_a+7_NN0k`fV?2t@lz&Kdwt}n&wE-BYHEEo&v8! z2oKDxt^zsdJxNh2q6wg>FgT6Y$;9eCVz-9<|2 ttdz0|T-I7oLI}Ui>^*Q9V@%6C{{eWAm^s`$a$5iZ002ovPDHLkV1h>z#XSH3 literal 0 HcmV?d00001 diff --git a/Resources/UI/refresh2.png b/Resources/UI/refresh2.png new file mode 100644 index 0000000000000000000000000000000000000000..e14b40f1c9d4339d2bd2fc0fa514135bd9f1c417 GIT binary patch literal 300 zcmeAS@N?(olHy`uVBq!ia0vp@K+Mg-1|*kkVowB8oCO|{#XzxhAj~*xjmB=Epk#?_ zL`iUdT1k0gQ7S`udAVL@UUqSEVnM22eo^}DcQ#T$MLRuR978lFwq7vIatah^eaOFE zVdI5}BfJsZQYGSx%rrOge_wEe^Hz6u*G8YD#0>&1ODYz}J+-yDy4UzK|8t)0tCHJv z{eB!Vc@^Mf&uVoeQSQCft%wKQwjm$N+2(!domj)W;kZHTu?SHHRg({W&RnK}+6_^O z)$Q>z+|T4*OGux)9mQI_wZNsqrscU?%8AQS)BZB?#;%{d-2CRv)0!cU=2G5!9;s$| s|G9Jfo%*zSh6meqUaS4PD)NKfJVrZn@#jZ3fSzFRboFyt=akR{0AuTO textBox1.Text; set { - textBox1.Text = value; - textBox1.SelectionStart = textBox1.Text.Length; + if (textBox1.InvokeRequired) + { + textBox1.Invoke(new MethodInvoker(() => { + textBox1.Text = value; + textBox1.SelectionStart = textBox1.Text.Length; + })); + } + else + { + textBox1.Text = value; + textBox1.SelectionStart = textBox1.Text.Length; + } } } diff --git a/UIResource.Designer.cs b/UIResource.Designer.cs index 511d9c7..bed00db 100644 --- a/UIResource.Designer.cs +++ b/UIResource.Designer.cs @@ -99,5 +99,25 @@ namespace VideoPreview { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap refresh { + get { + object obj = ResourceManager.GetObject("refresh", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap refresh2 { + get { + object obj = ResourceManager.GetObject("refresh2", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/UIResource.resx b/UIResource.resx index 2803227..0c7337a 100644 --- a/UIResource.resx +++ b/UIResource.resx @@ -130,4 +130,10 @@ Resources\UI\file2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Resources\UI\refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + Resources\UI\refresh2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file