当前位置:网站首页>Open source WPF control library adonisui

Open source WPF control library adonisui

2022-07-19 15:56:00 Dotnet cross platform

original text :https://github.com/benruehl/adonis-ui

translate : The wolf at the end of the desert ( Google translation blessing )

be used for WPF Application lightweight UI tool kit , Provide classic and enhanced Windows Visual effect :

89945dcdb96ced5535ee2b2f42431d13.gif

Warehouse information

  • Warehouse address :https://github.com/benruehl/adonis-ui

  • Demo:https://github.com/benruehl/adonis-ui#demo

048001b503b1708212052bbd1c143fab.png

What are they ?

  1. Almost all WPF Control's default style and template

  2. Other styles can be used as needed for convenience

  3. Two color schemes ( Light and dark ) It can also be used to customize styles

  4. Support changing color scheme at run time

  5. Support other custom color schemes

  6. Extension of built-in control , Provide watermark and other functions

  7. There are few custom controls for common use cases

Design principles

  1. Keep close to WPF Original appearance of

  2. No configuration required , But provide options for people who want to control global and personal behavior

  3. Support WPF Extensions to built-in controls that create new controls , In order to become a direct substitute for existing applications

file

Use document address :https://benruehl.github.io/adonis-ui/docs/getting-started/introduction/

Let's get started

  1. Reference... In your project AdonisUI and AdonisUI.ClassicTheme. It can be done by NuGet[1] Or download it manually [2] get . At present, it needs at least .NET Framework 4.5 or .NET Core 3.0.

Install-Package AdonisUI.ClassicTheme -Version 1.17.1
  1. Add resources to your application like this App.xaml in :

<Application xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/AdonisUI;component/ColorSchemes/Light.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/AdonisUI.ClassicTheme;component/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>
  1. from Adonis UI The default style of derives the window style , As shown below :

<Window.Style>
    <Style TargetType="Window" BasedOn="{StaticResource {x:Type Window}}"/>
</Window.Style>

Control features

Switch color schemes at runtime

Adonis UI With light and dark color schemes . You can add custom color schemes without restrictions .

Light scheme Dark scheme Scheme
7bd6bee37413c22341dea36aadb201cc.gif290cbafbb8abe9ee9058c8fde059cc09.gif

To switch color schemes at runtime ,ResourceDictionary You need to delete all colors and brushes containing the scheme from the application resources , So that you can add different color schemes . This can be done using the built-in ResourceLocator Class to complete , For example, in the click event handler .

AdonisUI.ResourceLocator.SetColorScheme(Application.Current.Resources, ResourceLocator.DarkColorScheme);

The first parameter must be right ResourceDictionary Contains references to color schemes , As its MergedDictionaries. The second parameter is the color scheme that should be added Uri.

Read more about switching color schemes [3]

Emphasis color

While relying on the uniform color of the background area and border , Accent colors can be used to visually highlight important points . By default , Both color schemes use blue as the accent color . This can be changed by overriding the emphasis color value . A set of styles helps to display controls such as buttons on accent colors .

Read more about colors and brushes [4]

Custom window title bar

Adonis UI Brings a custom window title bar , By default, it looks like Windows 10 The title bar is exactly the same , But there are several advantages . First , It respects the current color scheme , So when you switch to a dark color scheme, it will darken . secondly , Its color can also be set independently of the color scheme , For example, through bindings and triggers . Third , Its content can be easily customized , For example, by hiding icons 、 Add additional buttons or place labels in them . Derive your window AdonisWindow To receive these functions .



d24e54caad52f6a97efbb7713a74e569.pngb0aeb2be5fcf93dfe920cfa6c479d78b.png
70980b2d99128f732849e092dc734117.pngc5872c27f3c46205122513847c3b5b78.png

Read more about forms [5]

Cursor spotlight hover effect (Cursor Spotlight hover effect)

Dependent on interaction UI Control ( Button like 、 The text box 、 Combo box 、 List box, etc ) Used here is called Cursor Spotlight Hover effect . When hovering over a hidden control , It makes the layer around the cursor visible . It applies to two color schemes .

Light scheme Dark scheme Scheme
0aff5475de62470eca49c254efe9ed45.gif38c1c226ed616b4cbbae95b592055f3a.gif

Because it is related to OpacityMasks Working together is not limited to illuminating UI Control . It can be used to hide almost everything that can be used WPF Render things .

Read more about cursor spotlight effects [6]

chain reaction (Ripple effect)

By default , Button and ContextMenuItem The ripple effect appears when you click .ListBoxItems And support it , But it is disabled by default .

Light scheme Dark scheme Scheme
299399b981a043fbdc852fdb9272feb6.gif6dd6c1817b55b00f0acbe4243844fa47.gif

Read more about the ripple effect [7]

Layers

stay UI In design , It is common for containers to group items that belong together . for example , stay WPF in , This can be used GroupBoxes Make it easy . If the container is assigned different background colors to better distinguish the grouped items and their surroundings , Then color contrast may become a problem . Gray buttons may initially look good on a white application background , But when they are moved to a place that also has a gray background GroupBox In the middle of the day , They may lose visibility .

