From 3ad81d6d6cdc379ebf48e3f3456f499d732eb634 Mon Sep 17 00:00:00 2001 From: Jaex Date: Fri, 30 Sep 2022 03:59:40 +0300 Subject: [PATCH 1/3] Added BorderColor --- .../Controls/BlackStyle/BlackStyleLabel.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ShareX.HelpersLib/Controls/BlackStyle/BlackStyleLabel.cs b/ShareX.HelpersLib/Controls/BlackStyle/BlackStyleLabel.cs index d794448db..e7f01f823 100644 --- a/ShareX.HelpersLib/Controls/BlackStyle/BlackStyleLabel.cs +++ b/ShareX.HelpersLib/Controls/BlackStyle/BlackStyleLabel.cs @@ -112,6 +112,23 @@ public bool DrawBorder } } + private Color borderColor; + + [DefaultValue(typeof(Color), "Black")] + public Color BorderColor + { + get + { + return borderColor; + } + set + { + borderColor = value; + + Invalidate(); + } + } + private bool autoEllipsis; [DefaultValue(false)] @@ -150,7 +167,10 @@ protected override void OnPaint(PaintEventArgs pe) if (drawBorder) { - g.DrawRectangleProper(Pens.Black, ClientRectangle); + using (Pen pen = new Pen(BorderColor, 1)) + { + g.DrawRectangleProper(pen, ClientRectangle); + } } } } From 2e87952175a5252d0d77fb3c755b792e6e8c012e Mon Sep 17 00:00:00 2001 From: Jaex Date: Fri, 30 Sep 2022 04:12:23 +0300 Subject: [PATCH 2/3] Support image combine in main window with drag n drop --- .../Controls/BlackStyle/BlackStyleLabel.cs | 2 +- .../Controls/TaskThumbnailPanel.Designer.cs | 30 +++++++ ShareX/Controls/TaskThumbnailPanel.cs | 83 ++++++++++++++++++- ShareX/Controls/TaskThumbnailPanel.resx | 77 +++++++++++++++-- 4 files changed, 180 insertions(+), 12 deletions(-) diff --git a/ShareX.HelpersLib/Controls/BlackStyle/BlackStyleLabel.cs b/ShareX.HelpersLib/Controls/BlackStyle/BlackStyleLabel.cs index e7f01f823..f4b976b23 100644 --- a/ShareX.HelpersLib/Controls/BlackStyle/BlackStyleLabel.cs +++ b/ShareX.HelpersLib/Controls/BlackStyle/BlackStyleLabel.cs @@ -112,7 +112,7 @@ public bool DrawBorder } } - private Color borderColor; + private Color borderColor = Color.Black; [DefaultValue(typeof(Color), "Black")] public Color BorderColor diff --git a/ShareX/Controls/TaskThumbnailPanel.Designer.cs b/ShareX/Controls/TaskThumbnailPanel.Designer.cs index 6b8e29b94..fab610e23 100644 --- a/ShareX/Controls/TaskThumbnailPanel.Designer.cs +++ b/ShareX/Controls/TaskThumbnailPanel.Designer.cs @@ -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; } } diff --git a/ShareX/Controls/TaskThumbnailPanel.cs b/ShareX/Controls/TaskThumbnailPanel.cs index e85cf3416..4edcd0bd5 100644 --- a/ShareX/Controls/TaskThumbnailPanel.cs +++ b/ShareX/Controls/TaskThumbnailPanel.cs @@ -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(); diff --git a/ShareX/Controls/TaskThumbnailPanel.resx b/ShareX/Controls/TaskThumbnailPanel.resx index 258adaab8..0bfd9a2ea 100644 --- a/ShareX/Controls/TaskThumbnailPanel.resx +++ b/ShareX/Controls/TaskThumbnailPanel.resx @@ -138,7 +138,7 @@ lblTitle - ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=13.6.2.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null $this @@ -146,6 +146,36 @@ 1 + + Segoe UI, 20.25pt + + + 40, 128 + + + 184, 80 + + + 6 + + + Vertical + + + False + + + lblCombineVertical + + + ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null + + + pThumbnail + + + 0 + Top @@ -172,13 +202,43 @@ lblError - ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=13.6.2.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null pThumbnail - 0 + 1 + + + Segoe UI, 20.25pt + + + 40, 40 + + + 184, 80 + + + 5 + + + Horizontal + + + False + + + lblCombineHorizontal + + + ShareX.HelpersLib.BlackStyleLabel, ShareX.HelpersLib, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null + + + pThumbnail + + + 2 Bottom, Left, Right @@ -205,17 +265,20 @@ pbProgress - ShareX.HelpersLib.BlackStyleProgressBar, ShareX.HelpersLib, Version=13.6.2.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.BlackStyleProgressBar, ShareX.HelpersLib, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null pThumbnail - 1 + 3 Fill + + NoControl + 4, 4 @@ -235,7 +298,7 @@ pThumbnail - 2 + 4 0, 24 @@ -253,7 +316,7 @@ pThumbnail - ShareX.TaskRoundedCornerPanel, ShareX, Version=13.6.2.0, Culture=neutral, PublicKeyToken=null + ShareX.TaskRoundedCornerPanel, ShareX, Version=14.1.3.0, Culture=neutral, PublicKeyToken=null $this From 16772609467354907c6ab71118d59ae437dedcae Mon Sep 17 00:00:00 2001 From: Jaex Date: Fri, 30 Sep 2022 07:00:36 +0300 Subject: [PATCH 3/3] Overlay visual improvements --- .../Controls/TaskThumbnailPanel.Designer.cs | 8 ++--- ShareX/Controls/TaskThumbnailPanel.cs | 36 ++++++++----------- ShareX/Controls/TaskThumbnailPanel.resx | 10 +++--- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/ShareX/Controls/TaskThumbnailPanel.Designer.cs b/ShareX/Controls/TaskThumbnailPanel.Designer.cs index fab610e23..ec133cca3 100644 --- a/ShareX/Controls/TaskThumbnailPanel.Designer.cs +++ b/ShareX/Controls/TaskThumbnailPanel.Designer.cs @@ -65,6 +65,7 @@ private void InitializeComponent() // // pThumbnail // + this.pThumbnail.AllowDrop = true; this.pThumbnail.BackColor = System.Drawing.Color.Transparent; this.pThumbnail.Controls.Add(this.lblCombineVertical); this.pThumbnail.Controls.Add(this.lblError); @@ -77,6 +78,9 @@ private void InitializeComponent() this.pThumbnail.Radius = 5F; this.pThumbnail.Selected = false; this.pThumbnail.StatusLocation = ShareX.ThumbnailTitleLocation.Top; + this.pThumbnail.DragDrop += new System.Windows.Forms.DragEventHandler(this.pThumbnail_DragDrop); + this.pThumbnail.DragEnter += new System.Windows.Forms.DragEventHandler(this.pThumbnail_DragEnter); + this.pThumbnail.DragLeave += new System.EventHandler(this.pThumbnail_DragLeave); // // lblCombineVertical // @@ -129,16 +133,12 @@ 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); diff --git a/ShareX/Controls/TaskThumbnailPanel.cs b/ShareX/Controls/TaskThumbnailPanel.cs index 4edcd0bd5..78c62d1df 100644 --- a/ShareX/Controls/TaskThumbnailPanel.cs +++ b/ShareX/Controls/TaskThumbnailPanel.cs @@ -233,7 +233,6 @@ public Size ThumbnailSize public ThumbnailViewClickAction ClickAction { get; set; } private Rectangle dragBoxFromMouseDown; - private Orientation combineOrientation; public TaskThumbnailPanel(WorkerTask task) { @@ -322,10 +321,10 @@ private void UpdateLayout() 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); + lblCombineHorizontal.Location = new Point(pbThumbnail.Left, pbThumbnail.Top); + lblCombineHorizontal.Size = new Size(pbThumbnail.Width, pbThumbnail.Height / 2); + lblCombineVertical.Location = new Point(pbThumbnail.Left, pbThumbnail.Top + pbThumbnail.Height / 2 - 1); + lblCombineVertical.Size = new Size(pbThumbnail.Width, pbThumbnail.Height / 2 + 1); } public void UpdateThumbnail(Bitmap bmp = null) @@ -570,7 +569,7 @@ private void PbThumbnail_MouseMove(object sender, MouseEventArgs e) { if (Task.Info != null && !string.IsNullOrEmpty(Task.Info.FilePath) && File.Exists(Task.Info.FilePath)) { - AllowDrop = false; + pThumbnail.AllowDrop = false; Program.MainForm.AllowDrop = false; try @@ -581,7 +580,7 @@ private void PbThumbnail_MouseMove(object sender, MouseEventArgs e) } finally { - AllowDrop = true; + pThumbnail.AllowDrop = true; Program.MainForm.AllowDrop = true; } } @@ -592,7 +591,7 @@ private void PbThumbnail_MouseMove(object sender, MouseEventArgs e) } } - private void TaskThumbnailPanel_DragEnter(object sender, DragEventArgs e) + private void pThumbnail_DragEnter(object sender, DragEventArgs e) { string filePath = Task.Info.FilePath; @@ -610,28 +609,21 @@ private void TaskThumbnailPanel_DragEnter(object sender, DragEventArgs e) } } - private void TaskThumbnailPanel_DragLeave(object sender, EventArgs e) + private void pThumbnail_DragLeave(object sender, EventArgs e) { lblCombineHorizontal.Visible = false; lblCombineVertical.Visible = false; } - private void TaskThumbnailPanel_DragDrop(object sender, DragEventArgs e) + private void pThumbnail_DragDrop(object sender, DragEventArgs e) { - Rectangle horizontal = lblCombineHorizontal.RectangleToScreen(lblCombineHorizontal.ClientRectangle); + Orientation combineOrientation = Orientation.Horizontal; - if (horizontal.Contains(e.X, e.Y)) - { - combineOrientation = Orientation.Horizontal; - } - else - { - Rectangle vertical = lblCombineVertical.RectangleToScreen(lblCombineVertical.ClientRectangle); + Point vertical = lblCombineVertical.PointToScreen(lblCombineVertical.ClientRectangle.Location); - if (vertical.Contains(e.X, e.Y)) - { - combineOrientation = Orientation.Vertical; - } + if (e.Y >= vertical.Y) + { + combineOrientation = Orientation.Vertical; } string filePath = Task.Info.FilePath; diff --git a/ShareX/Controls/TaskThumbnailPanel.resx b/ShareX/Controls/TaskThumbnailPanel.resx index 0bfd9a2ea..ff41cd986 100644 --- a/ShareX/Controls/TaskThumbnailPanel.resx +++ b/ShareX/Controls/TaskThumbnailPanel.resx @@ -147,7 +147,7 @@ 1 - Segoe UI, 20.25pt + Segoe UI, 14.25pt 40, 128 @@ -159,7 +159,8 @@ 6 - Vertical + Combine images +(Vertical) False @@ -211,7 +212,7 @@ 1 - Segoe UI, 20.25pt + Segoe UI, 14.25pt 40, 40 @@ -223,7 +224,8 @@ 5 - Horizontal + Combine images +(Horizontal) False