mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added index label
This commit is contained in:
parent
de348f41a1
commit
178abbd36c
1 changed files with 19 additions and 0 deletions
|
@ -69,6 +69,7 @@ private void LoadCurrentImage()
|
|||
string imageFilePath = Images[CurrentImageIndex];
|
||||
Image img = ImageHelpers.LoadImage(imageFilePath);
|
||||
LoadImage(img);
|
||||
UpdateIndexLabel();
|
||||
}
|
||||
|
||||
private void NavigateImage(int position)
|
||||
|
@ -93,6 +94,14 @@ private void NavigateImage(int position)
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateIndexLabel()
|
||||
{
|
||||
if (!SupportsImageNavigation) return;
|
||||
|
||||
lblIndex.Text = CurrentImageIndex + 1 + " / " + Images.Length;
|
||||
lblIndex.Location = new Point((ClientSize.Width - lblIndex.Width) / 2, -1);
|
||||
}
|
||||
|
||||
public static void ShowImage(Image img)
|
||||
{
|
||||
if (img != null)
|
||||
|
@ -137,6 +146,8 @@ public static void ShowImage(string[] images, int currentImageIndex = 0)
|
|||
|
||||
private void ImageViewer_Shown(object sender, EventArgs e)
|
||||
{
|
||||
UpdateIndexLabel();
|
||||
|
||||
this.ForceActivate();
|
||||
}
|
||||
|
||||
|
@ -198,6 +209,7 @@ protected override void Dispose(bool disposing)
|
|||
private void InitializeComponent()
|
||||
{
|
||||
pbPreview = new MyPictureBox();
|
||||
lblIndex = new Label();
|
||||
SuspendLayout();
|
||||
|
||||
BackColor = SystemColors.Window;
|
||||
|
@ -210,6 +222,12 @@ private void InitializeComponent()
|
|||
WindowState = FormWindowState.Normal;
|
||||
StartPosition = FormStartPosition.Manual;
|
||||
|
||||
lblIndex.AutoSize = true;
|
||||
lblIndex.Font = new Font("Arial", 20f);
|
||||
lblIndex.Padding = new Padding(5);
|
||||
lblIndex.TextAlign = ContentAlignment.MiddleCenter;
|
||||
Controls.Add(lblIndex);
|
||||
|
||||
pbPreview.Cursor = Cursors.Hand;
|
||||
pbPreview.Dock = DockStyle.Fill;
|
||||
pbPreview.DrawCheckeredBackground = true;
|
||||
|
@ -231,6 +249,7 @@ private void InitializeComponent()
|
|||
}
|
||||
|
||||
private MyPictureBox pbPreview;
|
||||
private Label lblIndex;
|
||||
|
||||
#endregion Windows Form Designer generated code
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue