Beispiel #1
0
        private void DrawTextures(Graphics g)
        {
            // Draw items
            int scrollwidth = (scrollbar.Visible ? scrollbar.Width : 0);

            if (items.Count > 0)
            {
                int y      = scrollbar.Value;
                int height = ClientRectangle.Height;
                int i      = 0;

                ImageBrowserItemType currentType = ImageBrowserItemType.IMAGE; // initialized to random value
                bool currentUsedInMap            = false;

                ImageBrowserItem.SetBrushes(classicview, rectangles[0].X, rectangles[0].Y - y, rectangles[0].Width, rectangles[0].Height);

                foreach (ImageBrowserItemGroup ibig in itemgroups)
                {
                    if (classicview)
                    {
                        // draw corresponding title right above this item.
                        string hdrname = ibig.Title + ":";
                        DrawTextureHeader(g, hdrname, new Rectangle(2, rectangles[i].Y - (SystemFonts.MessageBoxFont.Height + 6) - y, ClientRectangle.Width - scrollwidth - 4, SystemFonts.MessageBoxFont.Height), false);
                        currentType      = items[i].ItemType;
                        currentUsedInMap = items[i].Icon.UsedInMap;
                    }

                    for (int j = 0; j < ibig.Items.Count; j++, i++)
                    {
                        Rectangle rec = rectangles[i];
                        if (rec.Bottom < y)
                        {
                            continue;
                        }
                        if (rec.Top > y + height)
                        {
                            break;
                        }

                        Image bmp = GetPreview(items[i], imagesize);
                        items[i].Draw(g, bmp, rec.X, rec.Y - y, rec.Width, rec.Height, selection.Contains(items[i]), items[i].Icon.UsedInMap, classicview);
                    }
                }
            }

            // Draw title on top of items
            if (!string.IsNullOrEmpty(title) && !classicview)
            {
                DrawTextureHeader(g, title, new Rectangle(2, 2, ClientRectangle.Width - scrollwidth - 4, SystemFonts.MessageBoxFont.Height), true);
            }
        }
        private void DrawTextures(Graphics g)
        {
            // Draw items
            int scrollwidth = (scrollbar.Visible ? scrollbar.Width : 0);

            if (items.Count > 0)
            {
                int y      = scrollbar.Value;
                int height = ClientRectangle.Height;

                ImageBrowserItemType currentType = ImageBrowserItemType.IMAGE; // initialized to random value
                bool currentUsedInMap            = false;

                ImageBrowserItem.SetBrushes(classicview, rectangles[0].X, rectangles[0].Y - y, rectangles[0].Width, rectangles[0].Height);
                for (var i = 0; i < items.Count; i++)
                {
                    if (classicview && (i == 0 || ((currentType == ImageBrowserItemType.IMAGE) != (items[i].ItemType == ImageBrowserItemType.IMAGE)) || (usedtexturesfirst && currentUsedInMap != items[i].Icon.UsedInMap)))
                    {
                        // draw corresponding title right above this item.
                        string hdrname;
                        if (items[i].ItemType == ImageBrowserItemType.IMAGE)
                        {
                            if (usedtexturesfirst && items[i].Icon.UsedInMap)
                            {
                                hdrname = "Used " + contenttype + ":";
                            }
                            else
                            {
                                hdrname = "All " + contenttype + ":";
                            }
                        }
                        else
                        {
                            hdrname = "Directories:";
                        }
                        DrawTextureHeader(g, hdrname, new Rectangle(2, rectangles[i].Y - (SystemFonts.MessageBoxFont.Height + 6) - y, ClientRectangle.Width - scrollwidth - 4, SystemFonts.MessageBoxFont.Height), false);
                        currentType      = items[i].ItemType;
                        currentUsedInMap = items[i].Icon.UsedInMap;
                    }

                    Rectangle rec = rectangles[i];
                    if (rec.Bottom < y)
                    {
                        continue;
                    }
                    if (rec.Top > y + height)
                    {
                        break;
                    }

                    Image bmp = GetPreview(items[i], imagesize);
                    items[i].Draw(g, bmp, rec.X, rec.Y - y, rec.Width, rec.Height, selection.Contains(items[i]), items[i].Icon.UsedInMap, classicview);
                }
            }

            // Draw title on top of items
            if (!string.IsNullOrEmpty(title) && !classicview)
            {
                DrawTextureHeader(g, title, new Rectangle(2, 2, ClientRectangle.Width - scrollwidth - 4, SystemFonts.MessageBoxFont.Height), true);
            }
        }