mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 09:17:36 +13:00
Support image combine in main window with drag n drop
This commit is contained in:
parent
3ad81d6d6c
commit
2e87952175
4 changed files with 180 additions and 12 deletions
|
@ -112,7 +112,7 @@ public bool DrawBorder
|
|||
}
|
||||
}
|
||||
|
||||
private Color borderColor;
|
||||
private Color borderColor = Color.Black;
|
||||
|
||||
[DefaultValue(typeof(Color), "Black")]
|
||||
public Color BorderColor
|
||||
|
|
30
ShareX/Controls/TaskThumbnailPanel.Designer.cs
generated
30
ShareX/Controls/TaskThumbnailPanel.Designer.cs
generated
|
@ -36,7 +36,9 @@ private void InitializeComponent()
|
|||
this.ttMain = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.lblTitle = new ShareX.HelpersLib.BlackStyleLabel();
|
||||
this.pThumbnail = new ShareX.TaskRoundedCornerPanel();
|
||||
this.lblCombineVertical = new ShareX.HelpersLib.BlackStyleLabel();
|
||||
this.lblError = new ShareX.HelpersLib.BlackStyleLabel();
|
||||
this.lblCombineHorizontal = new ShareX.HelpersLib.BlackStyleLabel();
|
||||
this.pbProgress = new ShareX.HelpersLib.BlackStyleProgressBar();
|
||||
this.pbThumbnail = new System.Windows.Forms.PictureBox();
|
||||
this.pThumbnail.SuspendLayout();
|
||||
|
@ -64,7 +66,9 @@ private void InitializeComponent()
|
|||
// pThumbnail
|
||||
//
|
||||
this.pThumbnail.BackColor = System.Drawing.Color.Transparent;
|
||||
this.pThumbnail.Controls.Add(this.lblCombineVertical);
|
||||
this.pThumbnail.Controls.Add(this.lblError);
|
||||
this.pThumbnail.Controls.Add(this.lblCombineHorizontal);
|
||||
this.pThumbnail.Controls.Add(this.pbProgress);
|
||||
this.pThumbnail.Controls.Add(this.pbThumbnail);
|
||||
resources.ApplyResources(this.pThumbnail, "pThumbnail");
|
||||
|
@ -74,6 +78,16 @@ private void InitializeComponent()
|
|||
this.pThumbnail.Selected = false;
|
||||
this.pThumbnail.StatusLocation = ShareX.ThumbnailTitleLocation.Top;
|
||||
//
|
||||
// lblCombineVertical
|
||||
//
|
||||
this.lblCombineVertical.BackColor = System.Drawing.Color.Transparent;
|
||||
this.lblCombineVertical.BorderColor = System.Drawing.Color.Empty;
|
||||
this.lblCombineVertical.DrawBorder = true;
|
||||
resources.ApplyResources(this.lblCombineVertical, "lblCombineVertical");
|
||||
this.lblCombineVertical.ForeColor = System.Drawing.Color.White;
|
||||
this.lblCombineVertical.Name = "lblCombineVertical";
|
||||
this.lblCombineVertical.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// lblError
|
||||
//
|
||||
resources.ApplyResources(this.lblError, "lblError");
|
||||
|
@ -84,6 +98,16 @@ private void InitializeComponent()
|
|||
this.lblError.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.lblError.MouseClick += new System.Windows.Forms.MouseEventHandler(this.lblError_MouseClick);
|
||||
//
|
||||
// lblCombineHorizontal
|
||||
//
|
||||
this.lblCombineHorizontal.BackColor = System.Drawing.Color.Transparent;
|
||||
this.lblCombineHorizontal.BorderColor = System.Drawing.Color.Empty;
|
||||
this.lblCombineHorizontal.DrawBorder = true;
|
||||
resources.ApplyResources(this.lblCombineHorizontal, "lblCombineHorizontal");
|
||||
this.lblCombineHorizontal.ForeColor = System.Drawing.Color.White;
|
||||
this.lblCombineHorizontal.Name = "lblCombineHorizontal";
|
||||
this.lblCombineHorizontal.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// pbProgress
|
||||
//
|
||||
resources.ApplyResources(this.pbProgress, "pbProgress");
|
||||
|
@ -105,12 +129,16 @@ private void InitializeComponent()
|
|||
//
|
||||
// TaskThumbnailPanel
|
||||
//
|
||||
this.AllowDrop = true;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.Controls.Add(this.pThumbnail);
|
||||
this.Controls.Add(this.lblTitle);
|
||||
this.Name = "TaskThumbnailPanel";
|
||||
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.TaskThumbnailPanel_DragDrop);
|
||||
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.TaskThumbnailPanel_DragEnter);
|
||||
this.DragLeave += new System.EventHandler(this.TaskThumbnailPanel_DragLeave);
|
||||
this.pThumbnail.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbThumbnail)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -125,5 +153,7 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.PictureBox pbThumbnail;
|
||||
private System.Windows.Forms.ToolTip ttMain;
|
||||
private HelpersLib.BlackStyleLabel lblError;
|
||||
private HelpersLib.BlackStyleLabel lblCombineHorizontal;
|
||||
private HelpersLib.BlackStyleLabel lblCombineVertical;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,6 +233,7 @@ public Size ThumbnailSize
|
|||
public ThumbnailViewClickAction ClickAction { get; set; }
|
||||
|
||||
private Rectangle dragBoxFromMouseDown;
|
||||
private Orientation combineOrientation;
|
||||
|
||||
public TaskThumbnailPanel(WorkerTask task)
|
||||
{
|
||||
|
@ -257,6 +258,8 @@ public void UpdateTheme()
|
|||
pThumbnail.PanelColor = ShareXResources.Theme.DarkBackgroundColor;
|
||||
ttMain.BackColor = ShareXResources.Theme.BackgroundColor;
|
||||
ttMain.ForeColor = ShareXResources.Theme.TextColor;
|
||||
lblCombineHorizontal.BorderColor = ShareXResources.Theme.BorderColor;
|
||||
lblCombineVertical.BorderColor = ShareXResources.Theme.BorderColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -265,6 +268,8 @@ public void UpdateTheme()
|
|||
pThumbnail.PanelColor = SystemColors.ControlLight;
|
||||
ttMain.BackColor = SystemColors.Window;
|
||||
ttMain.ForeColor = SystemColors.ControlText;
|
||||
lblCombineHorizontal.BorderColor = Color.Black;
|
||||
lblCombineVertical.BorderColor = Color.Black;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,6 +321,11 @@ private void UpdateLayout()
|
|||
lblTitle.Location = new Point(0, pThumbnail.Height + 2);
|
||||
lblError.Location = new Point((ClientSize.Width - lblError.Width) / 2, pThumbnail.Height - lblError.Height - 1);
|
||||
}
|
||||
|
||||
lblCombineHorizontal.Location = new Point(0, 0);
|
||||
lblCombineHorizontal.Size = new Size(pThumbnail.Width, pThumbnail.Height / 2);
|
||||
lblCombineVertical.Location = new Point(0, pThumbnail.Height / 2 - 1);
|
||||
lblCombineVertical.Size = new Size(pThumbnail.Width, pThumbnail.Height / 2);
|
||||
}
|
||||
|
||||
public void UpdateThumbnail(Bitmap bmp = null)
|
||||
|
@ -560,11 +570,20 @@ private void PbThumbnail_MouseMove(object sender, MouseEventArgs e)
|
|||
{
|
||||
if (Task.Info != null && !string.IsNullOrEmpty(Task.Info.FilePath) && File.Exists(Task.Info.FilePath))
|
||||
{
|
||||
AllowDrop = false;
|
||||
Program.MainForm.AllowDrop = false;
|
||||
IDataObject dataObject = new DataObject(DataFormats.FileDrop, new string[] { Task.Info.FilePath });
|
||||
dragBoxFromMouseDown = Rectangle.Empty;
|
||||
pbThumbnail.DoDragDrop(dataObject, DragDropEffects.Copy | DragDropEffects.Move);
|
||||
Program.MainForm.AllowDrop = true;
|
||||
|
||||
try
|
||||
{
|
||||
IDataObject dataObject = new DataObject(DataFormats.FileDrop, new string[] { Task.Info.FilePath });
|
||||
dragBoxFromMouseDown = Rectangle.Empty;
|
||||
pbThumbnail.DoDragDrop(dataObject, DragDropEffects.Copy | DragDropEffects.Move);
|
||||
}
|
||||
finally
|
||||
{
|
||||
AllowDrop = true;
|
||||
Program.MainForm.AllowDrop = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -573,6 +592,62 @@ private void PbThumbnail_MouseMove(object sender, MouseEventArgs e)
|
|||
}
|
||||
}
|
||||
|
||||
private void TaskThumbnailPanel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
string filePath = Task.Info.FilePath;
|
||||
|
||||
if (FileHelpers.IsImageFile(filePath) && e.Data.GetDataPresent(DataFormats.FileDrop, false) &&
|
||||
e.Data.GetData(DataFormats.FileDrop, false) is string[] files && files.Length > 0 && FileHelpers.IsImageFile(files[0]))
|
||||
{
|
||||
lblCombineHorizontal.Visible = true;
|
||||
lblCombineVertical.Visible = true;
|
||||
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void TaskThumbnailPanel_DragLeave(object sender, EventArgs e)
|
||||
{
|
||||
lblCombineHorizontal.Visible = false;
|
||||
lblCombineVertical.Visible = false;
|
||||
}
|
||||
|
||||
private void TaskThumbnailPanel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
Rectangle horizontal = lblCombineHorizontal.RectangleToScreen(lblCombineHorizontal.ClientRectangle);
|
||||
|
||||
if (horizontal.Contains(e.X, e.Y))
|
||||
{
|
||||
combineOrientation = Orientation.Horizontal;
|
||||
}
|
||||
else
|
||||
{
|
||||
Rectangle vertical = lblCombineVertical.RectangleToScreen(lblCombineVertical.ClientRectangle);
|
||||
|
||||
if (vertical.Contains(e.X, e.Y))
|
||||
{
|
||||
combineOrientation = Orientation.Vertical;
|
||||
}
|
||||
}
|
||||
|
||||
string filePath = Task.Info.FilePath;
|
||||
|
||||
if (FileHelpers.IsImageFile(filePath) && e.Data.GetDataPresent(DataFormats.FileDrop, false) &&
|
||||
e.Data.GetData(DataFormats.FileDrop, false) is string[] files && files.Length > 0 && FileHelpers.IsImageFile(files[0]))
|
||||
{
|
||||
string filePathDrop = files[0];
|
||||
|
||||
TaskHelpers.CombineImages(new string[] { filePathDrop, filePath }, combineOrientation);
|
||||
}
|
||||
|
||||
lblCombineHorizontal.Visible = false;
|
||||
lblCombineVertical.Visible = false;
|
||||
}
|
||||
|
||||
private void TtMain_Draw(object sender, DrawToolTipEventArgs e)
|
||||
{
|
||||
e.DrawBackground();
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
<value>lblTitle</value>
|
||||
</data>
|
||||
<data name=">>lblTitle.Type" xml:space="preserve">
|
||||
<value>ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=13.6.2.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
<value>ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>lblTitle.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
|
@ -146,6 +146,36 @@
|
|||
<data name=">>lblTitle.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="lblCombineVertical.Font" type="System.Drawing.Font, System.Drawing">
|
||||
<value>Segoe UI, 20.25pt</value>
|
||||
</data>
|
||||
<data name="lblCombineVertical.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>40, 128</value>
|
||||
</data>
|
||||
<data name="lblCombineVertical.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>184, 80</value>
|
||||
</data>
|
||||
<data name="lblCombineVertical.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>6</value>
|
||||
</data>
|
||||
<data name="lblCombineVertical.Text" xml:space="preserve">
|
||||
<value>Vertical</value>
|
||||
</data>
|
||||
<data name="lblCombineVertical.Visible" type="System.Boolean, mscorlib">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name=">>lblCombineVertical.Name" xml:space="preserve">
|
||||
<value>lblCombineVertical</value>
|
||||
</data>
|
||||
<data name=">>lblCombineVertical.Type" xml:space="preserve">
|
||||
<value>ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>lblCombineVertical.Parent" xml:space="preserve">
|
||||
<value>pThumbnail</value>
|
||||
</data>
|
||||
<data name=">>lblCombineVertical.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="lblError.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Top</value>
|
||||
|
@ -172,13 +202,43 @@
|
|||
<value>lblError</value>
|
||||
</data>
|
||||
<data name=">>lblError.Type" xml:space="preserve">
|
||||
<value>ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=13.6.2.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
<value>ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>lblError.Parent" xml:space="preserve">
|
||||
<value>pThumbnail</value>
|
||||
</data>
|
||||
<data name=">>lblError.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</data>
|
||||
<data name="lblCombineHorizontal.Font" type="System.Drawing.Font, System.Drawing">
|
||||
<value>Segoe UI, 20.25pt</value>
|
||||
</data>
|
||||
<data name="lblCombineHorizontal.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>40, 40</value>
|
||||
</data>
|
||||
<data name="lblCombineHorizontal.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>184, 80</value>
|
||||
</data>
|
||||
<data name="lblCombineHorizontal.TabIndex" type="System.Int32, mscorlib">
|
||||
<value>5</value>
|
||||
</data>
|
||||
<data name="lblCombineHorizontal.Text" xml:space="preserve">
|
||||
<value>Horizontal</value>
|
||||
</data>
|
||||
<data name="lblCombineHorizontal.Visible" type="System.Boolean, mscorlib">
|
||||
<value>False</value>
|
||||
</data>
|
||||
<data name=">>lblCombineHorizontal.Name" xml:space="preserve">
|
||||
<value>lblCombineHorizontal</value>
|
||||
</data>
|
||||
<data name=">>lblCombineHorizontal.Type" xml:space="preserve">
|
||||
<value>ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>lblCombineHorizontal.Parent" xml:space="preserve">
|
||||
<value>pThumbnail</value>
|
||||
</data>
|
||||
<data name=">>lblCombineHorizontal.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
</data>
|
||||
<data name="pbProgress.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
|
||||
<value>Bottom, Left, Right</value>
|
||||
|
@ -205,17 +265,20 @@
|
|||
<value>pbProgress</value>
|
||||
</data>
|
||||
<data name=">>pbProgress.Type" xml:space="preserve">
|
||||
<value>ShareX.HelpersLib.BlackStyleProgressBar, ShareX.HelpersLib, Version=13.6.2.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
<value>ShareX.HelpersLib.BlackStyleProgressBar, ShareX.HelpersLib, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>pbProgress.Parent" xml:space="preserve">
|
||||
<value>pThumbnail</value>
|
||||
</data>
|
||||
<data name=">>pbProgress.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
<value>3</value>
|
||||
</data>
|
||||
<data name="pbThumbnail.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||
<value>Fill</value>
|
||||
</data>
|
||||
<data name="pbThumbnail.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
|
||||
<value>NoControl</value>
|
||||
</data>
|
||||
<data name="pbThumbnail.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>4, 4</value>
|
||||
</data>
|
||||
|
@ -235,7 +298,7 @@
|
|||
<value>pThumbnail</value>
|
||||
</data>
|
||||
<data name=">>pbThumbnail.ZOrder" xml:space="preserve">
|
||||
<value>2</value>
|
||||
<value>4</value>
|
||||
</data>
|
||||
<data name="pThumbnail.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>0, 24</value>
|
||||
|
@ -253,7 +316,7 @@
|
|||
<value>pThumbnail</value>
|
||||
</data>
|
||||
<data name=">>pThumbnail.Type" xml:space="preserve">
|
||||
<value>ShareX.TaskRoundedCornerPanel, ShareX, Version=13.6.2.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
<value>ShareX.TaskRoundedCornerPanel, ShareX, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null</value>
|
||||
</data>
|
||||
<data name=">>pThumbnail.Parent" xml:space="preserve">
|
||||
<value>$this</value>
|
||||
|
|
Loading…
Reference in a new issue