That's why Adonis UI A simple hierarchical system is introduced , It can be based on UI The layer to which the control belongs is automatically adjusted UI The color of the control . By default , All styles Adonis UI Will automatically adapt to the system , But you can also disable it .

Light scheme Dark scheme Scheme
d3e4e4bd104ecdf5b7078dc3dc77cfab.png00f81260134710205dfdc5de50c75e68.png

These images show a picture by Buttons and GroupBoxes A simple layout . All controls use their default styles , There are no properties set except their contents . The layered system is responsible for slightly adjusting the color and color of the buttons on each layer GroupBoxes The background of . It ensures that there is always a difference between the background of the container and the background of the controls in the container . If there is no system , All buttons will have exactly the same background color .

The system is fully customizable . Of course , It applies to all controls , Not just buttons . Each control can be configured to add layers to its children , But by default, it is already for some controls ( Such as GroupBoxes) Enable it . Controls can also be forced to reside on a specific layer .

Read more about tiered systems [8]

Data validation support

WPF The data validation mechanism of provides the ability to validate attribute values and allocate error messages when they are invalid . stay Adonis UI in , If the control is bound to an invalid property , The error is indicated by a red border and an error icon in the control template . When the control gets keyboard focus or the user hovers over the icon , The error message will be displayed as a pop-up window . To set validation errors , You can use interfaces IDataErrorInfo or WPF.

Light scheme Dark scheme Scheme
9b8b0a41f3fe92bec0b77ab95baa6c05.png8f506138ccb244118fabaed654c31d19.png

By default , The error message pop-up window is displayed on the keyboard focus and mouse over . Both can be disabled separately .

Read more about data validation [9]

ComponentResourceKeys

Adonis UI The resources provided have allocated ComponentResourceKey, In order to use them in a simple way . Resources exist in color 、 paint brush 、 Size 、 style 、 Templates and icons . for example , The foreground brush of the current color scheme can be used by referencing its resource key , Such as Foreground="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}".ComponentResourceKeys Allow to use IntelliSense Done automatically , This will come in handy when exploring available resources .

Read more about resources [10]

Space

Between controls Space Usually by margin 、 Fill and grid row and column controls . In order to ensure the Space Agreement , You can choose a fixed size , Use anywhere ( Or its multiple ).Adonis UI Provides a system to support you to do so . By default , The base value of space is 8, But it can be adjusted for horizontal and vertical space respectively .

You can use space like this :

<RowDefinition Height="{adonisUi:Space 1}"/> <!-- equals Height="8" -->
<RowDefinition Height="{adonisUi:Space 2.5}"/> <!-- equals Height="20" -->
<RowDefinition Height="{adonisUi:Space 2.5+1}"/> <!-- equals Height="21" -->
<RowDefinition Height="{adonisUi:Space 2.5-1}"/> <!-- equals Height="19" -->

It is also applicable to the thickness of margin and filling :

<Button Margin="{adonisUi:Space 1}"/> <!-- equals Margin="8,8,8,8" -->
<Button Margin="{adonisUi:Space 1, 2}"/> <!-- equals Margin="8,16,8,16" -->
<Button Margin="{adonisUi:Space 1, 1+2, 2, 3}"/> <!-- equals Margin="8,10,16,24" -->

Read more about space [11]

demonstration

There's one on the board WPF Demo application , It shows Adonis UI Most of the functions . Please don't hesitate , Have a try .

Download... Here [12]

License

MIT Benjamin Rühl

Reference resources

  • AdonisUI - be used for WPF Application lightweight UI tool kit , Provide classic but enhanced Windows Visual effect [13]

Reference material

[1]

NuGet: https://www.nuget.org/packages/AdonisUI.ClassicTheme/

[2]

Manual Download : https://github.com/benruehl/adonis-ui/releases

[3]

Read more about switching color schemes : https://benruehl.github.io/adonis-ui/docs/guides/colors-and-brushes/#switching-color-schemes-at-runtime

[4]

Read more about colors and brushes : https://benruehl.github.io/adonis-ui/docs/guides/colors-and-brushes/

[5]

Read more about forms : https://benruehl.github.io/adonis-ui/docs/guides/window/

[6]

Read more about cursor spotlight effects : https://benruehl.github.io/adonis-ui/docs/guides/cursor-spotlight/

[7]

Read more about the ripple effect : https://benruehl.github.io/adonis-ui/docs/guides/ripple/

[8]

Read more about tiered systems : https://benruehl.github.io/adonis-ui/docs/guides/layers/

[9]

Read more about data validation : https://benruehl.github.io/adonis-ui/docs/guides/data-validation/

[10]

Read more about resources : https://benruehl.github.io/adonis-ui/docs/guides/styles-and-templates/

[11]

Read more about space : https://benruehl.github.io/adonis-ui/docs/guides/space/

[12]

Download... Here : https://github.com/benruehl/adonis-ui/releases/download/1.17/AdonisUI.Demo.zip

[13]

AdonisUI - be used for WPF Application lightweight UI tool kit , Provide classic but enhanced Windows Visual effect : https://mp.weixin.qq.com/s/TaX0PqCci4vMlTdmbLAsCw

原网站

版权声明
本文为[Dotnet cross platform]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/200/202207180035418244.html