コード例 #1
0
ファイル: TilesManagerPanel.cs プロジェクト: slagusev/Krea
        private void removeCurrentPalette_Click(object sender, EventArgs e)
        {
            if (this.texturesTabControl.SelectedTab != null)
            {
                if (this.texturesTabControl.SelectedTab.Text.Equals("Textures"))
                {
                    if (this.textureSheetCombBx.SelectedItem != null)
                    {
                        TileSheetModel sheetModel = (TileSheetModel)this.textureSheetCombBx.SelectedItem;
                        if (sheetModel != null)
                        {
                            if (MessageBox.Show("Are you sure to remove the \"" + sheetModel.ToString() + "\" tile models?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                                == DialogResult.Yes)
                            {
                                this.textureSheetCombBx.Items.Remove(sheetModel);


                                if (File.Exists(sheetModel.filename))
                                {
                                    File.Delete(sheetModel.filename);
                                }

                                this.refreshTextureTileModelLocations();
                            }
                        }
                    }
                }
                else if (this.texturesTabControl.SelectedTab.Text.Equals("Objects"))
                {
                    if (this.objectSheetsCombBx.SelectedItem != null)
                    {
                        TileSheetModel sheetModel = (TileSheetModel)this.objectSheetsCombBx.SelectedItem;
                        if (sheetModel != null)
                        {
                            if (MessageBox.Show("Are you sure to remove the \"" + sheetModel.ToString() + "\" tile models?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                                == DialogResult.Yes)
                            {
                                this.objectSheetsCombBx.Items.Remove(sheetModel);

                                if (File.Exists(sheetModel.filename))
                                {
                                    File.Delete(sheetModel.filename);
                                }

                                this.refreshObjectTileModelLocations();
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: TilesManagerPanel.cs プロジェクト: slagusev/Krea
 public List <TileModel> getObjectsSheetSelected()
 {
     if (this.objectSheetsCombBx.SelectedItem != null)
     {
         TileSheetModel sheetModel = (TileSheetModel)this.objectSheetsCombBx.SelectedItem;
         return(sheetModel.TileModels);
     }
     else
     {
         if (this.objectSheetsCombBx.Items.Count > 0)
         {
             this.objectSheetsCombBx.SelectedIndex = 0;
             TileSheetModel sheetModel = (TileSheetModel)this.objectSheetsCombBx.SelectedItem;
             return(sheetModel.TileModels);
         }
     }
     return(null);
 }
コード例 #3
0
ファイル: TilesManagerPanel.cs プロジェクト: slagusev/Krea
        private void addTextureSetToList(string pathImage, string name, Size tilesSize)
        {
            TileSheetModel sheetModel = new TileSheetModel(name, pathImage, true);

            //Charger la texture set
            Bitmap textureSet = new Bitmap(Image.FromFile(pathImage));

            //Recuperer le nombre de texture par ligne et colonne
            int nbTexturesLigne   = textureSet.Width / tilesSize.Width;
            int nbTexturesColonne = textureSet.Height / tilesSize.Height;


            //Creer et ajouter les textures
            for (int i = 0; i < nbTexturesColonne; i++)
            {
                for (int j = 0; j < nbTexturesLigne; j++)
                {
                    //Recuperer l'image de la texture
                    Bitmap texture = textureSet.Clone(new Rectangle(new Point(j * tilesSize.Width, i * tilesSize.Height), new Size(tilesSize.Width, tilesSize.Height)), System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                    //Creer une texture model et l'ajouter a la liste
                    int    index     = i * nbTexturesLigne + j;
                    string modelName = "TEXTURE_" + sheetModel.ToString() + "_" + index + "_MODEL";
                    GorgonLibrary.Graphics.Sprite sprite = new GorgonLibrary.Graphics.Sprite(modelName, GorgonLibrary.Graphics.Image.FromBitmap(modelName, texture));
                    texture.Dispose();

                    TileModel model = new TileModel(modelName, new Point(0, 0), tilesSize, sprite, true, true);

                    sheetModel.TileModels.Add(model);
                }
            }

            //Relacher la texture Set principale
            textureSet.Dispose();

            this.textureSheetCombBx.Items.Add(sheetModel);
        }
コード例 #4
0
ファイル: TilesManagerPanel.cs プロジェクト: nadar71/Krea
        private void addTextureSetToList(string pathImage,string name,Size tilesSize)
        {
            TileSheetModel sheetModel = new TileSheetModel(name,pathImage, true);

            //Charger la texture set
            Bitmap textureSet = new Bitmap(Image.FromFile(pathImage));

            //Recuperer le nombre de texture par ligne et colonne
            int nbTexturesLigne = textureSet.Width / tilesSize.Width;
            int nbTexturesColonne = textureSet.Height / tilesSize.Height;

            //Creer et ajouter les textures
            for (int i = 0; i < nbTexturesColonne; i++)
            {
                for (int j = 0; j < nbTexturesLigne; j++)
                {
                    //Recuperer l'image de la texture
                    Bitmap texture = textureSet.Clone(new Rectangle(new Point(j * tilesSize.Width, i * tilesSize.Height), new Size(tilesSize.Width, tilesSize.Height)), System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                    //Creer une texture model et l'ajouter a la liste
                    int index = i * nbTexturesLigne + j;
                    string modelName = "TEXTURE_" + sheetModel.ToString() + "_" + index + "_MODEL";
                    GorgonLibrary.Graphics.Sprite sprite = new GorgonLibrary.Graphics.Sprite(modelName, GorgonLibrary.Graphics.Image.FromBitmap(modelName,texture));
                    texture.Dispose();

                    TileModel model = new TileModel(modelName, new Point(0, 0), tilesSize, sprite, true, true);

                    sheetModel.TileModels.Add(model);

                }
            }

            //Relacher la texture Set principale
            textureSet.Dispose();

            this.textureSheetCombBx.Items.Add(sheetModel);
        }