mirror of
https://github.com/ShareX/ShareX.git
synced 2024-06-24 01:00:27 +12:00
Added "Pin to screen" button to history form context menu
This commit is contained in:
parent
330b7309e7
commit
a632c4face
|
@ -49,7 +49,7 @@ public partial class HistoryForm : Form
|
|||
private ListViewItem[] listViewCache;
|
||||
private int listViewCacheStartIndex;
|
||||
|
||||
public HistoryForm(string historyPath, HistorySettings settings, Action<string> uploadFile = null, Action<string> editImage = null)
|
||||
public HistoryForm(string historyPath, HistorySettings settings, Action<string> uploadFile = null, Action<string> editImage = null, Action<string> pinToScreen = null)
|
||||
{
|
||||
HistoryPath = historyPath;
|
||||
Settings = settings;
|
||||
|
@ -73,7 +73,7 @@ public HistoryForm(string historyPath, HistorySettings settings, Action<string>
|
|||
il.Images.Add(Resources.globe);
|
||||
lvHistory.SmallImageList = il;
|
||||
|
||||
him = new HistoryItemManager(uploadFile, editImage, true);
|
||||
him = new HistoryItemManager(uploadFile, editImage, pinToScreen, true);
|
||||
him.GetHistoryItems += him_GetHistoryItems;
|
||||
lvHistory.ContextMenuStrip = him.cmsHistory;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public partial class ImageHistoryForm : Form
|
|||
private HistoryItemManager him;
|
||||
private string defaultTitle;
|
||||
|
||||
public ImageHistoryForm(string historyPath, ImageHistorySettings settings, Action<string> uploadFile = null, Action<string> editImage = null)
|
||||
public ImageHistoryForm(string historyPath, ImageHistorySettings settings, Action<string> uploadFile = null, Action<string> editImage = null, Action<string> pinToScreen = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
tsMain.Renderer = new ToolStripRoundedEdgeRenderer();
|
||||
|
@ -61,7 +61,7 @@ public ImageHistoryForm(string historyPath, ImageHistorySettings settings, Actio
|
|||
ilvImages.BorderStyle = BorderStyle.None;
|
||||
}
|
||||
|
||||
him = new HistoryItemManager(uploadFile, editImage);
|
||||
him = new HistoryItemManager(uploadFile, editImage, pinToScreen);
|
||||
him.GetHistoryItems += him_GetHistoryItems;
|
||||
ilvImages.ContextMenuStrip = him.cmsHistory;
|
||||
|
||||
|
|
|
@ -50,12 +50,13 @@ public partial class HistoryItemManager
|
|||
public bool IsImageFile { get; private set; }
|
||||
public bool IsTextFile { get; private set; }
|
||||
|
||||
private Action<string> uploadFile, editImage;
|
||||
private Action<string> uploadFile, editImage, pinToScreen;
|
||||
|
||||
public HistoryItemManager(Action<string> uploadFile, Action<string> editImage, bool hideShowMoreInfoButton = false)
|
||||
public HistoryItemManager(Action<string> uploadFile, Action<string> editImage, Action<string> pinToScreen, bool hideShowMoreInfoButton = false)
|
||||
{
|
||||
this.uploadFile = uploadFile;
|
||||
this.editImage = editImage;
|
||||
this.pinToScreen = pinToScreen;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
|
@ -63,6 +64,7 @@ public HistoryItemManager(Action<string> uploadFile, Action<string> editImage, b
|
|||
tsmiCopy.HideImageMargin();
|
||||
tsmiUploadFile.Visible = uploadFile != null;
|
||||
tsmiEditImage.Visible = editImage != null;
|
||||
tsmiPinToScreen.Visible = pinToScreen != null;
|
||||
tsmiShowMoreInfo.Visible = !hideShowMoreInfoButton;
|
||||
}
|
||||
|
||||
|
@ -145,6 +147,9 @@ public bool HandleKeyInput(KeyEventArgs e)
|
|||
case Keys.Control | Keys.E:
|
||||
EditImage();
|
||||
break;
|
||||
case Keys.Control | Keys.P:
|
||||
PinToScreen();
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -574,6 +579,11 @@ public void EditImage()
|
|||
if (editImage != null && HistoryItem != null && IsImageFile) editImage(HistoryItem.FilePath);
|
||||
}
|
||||
|
||||
public void PinToScreen()
|
||||
{
|
||||
if (pinToScreen != null && HistoryItem != null && IsImageFile) pinToScreen(HistoryItem.FilePath);
|
||||
}
|
||||
|
||||
public void ShowMoreInfo()
|
||||
{
|
||||
new HistoryItemInfoForm(HistoryItem).Show();
|
||||
|
|
|
@ -42,6 +42,7 @@ public partial class HistoryItemManager
|
|||
private ToolStripSeparator tssOpen1;
|
||||
private ToolStripMenuItem tsmiOpenFile;
|
||||
private ToolStripMenuItem tsmiOpenFolder;
|
||||
|
||||
private ToolStripMenuItem tsmiCopy;
|
||||
private ToolStripMenuItem tsmiCopyURL;
|
||||
private ToolStripMenuItem tsmiCopyShortenedURL;
|
||||
|
@ -68,14 +69,17 @@ public partial class HistoryItemManager
|
|||
private ToolStripMenuItem tsmiCopyFileName;
|
||||
private ToolStripMenuItem tsmiCopyFileNameWithExtension;
|
||||
private ToolStripMenuItem tsmiCopyFolder;
|
||||
|
||||
private ToolStripMenuItem tsmiShowImagePreview;
|
||||
private ToolStripMenuItem tsmiShowMoreInfo;
|
||||
private ToolStripMenuItem tsmiUploadFile;
|
||||
private ToolStripMenuItem tsmiEditImage;
|
||||
private ToolStripMenuItem tsmiPinToScreen;
|
||||
private ToolStripMenuItem tsmiShowMoreInfo;
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
cmsHistory = new ContextMenuStrip();
|
||||
|
||||
tsmiOpen = new ToolStripMenuItem();
|
||||
tsmiOpenURL = new ToolStripMenuItem();
|
||||
tsmiOpenShortenedURL = new ToolStripMenuItem();
|
||||
|
@ -84,6 +88,7 @@ private void InitializeComponent()
|
|||
tssOpen1 = new ToolStripSeparator();
|
||||
tsmiOpenFile = new ToolStripMenuItem();
|
||||
tsmiOpenFolder = new ToolStripMenuItem();
|
||||
|
||||
tsmiCopy = new ToolStripMenuItem();
|
||||
tsmiCopyURL = new ToolStripMenuItem();
|
||||
tsmiCopyShortenedURL = new ToolStripMenuItem();
|
||||
|
@ -110,10 +115,13 @@ private void InitializeComponent()
|
|||
tsmiCopyFileName = new ToolStripMenuItem();
|
||||
tsmiCopyFileNameWithExtension = new ToolStripMenuItem();
|
||||
tsmiCopyFolder = new ToolStripMenuItem();
|
||||
|
||||
tsmiShowImagePreview = new ToolStripMenuItem();
|
||||
tsmiShowMoreInfo = new ToolStripMenuItem();
|
||||
tsmiUploadFile = new ToolStripMenuItem();
|
||||
tsmiEditImage = new ToolStripMenuItem();
|
||||
tsmiPinToScreen = new ToolStripMenuItem();
|
||||
tsmiShowMoreInfo = new ToolStripMenuItem();
|
||||
|
||||
cmsHistory.SuspendLayout();
|
||||
|
||||
//
|
||||
|
@ -126,6 +134,7 @@ private void InitializeComponent()
|
|||
tsmiShowImagePreview,
|
||||
tsmiUploadFile,
|
||||
tsmiEditImage,
|
||||
tsmiPinToScreen,
|
||||
tsmiShowMoreInfo
|
||||
});
|
||||
cmsHistory.Name = "cmsHistory";
|
||||
|
@ -409,13 +418,6 @@ private void InitializeComponent()
|
|||
tsmiShowImagePreview.Text = Resources.HistoryItemManager_InitializeComponent_Image_preview;
|
||||
tsmiShowImagePreview.Click += tsmiShowImagePreview_Click;
|
||||
//
|
||||
// tsmiShowMoreInfo
|
||||
//
|
||||
tsmiShowMoreInfo.Name = "tsmiShowMoreInfo";
|
||||
tsmiShowMoreInfo.Size = new Size(127, 22);
|
||||
tsmiShowMoreInfo.Text = Resources.HistoryItemManager_InitializeComponent_More_info;
|
||||
tsmiShowMoreInfo.Click += tsmiShowMoreInfo_Click;
|
||||
//
|
||||
// tsmiUploadFile
|
||||
//
|
||||
tsmiUploadFile.Name = "tsmiUploadFile";
|
||||
|
@ -431,6 +433,21 @@ private void InitializeComponent()
|
|||
tsmiEditImage.Size = new Size(127, 22);
|
||||
tsmiEditImage.Text = Resources.HistoryItemManager_InitializeComponent_EditImage;
|
||||
tsmiEditImage.Click += tsmiEditImage_Click;
|
||||
//
|
||||
// tsmiPinToScreen
|
||||
//
|
||||
tsmiPinToScreen.Name = "tsmiPinToScreen";
|
||||
tsmiPinToScreen.ShortcutKeyDisplayString = "Ctrl+P";
|
||||
tsmiPinToScreen.Size = new Size(127, 22);
|
||||
tsmiPinToScreen.Text = "Pin to screen"; // TODO: Translate
|
||||
tsmiPinToScreen.Click += tsmiPinToScreen_Click;
|
||||
//
|
||||
// tsmiShowMoreInfo
|
||||
//
|
||||
tsmiShowMoreInfo.Name = "tsmiShowMoreInfo";
|
||||
tsmiShowMoreInfo.Size = new Size(127, 22);
|
||||
tsmiShowMoreInfo.Text = Resources.HistoryItemManager_InitializeComponent_More_info;
|
||||
tsmiShowMoreInfo.Click += tsmiShowMoreInfo_Click;
|
||||
|
||||
cmsHistory.ResumeLayout(false);
|
||||
}
|
||||
|
@ -502,6 +519,7 @@ public void UpdateContextMenu(int itemCount)
|
|||
tsmiShowImagePreview.Enabled = false;
|
||||
tsmiUploadFile.Enabled = false;
|
||||
tsmiEditImage.Enabled = false;
|
||||
tsmiPinToScreen.Enabled = false;
|
||||
tsmiShowMoreInfo.Enabled = false;
|
||||
}
|
||||
else
|
||||
|
@ -566,6 +584,7 @@ public void UpdateContextMenu(int itemCount)
|
|||
tsmiShowImagePreview.Enabled = IsImageFile;
|
||||
tsmiUploadFile.Enabled = uploadFile != null && IsFileExist;
|
||||
tsmiEditImage.Enabled = editImage != null && IsImageFile;
|
||||
tsmiPinToScreen.Enabled = pinToScreen != null && IsImageFile;
|
||||
tsmiShowMoreInfo.Enabled = true;
|
||||
}
|
||||
|
||||
|
@ -717,6 +736,11 @@ private void tsmiEditImage_Click(object sender, EventArgs e)
|
|||
EditImage();
|
||||
}
|
||||
|
||||
private void tsmiPinToScreen_Click(object sender, EventArgs e)
|
||||
{
|
||||
PinToScreen();
|
||||
}
|
||||
|
||||
private void tsmiShowMoreInfo_Click(object sender, EventArgs e)
|
||||
{
|
||||
ShowMoreInfo();
|
||||
|
|
|
@ -730,14 +730,20 @@ public static void OpenScreenshotsFolder()
|
|||
public static void OpenHistory()
|
||||
{
|
||||
HistoryForm historyForm = new HistoryForm(Program.HistoryFilePath, Program.Settings.HistorySettings,
|
||||
filePath => UploadManager.UploadFile(filePath), filePath => AnnotateImageFromFile(filePath));
|
||||
filePath => UploadManager.UploadFile(filePath),
|
||||
filePath => AnnotateImageFromFile(filePath),
|
||||
filePath => PinToScreen(filePath));
|
||||
|
||||
historyForm.Show();
|
||||
}
|
||||
|
||||
public static void OpenImageHistory()
|
||||
{
|
||||
ImageHistoryForm imageHistoryForm = new ImageHistoryForm(Program.HistoryFilePath, Program.Settings.ImageHistorySettings,
|
||||
filePath => UploadManager.UploadFile(filePath), filePath => AnnotateImageFromFile(filePath));
|
||||
filePath => UploadManager.UploadFile(filePath),
|
||||
filePath => AnnotateImageFromFile(filePath),
|
||||
filePath => PinToScreen(filePath));
|
||||
|
||||
imageHistoryForm.Show();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue