Added index label

This commit is contained in:
Jaex 2022-03-16 00:14:38 +03:00
parent de348f41a1
commit 178abbd36c

View file

@ -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
}