private static void ImageListBox_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 ImagedItem <FirmwareImageMetadata>;

            if (item == null)
            {
                return;
            }

            try
            {
                var cachedImage = ImageCacheManager.GetImage(item.ImageCacheIndex, item.Value.BlockType);
                e.ItemHeight = Math.Min(e.ItemHeight, cachedImage.Height + Consts.ImageListBoxItemImageMargin);
            }
            catch (ObjectDisposedException)
            {
                // Ignore
            }
        }
        private void ImageListBox_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 ImagedItem <FirmwareImageMetadata>;

            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.GetImage(item.ImageCacheIndex, item.Value.BlockType);

                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();
        }
        private void Icb_MeasureItem(object sender, MeasureItemEventArgs e)
        {
            e.ItemHeight = Consts.ImageListBoxItemMaxHeight + Consts.ImageListBoxItemImageMargin;

            var comboBox = sender as ComboBox;

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

            var stringMetadata = comboBox.Tag as Tuple <FirmwareStringMetadata, int>;

            if (stringMetadata == null)
            {
                return;
            }

            var item = comboBox.Items[e.Index] as ImagedItem <byte>;

            if (item == null)
            {
                return;
            }

            try
            {
                var cachedImage = ImageCacheManager.GetImage(item.ImageCacheIndex, stringMetadata.Item1.BlockType);
                e.ItemHeight = Math.Min(e.ItemHeight, cachedImage.Height + Consts.ImageListBoxItemImageMargin);
            }
            catch (ObjectDisposedException)
            {
                // Ignore
            }
        }
Esempio n. 4
0
        private void ListIssues_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstIssues.Refresh();

            ClearSearchResults();
            if (lstIssues.SelectedIndex < 0)
            {
                return;
            }
            string issueId = ((Issue)lstIssues.SelectedItem).IssueID;

            lblComicName.Text  = _currentComic.Comics[0].ComicName;
            lblComicName.Text += @"  (" + _currentVolume.Volume.StartYear + @") " + @" Issue #" + ((Issue)lstIssues.SelectedItem).Issue_Number;
            CvIssueResponse issue = ComicVineManager.GetIssue(issueId);

            webDetails.DocumentText = "0";
            if (webDetails.Document != null)
            {
                webDetails.Document.OpenNew(true);
                webDetails.Document.Write(issue.Issue.Description);
            }

            webDetails.Refresh();
            if (issue.Issue.Image != null)
            {
                if (!string.IsNullOrEmpty(issue.Issue.Image.LargeUrl))
                {
                    imgDetail.Image = ImageCacheManager.GetImage(issue.Issue.Image.LargeUrl);
                }
                else
                {
                    imgDetail.Image = ImageCacheManager.GetImage(_currentComic.Comics[0].ComicImageURL);
                }
            }



            SetStatus("Ready ...");
        }
Esempio n. 5
0
        private void BindComic(CvVolume volume)
        {
            if (volume.Image?.LargeUrl == null)
            {
                volume = ComicVineManager.GetVolume(volume.Id.ToString()).Volume;
            }

            imgDetail.Image   = ImageCacheManager.GetImage(volume.Image.LargeUrl);
            lblComicName.Text = volume.Name;
            CvVolumeResponse v = new CvVolumeResponse();

            v.Volume           = volume;
            _currentVolume     = v;
            lblComicName.Text += @"  (" + _currentVolume.Volume.StartYear + @")";

            webDetails.DocumentText = "0";
            if (webDetails.Document != null)
            {
                webDetails.Document.OpenNew(true);
                webDetails.Document.Write(_currentVolume.Volume.Description);
            }

            webDetails.Refresh();

            if (_currentVolume.Volume.Publisher == null)
            {
                if (_currentVolume.Volume.Publisher != null)
                {
                    var pub = ComicVineManager.GetPublisher(_currentVolume.Volume.Publisher.Id);
                    imgPublisher.Image = ImageCacheManager.GetImage(pub.Publisher.Image.IconUrl);
                }
            }
            else
            {
                imgPublisher.Image = null;
            }
        }
Esempio n. 6
0
        private void BindComic(Title title)
        {
            _currentComic = MylarManager.GetComic(title.ComicID);

            imgDetail.Image = ImageCacheManager.GetImage(_currentComic.Comics[0].ComicImageURL ?? _currentVolume.Volume.Image.LargeUrl);

            lblComicName.Text = _currentComic.Comics[0].ComicName;

            _currentVolume     = ComicVineManager.GetVolume(title.ComicID);
            lblComicName.Text += @"  (" + _currentVolume.Volume.StartYear + @")";

            webDetails.DocumentText = "0";
            if (webDetails.Document != null)
            {
                webDetails.Document.OpenNew(true);
                webDetails.Document.Write(_currentVolume.Volume.Description);
            }

            webDetails.Refresh();

            var pub = ComicVineManager.GetPublisher(_currentVolume.Volume.Publisher.Id);

            imgPublisher.Image = ImageCacheManager.GetImage(pub.Publisher.Image.IconUrl);
        }