Пример #1
0
        private void addToPaletteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.TilesSelection != null)
            {
                TilesMap currentMap = this.TilesSelection.TilesMapParent;
                if (currentMap != null)
                {
                    for (int i = 0; i < this.TilesSelection.ListModelsSelected.Count; i++)
                    {
                        TileModel model = this.TilesSelection.ListModelsSelected[i];

                        if (model != null)
                        {
                            string finalName = model.Name.Replace("_MODEL", "");
                            if (model.IsTexture == true)
                            {
                                if (!currentMap.IsTileModelExists(currentMap.TileModelsTextureUsed, finalName))
                                {
                                    //Clone gorgon image
                                    Image img = model.GorgonSprite.Image.SaveBitmap();
                                    GorgonLibrary.Graphics.Image  newImage = GorgonLibrary.Graphics.Image.FromBitmap(finalName, img);
                                    GorgonLibrary.Graphics.Sprite sprite   = new GorgonLibrary.Graphics.Sprite(finalName, newImage);
                                    TileModel newModel = new TileModel(finalName, model.surfaceRect.Location, model.surfaceRect.Size,
                                                                       sprite, false, true);
                                    img.Dispose();
                                    img = null;

                                    currentMap.TileModelsTextureUsed.Add(newModel);
                                    currentMap.UpdateGorgonTileModel(newModel, true);
                                }
                            }
                            else
                            {
                                if (!currentMap.IsTileModelExists(currentMap.TileModelsObjectsUsed, finalName))
                                {
                                    //Clone gorgon image
                                    Image img = model.GorgonSprite.Image.SaveBitmap();
                                    GorgonLibrary.Graphics.Image  newImage = GorgonLibrary.Graphics.Image.FromBitmap(finalName, img);
                                    GorgonLibrary.Graphics.Sprite sprite   = new GorgonLibrary.Graphics.Sprite(finalName, newImage);
                                    TileModel newModel = new TileModel(finalName, model.surfaceRect.Location, model.surfaceRect.Size,
                                                                       sprite, false, false);
                                    img.Dispose();
                                    img = null;

                                    currentMap.TileModelsObjectsUsed.Add(newModel);
                                    currentMap.UpdateGorgonTileModel(newModel, true);
                                }
                            }
                        }
                    }
                    GorgonLibrary.Gorgon.Go();
                }
            }
        }