Example #1
0
        void Populate()
        {
            PartsView.Items.Clear();
            Dictionary <string, MBuildingBlock> Blocks = MBuildParts.GetBlocks();

            foreach (KeyValuePair <string, MBuildingBlock> kv in Blocks)
            {
                if (string.IsNullOrEmpty(kv.Value.Model))
                {
                    continue;
                }
                string       sIconPath = GetIconPathForModel(kv.Value.Model);
                ListViewItem lvi       = new ListViewItem(kv.Value.Name);
                lvi.Tag = kv.Value;
                if (!File.Exists(sIconPath))
                {
                    Console.WriteLine("BuildForm: File not found: " + sIconPath);
                }
                else
                {
                    Bitmap icon = new Bitmap(sIconPath);
                    imageList1.Images.Add(kv.Value.Name, icon);
                }

                lvi.ImageKey = kv.Value.Name;
                PartsView.Items.Add(lvi);
            }
        }
Example #2
0
        void CreateButtons()
        {
            Dictionary <string, MBuildingBlock> blocks = MBuildParts.GetBlocks();

            foreach (KeyValuePair <string, MBuildingBlock> k in blocks)
            {
                MBuildingBlock bb = k.Value;
                if (bb.Type != MBuildingBlock.MATERIAL_TYPE)
                {
                    continue;
                }
                string       sPath = Path.Combine(MFileSystem.AssetsPath, bb.Path);
                Bitmap       bmp   = new Bitmap(Path.GetFullPath(sPath));
                ListViewItem lvi   = new ListViewItem(bb.Name);
                imageList1.Images.Add(bb.TextureID, bmp);
                lvi.ImageKey = bb.TextureID;
                lvi.Tag      = bb.TextureID;
                TextureView.Items.Add(lvi);
            }
        }