Skip to content

Commit

Permalink
show image number in g1.dat and image lists
Browse files Browse the repository at this point in the history
  • Loading branch information
LeftofZen committed Oct 24, 2023
1 parent 7cafa9b commit 6d58472
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions OpenLocoToolGui/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public ILocoObject? CurrentUIObject
}
ILocoObject? currentUIObject;

IList<PictureBox> CurrentUIImages
IList<Control> CurrentUIImages
{
get => currentUIImages;
set
Expand All @@ -42,7 +42,7 @@ IList<PictureBox> CurrentUIImages
CurrentUIImagePageNumber = 0;
}
}
IList<PictureBox> currentUIImages = new List<PictureBox>();
IList<Control> currentUIImages = new List<Control>();

int CurrentUIImagePageNumber
{
Expand Down Expand Up @@ -352,7 +352,7 @@ private void setDataDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
}
}

IEnumerable<PictureBox> GetPictureBoxesForPage(int page) => CurrentUIImages.Skip(page * imagesPerPage).Take(imagesPerPage);
IEnumerable<Control> GetPictureBoxesForPage(int page) => CurrentUIImages.Skip(page * imagesPerPage).Take(imagesPerPage);

private void recreateIndexToolStripMenuItem_Click(object sender, EventArgs e)
{
Expand Down Expand Up @@ -489,24 +489,40 @@ void CreateSounds(SoundObject soundObject)
};

flpImageTable.Controls.Add(soundButton);

flpImageTable.ResumeLayout(true);
}

IEnumerable<PictureBox> CreateImageControls(IEnumerable<Bitmap> images)
IEnumerable<Control> CreateImageControls(IEnumerable<Bitmap> images)
{
// on these controls we could add a right_click handler to replace image with user-created one
var count = 0;
foreach (var img in images)
{
var panel = new FlowLayoutPanel
{
AutoSize = true,
BackColor = Color.LightGray,
BorderStyle = BorderStyle.FixedSingle,
FlowDirection = FlowDirection.TopDown,
};

var pb = new PictureBox
{
Image = img,
BorderStyle = BorderStyle.FixedSingle,
SizeMode = PictureBoxSizeMode.AutoSize,
ContextMenuStrip = imgContextMenu
ContextMenuStrip = imgContextMenu,
Dock = DockStyle.Bottom,
};

yield return pb;
var tb = new TextBox();
tb.MinimumSize = new Size(32, 16);
tb.Text = count++.ToString();
tb.Dock = DockStyle.Top;

panel.Controls.Add(tb);
panel.Controls.Add(pb);

yield return panel;
}
}

Expand Down

0 comments on commit 6d58472

Please sign in to comment.