Exemplo n.º 1
0
        private void AddResGroup(string name, ImageResourceGroup group)
        {
            Image img = LoadResourceImageFile(group.ResFilePath);

            if (img == null)
            {
                Logging.Instance.Log("加载资源文件 '{0}' 失败。", group.ResFilePath);
                return;
            }

            ItemContainer ic = new ItemContainer();

            ic.MultiLine = true;
            ic.TitleText = name;
            ic.Name      = name;
            ic.Tag       = group;
            foreach (var res in group.ResLut)
            {
                MetroTileItem tile = new MetroTileItem(res.Key, res.Key);
                tile.TitleText        = res.Key;
                tile.Text             = res.Key.ToLower();
                tile.Image            = ImageUtil.GetAtlasThumbnail(img, res.Value, tile.TileSize);
                tile.Click           += Tile_Clicked;
                tile.DoubleClick     += Tile_DoubleClicked;
                tile.ContainerControl = ic;
                ic.SubItems.Add(tile);
            }
            m_metroTilePanel.Items.Add(ic);
        }
Exemplo n.º 2
0
        private bool RefreshSelectedTile(MetroTileItem ti)
        {
            if (ti == null || ti.Parent == null)
            {
                return(false);
            }

            ItemContainer ic = ti.Parent as ItemContainer;

            if (ic == null)
            {
                return(false);
            }

            ImageResourceGroup group = ic.Tag as ImageResourceGroup;

            if (group == null)
            {
                return(false);
            }

            Image         img = LoadResourceImageFile(group.ResFilePath);
            ImageResource ir;

            if (group.ResLut.TryGetValue(ti.Name, out ir))
            {
                m_previewImage.Image = ImageUtil.GetAtlasThumbnail(img, ir, m_previewImage.Size);
            }

            m_nineGridSettings.RefreshUI(ic.Name, ti.Name, ir.Size);
            UpdateSelectedResourceURL(ic.Name, ti.Name, ir.Size);
            return(true);
        }