Example #1
0
    protected void RemoveToolBarItems()
    {
        List <string> toolBarItems = new List <string>();

        toolBarItems.Add("InsertFormElement");
        toolBarItems.Add("AboutDialog");
        toolBarItems.Add("Zoom");
        toolBarItems.Add("ToggleTableBorder");
        toolBarItems.Add("ModuleManager");
        toolBarItems.Add("SpellCheck");
        toolBarItems.Add("FlashManager");
        toolBarItems.Add("TemplateManager");
        toolBarItems.Add("DocumentManager");
        toolBarItems.Add("MediaManager");
        toolBarItems.Add("InsertCustomLink");
        toolBarItems.Add("LinkManager");
        toolBarItems.Add("ToggleDocking");
        toolBarItems.Add("ImageMapDialog");
        toolBarItems.Add("InsertSnippet");
        toolBarItems.Add("FormatCodeBlock");
        toolBarItems.Add("XHTMLValidator");
        toolBarItems.Add("ApplyClass");

        foreach (string toolBarItem in toolBarItems)
        {
            foreach (Telerik.Web.UI.EditorToolGroup collection in txtEditor.Tools)
            {
                Telerik.Web.UI.EditorTool item = collection.FindTool(toolBarItem);
                if (item != null)
                {
                    item.Visible = false;
                }
            }
        }
    }
Example #2
0
        /// <summary>
        /// Rimuove un bottone
        /// </summary>
        /// <param name="RDE">L'editor da cui eliminare i bottoni</param>
        /// <param name="ButtonName">Il nome del bottone. Usare ToolsName.ToString()</param>
        /// <param name="GroupName">
        /// ""           -->  Toglie dai gruppi senza nome
        /// "ALL"/null   -->  Toglie da TUTTI i gruppi
        /// "GruopName"  -->  Toglie dal gruppo specificato
        /// </param>
        /// <remarks></remarks>

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

            if ((string.IsNullOrEmpty(groupName)))
            {
                groupName = GroupName._ALL.ToString();
            }

            else if (groupName == GroupName._VOID.ToString())
            {
                groupName = "";
            }

            List <Telerik.Web.UI.EditorToolGroup> DelGroups = new List <Telerik.Web.UI.EditorToolGroup>();

            foreach (Telerik.Web.UI.EditorToolGroup @group in editor.Tools)
            {
                if ((@group != null) && (groupName == "_ALL" || @group.Tag == groupName))
                {
                    Telerik.Web.UI.EditorTool tool = default(Telerik.Web.UI.EditorTool);
                    try {
                        tool = @group.FindTool(buttonName);
                    } catch (Exception ex) {
                    }

                    if ((tool != null))
                    {
                        try {
                            @group.Tools.Remove(tool);
                        } catch (Exception ex) {
                        }
                    }

                    if (@group.Tools.Count <= 0)
                    {
                        DelGroups.Add(@group);
                    }
                }
            }

            if ((DelGroups != null) && DelGroups.Count > 0)
            {
                foreach (Telerik.Web.UI.EditorToolGroup @group in DelGroups)
                {
                    if ((@group != null) && @group.Tag == groupName)
                    {
                        editor.Tools.Remove(@group);
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Rimuove il bottone
        /// </summary>
        /// <param name="RDE">L'editor da cui togliere il bottone</param>
        /// <param name="ButtonName">Il nome del bottone</param>
        /// <param name="GroupName">Il gruppo da cui eleminare il bottone</param>
        /// <remarks></remarks>

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

            List <Telerik.Web.UI.EditorToolGroup> DelGroups = new List <Telerik.Web.UI.EditorToolGroup>();

            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)))
                {
                    Telerik.Web.UI.EditorTool tool = null;
                    try {
                        tool = @group.FindTool(buttonName.ToString());
                    } catch (Exception ex) {
                    }

                    if ((tool != null))
                    {
                        try {
                            @group.Tools.Remove(tool);
                        } catch (Exception ex) {
                        }
                    }

                    if (@group.Tools.Count <= 0)
                    {
                        DelGroups.Add(@group);
                    }
                }
            }

            if ((DelGroups != null) && DelGroups.Count > 0)
            {
                foreach (Telerik.Web.UI.EditorToolGroup @group in DelGroups)
                {
                    if ((@group != null))
                    {
                        editor.Tools.Remove(@group);
                    }
                }
            }
        }
Example #4
0
    protected void CreateCustomToolBarBtns()
    {
        txtEditor.EnsureToolsFileLoaded();

        //Custom toolbar item - insert custom links (to other documents);
        Telerik.Web.UI.EditorTool custom1 = new Telerik.Web.UI.EditorTool();
        custom1.Name     = "customInsertLink";
        custom1.ShortCut = "CTRL+l";
        custom1.Attributes.Add("title", "Insert Link");
        txtEditor.Tools[1].Tools.Add(custom1);

        //Custom toolbar item - Load draft if its publish mode and needs editing;
        Telerik.Web.UI.EditorTool custom2 = new Telerik.Web.UI.EditorTool();
        custom2.Name     = "customDraftLink";
        custom2.ShortCut = "CTRL+d";
        custom2.Attributes.Add("title", "Load Draft");
        //  txtEditor.Tools[1].Tools.Add(custom2);

        RemoveToolBarItems();
    }
Example #5
0
        public static Telerik.Web.UI.EditorTool GetToolButton(ref Telerik.Web.UI.RadEditor editor, ToolsName buttonName)
        {
            Telerik.Web.UI.EditorTool fButton = null;
            //If Not ToolsLoaded Then
            editor.EnsureToolsFileLoaded();
            //ToolsLoaded = True
            //End If

            foreach (Telerik.Web.UI.EditorToolGroup @group in editor.Tools)
            {
                if (@group != null)
                {
                    if (@group.Contains(buttonName.ToString()))
                    {
                        return(@group.FindTool(buttonName.ToString()));
                    }
                }
            }
            return(fButton);
        }
Example #6
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);
            }
        }
Example #7
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);
            }
        }