Maps for WinForms
テーマの適用

Customizing the look and feel of a control is an important part of the application development which is required to give it a seamless user interface. Our Themes for WinForms provides an easy and intuitive way to apply themes to all ComponentOne controls. It allows you to style the control using the ThemeController component and ThemeDesigner application.

Using ThemeController

The ThemeController component can be used to apply built-in themes to the controls. The component loads and manages visual themes and applies them to the control. You can simply drag and drop the ThemeController from the toolbox on your form and use the built-in themes to style the control. For example, BeigeOne, Material, MaterialDark,Office2016Green, etc. are some available built-in themes.

The following image shows applying themes to the Map control.

Apply theme to Map using designer

To apply a built-in theme to the Map control using designer, follow these steps:

  1. Drag and drop the ThemeController and Map controls on the form. Observe how ThemeController component gets added to the component tray.
  2. Right-click the Map control and select Properties from the context menu.
  3. In the Properties window, click the dropdown next to the Theme on ThemeController property and select a theme, for example, MaterialDark theme, from the ComponentOne themes list.

Apply theme to Map using code

  1. Switch to code editor and add the following code to Form_Load event:

    C#
    コードのコピー
    string[] themes = C1ThemeController.GetThemes();
    foreach (string theme in themes)
    // Populate ComboBox with themes
    cmb_themes.Items.Add(theme);
    cmb_themes.SelectedIndex = 0;              
    

    As you can observe from the code above, the ThemeController component loads and manages C1Visual themes, and the GetThemes method retrieves all themes registered with the application. The Add method adds the themes as items to the ComboBox, and the SelectIndex property selects the current theme in the ComboBox.

  2. Add the following code to the SelectedIndexChanged event of ComboBox:

    C#
    コードのコピー
    private void cmb_themes_SelectedIndexChanged(object sender, EventArgs e)
            {
                C1Theme theme = null;
                try
                {
                    theme = C1ThemeController.GetThemeByName(cmb_themes.Text, false);
                }
                catch
                {
                }
                if (theme != null)
                {
                    C1ThemeController.ApplyThemeToControlTree(c1Map1, theme);
                }
                this.Activate();
            }              
    

    The SelectedIndexChanged event of ComboBox occurs when the value of the SelectedIndex property changes. Further, the ThemeController calls the ApplyThemeToControl method to apply theme to the Map control.

  3. Run the code and observe the output.

Using ThemeDesigner

C1ThemeDesigner application provides you an easy-to-use UI so that you can create your own themes or modify the existing ones. The application gets installed on your system along with ComponentOne WinForms Edition and can be accessed through C1ThemeDesigner.4.exe located at the following location:

C:\Program Files (x86)\ComponentOne\Apps\v4.0

For more information on using C1ThemeDesigner application to create and modify themes, see C1Theme Designer Application Overview.