/// <summary>
        /// Creates a new dialog and edits a default animation.
        /// </summary>
        public MenuAnimationEditorUI()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // Set up our options.
            m_cboLayout.Items.Add( new ComboItem( "Circular (no animation)", new CircularLayoutManager() ) );
            m_cboLayout.Items.Add( new ComboItem( "Radial burst", new StarburstLayoutManager() ) );
            m_cboLayout.Items.Add( new ComboItem( "Spin along perimeter", new SpinLayoutManager() ) );
            m_cboLayout.Items.Add( new ComboItem( "Unfold along perimeter", new PerimeterUnfoldLayoutManager() ) );
            m_cboLayout.Items.Add( new ComboItem( "Radial burst and spin", new SpinningStarburstLayoutManager() ) );
            m_cboLayout.Items.Add( new ComboItem( "Radial burst and unfold", new UnfoldingStarburstLayoutManager() ) );

            m_cboEffect.Items.Add( new ComboItem( "No effect", new NoOpFrameModifier() ) );
            m_cboEffect.Items.Add( new ComboItem( "Fade in", new FadeInFrameModifier() ) );
            m_cboEffect.Items.Add( new ComboItem( "Zoom in", new ZoomInFrameModifier() ) );
            m_cboEffect.Items.Add( new ComboItem( "Burn in", new BurnInFrameModifier() ) );
            m_cboEffect.Items.Add( new ComboItem( "Fade in and zoom in", new FadeInZoomFrameModifier() ) );

            // Get our sample options.
            m_options = new MenuOptionCollection();
            m_options.Add();
            m_options.Add();
            m_options.Add();
            m_options.Add();
            m_options.Add();
            m_options.Add();

            // Set our default animation.
            Animation = new ForwardMenuAnimation();
        }
예제 #2
0
 /// <summary>
 /// Initializes a new collection, copying only the visible elements
 /// from the provided collection.
 /// </summary>
 private MenuOptionCollection( MenuOptionCollection getVisibles )
 {
     foreach( MenuOption option in getVisibles )
         if( option.Visible ) InnerList.Add( option );
 }
예제 #3
0
        /// <summary>
        /// Initializes the data for this frame.
        /// </summary>
        /// <param name="options">
        /// The options that are to be rendered into this frame.  Cannot
        /// be null, nor can it contain less than one option.
        /// </param>
        /// <param name="radius">
        /// The radius to apply to the menu layout.
        /// </param>
        /// <param name="frameIndex">
        /// Ignored.
        /// </param>
        /// <param name="frameCount">
        /// The number of frames comprising the animation, including this
        /// frame.  Must be at least one.
        /// </param>
        /// <param name="layout">
        /// The object to use for performing layout of the frame.  Cannot be
        /// null.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if any of the arguments are null references.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown if the provided options collection contains no elements.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown if any of the arguments are out of range.
        /// </exception>
        public FinalFrame( 
            MenuOptionCollection options,
            int radius,
            int frameIndex,
            int frameCount,
            IFrameLayoutManager layout
            )
        {
            if( options == null )
                throw new ArgumentNullException(
                    "options",
                    "The options parameter cannot be null"
                    );

            else if( options.Count == 0 )
                throw new ArgumentException(
                    "The options collection must contain at least one option",
                    "options"
                    );

            else if( layout == null )
                throw new ArgumentNullException(
                    "layout",
                    "The layout manager cannot be null"
                    );

            else if( frameCount < 1 )
                throw new ArgumentOutOfRangeException(
                    "frameCount",
                    frameCount,
                    "The frame count must be at least one."
                    );

            else
            {
                // Track the boundaries of this frame...
                int left = 0, top = 0, right = 0, bottom = 0;

                // Position the options...
                for( int i = 0; i < options.Count; i++ )
                {
                    // Get the position and default image.
                    FinalFrameOptionData option = new FinalFrameOptionData(
                        layout.GetOptionPosition(
                            radius,
                            i,
                            options.Count,
                            frameCount - 1,
                            frameCount
                            ),
                        options[ i ]
                        );

                    m_options.Add( option );

                    // Get the width of the normal option.
                    int l = option.CenterPixelPosition.X -
                        option.OptionBitmap.Width / 2;

                    int t = option.CenterPixelPosition.Y -
                        option.OptionBitmap.Height / 2;

                    int r = option.CenterPixelPosition.X +
                        option.OptionBitmap.Width / 2;

                    int b = option.CenterPixelPosition.Y +
                        option.OptionBitmap.Height / 2;

                    if( l < left ) left = l;
                    if( t < top ) top = t;
                    if( r > right ) right = r;
                    if( b > bottom ) bottom = b;

                    // Adjust for the height of the hover image.
                    l = option.CenterPixelPosition.X -
                        option.Option.CachedPrimaryHoverImage.Width / 2;

                    t = option.CenterPixelPosition.Y -
                        option.Option.CachedPrimaryHoverImage.Height / 2;

                    r = option.CenterPixelPosition.X +
                        option.Option.CachedPrimaryHoverImage.Width / 2;

                    b = option.CenterPixelPosition.Y +
                        option.Option.CachedPrimaryHoverImage.Height / 2;

                    if( l < left ) left = l;
                    if( t < top ) top = t;
                    if( r > right ) right = r;
                    if( b > bottom ) bottom = b;

                    // Adjust for the height of the pressed image.
                    l = option.CenterPixelPosition.X -
                        option.Option.CachedPrimaryPressedImage.Width / 2;

                    t = option.CenterPixelPosition.Y -
                        option.Option.CachedPrimaryPressedImage.Height / 2;

                    r = option.CenterPixelPosition.X +
                        option.Option.CachedPrimaryPressedImage.Width / 2;

                    b = option.CenterPixelPosition.Y +
                        option.Option.CachedPrimaryPressedImage.Height / 2;

                    if( l < left ) left = l;
                    if( t < top ) top = t;
                    if( r > right ) right = r;
                    if( b > bottom ) bottom = b;
                }

                // Set our bounds.
                m_bounds = Rectangle.FromLTRB( left, top, right, bottom );
            }
        }
