private void StringListBox_MeasureItem(object sender, MeasureItemEventArgs e)
        {
            e.ItemHeight = Consts.ImageListBoxItemMaxHeight + Consts.ImageListBoxItemImageMargin;

            var listBox = sender as ListBox;

            if (listBox == null)
            {
                return;
            }
            if (e.Index < 0)
            {
                return;
            }

            var item = listBox.Items[e.Index] as FirmwareStringMetadata;

            if (item == null)
            {
                return;
            }

            try
            {
                var cachedImage = ImageCacheManager.GetStringImage(item.Index, SelectedImageBlock);
                e.ItemHeight = Math.Min(e.ItemHeight, cachedImage.Height + Consts.ImageListBoxItemImageMargin);
            }
            catch (ObjectDisposedException)
            {
                // Ignore
            }
        }
        private void StringListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            var listBox = sender as ListBox;

            if (listBox == null)
            {
                return;
            }
            if (e.Index < 0)
            {
                return;
            }

            var item = listBox.Items[e.Index] as FirmwareStringMetadata;

            if (item == null)
            {
                return;
            }

            e.Graphics.SmoothingMode      = SmoothingMode.None;
            e.Graphics.InterpolationMode  = InterpolationMode.Low;
            e.Graphics.CompositingQuality = CompositingQuality.HighSpeed;
            e.DrawBackground();

            //var itemText = item.ToString();

            try
            {
                var imageScale = 1f;
                var image      = ImageCacheManager.GetStringImage(item.Index, SelectedImageBlock);

                /*var greatestDimension = Math.Max(image.Width, image.Height);
                 * if (greatestDimension > Consts.ImageListBoxItemMaxHeight) imageScale = (float)greatestDimension / Consts.ImageListBoxItemMaxHeight;*/

                var resultWidth  = image.Width / imageScale;
                var resultHeight = image.Height / imageScale;

                e.Graphics.DrawImage(image, e.Bounds.X + Consts.ImageListBoxItemImageMargin, e.Bounds.Y + (int)(e.Bounds.Height / 2f - resultHeight / 2f), resultWidth, resultHeight);
            }
            catch (ObjectDisposedException)
            {
                // Ignore
            }

            //var stringRectX = e.Bounds.X + Consts.ImageListBoxItemMaxHeight + Consts.ImageListBoxItemImageMargin * 2;
            //e.Graphics.DrawString(itemText, e.Font, new SolidBrush(e.ForeColor), new RectangleF(stringRectX, e.Bounds.Y, e.Bounds.Width - stringRectX - Consts.ImageListBoxItemImageMargin, e.Bounds.Height), m_listBoxStringFormat);
            e.DrawFocusRectangle();
        }