// RibbonUIButtonElementManagerBase.cs
// Copyright (c) 2016 Bentley Systems, Incorporated. All Rights Reserved.

using Haestad.Framework.Manager;
using Haestad.Framework.UI.Integration;

namespace Haestad.Framework.UI.Integration
{
    /// <summary>
    /// Abstract base class for managing groups of logical RibbonUIButton elements that are able to be customized by a user.
    /// A user should not be able to REMOVE commands; only collapse them, re-order, re-label etc.
    /// </summary>
    public abstract class RibbonUIButtonElementManagerBase : RibbonUIElementManagerBase
    {
        #region Constructor
        public RibbonUIButtonElementManagerBase(int storageElementId, string managerName, int managerVersion, IRibbonUICommandFactory ribbonUICommandFactory) 
            : base(storageElementId, managerName, managerVersion, ribbonUICommandFactory)
        {
        }
        #endregion

        #region Public Override Methods
        public override object Add(object[] arguments)
        {
            IRibbonUIButton element = (IRibbonUIButton)base.Add(arguments);
            if (arguments != null)
            {
                ButtonSize buttonSize = (ButtonSize)arguments[3];
                element.ButtonSize = buttonSize;

                ButtonStyle buttonStyle = (ButtonStyle)arguments[4];
                element.ButtonStyle = buttonStyle;
            }
            return element;
        }
        #endregion

        #region Public Methods
        public void AddRibbonUIButton(string ribbonUICommandName, bool initiallyVisible, bool separatorAfter, ButtonSize buttonSize, ButtonStyle buttonStyle)
        {
            Add(new object[] { ribbonUICommandName, initiallyVisible, separatorAfter, buttonSize, buttonStyle });
        }
        #endregion

        #region Protected Override Methods
        protected override IElementListManagerElement NewElement()
        {
            return new RibbonUIButton(Count, this);
        }
        #endregion
    }
}
