### Runtime Color Modification Example Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Demonstrates how to create a palette, modify specific colors using helper methods, and apply a new color scheme. ```cs // 1. Create palette (installs its default scheme) var black = new PaletteMicrosoft365Black(); // 2. Tweak a few colors black.SetSchemeColor(SchemeBaseColors.TextLabelControl, Color.Gold); black.UpdateSchemeColors(new() { [SchemeBaseColors.PanelClient] = Color.FromArgb(30, 30, 30), [SchemeBaseColors.ButtonNormalBack1] = Color.DarkBlue, }); // 3. Swap the whole scheme var highContrast = new PaletteMicrosoft365Black_BaseScheme { TextLabelControl = Color.White, PanelClient = Color.Black }; black.ApplyScheme(highContrast); ``` -------------------------------- ### SparkleColorScheme Example Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Documents/2021-palette-unification.md Demonstrates the structure of a new scheme class, inheriting from KryptonColorScheme and providing direct property implementations for rendering colors. ```csharp public sealed class SparkleColorScheme : KryptonColorScheme { // ctor may take nothing or a ThemeVariant flag (Light/Dark). public override Color ButtonPressedBorder => Color.Black; public override Color ButtonPressedBegin => _sparkle[8]; // …and so on… } ``` -------------------------------- ### Usage Example: Applying Default Palette Colors Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Demonstrates how to use ApplyBaseColors in a theme editor to load default palette colors. Includes fallback logic if the direct application fails. ```csharp // 1. Get colors from source palette (e.g., via BaseScheme) var schemeColors = sourceScheme.ToArray(); // 2. Apply to custom palette - no reflection needed! if (customPalette.ApplyBaseColors(schemeColors)) { // Success - UI automatically refreshes } else { // Fallback to PopulateFromBase() for full clone customPalette.PopulateFromBase(false); } ``` -------------------------------- ### Color Array Processing: Initial Colors Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Example of the initial color array definition for a palette scheme, highlighting the start of the array. ```cs private static readonly Color[] _schemeBaseColors = [ Color.FromArgb(21, 66, 139), // TextLabelControl Color.FromArgb(21, 66, 139), // TextButtonNormal ``` -------------------------------- ### Install dictionary-en-gb with npm Source: https://github.com/krypton-suite/standard-toolkit/blob/master/dictionary-en-gb/readme.md Install the dictionary-en-gb package using npm. Ensure you are using a compatible Node.js version (12.20+, 14.14+, or 16.0+). ```sh npm install dictionary-en-gb ``` -------------------------------- ### Modern Palette Constructor with KryptonColorSchemeBase Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Example of a modern constructor for a palette class that accepts a KryptonColorSchemeBase. This constructor uses a strongly-typed scheme and converts it to the required arrays via extension methods. ```csharp // Modern, safer way – pass a strongly-typed scheme in Palette-family `Base` class protected readonly KryptonColorSchemeBase? BaseColors; public PaletteMicrosoft365Black() : base(new PaletteMicrosoft365Black_BaseScheme(), _checkBoxList, _galleryButtonList, _radioButtonArray, new PaletteMicrosoft365Black_BaseScheme().ToTrackBarArray()) { } ``` -------------------------------- ### Run Built ModernBuild Executable Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Scripts/ModernBuild/README.md Execute the compiled ModernBuild application directly from its output path. An example path is provided. ```powershell Scripts/ModernBuild/bin/Debug/net9.0-windows/ModernBuild.exe ``` -------------------------------- ### Handling Missing Enum Values Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Example showing how a missing enum value by comment is handled, with the color assigned to a default empty color. ```cs public override Color RibbonGroupButtonText { get; set; } = GlobalStaticValues.EMPTY_COLOR; // missing value ``` -------------------------------- ### Customize Themed System Menu with Custom Items Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Themed-System-Menu.md Add custom menu items to the themed system menu. This example shows how to add a separator and a new custom menu item with a click event handler. ```csharp // Add custom menu items if (ThemedSystemMenu != null) { var customItem = new KryptonContextMenuItem("Custom Action"); customItem.Click += (sender, e) => MessageBox.Show("Custom action!"); ThemedSystemMenu.ContextMenu.Items.Add(new KryptonContextMenuSeparator()); ThemedSystemMenu.ContextMenu.Items.Add(customItem); } ``` -------------------------------- ### Run ThemeSwapRepro Project Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/TestHarnesses/ThemeSwapRepro/README.md Execute the ThemeSwapRepro project using the .NET CLI. This command builds and runs the project in Debug configuration, targeting the specified project file. ```bash dotnet run --project "Source/TestHarnesses/ThemeSwapRepro/ThemeSwapRepro.csproj" -c Debug ``` -------------------------------- ### Preview All Palettes Without Writing Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Simulates all transformations in memory and prints validation results without modifying any files. Use this to ensure the migration process is safe before applying changes. ```bash kptheme genscheme --migrate --dry-run -d "Source/Krypton Components/Krypton.Toolkit/Palette Builtin" ``` -------------------------------- ### Run Sample App (Debug) Source: https://github.com/krypton-suite/standard-toolkit/blob/master/AGENTS.md Command to run the TestForm sample application in Debug configuration using the .NET CLI. ```bash dotnet run --project "Source/Krypton Components/TestForm/TestForm.csproj" -c Debug ``` -------------------------------- ### Preset Builds (Windows cmd) Source: https://github.com/krypton-suite/standard-toolkit/blob/master/AGENTS.md Commands to trigger preset builds using Windows command prompt scripts. Options include an interactive menu or specific build types like stable, canary, or nightly. ```batch run.cmd ``` ```batch Scripts/VS2022/build-stable.cmd ``` ```batch Scripts/VS2022/build-canary.cmd ``` ```batch Scripts/VS2022/build-nightly.cmd ``` -------------------------------- ### Build Solution (Debug) Source: https://github.com/krypton-suite/standard-toolkit/blob/master/AGENTS.md Command to build the entire Krypton Toolkit Suite solution in Debug configuration using the .NET CLI. ```bash dotnet build "Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.sln" -c Debug ``` -------------------------------- ### Run ModernBuild Project Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Scripts/ModernBuild/README.md Run the ModernBuild tool directly using dotnet run. This is the recommended way to launch the application. ```powershell dotnet run --project Scripts/ModernBuild/ModernBuild.csproj ``` -------------------------------- ### Replacing Old ColorTable Instantiation Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Documents/2021-palette-unification.md Shows how to replace the instantiation of theme-specific color tables with the new unified KryptonColorTable, passing in a unified scheme. ```csharp new KryptonColorTable(myUnifiedScheme); ``` -------------------------------- ### Select Renderer Implementation Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Documents/palette-mechanics-intro.md Base palettes override GetRenderer() to select the appropriate renderer implementation for their theme. ```csharp public override IRenderer GetRenderer() => KryptonManager.RenderOffice2013; // or public override IRenderer GetRenderer() => KryptonManager.RenderMicrosoft365; ``` -------------------------------- ### Build Local VSIX for Krypton Templates Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Templates/README.md Restore dependencies and build the VSIX project for Krypton templates. This command generates the VSIX file in the specified output directory. ```cmd dotnet restore "Templates\Vsix\Krypton.Templates.Vsix\Krypton.Templates.Vsix.csproj" dotnet msbuild "Templates\Vsix\Krypton.Templates.Vsix\Krypton.Templates.Vsix.csproj" /p:Configuration=Release /p:DeployExtension=false ``` -------------------------------- ### Build ModernBuild Project Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Scripts/ModernBuild/README.md Build the ModernBuild project using dotnet build. This is an optional step before running. ```powershell dotnet build Scripts/ModernBuild/ModernBuild.csproj -c Release ``` -------------------------------- ### KryptonColorTable for ToolStrip Rendering Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Documents/palette-mechanics-intro.md KryptonColorTable extends ProfessionalColorTable to provide theme-specific colors for .NET ToolStrip rendering. ```csharp public override KryptonColorTable ColorTable => Table ??= new KryptonColorTable365(BaseColors!.ToArray(), InheritBool.True, this); ``` -------------------------------- ### Replacing Obsolete ColorTable Instantiation Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Documents/2021-palette-unification.md Illustrates the refactoring step where old instantiations of KryptonColorTableXXX are replaced with the new scheme and unified color table pattern. ```csharp new KryptonColorTable365(colors, roundedEdges, palette); ``` ```csharp var scheme = new Microsoft365ColorScheme(colors, roundedEdges); var colorTable = new KryptonColorTable(scheme); ``` -------------------------------- ### Generate Scheme Classes Only Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Creates or updates the strongly-typed scheme class file next to the specified palette file. The palette source itself remains untouched. ```bash kptheme genscheme -f PaletteMicrosoft365Black.cs ``` -------------------------------- ### Apply Templates NuGet Package Channel Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Templates/README.md Use this PowerShell script to apply the desired NuGet package channel (stable, canary, alpha) before building a local VSIX. This ensures the VSIX uses the correct package version. ```powershell pwsh -NoProfile -File "Scripts\CI\Apply-TemplatesNuGetPackage.ps1" -Channel stable pwsh -NoProfile -File "Scripts\CI\Apply-TemplatesNuGetPackage.ps1" -Channel canary pwsh -NoProfile -File "Scripts\CI\Apply-TemplatesNuGetPackage.ps1" -Channel alpha ``` -------------------------------- ### Set NuGet API Key for NuGet.org Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Scripts/ModernBuild/README.md Set your API key for pushing packages to NuGet.org. This command configures the source for future operations. ```powershell nuget.exe setapikey -Source https://api.nuget.org/v3/index.json ``` -------------------------------- ### Add GitHub Packages Source for NuGet Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Scripts/ModernBuild/README.md Add a custom NuGet source for GitHub Packages. Ensure you replace with your GitHub username or organization name. ```powershell nuget.exe sources add -Name github -Source https://nuget.pkg.github.com//index.json ``` -------------------------------- ### Configure Themed System Menu Trigger Methods Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Themed-System-Menu.md Configure which trigger methods are enabled for the themed system menu. You can enable or disable left-click, right-click, and Alt+Space shortcuts. ```csharp // Configure which trigger methods are enabled ShowThemedSystemMenuOnLeftClick = true; // Left-click on title bar ShowThemedSystemMenuOnRightClick = true; // Right-click on title bar ShowThemedSystemMenuOnAltSpace = true; // Alt+Space keyboard shortcut // You can disable specific methods while keeping others enabled ShowThemedSystemMenuOnLeftClick = false; // Disable left-click trigger ``` -------------------------------- ### PaletteMicrosoft365Base Constructor Overload Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md An overload for the constructor that accepts a KryptonColorSchemeBase implementation. It converts the scheme to a Color[] and forwards it to the main constructor, while also storing the scheme in the BaseColors member. ```csharp /// /// Overload that accepts any KryptonColorSchemeBase implementation. /// Converts it to a Color[] and forwards to the main constructor. /// protected PaletteMicrosoft365Base( KryptonColorSchemeBase scheme, ImageList checkBoxList, ImageList galleryButtonList, Image?[] radioButtonArray, Color[] trackBarColors) : this(scheme.ToArray(), checkBoxList, galleryButtonList, radioButtonArray, trackBarColors) { BaseColors = scheme; } ``` -------------------------------- ### Constructor Update for New Scheme Class Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Updates a constructor to use a new base scheme class pattern, replacing old color array initializations with new scheme instances and extension methods. ```csharp // OLD (non-static!) Constructor: public PaletteMicrosoft365Black() : base(_schemeBaseColors, _checkBoxList, _galleryButtonList, _radioButtonArray, _trackBarColors) { } // NEW Constructor using the new scheme class: public PaletteMicrosoft365Black() : base( new PaletteMicrosoft365Black_BaseScheme(), _checkBoxList, _galleryButtonList, _radioButtonArray, new PaletteMicrosoft365Black_BaseScheme().ToTrackBarArray()) { } ``` -------------------------------- ### Full Palette Migration Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Performs a complete migration, updating scheme files and modifying palette sources in place. Use this command after a successful dry-run. Family-base palettes retain their arrays, while theme palettes lose them. ```bash kptheme genscheme --migrate -d "Palette Builtin" --overwrite ``` -------------------------------- ### Unified KryptonColorTable Implementation Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Documents/2021-palette-unification.md Defines a single generic KryptonColorTable that accepts any KryptonColorSchemeBase instance and forwards rendering properties to it. ```csharp public sealed class KryptonColorTable : ProfessionalColorTable { private readonly KryptonColorSchemeBase _scheme; public KryptonColorTable(KryptonColorSchemeBase scheme) => _scheme = scheme ?? throw new ArgumentNullException(nameof(scheme)); // Forward every ProfessionalColorTable property to the scheme public override Color ButtonPressedBorder => _scheme.ButtonPressedBorder; // …add overrides for each property defined in ProfessionalColorTable… } ``` -------------------------------- ### Color Array Processing: Multi-line Statements Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Demonstrates handling of color definitions that span multiple lines, including comments within the parameter list. ```cs Color.FromArgb(140, 172, 211), // RibbonGroupSeparatorDark ``` -------------------------------- ### Basic Themed System Menu Usage Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Themed-System-Menu.md The themed system menu is enabled by default. It can be triggered by left-clicking the title bar, right-clicking the title bar, or pressing Alt+Space. ```csharp // The themed system menu is enabled by default // It can be triggered in multiple ways: // 1. Left-click on the title bar (except on control buttons) // 2. Right-click on the title bar (except on control buttons) // 3. Press Alt+Space keyboard shortcut ``` -------------------------------- ### Color Array Processing: Handling Comments Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Illustrates how the script handles color definitions with comments, showing a single color definition with a comment. ```cs Color.FromArgb(134, 179, 236), //(155, 187, 227), // RibbonMinimizeBarDark ``` -------------------------------- ### Query Renderer and Palette Values Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Documents/palette-mechanics-intro.md Visual classes query the current palette for rendering values and then call the selected renderer to perform drawing operations. ```csharp IRenderer renderer = currentPalette.GetRenderer(); ``` ```csharp Color back = palette.GetBackColor1(style, state); Padding pad = palette.GetMetricPadding(...); ``` ```csharp renderer.Draw...(..., back, pad, ...); ``` -------------------------------- ### Existing ColorTable Override Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Documents/2021-palette-unification.md Illustrates the current pattern where each theme base class overrides ColorTable to instantiate its own derived color table. ```csharp public override KryptonColorTable ColorTable => Table ??= new KryptonColorTable365(...); ``` -------------------------------- ### Dictionary Buffer Structure Source: https://github.com/krypton-suite/standard-toolkit/blob/master/dictionary-en-gb/readme.md The dictionary object returned by the package contains 'dic' and 'aff' properties, which are Node.js Buffers representing the index.dic and index.aff files. ```js {dic: , aff: } ``` -------------------------------- ### Apply Base Colors to Custom Palette Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md A public API for theme editors to apply a new color scheme to a custom palette. It utilizes CopySchemeColors for safe updates and returns a boolean indicating success. ```csharp public bool ApplyBaseColors(Color[] colors) { if (colors == null) throw new ArgumentNullException(nameof(colors)); if (_basePalette == null) return false; CopySchemeColors(colors); return true; } ``` -------------------------------- ### Forcing ColorTable Update Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Shows how to manually reset the ColorTable cache by setting the palette's Table property to null. ```cs palette.Table = null; // next access to palette.ColorTable will rebuild from current colors ``` -------------------------------- ### Use dictionary-en-gb in Node.js Source: https://github.com/krypton-suite/standard-toolkit/blob/master/dictionary-en-gb/readme.md Import and use the dictionary-en-gb package in your Node.js application. The callback function receives an error object or the dictionary buffers (dic and aff). ```js import dictionaryEnGb from 'dictionary-en-gb' dictionaryEnGb(function (error, enGb) { if (error) throw error console.log(enGb) // To do: use `enGb` somehow }) ``` -------------------------------- ### Thread-Safe Batch Color Update Source: https://github.com/krypton-suite/standard-toolkit/blob/master/Source/Krypton Components/Krypton.Toolkit/Palette Builtin/Base/README.md Updates multiple scheme colors in a thread-safe manner using a dictionary. Forces color table regeneration after updates. ```csharp // Thread-safe batch update public void UpdateSchemeColors(Dictionary colorUpdates) { if (colorUpdates is null) throw new ArgumentNullException(nameof(colorUpdates)); lock (_schemeColorsLock) { foreach (var update in colorUpdates) { _ribbonColors[(int)update.Key] = update.Value; } Table = null; // force color-table regeneration } } ```