ThemeKit 8.6.4
dotnet add package ThemeKit --version 8.6.4
NuGet\Install-Package ThemeKit -Version 8.6.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ThemeKit" Version="8.6.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ThemeKit" Version="8.6.4" />
<PackageReference Include="ThemeKit" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ThemeKit --version 8.6.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ThemeKit, 8.6.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ThemeKit@8.6.4
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ThemeKit&version=8.6.4
#tool nuget:?package=ThemeKit&version=8.6.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ThemeKit
Движок тем оформления для WinForms-приложений (.NET 8). 6 встроенных тем + возможность создавать свои. Автоматическое сохранение выбора пользователя.
Установка
dotnet add package ThemeKit
Быстрый старт
using ThemeKit;
Theme.Apply(this, "Dark"); // тёмная тема
Theme.Apply(this, "Light"); // светлая тема
Theme.Apply(this, "Blue"); // синяя корпоративная
Theme.Apply(this, "Green"); // зелёная
Theme.Apply(this, "Purple"); // фиолетовая
Theme.Apply(this, "Orange"); // оранжевая
Сохранение выбора пользователя
// Применить и сохранить выбор (запомнится между запусками)
Theme.ApplyAndSave(this, "Dark");
// При запуске приложения -- загрузить сохранённую тему
Theme.LoadSaved(this);
// Узнать текущую сохранённую тему
string current = Theme.GetSaved(); // "Dark"
Получение списка тем
string[] themes = Theme.GetNames();
// ["Dark", "Light", "Blue", "Green", "Purple", "Orange"]
Доступные темы
| Тема | Фон | Текст | Кнопки | Акцент |
|---|---|---|---|---|
| Dark | #2D2D30 | #F1F1F1 | #3E3E42 | #007ACC |
| Light | #FFFFFF | #1E1E1E | #E1E1E1 | #0078D7 |
| Blue | #E3F2FD | #0D47A1 | #BBDEFB | #1976D2 |
| Green | #E8F5E9 | #1B5E20 | #C8E6C9 | #388E3C |
| Purple | #F3E5F5 | #4A148C | #CE93D8 | #7B1FA2 |
| Orange | #FFF3E0 | #E65100 | #FFCC80 | #F57C00 |
Регистрация своей темы
Theme.Register("Corporate", new ThemeColors(
FormBack: Color.FromArgb(240, 240, 245),
FormFore: Color.FromArgb(30, 30, 60),
ControlBack: Color.FromArgb(240, 240, 245),
ControlFore: Color.FromArgb(30, 30, 60),
ButtonBack: Color.FromArgb(200, 200, 220),
ButtonFore: Color.FromArgb(30, 30, 60),
GridBack: Color.FromArgb(240, 240, 245),
GridFore: Color.FromArgb(30, 30, 60),
GridHeaderBack: Color.FromArgb(200, 200, 220),
GridHeaderFore: Color.FromArgb(30, 30, 60),
GridAlternateRowBack: Color.FromArgb(230, 230, 240),
AccentColor: Color.FromArgb(70, 70, 150)
));
Theme.Apply(this, "Corporate");
Поддерживаемые контролы
Метод Theme.Apply рекурсивно обходит все контролы формы и применяет цвета к:
Form,Panel,TabControl,FlowLayoutPanelButton,TextBox,ComboBox,NumericUpDown,CheckBoxLabelDataGridView(включая заголовки, строки и выделение)MenuStrip,StatusStrip- Все вложенные контролы на любом уровне
Пример: Интернет-магазин с переключателем тем
using ThemeKit;
public partial class ShopForm : Form
{
public ShopForm()
{
InitializeComponent();
// Загрузить сохранённую тему при запуске
Theme.LoadSaved(this);
// Меню выбора тем
foreach (string name in Theme.GetNames())
{
var item = new ToolStripMenuItem(name);
item.Click += (s, e) => Theme.ApplyAndSave(this, name);
menuThemes.DropDownItems.Add(item);
}
}
}
Пример: Медицинская система (тёмная тема для ночных смен)
using ThemeKit;
// Автоматический выбор темы по времени суток
var hour = DateTime.Now.Hour;
string themeName = (hour >= 20 || hour < 7) ? "Dark" : "Light";
Theme.ApplyAndSave(this, themeName);
Пример: Школьный журнал (весёлые цвета)
using ThemeKit;
// Зелёная тема для начальных классов
Theme.Apply(this, "Green");
// Или фиолетовая для старших
Theme.Apply(this, "Purple");
API-справочник
| Метод | Описание |
|---|---|
Theme.Apply(form, name) |
Применяет тему к форме |
Theme.ApplyAndSave(form, name) |
Применяет и сохраняет выбор |
Theme.LoadSaved(form) |
Загружает сохранённую тему |
Theme.GetSaved() |
Возвращает имя сохранённой темы |
Theme.GetNames() |
Список всех доступных тем |
Theme.Register(name, colors) |
Регистрирует пользовательскую тему |
Лицензия
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0-windows7.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ThemeKit:
| Package | Downloads |
|---|---|
|
ISBuilder
Information System Builder — full toolkit for building .NET 8 WinForms applications with EF Core, SQL Server. Export, CRUD, forms, charts, auth, reports, validation, themes. |
GitHub repositories
This package is not used by any popular GitHub repositories.