/// <summary> /// Uses durations from the specified image to set up the control for indexing. This will stop playback. /// </summary> /// <typeparam name="T">The type of the frame images.</typeparam> /// <param name="image">The image whose durations should be used to specify frame and time indexes.</param> public void UseTimingsFrom <T>(GifImage <T> image) { Playing = false; if (image == null) { durations = null; sectionValues = null; FrameSelector.Maximum = 0; TimeSelector.Maximum = 0; FrameLabel.Text = ""; Enabled = false; } else { durations = new int[image.Frames.Length]; sectionValues = new int[image.Frames.Length + 1]; sectionValues[0] = 0; var accumulatedDuration = 0; for (var i = 0; i < image.Frames.Length; i++) { var duration = image.Frames[i].Duration; durations[i] = duration; accumulatedDuration += duration; sectionValues[i + 1] = accumulatedDuration; } FrameSelector.Maximum = image.Frames.Length - 1; TimeSelector.Maximum = image.Duration; UpdateLabel(); Enabled = true; } TimeSelectorSections.Invalidate(); }
/// <summary> /// Raises the <see cref="E:DesktopSprites.DesktopPonies.AnimatedImageIndexer.IndexChanged"/> event. /// </summary> protected virtual void OnIndexChanged() { UpdateLabel(); TimeSelectorSections.Invalidate(); IndexChanged.Raise(this); }