예제 #4
0
        /// <summary>
        /// Initializes an animation for the provided collection.
        /// </summary>
        /// <param name="options">
        /// The options to animate.  This parameter cannot be null,
        /// nor can the result of its 
        /// <see cref="MenuOptionCollection.GetVisibleOptions"/>
        /// method be empty.
        /// </param>
        /// <param name="radius">
        /// The radius to apply to the menu layout.
        /// </param>
        /// <param name="frameCount">
        /// The number of frames to render.  Must be at least one.
        /// </param>
        /// <param name="layout">
        /// The object used to lay out the menu options during the animation.
        /// </param>
        /// <param name="modifier">
        /// An object that transforms images during the animation.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if any of the provided parameters are null.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown if the provided frameCount option is less than one.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown if there are no visible options in the provided collection.
        /// </exception>
        public ReverseFrameCollection(
            MenuOptionCollection options,
            int radius,
            int frameCount,
            IFrameLayoutManager layout,
            IFrameModifier modifier
            )
        {
            if( options == null )
                throw new ArgumentNullException(
                    "options",
                    "You must provide a set of options"
                    );

            else if( layout == null )
                throw new ArgumentNullException(
                    "layout",
                    "You must provide a layout manager"
                    );

            else if( modifier == null )
                throw new ArgumentNullException(
                    "modifier",
                    "You must provide a modifier"
                    );

            else if( frameCount < 1 )
                throw new ArgumentOutOfRangeException(
                    "frameCount",
                    frameCount,
                    "You must provide at least one frame to render"
                    );

            else
            {
                MenuOptionCollection visibleOptions =
                    options.GetVisibleOptions();

                if( visibleOptions.Count == 0 )
                    throw new ArgumentException(
                        "There were no visible options to render",
                        "options"
                        );

                else
                {
                    // Final frame.
                    m_finalFrame = new FinalFrame(
                        visibleOptions,
                        radius,
                        frameCount - 1,
                        frameCount,
                        layout
                        );

                    m_frames.Add( m_finalFrame );

                    // Animate.
                    for( int i = frameCount - 2; i >= 0; i-- )
                        m_frames.Add( new Frame(
                            visibleOptions,
                            radius,
                            i,
                            frameCount,
                            layout,
                            modifier
                            ) );
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Initializes the data for the given frame.
        /// </summary>
        /// <param name="options">
        /// The options that are to be rendered into this frame.  Cannot
        /// be null.
        /// </param>
        /// <param name="radius">
        /// The radius to apply to the menu layout.
        /// </param>
        /// <param name="frameIndex">
        /// The index of the frame to render.  Must be at least zero and
        /// must be less than frameCount - 1.
        /// </param>
        /// <param name="frameCount">
        /// The number of frames to render.  Must be at least 1.
        /// </param>
        /// <param name="layout">
        /// The object to use for performing layout of the frame.  Cannot be
        /// null.
        /// </param>
        /// <param name="modifier">
        /// The modifications to apply to the rendered options.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if any of the arguments are null references.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown if any of the arguments are out of range.
        /// </exception>
        public Frame( 
            MenuOptionCollection options,
            int radius,
            int frameIndex,
            int frameCount,
            IFrameLayoutManager layout,
            IFrameModifier modifier
            )
        {
            if( options == null )
                throw new ArgumentNullException(
                    "options",
                    "The options parameter cannot be null"
                    );

            else if( layout == null )
                throw new ArgumentNullException(
                    "layout",
                    "The layout manager cannot be null"
                    );

            else if( modifier == null )
                throw new ArgumentNullException(
                    "modifier",
                    "You must provide a frame modifier"
                    );

            else if( frameCount < 1 )
                throw new ArgumentOutOfRangeException(
                    "frameCount",
                    frameCount,
                    "The frame count must be at least one."
                    );

            else if( frameIndex < 0 || frameIndex >= frameCount - 1 )
                throw new ArgumentOutOfRangeException(
                    "frameIndex",
                    frameIndex,
                    "The frame index must be at least zero, and must be strictly less than frameCount - 1"
                    );

            else
            {
                // Track the boundaries of this frame...
                int left = 0, top = 0, right = 0, bottom = 0;

                // Position and modify the options...
                for( int i = 0; i < options.Count; i++ )
                {
                    // Get the position and default image.
                    FrameOptionData original = new FrameOptionData(
                        layout.GetOptionPosition(
                        radius,
                        i,
                        options.Count,
                        frameIndex,
                        frameCount
                        ),
                        options[ i ].CachedPrimaryImage
                        );

                    FrameOptionData current = new FrameOptionData(
                        original.CenterPixelPosition,
                        (Bitmap)original.OptionBitmap.Clone()
                        );

                    // Modify the default image.
                    current = modifier.ModifyFrame(
                        original,
                        frameIndex,
                        frameCount
                        );

                    // Was the data cleared?
                    if( current != null && current.HasBitmap )
                    {
                        m_options.Add( current );

                        int l = current.CenterPixelPosition.X -
                            current.OptionBitmap.Width / 2;

                        int t = current.CenterPixelPosition.Y -
                            current.OptionBitmap.Height / 2;

                        int r = current.CenterPixelPosition.X +
                            current.OptionBitmap.Width / 2;

                        int b = current.CenterPixelPosition.Y +
                            current.OptionBitmap.Height / 2;

                        if( l < left ) left = l;
                        if( t < top ) top = t;
                        if( r > right ) right = r;
                        if( b > bottom ) bottom = b;
                    }
                }

                // Set our bounds.
                m_bounds = Rectangle.FromLTRB( left, top, right, bottom );
            }
        }
예제 #6
0
 /// <summary>
 /// Returns a new set of frames for this animation, and does not cache
 /// the result.
 /// </summary>
 /// <param name="menuOptions">
 /// The menu options to animate.  Cannot be null.
 /// </param>
 /// <param name="radius">
 /// The radius to apply to the menu layout.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Thrown if the provided collection is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Thrown if the provided collection does not contain any visible 
 /// options to animate.
 /// </exception>
 public override FrameCollection GetUncachedAnimation(
     MenuOptionCollection menuOptions,
     int radius
     )
 {
     return new ReverseFrameCollection(
         menuOptions,
         radius,
         FramesToRender,
         LayoutAnimator,
         FrameImageEffect
         );
 }
예제 #7
0
 /// <summary>
 /// Returns a new set of frames for this animation, and does not cache
 /// the result.
 /// </summary>
 /// <param name="menuOptions">
 /// The menu options to animate.  Cannot be null.
 /// </param>
 /// <param name="radius">
 /// The radius to apply to the menu layout.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Thrown if the provided collection is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Thrown if the provided collection does not contain any visible 
 /// options to animate.
 /// </exception>
 public abstract FrameCollection GetUncachedAnimation(
     MenuOptionCollection menuOptions,
     int radius
     );
예제 #8
0
        /// <summary>
        /// Returns a set of frames for this animation.
        /// </summary>
        /// <param name="menuOptions">
        /// The menu options to animate.  Cannot be null.
        /// </param>
        /// <param name="radius">
        /// The radius to apply to the menu layout.
        /// </param>
        /// <param name="cacheResult">
        /// If true, the result of this method will be saved for quick 
        /// reference later.  To clear a cached result, use the 
        /// <see cref="ClearAnimation"/> method.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if the provided collection is null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown if the provided collection does not contain any visible 
        /// options to animate.
        /// </exception>
        public FrameCollection GetAnimation( 
            MenuOptionCollection menuOptions, 
            int radius,
            bool cacheResult 
            )
        {
            if( m_animation != null )
                return m_animation;

            else
            {
                FrameCollection animation =
                    GetUncachedAnimation( menuOptions, radius );

                if( cacheResult ) m_animation = animation;
                return animation;
            }
        }
예제 #9
0
 /// <summary>
 /// Returns a set of frames for this animation.
 /// </summary>
 /// <param name="menuOptions">
 /// The menu options to animate.  Cannot be null.
 /// </param>
 /// <param name="radius">
 /// The radius to apply to the menu layout.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// Thrown if the provided collection is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// Thrown if the provided collection does not contain any visible 
 /// options to animate.
 /// </exception>
 public FrameCollection GetAnimation( 
     MenuOptionCollection menuOptions,
     int radius
     )
 {
     return GetAnimation( menuOptions, radius, true );
 }