mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Show checkbox when panel is selected
This commit is contained in:
parent
928c3a7fcb
commit
a62cc8c700
4 changed files with 91 additions and 17 deletions
17
ShareX/Controls/TaskThumbnailPanel.Designer.cs
generated
17
ShareX/Controls/TaskThumbnailPanel.Designer.cs
generated
|
@ -34,6 +34,7 @@ private void InitializeComponent()
|
|||
this.components = new System.ComponentModel.Container();
|
||||
this.lblTitle = new ShareX.HelpersLib.BlackStyleLabel();
|
||||
this.ttMain = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.cbSelected = new ShareX.HelpersLib.BlackStyleCheckBox();
|
||||
this.pThumbnail = new ShareX.TaskRoundedCornerPanel();
|
||||
this.pbProgress = new ShareX.HelpersLib.BlackStyleProgressBar();
|
||||
this.pbThumbnail = new System.Windows.Forms.PictureBox();
|
||||
|
@ -63,9 +64,23 @@ private void InitializeComponent()
|
|||
this.ttMain.ReshowDelay = 100;
|
||||
this.ttMain.Draw += new System.Windows.Forms.DrawToolTipEventHandler(this.TtMain_Draw);
|
||||
//
|
||||
// cbSelected
|
||||
//
|
||||
this.cbSelected.BackColor = System.Drawing.Color.Transparent;
|
||||
this.cbSelected.Checked = true;
|
||||
this.cbSelected.Font = new System.Drawing.Font("Arial", 8F);
|
||||
this.cbSelected.ForeColor = System.Drawing.Color.White;
|
||||
this.cbSelected.Location = new System.Drawing.Point(8, 8);
|
||||
this.cbSelected.Name = "cbSelected";
|
||||
this.cbSelected.Size = new System.Drawing.Size(13, 13);
|
||||
this.cbSelected.SpaceAfterCheckBox = 3;
|
||||
this.cbSelected.TabIndex = 2;
|
||||
this.cbSelected.Visible = false;
|
||||
//
|
||||
// pThumbnail
|
||||
//
|
||||
this.pThumbnail.BackColor = System.Drawing.Color.Transparent;
|
||||
this.pThumbnail.Controls.Add(this.cbSelected);
|
||||
this.pThumbnail.Controls.Add(this.pbProgress);
|
||||
this.pThumbnail.Controls.Add(this.pbThumbnail);
|
||||
this.pThumbnail.Location = new System.Drawing.Point(0, 24);
|
||||
|
@ -74,6 +89,7 @@ private void InitializeComponent()
|
|||
this.pThumbnail.PanelColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(32)))), ((int)(((byte)(38)))));
|
||||
this.pThumbnail.Radius = 5F;
|
||||
this.pThumbnail.Size = new System.Drawing.Size(256, 256);
|
||||
this.pThumbnail.StatusLocation = ShareX.ThumbnailTitleLocation.Top;
|
||||
this.pThumbnail.TabIndex = 0;
|
||||
this.pThumbnail.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PbThumbnail_MouseClick);
|
||||
//
|
||||
|
@ -128,5 +144,6 @@ private void InitializeComponent()
|
|||
private HelpersLib.BlackStyleProgressBar pbProgress;
|
||||
private System.Windows.Forms.PictureBox pbThumbnail;
|
||||
private System.Windows.Forms.ToolTip ttMain;
|
||||
private HelpersLib.BlackStyleCheckBox cbSelected;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,25 @@ public partial class TaskThumbnailPanel : UserControl
|
|||
|
||||
public WorkerTask Task { get; private set; }
|
||||
|
||||
private bool selected;
|
||||
|
||||
public bool Selected
|
||||
{
|
||||
get
|
||||
{
|
||||
return selected;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (selected != value)
|
||||
{
|
||||
selected = value;
|
||||
|
||||
cbSelected.Visible = selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string title;
|
||||
|
||||
public string Title
|
||||
|
@ -428,7 +447,7 @@ private void PbThumbnail_MouseUp(object sender, MouseEventArgs e)
|
|||
|
||||
private void PbThumbnail_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (ThumbnailSupportsClick && e.Button == MouseButtons.Left && Task.Info != null)
|
||||
if (ThumbnailSupportsClick && ModifierKeys != Keys.Control && e.Button == MouseButtons.Left && Task.Info != null)
|
||||
{
|
||||
string filePath = Task.Info.FilePath;
|
||||
|
||||
|
|
4
ShareX/Controls/TaskThumbnailView.Designer.cs
generated
4
ShareX/Controls/TaskThumbnailView.Designer.cs
generated
|
@ -42,7 +42,7 @@ private void InitializeComponent()
|
|||
this.flpMain.TabIndex = 0;
|
||||
this.flpMain.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FlpMain_MouseDown);
|
||||
this.flpMain.MouseEnter += new System.EventHandler(this.FlpMain_MouseEnter);
|
||||
this.flpMain.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Panel_MouseUp);
|
||||
this.flpMain.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TaskThumbnailView_MouseUp);
|
||||
//
|
||||
// TaskThumbnailView
|
||||
//
|
||||
|
@ -55,7 +55,7 @@ private void InitializeComponent()
|
|||
this.Size = new System.Drawing.Size(242, 228);
|
||||
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.FlpMain_MouseDown);
|
||||
this.MouseEnter += new System.EventHandler(this.FlpMain_MouseEnter);
|
||||
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Panel_MouseUp);
|
||||
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TaskThumbnailView_MouseUp);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License
|
|||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
@ -153,16 +154,7 @@ private TaskThumbnailPanel CreatePanel(WorkerTask task)
|
|||
{
|
||||
TaskThumbnailPanel panel = new TaskThumbnailPanel(task);
|
||||
panel.MouseEnter += FlpMain_MouseEnter;
|
||||
panel.MouseDown += (sender, e) =>
|
||||
{
|
||||
if (ModifierKeys == Keys.Control)
|
||||
{
|
||||
SelectedPanels.Clear();
|
||||
}
|
||||
|
||||
SelectedPanels.Add(panel);
|
||||
};
|
||||
panel.MouseUp += Panel_MouseUp;
|
||||
panel.MouseUp += (object sender, MouseEventArgs e) => Panel_MouseUp(sender, e, panel);
|
||||
panel.ThumbnailSize = ThumbnailSize;
|
||||
panel.TitleVisible = TitleVisible;
|
||||
panel.TitleLocation = TitleLocation;
|
||||
|
@ -206,6 +198,16 @@ public void UpdateAllThumbnails(bool forceUpdate = false)
|
|||
}
|
||||
}
|
||||
|
||||
public void UnselectAllPanels()
|
||||
{
|
||||
SelectedPanels.Clear();
|
||||
|
||||
foreach (TaskThumbnailPanel panel in Panels)
|
||||
{
|
||||
panel.Selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnContextMenuRequested(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (ContextMenuRequested != null)
|
||||
|
@ -214,7 +216,7 @@ protected void OnContextMenuRequested(object sender, MouseEventArgs e)
|
|||
}
|
||||
}
|
||||
|
||||
private void FlpMain_MouseEnter(object sender, System.EventArgs e)
|
||||
private void FlpMain_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
// Workaround to handle mouse wheel scrolling in Windows 7
|
||||
if (NativeMethods.GetForegroundWindow() == ParentForm.Handle && !flpMain.Focused)
|
||||
|
@ -225,12 +227,48 @@ private void FlpMain_MouseEnter(object sender, System.EventArgs e)
|
|||
|
||||
private void FlpMain_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
SelectedPanels.Clear();
|
||||
UnselectAllPanels();
|
||||
}
|
||||
|
||||
private void Panel_MouseUp(object sender, MouseEventArgs e)
|
||||
private void TaskThumbnailView_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
Panel_MouseUp(sender, e, null);
|
||||
}
|
||||
|
||||
private void Panel_MouseUp(object sender, MouseEventArgs e, TaskThumbnailPanel panel)
|
||||
{
|
||||
if (panel == null)
|
||||
{
|
||||
UnselectAllPanels();
|
||||
}
|
||||
|
||||
if (panel != null)
|
||||
{
|
||||
if (ModifierKeys == Keys.Control)
|
||||
{
|
||||
if (panel.Selected)
|
||||
{
|
||||
panel.Selected = false;
|
||||
SelectedPanels.Remove(panel);
|
||||
}
|
||||
else
|
||||
{
|
||||
panel.Selected = true;
|
||||
SelectedPanels.Add(panel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!panel.Selected)
|
||||
{
|
||||
UnselectAllPanels();
|
||||
panel.Selected = true;
|
||||
SelectedPanels.Add(panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ModifierKeys != Keys.Control && e.Button == MouseButtons.Right)
|
||||
{
|
||||
OnContextMenuRequested(sender, e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue