Localize color dialog, extend button width

2 posts, 1 answers
  1. Mihajlo
    Mihajlo avatar
    38 posts
    Member since:
    Aug 2018

    Posted 05 Feb Link to this post

    During localization it may happen that some buttons should become wider. In my case changing ColorDialogLocalizationProvider.CurrentProvider is not enough. For most dialogs that can appear from rich text editor I can replace them with inherited class and play with this.Controls property. But I don't see a way to do that for color dialog.

    I could override three event handlers (ButtonBackColor_Click, ButtonForeColor_Click, ButtonParagraphBackColor_Click) of RichTextEditorRibbonBar and take and tweak the code that is there, but that feels like a kludge. What is the proper way to tweak control sizes in color dialogs created from rich text editor?

  2. Answer
    Hristo
    Admin
    Hristo avatar
    1506 posts

    Posted 06 Feb Link to this post

    Hi Mihajlo,

    Thank you for writing.

    There is no public API to allow modifications of the layout inside the color dialog or inside the user controls added to it. A possible solution might be, to create a custom RichTextEditorRibbonBar and change the locations of the controls added to the dialog form: 
    public class MyRichTextEditorRibbonBar : RichTextEditorRibbonBar
    {
        protected override void ButtonForeColor_Click(object sender, EventArgs e)
        {
            RadColorDialog dialog = new RadColorDialog();
            RadColorDialogForm dialogForm = (RadColorDialogForm)dialog.ColorDialogForm;
     
            if (dialogForm.Controls.Count > 0)
            {
                RadColorSelector colorSelector = dialogForm.Controls[0] as RadColorSelector;
                if (colorSelector != null)
                {
                    foreach (Control c in colorSelector.Controls)
                    {
                        // Here you can adjust the locations and size of the controls
                        Console.WriteLine(c.Text != "" ? c.Text : c.Name);
                    }
                }
            }
     
            dialogForm.ThemeName = this.ThemeName;
            dialogForm.ShowIcon = false;
            dialogForm.ShowInTaskbar = false;
     
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                ChangeFontForeColorCommand command = new ChangeFontForeColorCommand(this.RichTextBoxActiveEditor);
                this.ExecuteCommand(command, (Telerik.WinControls.RichTextEditor.UI.Color)dialog.SelectedColor);
            }
        }
    }

    Let me know if you need further assistance.

    Regards,
    Hristo
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top