示例#1
0
        /// <summary>
        /// <para>Loads an animation frame from the currently loaded animation.</para>
        /// <para>Make sure to set the animation using <see cref="Setup"/> and only selecting frames from the current loaded animation.</para>
        /// </summary>
        /// <param name="frame">Refence to the frame to load into the viewer</param>
        public void LoadFrame(Animation.AnimationEntry.Frame frame)
        {
            LoadedFrame = frame;
            var path = Path.Combine(FilePath, LoadedAnimation.SpriteSheets[frame.SpriteSheet]);

            if (File.Exists(path))
            {
                GIF.Load(path);
            }
            else
            {
                var messagebox = new HedgeMessageBox("Failed to load sprite sheet!",
                                                     "The sprite sheet for the loaded sprite\ncould not be found.");
                messagebox.AddButton("Select sprite sheet file", () =>
                {
                    var ofd    = new OpenFileDialog();
                    ofd.Filter = "Graphics Interchange Format|*.gif";
                    if (ofd.ShowDialog() == true)
                    {
                        GIF.Load(ofd.FileName);
                    }
                    messagebox.Close();
                });
                messagebox.AddButton("Cancel", () => { messagebox.Close(); });
                messagebox.Show();
            }
        }
        private void UI_SaveFile_Click(object sender, RoutedEventArgs e)
        {
            if (LoadedFileType != null)
            {
                LoadedFileType.Write(LoadedFileType.filePath, Palettes, CurrentPaletteSet);
                return;
            }

            var messagebox = new HedgeMessageBox("Save Warning!", "No File was loaded prior to saving!\n" +
                                                 "ManiaPal is currently unable to save to any\nMania formats without it being loaded prior to saving.");

            messagebox.AddButton("Save Palette as Adobe Colour Table", () =>
            {
                var fileType = FileTypes.FirstOrDefault(t => t.GetFileTypeName() == "Adobe Colour Table");
                var sfd      = new SaveFileDialog();
                sfd.Filter   = fileType.GetSupportedFileFilters();
                if (sfd.ShowDialog() == true)
                {
                    fileType.Write(sfd.FileName, Palettes, CurrentPaletteSet);
                }
                messagebox.Close();
            });
            messagebox.AddButton("Don't Save", () => { messagebox.Close(); });
            messagebox.Show();
        }