/// <summary>
 /// Adds an image button to the ToolBar.
 /// </summary>
 /// <param name="aCommandUrl">A command URL e.g. "macro:///Standard.Module1.myMacro()"</param>
 /// <param name="aGraphic">A graphic for the Button. Use the <code>XImgMgr</code> to retrieve or register the image.</param>
 /// <param name="itemLabel">The item label.</param>
 /// <param name="dublicate">Set <code>true</code> if you want to add this button even if the commandUrl allready exist in the ToolBar</param>
 /// <param name="index">Index for the position of the Button. Postitive value means normal index, negative value means position from the the end of all buttons, <code>-0</code> means at the and of the list. </param>
 /// <param name="buttonType"> </param>
 /// <param name="nImageType">Type of the image. Standard is 0</param>
 /// <returns></returns>
 public bool AddImgButton(string aCommandUrl, XGraphic aGraphic, string itemLabel, bool dublicate = false, int index = -0,
                          OO.PropertyControlType buttonType = 0, short nImageType = 0)
 {
     return AddImgButton(new[] { aCommandUrl }, new[] { aGraphic }, new[] { itemLabel }, dublicate, new[] { index },
                         buttonType, nImageType);
 }
        /// <summary>
        /// Adds the img button.
        /// </summary>
        /// <param name="aCommandUrlSequence">A command URLs e.g. "macro:///Standard.Module1.myMacro()"</param>
        /// <param name="aGraphicSequence">A graphics for the Button. Use the <code>XImgMgr</code> to retrieve or register the image.</param>
        /// <param name="itemLabelSequence">The item labels.</param>
        /// <param name="dublicate">Set <code>true</code> if you want to add this button even if the commandUrl allready exist in the ToolBar</param>
        /// <param name="index"> </param>
        /// <param name="buttonType"> </param>
        /// <param name="nImageType">Type of the images. Standard is 0</param>
        /// <returns></returns>
        public bool AddImgButton(string[] aCommandUrlSequence, XGraphic[] aGraphicSequence, string[] itemLabelSequence, bool dublicate = false,
                                 int[] index = null, OO.PropertyControlType buttonType = 0, short nImageType = 0)
        {
            if (XImgMgr == null) return false;

            XImgMgr.insertImages(nImageType, aCommandUrlSequence, aGraphicSequence);

            for (int i = 0; i < aCommandUrlSequence.Length; i++)
            {
                if (!dublicate && ButtonAllreadyExists(aCommandUrlSequence[i]))
                    continue;

                int z = GetIndex(index, i);

                // Creates the PropertyValue set for the toolbar
                PropertyValue[] toolbarItemProperty = SetItemProperty(aCommandUrlSequence[i], itemLabelSequence[i],
                                                                      buttonType);

                // Adds the new toolbar to the toolbar container
                Settings.insertByIndex(z, Any.GetAsOne(toolbarItemProperty));
            }

            StoreSettings();

            return true;
        }
 /// <summary>
 /// Sets the item property.
 /// </summary>
 /// <param name="commandId">The command id.</param>
 /// <param name="label">The label.</param>
 /// <param name="piEItemType"> </param>
 /// <returns></returns>
 public static PropertyValue[] SetItemProperty(string commandId, string label,
                                               OO.PropertyControlType piEItemType = 0)
 {
     var itemProperty = new PropertyValue[4];
     itemProperty[0] = new PropertyValue { Name = "CommandURL", Value = Any.Get(commandId) };
     itemProperty[1] = new PropertyValue { Name = "Label", Value = Any.Get(label) };
     itemProperty[2] = new PropertyValue { Name = "Type", Value = Any.Get((short)piEItemType) };
     itemProperty[3] = new PropertyValue { Name = "IsVisible", Value = Any.Get(true) };
     return itemProperty;
 }