Styling and Customization

Theme Management

Krypton is a popular framework for .NET applications, providing a rich set of UI controls and styling options. It allows you to customize the look and feel of your application to match your brand or preferences.

Theme Application

Krypton uses a theme manager to apply styling to its controls. The theme manager can be set at the application level or for individual controls.

  • Application Level: The KryptonManager class in Krypton.Toolkit provides methods for setting the theme at the application level.
// Set Krypton theme globally
          KryptonManager.GlobalPalette = new KryptonPalette(KryptonPaletteMode.ProfessionalSystem);
          
  • Control Level: You can set the theme for individual controls using their PaletteMode property.
// Set Krypton theme for a specific button
          kryptonButton1.PaletteMode = PaletteMode.ProfessionalOffice2003;
          

Themes

Krypton provides a variety of built-in themes, each with a distinct visual style. You can choose from the following themes:

  • ProfessionalSystem: The default Krypton theme.
  • ProfessionalOffice2003: A theme mimicking the Office 2003 style.
  • ProfessionalOffice2007Black: A dark theme inspired by Office 2007.
  • ProfessionalOffice2007Blue: A light theme inspired by Office 2007.
  • ProfessionalOffice2010Black: A dark theme inspired by Office 2010.
  • ProfessionalOffice2010Silver: A light theme inspired by Office 2010.
  • SparkleBlue: A vibrant blue theme.
  • SparkleOrange: A vibrant orange theme.
  • SparklePurple: A vibrant purple theme.

You can also customize these themes or create your own custom themes using the Krypton Palette.

Customization

Krypton allows extensive customization of its UI elements. You can modify the appearance of various components like buttons, menus, toolbars, and more.

Color and Appearance

  • Palette: The Krypton Palette provides a comprehensive way to customize colors, fonts, and other visual attributes. You can access the palette’s properties to modify various aspects of the UI.
// Access the palette object for a specific control
          KryptonPalette palette = kryptonButton1.Palette;
          
          // Modify the button's back color
          palette.Button.ButtonNormal.Back.Color1 = Color.Green;
          
  • PaletteMode: You can use PaletteMode to set the overall appearance of the UI. Different palette modes provide distinct color schemes and styles.

Layout and Dimensions

  • Size: You can modify the size of controls using their properties.
// Set the button's width
          kryptonButton1.Width = 150;
          
  • Padding: You can adjust the spacing around the content of controls using their padding properties.

Text and Fonts

  • Font: You can customize the font for UI elements by setting the font property of the control.
// Set the button's font
          kryptonButton1.Font = new Font("Arial", 12);
          
  • Text: You can modify the text displayed by controls using their Text property.

Custom Themes

Krypton allows you to create your own custom themes by inheriting from the KryptonPalette class. This allows you to fully customize the appearance of your application.

// Create a custom theme
          public class MyCustomTheme : KryptonPalette
          {
              // Override the properties of the theme
              public override Color ButtonNormalBackColor => Color.Blue;
          }
          

Example

// Apply the SparkleBlue theme globally
          KryptonManager.GlobalPalette = new KryptonPalette(KryptonPaletteMode.SparkleBlue);
          
          // Customize a button
          kryptonButton1.PaletteMode = PaletteMode.ProfessionalOffice2010Black;
          kryptonButton1.Text = "My Button";
          kryptonButton1.Width = 100;
          

Source Information