Ribbon for WinForms
テーマ
リボンの使用 > テーマ

A user can apply themes to the C1Ribbon control in the WinForms application by selecting one of the built-in themes, which can be accessed by adding the reference assembly C1.Win.C1Themes.4.5.2.

The assembly provides the following built-in themes:

Themes can be added to the C1Ribbon control only through the code. In order to add the Themes functionality to C1Ribbon, you can create a ComboBox using the ControlHost RibbonGroup Item and populate the ComboBox with the available themes. The user can then call the GetThemeByName method of the C1ThemeController class to retrieve the themes registered with the application by their names. Further, you can call the ApplyThemeToControlTree method to recursively apply a theme to a control and its children. This is depicted in the code snippet below:

Public Class ComboBoxHost
    Inherits RibbonControlHost
    Public Sub New()
        MyBase.New(New System.Windows.Forms.ComboBox())
        Dim ribbonBox = DirectCast(MyBase.Control, ComboBox)
        ribbonBox.Items.AddRange(C1ThemeController.GetThemes())
        ribbonBox.Text = "Select a theme"
        AddHandler ribbonBox.SelectedIndexChanged, AddressOf RibbonBox_SelectedIndexChanged
    End Sub

    Private Sub RibbonBox_SelectedIndexChanged(sender As Object, e As EventArgs)
        Dim themmeCombo As ComboBox = DirectCast(sender, ComboBox)
        Dim theme As C1Theme = C1ThemeController.GetThemeByName(themmeCombo.Text, False)
        C1ThemeController.ApplyThemeToControlTree(Me.Ribbon, theme)
    End Sub
End Class
    private void c1Ribbon1_RibbonEvent(object sender, RibbonEventArgs e)
    {
        //利用可能なテーマをコンボボックスに適用します
        var themeCombo = (ComboBox)comboBoxHost1.Control;
        themeCombo.Items.AddRange(C1ThemeController.GetThemes());
        themeCombo.Text = "Select a theme";
        themeCombo.SelectedIndexChanged += ThemeCombo_SelectedIndexChanged;
    }

    //選択したテーマをリボンに適用します
    private void ThemeCombo_SelectedIndexChanged(object sender, EventArgs e)
    {
        ComboBox themmeCombo = ((ComboBox)sender);
        C1Theme theme = C1ThemeController.GetThemeByName(themmeCombo.Text, false);
        C1ThemeController.ApplyThemeToControlTree(this.Ribbon, theme);
    }
}

//ControlHostのRibbonGroupアイテムを使用してComboBoxをリボンに追加します
public class ComboBoxHost : RibbonControlHost
{
    public ComboBoxHost() : base(new System.Windows.Forms.ComboBox())
    {

    }
}