예제 #1
0
        //-----------------------------------------------------------
        // Save a SS file to be used when opening a new sprite selector
        // sender (object): (Unused)
        // e (EventArgs): (Unused)
        //-----------------------------------------------------------
        private void SaveSelectorMi_Click(object sender, EventArgs e)
        {
            if (spriteSelector != null)
            {
                SaveSpriteSelector save = new SaveSpriteSelector()
                {
                    gridWidthS       = spriteSelector.gridWidth,
                    gridHeightS      = spriteSelector.gridHeight,
                    spacingS         = spriteSelector.gridSpacing,
                    currentSpriteS   = spriteSelector.currentSpriteLocation,
                    spriteImagePathS = spriteImagePath
                };
                SaveFileDialog saveFileDialog = new SaveFileDialog()
                {
                    FileName = "Sprite.SS",
                    Filter   = "Sprite Selector Image|*.SS",
                    Title    = "Save a Sprite Selector"
                };
                saveFileDialog.ShowDialog();

                if (saveFileDialog.FileName != "")
                {
                    System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(SaveSpriteSelector));
                    System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog.OpenFile();
                    xmlSerializer.Serialize(fs, save);
                    fs.Close();
                }
            }
        }
예제 #2
0
        //-----------------------------------------------------------
        // Opens a SS file when opening sprite selector
        // sender (object): (Unused)
        // e (EventArgs): (Unused)
        //-----------------------------------------------------------
        private void OpenSelectorMi_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog()
            {
                Filter = "Sprite Selector Image|*.SS"
            };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                if (dlg.CheckFileExists == true)
                {
                    System.IO.Stream stream = System.IO.File.Open(dlg.FileName, System.IO.FileMode.Open);
                    System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(SaveSpriteSelector));
                    SaveSpriteSelector save = (SaveSpriteSelector)xmlSerializer.Deserialize(stream);
                    stream.Close();
                    if (spriteSelector != null)
                    {
                        spriteSelector.Dispose();
                    }
                    spriteSelector  = new SpriteSelector(save.gridWidthS, save.gridHeightS, save.spacingS, save.spriteImagePathS, save.currentSpriteS);
                    spriteImagePath = save.spriteImagePathS;
                    spriteSelector.Show();
                    DrawFrameGrid();
                }
            }
        }