diff --git a/.vs/VideoPreview/v16/.suo b/.vs/VideoPreview/v16/.suo index 30cbbf7..122de5e 100644 Binary files a/.vs/VideoPreview/v16/.suo and b/.vs/VideoPreview/v16/.suo differ 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 0000000..6e6d918 Binary files /dev/null and b/Resources/UI/refresh.png differ diff --git a/Resources/UI/refresh2.png b/Resources/UI/refresh2.png new file mode 100644 index 0000000..e14b40f Binary files /dev/null and b/Resources/UI/refresh2.png differ diff --git a/RyzStudio/Windows/ThemedForms/TextBox/TButtonTextBox.cs b/RyzStudio/Windows/ThemedForms/TextBox/TButtonTextBox.cs index 9f8f168..2bbab1a 100644 --- a/RyzStudio/Windows/ThemedForms/TextBox/TButtonTextBox.cs +++ b/RyzStudio/Windows/ThemedForms/TextBox/TButtonTextBox.cs @@ -102,8 +102,18 @@ get => 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