コード例 #1
0
ファイル: Misc.cs プロジェクト: Olreich/skaa_editor
        internal static Project LoadZipProject(string filePath)
        {
            string path = Path.GetDirectoryName(filePath);
            //todo: Open for updating
            ZipArchive arch = ZipFile.Open(filePath, ZipArchiveMode.Read);
            //todo: change this to a temp folder with randomly generated name
            arch.ExtractToDirectory(path + '\\' + Path.GetFileNameWithoutExtension(filePath));

            //foreach(ZipArchiveEntry ent in arch.Entries)
            //{
            //    string[] name;
            //    name = ent.Name.Split( new char[]{'.'} );
            //    switch(name[1])
            //    {
            //        case "res":
            //            //p.PalStruct.PaletteFileName = ent.Name;
            //            p.LoadPalette()
            //            break;
            //        case "set":
            //            p.SetStruct.GameSetFileName = ent.Name;
            //            break;
            //        case "spr":
            //            p.SprStruct.SpriteFileName = ent.Name;
            //            break;
            //        default:
            //            throw new FileFormatException("Expecting RES, SET and SPR file extensions.\nReceived " + name[1]);
            //    }
            //}

            Project p = new Project(false);
            //p.LoadPalette(path + '\\' + arch.Entries.First(ent => ent.Name.Split(new char[] { '.' })[1] == "res"));
            //p.LoadGameSet(path + '\\' + arch.Entries.First(ent => ent.Name.Split(new char[] { '.' })[1] == "set"));
            //p.LoadSprite(path + '\\' + arch.Entries.First(ent => ent.Name.Split(new char[] { '.' })[1] == "spr"));
            return p;
        }
コード例 #2
0
ファイル: Misc.cs プロジェクト: Olreich/skaa_editor
        internal static void ZipProject(Project p, string filePath)
        {
            using (FileStream zipStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
            {
                using (ZipArchive arch = new ZipArchive(zipStream, ZipArchiveMode.Create))
                {
                    //ZipArchiveEntry paletteEntry = arch.CreateEntry(Path.GetFileName(p.SuperPal.PaletteFileName));
                    //p.SuperPal.PaletteFileMemoryStream.WriteTo(paletteEntry.Open());

                    //ZipArchiveEntry setEntry = arch.CreateEntry(Path.GetFileName(p.ActiveGameSet.FileName));
                    //p.ActiveGameSet.RawDataStream.WriteTo(setEntry.Open());
                    //ZipArchiveEntry spriteEntry = arch.CreateEntry(Path.GetFileName(p.SuperSpr.SpriteFileName));
                    //p.SuperSpr.SpriteFileMemoryStream.WriteTo(spriteEntry.Open());

                    //using (StreamWriter sw = new StreamWriter(paletteEntry.Open()))
                    //{
                    //    //sw.Write(Convert.ToBase64CharArray(p.PaletteFileMemoryStream.ToArray(), 0, (int) p.PaletteFileMemoryStream.Length, );
                    //    sw.WriteLine("Information about this package.");
                    //    sw.WriteLine("========================");
                    //}
                }
            }
        }
コード例 #3
0
        private void openProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //todo: confirm user doesn't want to save the current changes
            //if (this.ActiveProject != null)
            //{
            //    if (!Confirm())
            //        return;
            //}

            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.DefaultExt = ".skp";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    this.ActiveProject = Project.LoadProject(dlg.FileName);
                    SetupUI();
                }
            }

        }
コード例 #4
0
        private void newProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.ActiveProject.ActiveSprite != null)
            {
                string msg = "This will close the current sprite. Continue?";

                if (MessageBox.Show(msg, "Wait!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    this.ActiveProject = null;
                    NewProject(false);
                    this.ActiveProject.LoadPalette();
                    this.cbMultiColumn.DataSource = null;
                }
                else
                {
                    return;
                }
            }
        }
コード例 #5
0
 private void closeProjectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     this.ActiveProject = null;
     this.cbMultiColumn.DataSource = null;
     this.colorGridChooser.Palette = Cyotek.Windows.Forms.ColorPalette.None;
 }
コード例 #6
0
        private void NewProject(bool loadDefaults)
        {
            if (this.ActiveProject == null)
                this.ActiveProject = new Project(loadDefaults);
            else
                closeProjectToolStripMenuItem_Click(null, null);

            OnActiveProjectChanged(EventArgs.Empty);
            //ActiveProject_PaletteChanged(null, null);
        }