コード例 #1
0
ファイル: EditorHelper.cs プロジェクト: EdutechSRL/Adevico
        /// <summary>
        /// Rimuove un gruppo di bottoni dall'editor
        /// </summary>
        /// <param name="RDE">L'editor da cui togliere i bottoni</param>
        /// <param name="GroupName">Il nome del gruppo da togliere</param>
        /// <remarks></remarks>

        public static void RemoveGroup(ref Telerik.Web.UI.RadEditor editor, 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) && @group.Tag == groupName.ToString())
                {
                    DelGroups.Add(@group);
                }
            }

            if ((DelGroups != null) && DelGroups.Count > 0)
            {
                foreach (Telerik.Web.UI.EditorToolGroup @group in DelGroups)
                {
                    if ((@group != null))
                    {
                        editor.Tools.Remove(@group);
                    }
                }
            }
        }
コード例 #2
0
ファイル: EditorHelper.cs プロジェクト: EdutechSRL/Adevico
        /// <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);
                    }
                }
            }
        }
コード例 #3
0
ファイル: EditorHelper.cs プロジェクト: EdutechSRL/Adevico
        /// <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);
                    }
                }
            }
        }
コード例 #4
0
ファイル: EditorHelper.cs プロジェクト: EdutechSRL/Adevico
        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);
        }
コード例 #5
0
ファイル: EditorHelper.cs プロジェクト: EdutechSRL/Adevico
        /// <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);
            }
        }
コード例 #6
0
ファイル: EditorHelper.cs プロジェクト: EdutechSRL/Adevico
        /// <summary>
        /// Rimuove un gruppo di bottoni
        /// </summary>
        /// <param name="RDE">L'editor da cui eliminare i bottoni</param>
        /// <param name="GroupName">
        /// ""           -->  Toglie dai gruppi senza nome
        /// "_ALL"/null   -->  Toglie TUTTI i gruppi!!!
        /// "GruopName"  -->  Toglie dal gruppo specificato
        /// </param>
        /// <remarks>
        /// </remarks>

        public static void RemoveGroup(ref Telerik.Web.UI.RadEditor editor, string groupName)
        {
            if (string.IsNullOrEmpty(groupName))
            {
                groupName = "";
            }
            else if (groupName == GroupName._VOID.ToString())
            {
                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) && (@group.Tag == groupName | groupName == GroupName._ALL.ToString()))
                {
                    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);
                    }
                }
            }
        }
コード例 #7
0
ファイル: EditorHelper.cs プロジェクト: EdutechSRL/Adevico
        /// <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);
            }
        }