-
-
Notifications
You must be signed in to change notification settings - Fork 294
Allow Theme manager to preload themes from different assemblies, after initial load of sample defaults #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -536,4 +536,55 @@ Use the `ViewportTransform` dependency property to have the grid move with the v | |
| </Window> | ||
| ``` | ||
|
|
||
| > Tip: Right-click and drag the screen around to move the view and use the mouse wheel to zoom in and out. | ||
| > Tip: Right-click and drag the screen around to move the view and use the mouse wheel to zoom in and out. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The wiki contains documentation only about Nodify because that's the published package on NuGet. The Nodify.Shared project was developed as a utility project for quickly developing example apps and was not meant to be used in production. However, the best place for this type of documentation would be a new README file in the Examples folder. |
||
|
|
||
| ## Applying custom theme | ||
|
|
||
| Firstly define the theme in your assembly, if you don't have custom `Brushes` or `Controls` in your assembly then ommit those from the `MergedDictionary`. | ||
|
|
||
| Create the file in your project under `Themes/Custom.xaml`: | ||
|
|
||
| ```xml | ||
| <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
|
|
||
| <ResourceDictionary.MergedDictionaries> | ||
| <ResourceDictionary Source="pack://application:,,,/Nodify.Shared;component/Themes/Brushes.xaml" /> | ||
| <ResourceDictionary Source="pack://application:,,,/Nodify.Shared;component/Themes/Controls.xaml" /> | ||
| <ResourceDictionary Source="Brushes.xaml" /> | ||
| <ResourceDictionary Source="Controls.xaml" /> | ||
| </ResourceDictionary.MergedDictionaries> | ||
|
|
||
| <!-- from shared --> | ||
| <Color x:Key="ForegroundColor">White</Color> | ||
|
|
||
| </ResourceDictionary> | ||
| ``` | ||
|
|
||
| Redefine all colors you dislike by copying and them to your theme from: | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you meant: |
||
|
|
||
| - `Nodify/Themes/Nodify.xaml` | ||
| - `Nodify.Shared/Themes/Nodify.xaml` | ||
|
|
||
| To load a custom theme inside your application (from the assembly where your theme is defined) call `ThemeManager.PreloadThemes`: | ||
|
|
||
| ```cs | ||
| // Preload now themes with correct assembly setup | ||
| ThemeManager.PreloadThemes(Assembly.GetExecutingAssembly()?.GetName().Name, | ||
| new string[] | ||
| { | ||
| "Dark", | ||
| "Light", | ||
| "Nodify", | ||
| "Custom", | ||
| } | ||
| ); // | ||
| ``` | ||
|
|
||
| This will also add your theme to the theme cycle of the manager. If you want to remove the default themes from the cycle, ommit them from the preload call. | ||
|
|
||
| Finally apply your theme: | ||
|
|
||
| ```cs | ||
| ThemeManager.SetTheme("Custom"); | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we detect duplicates in the
PreloadThemesfunction? This may be the reason why changing themes is now slower than before (verified with ~400 nodes in Playground)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its possible, but i guess the order is more important, not necessarily the duplication. The performance issue is likely related to Output Warning messages.