Exemple #1
0
        void LoadImageset(Imageset imageset)
        {
            try
            {
                if (imageset.Tag == null)
                    imageset.Tag = System.Drawing.Image.FromFile(imageset.FileName);

                foreach (GameData.Image image in imageset.Images)
                    image.Imageset = imageset;
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
        void NewImage(Imageset imageset, GameData.Image image)
        {
            SettingDlg dlg = new SettingDlg("New image", image);
            if (dlg.ShowDialog() != DialogResult.OK)
                return;

            if (imageset.Contains(image.Name))
            {
                MessageBox.Show(String.Format("The image '{0}' already exist!!", image.Name));
                return;
            }

            imageset.Add(image);
            image.Imageset = imageset;

            ShowImageset(imageset);

            listView2.Items[listView2.Items.Count - 1].Selected = true;
        }
Exemple #3
0
        private void OnImportImageClicked(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
                return;

            try
            {
                System.Drawing.Image texture = System.Drawing.Image.FromFile(openFileDialog1.FileName);
                String name = Path.GetFileName(openFileDialog1.FileName);
                if (name.LastIndexOf('.') > 0)
                    name = name.Substring(0, name.LastIndexOf('.'));

                ImagesetInfo info = new ImagesetInfo(name, openFileDialog1.FileName);
                SettingDlg dlg = new SettingDlg("Import image", info);
                if (dlg.ShowDialog() != DialogResult.OK)
                    return;

                if (ImagesetManager.Instance.Contains(info.Name))
                    throw new Exception(String.Format("The image name '{0}' already exist!!!", info.Name));

                Imageset imageset = new Imageset();
                imageset.Name = info.Name;
                imageset.FileName = info.FileName;
                imageset.Width = texture.Width;
                imageset.Height = texture.Height;
                imageset.Tag = texture;
                ImagesetManager.Instance.Add(imageset);

                LoadImagesets();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Import failed!!!");
            }
        }
Exemple #4
0
        void ShowImageset(Imageset imageset)
        {
            listView2.Items.Clear();

            foreach (GameData.Image image in imageset.Images)
            {
                ListViewItem lvItem = listView2.Items.Add(image.Name);
                lvItem.SubItems.Add(image.X.ToString());
                lvItem.SubItems.Add(image.Y.ToString());
                lvItem.SubItems.Add(image.Width.ToString());
                lvItem.SubItems.Add(image.Height.ToString());

                lvItem.Tag = image;
            }

            try
            {
                System.Drawing.Image texture = System.Drawing.Image.FromFile(imageset.FileName);

                panel1.Size = texture.Size;
                panel1.BackgroundImage = texture;
                panel1.Tag = imageset;
            }
            catch (Exception)
            {
            }
        }
Exemple #5
0
 void LoadImageset(Imageset imageset)
 {
     try
     {
         if (imageset.Tag == null)
         {
             Texture2D t = this.Content.Load<Texture2D>(Path.GetFileNameWithoutExtension(imageset.FileName));
             imageset.Tag = t;
         }
         foreach (GameData.Image image in imageset.Images)
         {
             Rectangle rect = new Rectangle(image.X, image.Y, image.Width, image.Height);
             image.Imageset = imageset;
         }
     }
     catch (Exception)
     {
     }
 }