Exemplo n.º 1
0
        private bool ButtonAllreadyExists(string commandUrl)
        {
            XIndexContainer mOoToolbarSettings = Settings;

            if (mOoToolbarSettings == null)
            {
                return(false);
            }
            int iCount = mOoToolbarSettings.getCount();

            for (int i = 0; i < iCount; i++)
            {
                Array ooToolbarButton = mOoToolbarSettings.getByIndex(i).Value as Array ?? new Array[0];

                int jCount = ooToolbarButton.GetUpperBound(0);
                for (int j = 0; j < jCount; j++)
                {
                    var pv = ((PropertyValue)ooToolbarButton.GetValue(j));
                    if (pv.Name.Equals("CommandURL"))
                    {
                        if (pv.Value.Value.Equals(commandUrl))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the button propery.
        /// </summary>
        /// <param name="commandUrl">The command URL.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="value">The value.</param>
        public void SetButtonPropery(String commandUrl, string propertyName, object value)
        {
            XIndexContainer mOoToolbarSettings = Settings;

            if (mOoToolbarSettings == null)
            {
                return;
            }

            bool bButtonFound = false;
            bool save         = false;

            int iCount = mOoToolbarSettings.getCount();

            for (int i = 0; i < iCount; i++)
            {
                Array ooToolbarButton = mOoToolbarSettings.getByIndex(i).Value as Array ?? new Array[0];

                int jCount = ooToolbarButton.GetUpperBound(0);
                for (int j = 0; j < jCount; j++)
                {
                    var pv = ((PropertyValue)ooToolbarButton.GetValue(j));
                    if (pv.Name.Equals("CommandURL"))
                    {
                        if (pv.Value.Value.Equals(commandUrl))
                        {
                            bButtonFound = true;
                        }
                    }
                    else if (pv.Name.Equals(propertyName) && bButtonFound && (bool)pv.Value.Value)
                    {
                        pv.Value     = Any.Get(value);
                        bButtonFound = false;
                        save         = true;
                    }
                    else if (j + 1 >= jCount)
                    {
                        ooToolbarButton.SetValue(new PropertyValue {
                            Name = propertyName, Value = Any.Get(value)
                        }, jCount);
                        bButtonFound = false;
                        save         = true;
                    }
                }
                if (save)
                {
                    mOoToolbarSettings.replaceByIndex(i, Any.GetAsOne(ooToolbarButton));
                }
            }
            if (save)
            {
                Settings = mOoToolbarSettings;
            }
        }