Пример #1
0
        /// <summary>
        /// Aggiunge un bottone
        /// </summary>
        /// <param name="RDE">L'editor a cui aggiungere il bottone</param>
        /// <param name="ButtonName">Il nome del bottone</param>
        /// <param name="GroupName">Il nome del gruppo a cui aggiungere il bottone</param>
        /// <remarks>Se il gruppo non c'è, verra ricreato</remarks>

        public static void AddButton(ref Telerik.Web.UI.RadEditor editor, ToolsName buttonName, GroupName groupName)
        {
            //If Not ToolsLoaded Then
            editor.EnsureToolsFileLoaded();
            //ToolsLoaded = True
            //End If

            bool found = false;

            foreach (Telerik.Web.UI.EditorToolGroup @group in editor.Tools)
            {
                if ((@group != null) && ((groupName == GroupName._ALL) || @group.Tag == groupName.ToString() || (string.IsNullOrEmpty(@group.Tag) && groupName == GroupName._VOID)))
                {
                    found = true;
                    Telerik.Web.UI.EditorTool tool = null;
                    try {
                        tool = @group.FindTool(buttonName.ToString());
                    } catch (Exception ex) {
                    }

                    if ((tool == null))
                    {
                        tool      = new Telerik.Web.UI.EditorTool();
                        tool.Name = buttonName.ToString();
                        //tool.ShortCut = "CTRL+B"
                        @group.Tools.Add(tool);
                    }
                }
            }

            if (!found)
            {
                Telerik.Web.UI.EditorToolGroup NewGroup = new Telerik.Web.UI.EditorToolGroup();
                editor.Tools.Add(NewGroup);
                Telerik.Web.UI.EditorTool Tool = new Telerik.Web.UI.EditorTool();
                Tool.Name = buttonName.ToString();
                NewGroup.Tools.Add(Tool);
            }
        }
Пример #2
0
        /// <summary>
        /// Aggiunge un bottone a specifici gruppi
        /// </summary>
        /// <param name="RDE">L'editor a cui aggiungere il bottone</param>
        /// <param name="ButtonName">Il nome del Tool (usare ToolsName.ToString())</param>
        /// <param name="GroupName"></param>
        /// <remarks>
        /// Se il gruppo non esite, ne verrà creato uno nuovo!
        /// </remarks>

        public static void AddButton(ref Telerik.Web.UI.RadEditor editor, string buttonName, string groupName)
        {
            editor.EnsureToolsFileLoaded();
            Boolean found = false;

            if (!string.IsNullOrEmpty(groupName))
            {
                foreach (Telerik.Web.UI.EditorToolGroup @group in editor.Tools)
                {
                    if ((@group != null) && @group.Tag == groupName)
                    {
                        found = true;
                        Telerik.Web.UI.EditorTool tool = null;
                        try {
                            tool = @group.FindTool(buttonName);
                        } catch (Exception ex) {
                        }

                        if ((tool == null))
                        {
                            tool      = new Telerik.Web.UI.EditorTool();
                            tool.Name = buttonName;
                            @group.Tools.Add(tool);
                        }
                    }
                }
            }

            if (!found)
            {
                Telerik.Web.UI.EditorToolGroup NewGroup = new Telerik.Web.UI.EditorToolGroup();
                editor.Tools.Add(NewGroup);
                Telerik.Web.UI.EditorTool Tool = new Telerik.Web.UI.EditorTool();
                Tool.Name = buttonName;
                NewGroup.Tools.Add(Tool);
            }
        }