diff --git a/ShareX.MediaLib/Forms/VideoConverterForm.Designer.cs b/ShareX.MediaLib/Forms/VideoConverterForm.Designer.cs index 61d486fac..2101461ed 100644 --- a/ShareX.MediaLib/Forms/VideoConverterForm.Designer.cs +++ b/ShareX.MediaLib/Forms/VideoConverterForm.Designer.cs @@ -176,8 +176,8 @@ private void InitializeComponent() // // VideoConverterForm // + this.AllowDrop = true; resources.ApplyResources(this, "$this"); - this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BackColor = System.Drawing.SystemColors.Window; this.Controls.Add(this.lblVideoQualityValue); @@ -204,6 +204,8 @@ private void InitializeComponent() this.MaximizeBox = false; this.Name = "VideoConverterForm"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.VideoConverterForm_FormClosing); + this.DragDrop += new System.Windows.Forms.DragEventHandler(this.VideoConverterForm_DragDrop); + this.DragEnter += new System.Windows.Forms.DragEventHandler(this.VideoConverterForm_DragEnter); ((System.ComponentModel.ISupportInitialize)(this.tbVideoQuality)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/ShareX.MediaLib/Forms/VideoConverterForm.cs b/ShareX.MediaLib/Forms/VideoConverterForm.cs index d8a2c2b5d..742297a8b 100644 --- a/ShareX.MediaLib/Forms/VideoConverterForm.cs +++ b/ShareX.MediaLib/Forms/VideoConverterForm.cs @@ -153,6 +153,21 @@ private void UpdateOptions() !string.IsNullOrEmpty(Options.OutputFileName); } + private void UpdateInputFilePathTextBox(string filePath) + { + txtInputFilePath.Text = filePath; + + if (string.IsNullOrEmpty(txtOutputFolder.Text)) + { + txtOutputFolder.Text = Path.GetDirectoryName(filePath); + } + + if (string.IsNullOrEmpty(txtOutputFileName.Text)) + { + txtOutputFileName.Text = Path.GetFileNameWithoutExtension(filePath) + "-output"; + } + } + private bool StartEncoding() { bool result = false; @@ -212,17 +227,7 @@ private void btnInputFilePathBrowse_Click(object sender, EventArgs e) if (ofd.ShowDialog(this) == DialogResult.OK) { string filePath = ofd.FileName; - txtInputFilePath.Text = filePath; - - if (string.IsNullOrEmpty(txtOutputFolder.Text)) - { - txtOutputFolder.Text = Path.GetDirectoryName(filePath); - } - - if (string.IsNullOrEmpty(txtOutputFileName.Text)) - { - txtOutputFileName.Text = Path.GetFileNameWithoutExtension(filePath) + "-output"; - } + UpdateInputFilePathTextBox(filePath); } } } @@ -302,6 +307,27 @@ private async void btnEncode_Click(object sender, EventArgs e) } } + private void VideoConverterForm_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void VideoConverterForm_DragDrop(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop, false) && e.Data.GetData(DataFormats.FileDrop, false) is string[] files && files.Length > 0) + { + string filePath = files[0]; + UpdateInputFilePathTextBox(filePath); + } + } + private void VideoConverterForm_FormClosing(object sender, FormClosingEventArgs e) { formClosing = true; diff --git a/ShareX.MediaLib/Forms/VideoConverterForm.resx b/ShareX.MediaLib/Forms/VideoConverterForm.resx index f1ed4c3ed..abc6dce51 100644 --- a/ShareX.MediaLib/Forms/VideoConverterForm.resx +++ b/ShareX.MediaLib/Forms/VideoConverterForm.resx @@ -594,7 +594,7 @@ pbProgress - ShareX.HelpersLib.BlackStyleProgressBar, ShareX.HelpersLib, Version=13.0.2.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.BlackStyleProgressBar, ShareX.HelpersLib, Version=13.6.1.0, Culture=neutral, PublicKeyToken=null $this @@ -633,7 +633,7 @@ True - 6, 13 + 96, 96 456, 278