Added: refresh

This commit is contained in:
Ray 2021-10-06 12:57:50 +01:00
parent 3e3d93f3c7
commit dccf7b2d06
8 changed files with 105 additions and 16 deletions

Binary file not shown.

23
MainForm.Designer.cs generated
View File

@ -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;
}
}

View File

@ -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
});
}
}
}

BIN
Resources/UI/refresh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

BIN
Resources/UI/refresh2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

View File

@ -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;
}
}
}

20
UIResource.Designer.cs generated
View File

@ -99,5 +99,25 @@ namespace VideoPreview {
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap refresh {
get {
object obj = ResourceManager.GetObject("refresh", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap refresh2 {
get {
object obj = ResourceManager.GetObject("refresh2", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -130,4 +130,10 @@
<data name="file2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\UI\file2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="refresh" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\UI\refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="refresh2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\UI\refresh2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>