Remove boilerplate code, add comments
This commit is contained in:
Родитель
3ebc2e2d71
Коммит
c33fde7c4a
|
@ -3,6 +3,9 @@
|
||||||
##
|
##
|
||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# Ignore IDEA files
|
||||||
|
**/*/.idea
|
||||||
|
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
*.suo
|
*.suo
|
||||||
|
|
|
@ -14,7 +14,8 @@ The simplest way to get started is to add this repo as a [submodule](https://git
|
||||||
mkdir ./external
|
mkdir ./external
|
||||||
git submodule add git@github.com:worldbeater/Avalonia.Citrus.git ./external/citrus
|
git submodule add git@github.com:worldbeater/Avalonia.Citrus.git ./external/citrus
|
||||||
# Reference the ../external/citrus/src/Avalonia.Citrus/Avalonia.Citrus.csproj project then.
|
# Reference the ../external/citrus/src/Avalonia.Citrus/Avalonia.Citrus.csproj project then.
|
||||||
# The ../external/citrus/src/Citrus/Citrus.csproj is the sandbox where you can browse the markup.
|
# The ../external/citrus/src/Avalonia.Citrus.Sandbox/Avalonia.Citrus.Sandbox.csproj is
|
||||||
|
# the sandbox where you can browse the markup samples.
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, reference the default theme (or, the night theme) from your `App.xaml` file:
|
Then, reference the default theme (or, the night theme) from your `App.xaml` file:
|
||||||
|
@ -41,4 +42,4 @@ Then, reference the default theme (or, the night theme) from your `App.xaml` fil
|
||||||
</Application>
|
</Application>
|
||||||
```
|
```
|
||||||
|
|
||||||
Done! Now the templates of all default controls are updated. See the [sandbox project](https://github.com/worldbeater/Avalonia.Citrus/blob/master/src/Citrus/MainWindow.xaml) for more examples.
|
Done! Now the templates of all default controls are updated. See the [sandbox project](https://github.com/worldbeater/Avalonia.Citrus/blob/master/src/Avalonia.Citrus.Sandbox/MainWindow.xaml) for more examples.
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
x:Class="Avalonia.Citrus.Sandbox.App">
|
||||||
|
<Application.Styles>
|
||||||
|
<!--
|
||||||
|
Note: In this project, the <StyleInclude /> line below has no affect.
|
||||||
|
This happens because we override the styles in the main window styles
|
||||||
|
section, see the 'MainWindowViewModel.cs' file for more info.
|
||||||
|
-->
|
||||||
|
<StyleInclude Source="avares://Avalonia.Citrus/Citrus.xaml"/>
|
||||||
|
</Application.Styles>
|
||||||
|
</Application>
|
|
@ -1,8 +1,7 @@
|
||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
namespace Citrus
|
namespace Avalonia.Citrus.Sandbox
|
||||||
{
|
{
|
||||||
public class App : Application
|
public class App : Application
|
||||||
{
|
{
|
|
@ -1,8 +1,8 @@
|
||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
Background="{DynamicResource ThemeBackgroundColor}"
|
Background="{DynamicResource ThemeBackgroundColor}"
|
||||||
Width="920" Height="630"
|
x:Class="Avalonia.Citrus.Sandbox.MainWindow"
|
||||||
x:Class="Citrus.MainWindow">
|
Width="920" Height="630">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
|
@ -2,7 +2,7 @@ using Avalonia.Markup.Xaml;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace Citrus
|
namespace Avalonia.Citrus.Sandbox
|
||||||
{
|
{
|
||||||
public class MainWindow : ReactiveWindow<MainWindowViewModel>
|
public class MainWindow : ReactiveWindow<MainWindowViewModel>
|
||||||
{
|
{
|
|
@ -7,7 +7,7 @@ using ReactiveUI.Fody.Helpers;
|
||||||
using ReactiveUI.Validation.Extensions;
|
using ReactiveUI.Validation.Extensions;
|
||||||
using ReactiveUI.Validation.Helpers;
|
using ReactiveUI.Validation.Helpers;
|
||||||
|
|
||||||
namespace Citrus
|
namespace Avalonia.Citrus.Sandbox
|
||||||
{
|
{
|
||||||
public sealed class MainWindowViewModel : ReactiveValidationObject<MainWindowViewModel>
|
public sealed class MainWindowViewModel : ReactiveValidationObject<MainWindowViewModel>
|
||||||
{
|
{
|
||||||
|
@ -24,8 +24,13 @@ namespace Citrus
|
||||||
{
|
{
|
||||||
_window = window;
|
_window = window;
|
||||||
_changeTheme = ReactiveCommand.Create(PerformThemeChange);
|
_changeTheme = ReactiveCommand.Create(PerformThemeChange);
|
||||||
|
|
||||||
|
// We add the style to the main window styles section,
|
||||||
|
// so it will override the default style defined in App.xaml.
|
||||||
_window.Styles.Add(_lightStyle);
|
_window.Styles.Add(_lightStyle);
|
||||||
|
|
||||||
|
// This is ReactiveUI.Validation magic, that supports
|
||||||
|
// INotifyDataErrorInfo <TextBox /> error messages.
|
||||||
this.ValidationRule(x => x.Message,
|
this.ValidationRule(x => x.Message,
|
||||||
message => !string.IsNullOrWhiteSpace(message),
|
message => !string.IsNullOrWhiteSpace(message),
|
||||||
"This text is not happy to be empty!");
|
"This text is not happy to be empty!");
|
||||||
|
@ -38,6 +43,9 @@ namespace Citrus
|
||||||
|
|
||||||
private void PerformThemeChange()
|
private void PerformThemeChange()
|
||||||
{
|
{
|
||||||
|
// Here, we change the first style in the main window styles
|
||||||
|
// section, and the main window instantly refreshes. Remember
|
||||||
|
// to invoke such methods from the UI thread.
|
||||||
switch (_theme)
|
switch (_theme)
|
||||||
{
|
{
|
||||||
case Theme.Light:
|
case Theme.Light:
|
||||||
|
@ -57,7 +65,7 @@ namespace Citrus
|
||||||
|
|
||||||
private static StyleInclude CreateStyle(string url) =>
|
private static StyleInclude CreateStyle(string url) =>
|
||||||
new StyleInclude(
|
new StyleInclude(
|
||||||
new Uri("resm:Styles?assembly=Citrus"))
|
new Uri("resm:Styles?assembly=Avalonia.Citrus.Sandbox"))
|
||||||
{Source = new Uri(url)};
|
{Source = new Uri(url)};
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
using Avalonia;
|
using Avalonia.Dialogs;
|
||||||
using Avalonia.Dialogs;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Citrus
|
namespace Avalonia.Citrus.Sandbox
|
||||||
{
|
{
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
|
@ -5,18 +5,10 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Update="**\*.xaml.cs">
|
<!--<Compile Update="**\*.xaml.cs">
|
||||||
<DependentUpon>%(Filename)</DependentUpon>
|
<DependentUpon>%(Filename)</DependentUpon>
|
||||||
</Compile>
|
</Compile>-->
|
||||||
<AvaloniaResource Include="**\*.xaml">
|
<AvaloniaResource Include="**\*.xaml" />
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</AvaloniaResource>
|
|
||||||
<Compile Update="Default\Sea.xaml.cs">
|
|
||||||
<DependentUpon>Sea.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Update="Rust.xaml.cs">
|
|
||||||
<DependentUpon>Rust.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus
|
|
||||||
{
|
|
||||||
public class Citrus : Styles
|
|
||||||
{
|
|
||||||
public Citrus() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus
|
|
||||||
{
|
|
||||||
public class Rust : Styles
|
|
||||||
{
|
|
||||||
public Rust() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus
|
|
||||||
{
|
|
||||||
public class CitrusNight : Styles
|
|
||||||
{
|
|
||||||
public CitrusNight() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class BorderStyles : Styles
|
|
||||||
{
|
|
||||||
public BorderStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class ButtonStyles : Styles
|
|
||||||
{
|
|
||||||
public ButtonStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class CalendarStyles : Styles
|
|
||||||
{
|
|
||||||
public CalendarStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class CheckBoxStyles : Styles
|
|
||||||
{
|
|
||||||
public CheckBoxStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class ComboBoxStyles : Styles
|
|
||||||
{
|
|
||||||
public ComboBoxStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class ExpanderStyles : Styles
|
|
||||||
{
|
|
||||||
public ExpanderStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class ListBoxStyles : Styles
|
|
||||||
{
|
|
||||||
public ListBoxStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class MenuStyles : Styles
|
|
||||||
{
|
|
||||||
public MenuStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class NumericUpDownStyles : Styles
|
|
||||||
{
|
|
||||||
public NumericUpDownStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class ProgressBarStyles : Styles
|
|
||||||
{
|
|
||||||
public ProgressBarStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class RadioButtonStyles : Styles
|
|
||||||
{
|
|
||||||
public RadioButtonStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class SliderStyles : Styles
|
|
||||||
{
|
|
||||||
public SliderStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class TabControlStyles : Styles
|
|
||||||
{
|
|
||||||
public TabControlStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class TextBlockStyles : Styles
|
|
||||||
{
|
|
||||||
public TextBlockStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class TextBoxStyles : Styles
|
|
||||||
{
|
|
||||||
public TextBoxStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class ToggleButtonStyles : Styles
|
|
||||||
{
|
|
||||||
public ToggleButtonStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Styling;
|
|
||||||
|
|
||||||
namespace Avalonia.Citrus.Theme
|
|
||||||
{
|
|
||||||
public class TreeViewStyles : Styles
|
|
||||||
{
|
|
||||||
public TreeViewStyles() => AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Citrus", "Citrus\Citrus.csproj", "{F2095CAF-992A-4B77-8E8A-372571D627FF}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Citrus.Sandbox", "Avalonia.Citrus.Sandbox\Avalonia.Citrus.Sandbox.csproj", "{F2095CAF-992A-4B77-8E8A-372571D627FF}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Citrus", "Avalonia.Citrus\Avalonia.Citrus.csproj", "{D02EB1E5-0D24-4139-BCCB-C62B13536D82}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Citrus", "Avalonia.Citrus\Avalonia.Citrus.csproj", "{D02EB1E5-0D24-4139-BCCB-C62B13536D82}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
<Application xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
x:Class="Citrus.App">
|
|
||||||
<Application.Styles>
|
|
||||||
<StyleInclude Source="avares://Avalonia.Citrus/Citrus.xaml"/>
|
|
||||||
</Application.Styles>
|
|
||||||
</Application>
|
|
Загрузка…
Ссылка в новой задаче