private void ImportPatAnimationForm_FormClosing(object sender, FormClosingEventArgs e) { if (_Images != null) { _Images.Dispose(); _Images = null; } timer1.Enabled = false; }
private void ImportPatAnimationForm_Shown(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK) { CancelDialog(); return; } var file = openFileDialog1.FileName; var path = Path.GetDirectoryName(file); var palFile = Path.Combine(path, "palette000.pal"); if (!File.Exists(palFile)) { if (MessageBox.Show("Palette file not found. Please choose one.", "Animation Import", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.OK) { if (openFileDialog2.ShowDialog() != System.Windows.Forms.DialogResult.OK) { CancelDialog(); return; } palFile = openFileDialog2.FileName; } else { palFile = null; } } //create objects GSPat.GSPatFile gspat; using (var s = File.OpenRead(file)) { gspat = GSPat.GSPatReader.ReadFromStream(s); } var pal = palFile != null?Images.CV2Palette.ReadPaletteFile(palFile) : null; //create image manager _Images = new GSPat.ImageManager(gspat, path, pal); //refresh list var lastIndex = -1; var segmentIndex = 0; foreach (var animation in gspat.Animations) { ++segmentIndex; if (animation.AnimationID == -1) { //can't import clone animation lastIndex = -1; continue; } else if (animation.AnimationID == -2) { AddFollowerAnimation(animation, lastIndex, segmentIndex); } else { AddAnimation(animation); lastIndex = animation.AnimationID; segmentIndex = 0; } } _GSPatFile = gspat; _Path = path; _Palette = palFile; }