Krypton Standard Toolkit Documentation

repository·master·Indexed 20 days ago

https://github.com/krypton-suite/standard-toolkit

A comprehensive suite of UI components and utilities for .NET developers, providing advanced styling, docking, and specialized controls such as Ribbons and Navigators. The suite includes the Krypton Toolkit, Krypton Ribbon, Krypton Navigator, Krypton Workspace, and Krypton Docking to create professional interfaces similar to Microsoft Office and Microsoft 365. Documentation covers installation via NuGet, migration guides for versions 90.00 through 110.00, and .NET compatibility requirements.

Tokens
11.2K
Snippets
24
Records
63
Agent score
70%

What's inside Krypton Standard Toolkit

  1. Overview of PaletteViewer

    master

    PaletteViewer is a WinForms utility built with .NET 4.7.2 and the Krypton Toolkit. It is designed to visualize every color exposed by the Krypton palette API across multiple themes. It condenses the entire color surface into a single, scrollable KryptonDataGridView, allowing developers and designers to audit, compare, and explore palette data.

    It is particularly useful for catching alignment errors in custom themes, such as:

    • Missing, unlabelled, or out-of-order color indices.
    • Arrays that are too short or return unexpected transparent colors.
    • IndexOutOfRangeException risks caused by misaligned SchemeBaseColors arrays.
  2. Overview of Krypton Suite products

    master

    The Krypton Suite provides UI components for creating professional, consistent applications with themes similar to Microsoft Office (2007/2010/2013) and Microsoft 365. The suite consists of five main products:

    1. Krypton Toolkit: The base set of controls.
    2. Krypton Ribbon: Ribbon-style interface components.
    3. Krypton Navigator: Navigation-focused components.
    4. Krypton Workspace: Workspace management components.
    5. Krypton Docking: Docking-capable UI components.
  3. Use the Krypton Toolkit for basic UI components

    master
    The Krypton Toolkit provides a set of basic user interface components designed to work in tandem with standard .NET Framework controls like MenuStrip, StatusStrip, and ToolStrip. It is used to speed up the development of professional-looking applications by providing themed controls such as forms, groups, and progress bars. The signed Krypton Toolkit assembly can be distributed with your products without charge or royalty.
  4. How the rendering execution flow works

    master

    The rendering process follows a specific sequence to ensure visual consistency:

    1. Retrieve Renderer: The control's ViewManager or Visual class gets the renderer from the current palette: IRenderer renderer = currentPalette.GetRenderer();
    2. Query Values: The Visual code requests specific theme values (colors, padding, etc.) from the palette or redirector: Color back = palette.GetBackColor1(style, state);
    3. Execute Draw: The Visual code calls the renderer's drawing methods using those retrieved values: renderer.Draw...(..., back, pad, ...);
    // 1. Get the renderer
    IRenderer renderer = currentPalette.GetRenderer();
    
    // 2. Get values from the palette
    Color back = palette.GetBackColor1(style, state);
    Padding pad = palette.GetMetricPadding(...);
    
    // 3. Call the renderer to perform the drawing
    renderer.Draw...(..., back, pad, ...);
  5. Understand the Palette Unification Architecture

    master

    The Krypton Suite uses a split architecture to manage theme colors, separating the high-level color definitions (Schemes) from the low-level WinForms rendering requirements (Tables).

    • KryptonColorScheme (The Scheme): A comprehensive, authoritative contract containing every color available in a theme (e.g., ~239 properties). This is the primary API surface for developers to access specific theme colors.
    • KryptonColorTable (The Bridge): A single, generic implementation of ProfessionalColorTable that acts as a bridge. It implements only the ~70 properties required by WinForms rendering and forwards those requests to the active KryptonColorScheme.

    This model allows for a massive palette API while keeping the rendering logic slim and maintainable. Adding a new theme only requires creating a new KryptonColorScheme subclass; no changes to the renderer bridge are necessary.

  6. Understand the Palette Mechanics in Krypton

    master

    Krypton uses a layered architecture to decouple drawing logic from theme values. This system consists of four main components:

    1. PaletteBase: The root abstract class providing the public API for retrieving theme values (Colors, Images, Typography, Layout metrics, and Hints).
    2. PaletteRedirect: A middle layer that sits between a control and a base palette. It allows for dynamic redirection to alternate palettes or overriding a subset of values without replacing the entire theme.
    3. Visual Classes: Classes like VisualForm or VisualButton that implement drawing logic. They do not hard-code values; instead, they query a palette (often via a redirector) and pass those values to a renderer.
    4. IRenderer: The implementation layer (found in Krypton.Toolkit.Rendering) that performs the actual GDI+ or rendering operations using the values provided by the palette.

    This separation enables easy theming (adding a new palette/renderer pair), dynamic theming (switching redirectors at runtime), and centralized drawing logic.

  7. Implement docking layouts with Krypton Docking

    master

    The Krypton Docking component set allows users to customize their application layout by dragging and dropping docking pages into new locations, similar to the docking behavior in Visual Studio 2008/2010.

    Key characteristics:

    • Each docking area uses an instance of the Krypton Workspace to manage page organization.
    • Integrates with the Krypton Toolkit architecture to ensure a consistent look and feel.
  8. How unified color scheme access works in Krypton Toolkit

    master

    The Krypton Toolkit uses a unified, reflection-free architecture for runtime color manipulation across all palette families. This is achieved through three primary mechanisms:

    1. SchemeColors Property: An abstract property in PaletteBase that exposes the internal color array. Derived families (like PaletteMicrosoft365Base) override this to return their specific color arrays, while KryptonCustomPaletteBase delegates this to its wrapped palette.
    2. CopySchemeColors Method: A protected helper in PaletteBase used to safely update the color scheme. It performs a thread-safe array copy, invalidates the color table cache (handling various field/property names like Table or _table), and triggers a UI refresh via the OnPalettePaint event.
    3. ApplyBaseColors Public API: A public method on KryptonCustomPaletteBase that allows external theme editors to pass a Color[] array to the palette.

    This design ensures that color updates are thread-safe, deterministic, and automatically trigger UI refreshes without requiring slow reflection-based access to private fields.

  9. Use Color Tables for ToolStrip rendering

    master

    While standard Krypton controls use IRenderer, WinForms MenuStrip, ToolStrip, StatusStrip, and ContextMenuStrip use a different pipeline involving Color Tables.

    • KryptonColorTable: Extends ProfessionalColorTable. It exposes properties that the .NET ToolStripProfessionalRenderer consumes.
    • KryptonProfessionalRenderer: The specific Krypton renderer used for menus/strips. It is initialized with a KryptonColorTable instance.

    Each built-in palette exposes a theme-specific ColorTable property. When you switch a palette, both the IRenderer (for controls) and the ColorTable (for menus/strips) are updated to maintain visual consistency.

    // How a palette exposes its color table
    public override KryptonColorTable ColorTable =>
        Table ??= new KryptonColorTable365(BaseColors!.ToArray(), InheritBool.True, this);
  10. Navigate pages using Krypton Navigator

    master
    The Krypton Navigator is an advanced navigation control that functions as an enhanced version of the standard TabControl. It offers multiple modes of operation to allow users to navigate through a set of pages in various ways. It is designed to integrate seamlessly with the Krypton Toolkit architecture.
  11. Implement a Microsoft Office-style ribbon with Krypton Ribbon

    master

    The Krypton Ribbon mimics the look, feel, and operation of the ribbon controls found in Microsoft Office (2007/2010/2013/365). It includes advanced features such as:

    • Quick access toolbar
    • Contextual tabs
    • Auto-shrinking groups

    It integrates with the Krypton Toolkit architecture to maintain a consistent visual style across your application.

  12. Create customizable document areas with Krypton Workspace

    master

    The Krypton Workspace allows you to create a document area where users can drag and drop pages into new positions, similar to the Visual Studio document area.

    Key characteristics:

    • High flexibility and functionality for page organization.
    • Each cell within the workspace utilizes an instance of the Krypton Navigator to provide diverse display and organization options.
    • Integrates with the Krypton Toolkit architecture for visual consistency.