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
|
||||
|
||||
# Ignore IDEA files
|
||||
**/*/.idea
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
|
|
|
@ -14,7 +14,8 @@ The simplest way to get started is to add this repo as a [submodule](https://git
|
|||
mkdir ./external
|
||||
git submodule add git@github.com:worldbeater/Avalonia.Citrus.git ./external/citrus
|
||||
# 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:
|
||||
|
@ -41,4 +42,4 @@ Then, reference the default theme (or, the night theme) from your `App.xaml` fil
|
|||
</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.Markup.Xaml;
|
||||
|
||||
namespace Citrus
|
||||
namespace Avalonia.Citrus.Sandbox
|
||||
{
|
||||
public class App : Application
|
||||
{
|
|
@ -1,8 +1,8 @@
|
|||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Background="{DynamicResource ThemeBackgroundColor}"
|
||||
Width="920" Height="630"
|
||||
x:Class="Citrus.MainWindow">
|
||||
x:Class="Avalonia.Citrus.Sandbox.MainWindow"
|
||||
Width="920" Height="630">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
|
@ -2,7 +2,7 @@ using Avalonia.Markup.Xaml;
|
|||
using Avalonia.ReactiveUI;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Citrus
|
||||
namespace Avalonia.Citrus.Sandbox
|
||||
{
|
||||
public class MainWindow : ReactiveWindow<MainWindowViewModel>
|
||||
{
|
|
@ -7,7 +7,7 @@ using ReactiveUI.Fody.Helpers;
|
|||
using ReactiveUI.Validation.Extensions;
|
||||
using ReactiveUI.Validation.Helpers;
|
||||
|
||||
namespace Citrus
|
||||
namespace Avalonia.Citrus.Sandbox
|
||||
{
|
||||
public sealed class MainWindowViewModel : ReactiveValidationObject<MainWindowViewModel>
|
||||
{
|
||||
|
@ -24,8 +24,13 @@ namespace Citrus
|
|||
{
|
||||
_window = window;
|
||||
_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);
|
||||
|
||||
// This is ReactiveUI.Validation magic, that supports
|
||||
// INotifyDataErrorInfo <TextBox /> error messages.
|
||||
this.ValidationRule(x => x.Message,
|
||||
message => !string.IsNullOrWhiteSpace(message),
|
||||
"This text is not happy to be empty!");
|
||||
|
@ -38,6 +43,9 @@ namespace Citrus
|
|||
|
||||
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)
|
||||
{
|
||||
case Theme.Light:
|
||||
|
@ -57,7 +65,7 @@ namespace Citrus
|
|||
|
||||
private static StyleInclude CreateStyle(string url) =>
|
||||
new StyleInclude(
|
||||
new Uri("resm:Styles?assembly=Citrus"))
|
||||
new Uri("resm:Styles?assembly=Avalonia.Citrus.Sandbox"))
|
||||
{Source = new Uri(url)};
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Dialogs;
|
||||
using Avalonia.Dialogs;
|
||||
using Avalonia.ReactiveUI;
|
||||
|
||||
namespace Citrus
|
||||
namespace Avalonia.Citrus.Sandbox
|
||||
{
|
||||
public static class Program
|
||||
{
|
|
@ -5,18 +5,10 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="**\*.xaml.cs">
|
||||
<!--<Compile Update="**\*.xaml.cs">
|
||||
<DependentUpon>%(Filename)</DependentUpon>
|
||||
</Compile>
|
||||
<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>
|
||||
</Compile>-->
|
||||
<AvaloniaResource Include="**\*.xaml" />
|
||||
</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
|
||||
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
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Citrus", "Avalonia.Citrus\Avalonia.Citrus.csproj", "{D02EB1E5-0D24-4139-BCCB-C62B13536D82}"
|
||||
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>
|
Загрузка…
Ссылка в новой задаче