mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Handle non image files, auto hide labels
This commit is contained in:
parent
178abbd36c
commit
e0665a20ca
2 changed files with 26 additions and 8 deletions
|
@ -172,8 +172,17 @@ public MyPictureBox()
|
|||
|
||||
private void UpdateImageSizeLabel()
|
||||
{
|
||||
if (IsValidImage)
|
||||
{
|
||||
lblImageSize.Visible = true;
|
||||
lblImageSize.Text = $"{Image.Width} x {Image.Height}";
|
||||
lblImageSize.Location = new Point((ClientSize.Width - lblImageSize.Width) / 2, ClientSize.Height - lblImageSize.Height + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
lblImageSize.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateTheme()
|
||||
{
|
||||
|
@ -225,9 +234,18 @@ public void LoadImage(Image img)
|
|||
if (!isImageLoading)
|
||||
{
|
||||
Reset();
|
||||
|
||||
if (img != null)
|
||||
{
|
||||
isImageLoading = true;
|
||||
Image = (Image)img.Clone();
|
||||
isImageLoading = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Image = null;
|
||||
}
|
||||
|
||||
AutoSetSizeMode();
|
||||
}
|
||||
}
|
||||
|
@ -310,8 +328,6 @@ private void AutoSetSizeMode()
|
|||
{
|
||||
if (IsValidImage)
|
||||
{
|
||||
lblImageSize.Text = $"{Image.Width} x {Image.Height}";
|
||||
|
||||
if (Image.Width > pbMain.ClientSize.Width || Image.Height > pbMain.ClientSize.Height)
|
||||
{
|
||||
pbMain.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
|
|
|
@ -74,7 +74,7 @@ private void LoadCurrentImage()
|
|||
|
||||
private void NavigateImage(int position)
|
||||
{
|
||||
if (!SupportsImageNavigation) return;
|
||||
if (!SupportsImageNavigation || Images.Length < 2) return;
|
||||
|
||||
int nextImageIndex = CurrentImageIndex + position;
|
||||
|
||||
|
@ -96,9 +96,10 @@ private void NavigateImage(int position)
|
|||
|
||||
private void UpdateIndexLabel()
|
||||
{
|
||||
if (!SupportsImageNavigation) return;
|
||||
if (!SupportsImageNavigation || Images.Length < 2) return;
|
||||
|
||||
lblIndex.Text = CurrentImageIndex + 1 + " / " + Images.Length;
|
||||
lblIndex.Visible = true;
|
||||
lblIndex.Location = new Point((ClientSize.Width - lblIndex.Width) / 2, -1);
|
||||
}
|
||||
|
||||
|
@ -226,6 +227,7 @@ private void InitializeComponent()
|
|||
lblIndex.Font = new Font("Arial", 20f);
|
||||
lblIndex.Padding = new Padding(5);
|
||||
lblIndex.TextAlign = ContentAlignment.MiddleCenter;
|
||||
lblIndex.Visible = false;
|
||||
Controls.Add(lblIndex);
|
||||
|
||||
pbPreview.Cursor = Cursors.Hand;
|
||||
|
|
Loading…
Reference in a new issue