Exemple #1
0
        /// <summary>
        /// Shows an ErrorBox with the given information on it
        /// </summary>
        /// <param name="message">The message to display</param>
        /// <param name="caption">The caption to use on the box</param>
        /// <param name="copyInfo">The copiable info</param>
        /// <returns></returns>
        public static DialogResult Show(string message, string caption, string copyInfo)
        {
            ErrorBox box = new ErrorBox(message, caption, copyInfo);

            return(box.ShowDialog());
        }
Exemple #2
0
        /// <summary>
        /// Export the selected frames into a folder
        /// </summary>
        public void ExportFrames()
        {
            // Get the current time to use in the iterator:
            DateTime t = DateTime.Now;

            // Get the path and trim the leading characters:
            string path = _formatForm.SavePath.Trim(' ', '\\');

            // Get the filename and extension:
            string fileName  = _formatForm.FileName;
            string extension = _formatForm.Extension;

            // Get a valid imageformat to use in the savind process:
            ImageFormat format = GetFormatByString(extension);

            // Get the frame range:
            Point range = tlc_timeline.GetRange();

            range.X -= 1;

            // Unload the GIF from the memory, so we can work it with:
            LoadGif("");

            // Load the GIF file:
            Image m = Image.FromFile(CurrentGif.GifPath);

            // Get the frame dimension to advance the frames:
            FrameDimension frameDimension = new FrameDimension(m.FrameDimensionsList[0]);

            try
            {
                for (int x = range.X; x < (range.X + 1) + range.Y; x++)
                {
                    // Get the name:
                    string name = fileName;

                    // Replace the tokens:
                    while (name.Contains("{%i}"))
                    {
                        name = name.Replace("{%i}", (x + 1) + "");
                    }
                    while (name.Contains("{%h}"))
                    {
                        name = name.Replace("{%h}", "" + t.Hour);
                    }
                    while (name.Contains("{%m}"))
                    {
                        name = name.Replace("{%m}", "" + t.Minute);
                    }
                    while (name.Contains("{%s}"))
                    {
                        name = name.Replace("{%s}", "" + t.Second);
                    }

                    // Create the bitmap and the graphics:
                    Bitmap   b = new Bitmap(m.Width, m.Height);
                    Graphics g = Graphics.FromImage(b);

                    // Advance to the desired frame:
                    m.SelectActiveFrame(frameDimension, x);

                    // Draw the image:
                    g.DrawImageUnscaled(m, 0, 0);

                    // Save the image down to the path with the given format:
                    b.Save(path + "\\" + name + extension, format);

                    // Dispose the bitmap and the graphics:
                    g.Dispose();
                    b.Dispose();
                }
            }
            catch (Exception e)
            {
                ErrorBox.Show("Error exporting frames: " + e.Message, "Error", e.StackTrace);
            }

            // Dispose the GIF:
            m.Dispose();

            // Reload the GIF:
            LoadGif(CurrentGif.GifPath);
        }