committed by
GitHub
152 changed files with 5579 additions and 826 deletions
@ -1,6 +1,7 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<DefaultTestTimeout>1000</DefaultTestTimeout> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,9 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoredTests> |
|||
<NamedTestSelector> |
|||
<TestName>Avalonia.Markup.UnitTests.Data.Plugins.DataAnnotationsValidationPluginTests.Produces_Aggregate_BindingNotificationsx</TestName> |
|||
</NamedTestSelector> |
|||
</IgnoredTests> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -1,6 +1,7 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<DefaultTestTimeout>1000</DefaultTestTimeout> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="MonoMac.NetStandard" Version="0.0.3" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="reactiveui" Version="8.0.0-alpha0073" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -1,11 +1,10 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="System.Reactive" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Core" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Interfaces" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.Linq" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.0.0" /> |
|||
<PackageReference Condition="'$(TargetFramework)' == 'net45'" Include="System.Reactive.Windows.Threading" Version="3.0.0" /> |
|||
<PackageReference Condition="'$(TargetFramework)' == 'net461'" Include="System.Reactive.Windows.Threading" Version="3.0.0" /> |
|||
<PackageReference Include="System.Reactive" Version="3.1.1" /> |
|||
<PackageReference Include="System.Reactive.Core" Version="3.1.1" /> |
|||
<PackageReference Include="System.Reactive.Interfaces" Version="3.1.1" /> |
|||
<PackageReference Include="System.Reactive.Linq" Version="3.1.1" /> |
|||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.1.1" /> |
|||
<PackageReference Condition="$(TargetFramework.StartsWith('net4'))" Include="System.Reactive.Windows.Threading" Version="3.1.1" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -0,0 +1,33 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" MinWidth="500" MinHeight="300" |
|||
Title="Avalonia Control Gallery" |
|||
Icon="resm:ControlCatalog.Assets.test_icon.ico?assembly=ControlCatalog" |
|||
xmlns:local="clr-namespace:ControlCatalog;assembly=ControlCatalog" HasSystemDecorations="False"> |
|||
<Grid RowDefinitions="5,*,5" ColumnDefinitions="5,*,5"> |
|||
<DockPanel Grid.Column="1" Grid.Row="1" > |
|||
<Grid Name="TitleBar" Background="LightBlue" DockPanel.Dock="Top" ColumnDefinitions="Auto,*,Auto"> |
|||
<TextBlock VerticalAlignment="Center" Margin="5,0,0,0">Title</TextBlock> |
|||
<StackPanel Grid.Column="2" Orientation="Horizontal"> |
|||
<StackPanel.Styles> |
|||
<Style Selector="Button"> |
|||
<Setter Property="Margin" Value="2"/> |
|||
</Style> |
|||
</StackPanel.Styles> |
|||
<Button Name="MinimizeButton">_</Button> |
|||
<Button Name="MaximizeButton">[ ]</Button> |
|||
<Button Name="CloseButton">X</Button> |
|||
</StackPanel> |
|||
</Grid> |
|||
<Border Background="White" Margin="5"> |
|||
<TextBlock>Hello world!</TextBlock> |
|||
</Border> |
|||
</DockPanel> |
|||
<Border Name="TopLeft" Background="Red"/> |
|||
<Border Name="TopRight" Background="Red" Grid.Column="2" /> |
|||
<Border Name="BottomLeft" Background="Red" Grid.Row="2" /> |
|||
<Border Name="BottomRight" Background="Red" Grid.Row="2" Grid.Column="2"/> |
|||
<Border Name="Top" Background="Blue" Grid.Column="1" /> |
|||
<Border Name="Right" Background="Blue" Grid.Row="1" Grid.Column="2" /> |
|||
<Border Name="Bottom" Background="Blue" Grid.Row="2" Grid.Column="1" /> |
|||
<Border Name="Left" Background="Blue" Grid.Row="1" /> |
|||
</Grid> |
|||
</Window> |
|||
@ -0,0 +1,53 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
using System; |
|||
using Avalonia.Input; |
|||
|
|||
namespace ControlCatalog |
|||
{ |
|||
public class DecoratedWindow : Window |
|||
{ |
|||
public DecoratedWindow() |
|||
{ |
|||
this.InitializeComponent(); |
|||
this.AttachDevTools(); |
|||
} |
|||
|
|||
void SetupSide(string name, StandardCursorType cursor, WindowEdge edge) |
|||
{ |
|||
var ctl = this.FindControl<Control>(name); |
|||
ctl.Cursor = new Cursor(cursor); |
|||
ctl.PointerPressed += delegate |
|||
{ |
|||
PlatformImpl.BeginResizeDrag(edge); |
|||
}; |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
this.FindControl<Control>("TitleBar").PointerPressed += delegate |
|||
{ |
|||
PlatformImpl.BeginMoveDrag(); |
|||
}; |
|||
SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West); |
|||
SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East); |
|||
SetupSide("Top", StandardCursorType.TopSide, WindowEdge.North); |
|||
SetupSide("Bottom", StandardCursorType.BottomSize, WindowEdge.South); |
|||
SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest); |
|||
SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast); |
|||
SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest); |
|||
SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast); |
|||
this.FindControl<Button>("MinimizeButton").Click += delegate { this.WindowState = WindowState.Minimized; }; |
|||
this.FindControl<Button>("MaximizeButton").Click += delegate |
|||
{ |
|||
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; |
|||
}; |
|||
this.FindControl<Button>("CloseButton").Click += delegate |
|||
{ |
|||
Close(); |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui"> |
|||
<StackPanel Orientation="Vertical" Gap="4" Margin="4"> |
|||
<Button Name="OpenFile">Open File</Button> |
|||
<Button Name="SaveFile">Save File</Button> |
|||
<Button Name="SelectFolder">Select Folder</Button> |
|||
<StackPanel Orientation="Horizontal"> |
|||
<CheckBox Name="IsModal" IsChecked="True"/> |
|||
<TextBlock>Modal to window</TextBlock> |
|||
</StackPanel> |
|||
<Button Name="DecoratedWindow">Decorated window</Button> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,46 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
#pragma warning disable 4014
|
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class DialogsPage : UserControl |
|||
{ |
|||
public DialogsPage() |
|||
{ |
|||
this.InitializeComponent(); |
|||
this.FindControl<Button>("OpenFile").Click += delegate |
|||
{ |
|||
new OpenFileDialog() |
|||
{ |
|||
Title = "Open file" |
|||
}.ShowAsync(GetWindow()); |
|||
}; |
|||
this.FindControl<Button>("SaveFile").Click += delegate |
|||
{ |
|||
new SaveFileDialog() |
|||
{ |
|||
Title = "Save file" |
|||
}.ShowAsync(GetWindow()); |
|||
}; |
|||
this.FindControl<Button>("SelectFolder").Click += delegate |
|||
{ |
|||
new OpenFolderDialog() |
|||
{ |
|||
Title = "Select folder" |
|||
}.ShowAsync(GetWindow()); |
|||
}; |
|||
this.FindControl<Button>("DecoratedWindow").Click += delegate |
|||
{ |
|||
new DecoratedWindow().Show(); |
|||
}; |
|||
} |
|||
|
|||
Window GetWindow() => this.FindControl<CheckBox>("IsModal").IsChecked ? (Window)this.VisualRoot : null; |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,82 @@ |
|||
using System; |
|||
using Avalonia.Input; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
public class RepeatButton : Button |
|||
{ |
|||
/// <summary>
|
|||
/// Defines the <see cref="Delay"/> property.
|
|||
/// </summary>
|
|||
public static readonly StyledProperty<int> DelayProperty = |
|||
AvaloniaProperty.Register<Button, int>(nameof(Delay), 100); |
|||
|
|||
private DispatcherTimer _repeatTimer; |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the amount of time, in milliseconds, of repeating clicks.
|
|||
/// </summary>
|
|||
public int Delay |
|||
{ |
|||
get { return GetValue(DelayProperty); } |
|||
set { SetValue(DelayProperty, value); } |
|||
} |
|||
|
|||
private void StartTimer() |
|||
{ |
|||
if (_repeatTimer == null) |
|||
{ |
|||
_repeatTimer = new DispatcherTimer(); |
|||
_repeatTimer.Tick += (o, e) => OnClick(); |
|||
} |
|||
|
|||
if (_repeatTimer.IsEnabled) return; |
|||
|
|||
_repeatTimer.Interval = TimeSpan.FromMilliseconds(Delay); |
|||
_repeatTimer.Start(); |
|||
} |
|||
|
|||
private void StopTimer() |
|||
{ |
|||
_repeatTimer?.Stop(); |
|||
} |
|||
|
|||
protected override void OnKeyDown(KeyEventArgs e) |
|||
{ |
|||
base.OnKeyDown(e); |
|||
|
|||
if (e.Key == Key.Space) |
|||
{ |
|||
StartTimer(); |
|||
} |
|||
} |
|||
|
|||
protected override void OnKeyUp(KeyEventArgs e) |
|||
{ |
|||
base.OnKeyUp(e); |
|||
|
|||
StopTimer(); |
|||
} |
|||
|
|||
protected override void OnPointerPressed(PointerPressedEventArgs e) |
|||
{ |
|||
base.OnPointerPressed(e); |
|||
|
|||
if (e.MouseButton == MouseButton.Left) |
|||
{ |
|||
StartTimer(); |
|||
} |
|||
} |
|||
|
|||
protected override void OnPointerReleased(PointerReleasedEventArgs e) |
|||
{ |
|||
base.OnPointerReleased(e); |
|||
|
|||
if (e.MouseButton == MouseButton.Left) |
|||
{ |
|||
StopTimer(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Avalonia.Controls; |
|||
using Avalonia.Threading; |
|||
using ReactiveUI; |
|||
using System; |
|||
using System.Reactive.Concurrency; |
|||
using System.Threading; |
|||
|
|||
namespace Avalonia |
|||
{ |
|||
public static class AppBuilderExtensions |
|||
{ |
|||
public static TAppBuilder UseReactiveUI<TAppBuilder>(this TAppBuilder builder) |
|||
where TAppBuilder : AppBuilderBase<TAppBuilder>, new() |
|||
{ |
|||
return builder.AfterSetup(_ => |
|||
{ |
|||
RxApp.MainThreadScheduler = AvaloniaScheduler.Instance; |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Reactive.Concurrency; |
|||
using System.Threading; |
|||
|
|||
|
|||
namespace ReactiveUI |
|||
{ |
|||
/// <summary>
|
|||
/// Ignore me. This class is a secret handshake between RxUI and RxUI.Xaml
|
|||
/// in order to register certain classes on startup that would be difficult
|
|||
/// to register otherwise.
|
|||
/// </summary>
|
|||
public class PlatformRegistrations : IWantsToRegisterStuff |
|||
{ |
|||
public void Register(Action<Func<object>, Type> registerFunction) |
|||
{ |
|||
RxApp.MainThreadScheduler = new SynchronizationContextScheduler(SynchronizationContext.Current); |
|||
} |
|||
} |
|||
} |
|||
@ -1,34 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace System.Runtime.Serialization |
|||
{ |
|||
class IgnoreDataMemberAttribute : Attribute |
|||
{ |
|||
} |
|||
|
|||
class DataMemberAttribute : Attribute |
|||
{ |
|||
} |
|||
class OnDeserializedAttribute : Attribute |
|||
{ |
|||
} |
|||
|
|||
class DataContractAttribute : Attribute |
|||
{ |
|||
} |
|||
|
|||
class StreamingContext { } |
|||
} |
|||
|
|||
namespace System.Diagnostics.Contracts |
|||
{ |
|||
static class Contract |
|||
{ |
|||
public static void Requires(bool condition) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1 +0,0 @@ |
|||
Subproject commit 3f725c808b1d4c8457f0d3204e0a071aa462cd75 |
|||
@ -0,0 +1,19 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// An indexed dictionary of resources.
|
|||
/// </summary>
|
|||
public interface IResourceDictionary : IResourceProvider, IDictionary<object, object> |
|||
{ |
|||
/// <summary>
|
|||
/// Gets a collection of child resource dictionaries.
|
|||
/// </summary>
|
|||
IList<IResourceProvider> MergedDictionaries { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Represents resource provider in a tree.
|
|||
/// </summary>
|
|||
public interface IResourceNode : IResourceProvider |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the parent resource node, if any.
|
|||
/// </summary>
|
|||
IResourceNode ResourceParent { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Represents an object that can be queried for resources.
|
|||
/// </summary>
|
|||
public interface IResourceProvider |
|||
{ |
|||
/// <summary>
|
|||
/// Raised when resources in the provider are changed.
|
|||
/// </summary>
|
|||
event EventHandler<ResourcesChangedEventArgs> ResourcesChanged; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value indicating whether the element has resources.
|
|||
/// </summary>
|
|||
bool HasResources { get; } |
|||
|
|||
/// <summary>
|
|||
/// Tries to find a resource within the provider.
|
|||
/// </summary>
|
|||
/// <param name="key">The resource key.</param>
|
|||
/// <param name="value">
|
|||
/// When this method returns, contains the value associated with the specified key,
|
|||
/// if the key is found; otherwise, null.
|
|||
/// </param>
|
|||
/// <returns>
|
|||
/// True if the resource if found, otherwise false.
|
|||
/// </returns>
|
|||
bool TryGetResource(string key, out object value); |
|||
} |
|||
} |
|||
@ -0,0 +1,101 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Collections.Specialized; |
|||
using System.Linq; |
|||
using Avalonia.Collections; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// An indexed dictionary of resources.
|
|||
/// </summary>
|
|||
public class ResourceDictionary : AvaloniaDictionary<object, object>, IResourceDictionary |
|||
{ |
|||
private AvaloniaList<IResourceProvider> _mergedDictionaries; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="ResourceDictionary"/> class.
|
|||
/// </summary>
|
|||
public ResourceDictionary() |
|||
{ |
|||
CollectionChanged += OnCollectionChanged; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public event EventHandler<ResourcesChangedEventArgs> ResourcesChanged; |
|||
|
|||
/// <inheritdoc/>
|
|||
public IList<IResourceProvider> MergedDictionaries |
|||
{ |
|||
get |
|||
{ |
|||
if (_mergedDictionaries == null) |
|||
{ |
|||
_mergedDictionaries = new AvaloniaList<IResourceProvider>(); |
|||
_mergedDictionaries.ResetBehavior = ResetBehavior.Remove; |
|||
_mergedDictionaries.ForEachItem( |
|||
x => |
|||
{ |
|||
if (x.HasResources) |
|||
{ |
|||
OnResourcesChanged(); |
|||
} |
|||
|
|||
x.ResourcesChanged += MergedDictionaryResourcesChanged; |
|||
}, |
|||
x => |
|||
{ |
|||
if (x.HasResources) |
|||
{ |
|||
OnResourcesChanged(); |
|||
} |
|||
|
|||
x.ResourcesChanged -= MergedDictionaryResourcesChanged; |
|||
}, |
|||
() => { }); |
|||
} |
|||
|
|||
return _mergedDictionaries; |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
bool IResourceProvider.HasResources |
|||
{ |
|||
get => Count > 0 || (_mergedDictionaries?.Any(x => x.HasResources) ?? false); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public bool TryGetResource(string key, out object value) |
|||
{ |
|||
if (TryGetValue(key, out value)) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
if (_mergedDictionaries != null) |
|||
{ |
|||
for (var i = _mergedDictionaries.Count - 1; i >= 0; --i) |
|||
{ |
|||
if (_mergedDictionaries[i].TryGetResource(key, out value)) |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
private void OnResourcesChanged() |
|||
{ |
|||
ResourcesChanged?.Invoke(this, new ResourcesChangedEventArgs()); |
|||
} |
|||
|
|||
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) => OnResourcesChanged(); |
|||
private void MergedDictionaryResourcesChanged(object sender, ResourcesChangedEventArgs e) => OnResourcesChanged(); |
|||
} |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
using System; |
|||
using System.Reactive; |
|||
using System.Reactive.Linq; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
public static class ResourceProviderExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// Finds the specified resource by searching up the logical tree and then global styles.
|
|||
/// </summary>
|
|||
/// <param name="control">The control.</param>
|
|||
/// <param name="key">The resource key.</param>
|
|||
/// <returns>The resource, or <see cref="AvaloniaProperty.UnsetValue"/> if not found.</returns>
|
|||
public static object FindResource(this IResourceNode control, string key) |
|||
{ |
|||
if (control.TryFindResource(key, out var value)) |
|||
{ |
|||
return value; |
|||
} |
|||
|
|||
return AvaloniaProperty.UnsetValue; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Tries to the specified resource by searching up the logical tree and then global styles.
|
|||
/// </summary>
|
|||
/// <param name="control">The control.</param>
|
|||
/// <param name="key">The resource key.</param>
|
|||
/// <param name="value">On return, contains the resource if found, otherwise null.</param>
|
|||
/// <returns>True if the resource was found; otherwise false.</returns>
|
|||
public static bool TryFindResource(this IResourceNode control, string key, out object value) |
|||
{ |
|||
Contract.Requires<ArgumentNullException>(control != null); |
|||
Contract.Requires<ArgumentNullException>(key != null); |
|||
|
|||
var current = control; |
|||
|
|||
while (current != null) |
|||
{ |
|||
if (current is IResourceNode host) |
|||
{ |
|||
if (host.TryGetResource(key, out value)) |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
|
|||
current = current.ResourceParent; |
|||
} |
|||
|
|||
value = null; |
|||
return false; |
|||
} |
|||
|
|||
public static IObservable<object> GetResourceObservable(this IResourceNode target, string key) |
|||
{ |
|||
return Observable.FromEventPattern<ResourcesChangedEventArgs>( |
|||
x => target.ResourcesChanged += x, |
|||
x => target.ResourcesChanged -= x) |
|||
.StartWith((EventPattern<ResourcesChangedEventArgs>)null) |
|||
.Select(x => target.FindResource(key)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
public class ResourcesChangedEventArgs : EventArgs |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Avalonia.Controls; |
|||
|
|||
namespace Avalonia.Styling |
|||
{ |
|||
/// <summary>
|
|||
/// Defines an interface through which a <see cref="Style"/>'s parent can be set.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// You should not usually need to use this interface - it is for internal use only.
|
|||
/// </remarks>
|
|||
public interface ISetStyleParent : IStyle |
|||
{ |
|||
/// <summary>
|
|||
/// Sets the style parent.
|
|||
/// </summary>
|
|||
/// <param name="parent">The parent.</param>
|
|||
void SetParent(IResourceNode parent); |
|||
|
|||
/// <summary>
|
|||
/// Notifies the style that a change has been made to resources that apply to it.
|
|||
/// </summary>
|
|||
/// <param name="e">The event args.</param>
|
|||
/// <remarks>
|
|||
/// This method will be called automatically by the framework, you should not need to call
|
|||
/// this method yourself.
|
|||
/// </remarks>
|
|||
void NotifyResourcesChanged(ResourcesChangedEventArgs e); |
|||
} |
|||
} |
|||
@ -1,42 +0,0 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Styling |
|||
{ |
|||
public static class StyleExtensions |
|||
{ |
|||
/// <summary>
|
|||
/// Tries to find a named style resource.
|
|||
/// </summary>
|
|||
/// <param name="control">The control from which to find the resource.</param>
|
|||
/// <param name="name">The resource name.</param>
|
|||
/// <returns>
|
|||
/// The resource if found, otherwise <see cref="AvaloniaProperty.UnsetValue"/>.
|
|||
/// </returns>
|
|||
public static object FindStyleResource(this IStyleHost control, string name) |
|||
{ |
|||
Contract.Requires<ArgumentNullException>(control != null); |
|||
Contract.Requires<ArgumentNullException>(name != null); |
|||
Contract.Requires<ArgumentException>(!string.IsNullOrWhiteSpace(name)); |
|||
|
|||
while (control != null) |
|||
{ |
|||
if (control.IsStylesInitialized) |
|||
{ |
|||
var result = control.Styles.FindResource(name); |
|||
|
|||
if (result != AvaloniaProperty.UnsetValue) |
|||
{ |
|||
return result; |
|||
} |
|||
} |
|||
|
|||
control = control.StylingParent; |
|||
} |
|||
|
|||
return AvaloniaProperty.UnsetValue; |
|||
} |
|||
} |
|||
} |
|||
@ -1,90 +0,0 @@ |
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Avalonia.Styling |
|||
{ |
|||
/// <summary>
|
|||
/// Holds resources for a <see cref="Style"/>.
|
|||
/// </summary>
|
|||
public class StyleResources : IDictionary<string, object>, IDictionary |
|||
{ |
|||
private Dictionary<string, object> _inner = new Dictionary<string, object>(); |
|||
|
|||
public object this[string key] |
|||
{ |
|||
get { return _inner[key]; } |
|||
set { _inner[key] = value; } |
|||
} |
|||
|
|||
public int Count => _inner.Count; |
|||
|
|||
ICollection<string> IDictionary<string, object>.Keys => _inner.Keys; |
|||
|
|||
ICollection<object> IDictionary<string, object>.Values => _inner.Values; |
|||
|
|||
bool ICollection<KeyValuePair<string, object>>.IsReadOnly => false; |
|||
|
|||
object IDictionary.this[object key] |
|||
{ |
|||
get { return ((IDictionary)_inner)[key]; } |
|||
set { ((IDictionary)_inner)[key] = value; } |
|||
} |
|||
|
|||
ICollection IDictionary.Keys => _inner.Keys; |
|||
|
|||
ICollection IDictionary.Values => _inner.Values; |
|||
|
|||
bool ICollection.IsSynchronized => false; |
|||
|
|||
object ICollection.SyncRoot => ((IDictionary)_inner).SyncRoot; |
|||
|
|||
bool IDictionary.IsFixedSize => false; |
|||
|
|||
bool IDictionary.IsReadOnly => false; |
|||
|
|||
public void Add(string key, object value) => _inner.Add(key, value); |
|||
|
|||
public void Clear() => _inner.Clear(); |
|||
|
|||
public bool ContainsKey(string key) => _inner.ContainsKey(key); |
|||
|
|||
public bool Remove(string key) => _inner.Remove(key); |
|||
|
|||
public IEnumerator<KeyValuePair<string, object>> GetEnumerator() => _inner.GetEnumerator(); |
|||
|
|||
public bool TryGetValue(string key, out object value) => _inner.TryGetValue(key, out value); |
|||
|
|||
bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item) |
|||
{ |
|||
return ((IDictionary<string, object>)_inner).Contains(item); |
|||
} |
|||
|
|||
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item) |
|||
{ |
|||
((IDictionary<string, object>)_inner).Add(item); |
|||
} |
|||
|
|||
void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] array, int arrayIndex) |
|||
{ |
|||
((IDictionary<string, object>)_inner).CopyTo(array, arrayIndex); |
|||
} |
|||
|
|||
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item) |
|||
{ |
|||
return ((IDictionary<string, object>)_inner).Remove(item); |
|||
} |
|||
|
|||
void ICollection.CopyTo(Array array, int index) => ((IDictionary)_inner).CopyTo(array, index); |
|||
|
|||
IEnumerator IEnumerable.GetEnumerator() => _inner.GetEnumerator(); |
|||
|
|||
IDictionaryEnumerator IDictionary.GetEnumerator() => ((IDictionary)_inner).GetEnumerator(); |
|||
|
|||
void IDictionary.Add(object key, object value) => ((IDictionary)_inner).Add(key, value); |
|||
|
|||
bool IDictionary.Contains(object key) => ((IDictionary)_inner).Contains(key); |
|||
|
|||
void IDictionary.Remove(object key) => ((IDictionary)_inner).Remove(key); |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui"> |
|||
<Style Selector="RepeatButton"> |
|||
<Setter Property="Background" |
|||
Value="{StyleResource ThemeControlMidBrush}" /> |
|||
<Setter Property="BorderBrush" |
|||
Value="{StyleResource ThemeBorderLightBrush}" /> |
|||
<Setter Property="BorderThickness" |
|||
Value="{StyleResource ThemeBorderThickness}" /> |
|||
<Setter Property="Foreground" |
|||
Value="{StyleResource ThemeForegroundBrush}" /> |
|||
<Setter Property="HorizontalContentAlignment" |
|||
Value="Center" /> |
|||
<Setter Property="VerticalContentAlignment" |
|||
Value="Center" /> |
|||
<Setter Property="Padding" |
|||
Value="4" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Padding="{TemplateBinding Padding}" |
|||
TextBlock.Foreground="{TemplateBinding Foreground}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="RepeatButton:pointerover /template/ ContentPresenter"> |
|||
<Setter Property="BorderBrush" |
|||
Value="{StyleResource ThemeBorderMidBrush}" /> |
|||
</Style> |
|||
<Style Selector="RepeatButton:pressed /template/ ContentPresenter"> |
|||
<Setter Property="Background" |
|||
Value="{StyleResource ThemeControlDarkBrush}" /> |
|||
</Style> |
|||
<Style Selector="RepeatButton:disabled"> |
|||
<Setter Property="Opacity" |
|||
Value="{StyleResource ThemeDisabledOpacity}" /> |
|||
</Style> |
|||
</Styles> |
|||
@ -1,35 +1,127 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui"> |
|||
<Style Selector="ScrollBar"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{StyleResource ThemeControlMidBrush}"> |
|||
<Track Minimum="{TemplateBinding Minimum}" |
|||
Maximum="{TemplateBinding Maximum}" |
|||
Value="{TemplateBinding Path=Value, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding ViewportSize}" |
|||
Orientation="{TemplateBinding Orientation}"> |
|||
<Thumb Name="thumb"> |
|||
<Thumb.Template> |
|||
<ControlTemplate> |
|||
<Border Background="{StyleResource ThemeControlDarkBrush}"/> |
|||
</ControlTemplate> |
|||
</Thumb.Template> |
|||
</Thumb> |
|||
</Track> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ScrollBar:horizontal"> |
|||
<Setter Property="Height" Value="10"/> |
|||
</Style> |
|||
<Style Selector="ScrollBar:horizontal /template/ Thumb#thumb"> |
|||
<Setter Property="MinWidth" Value="10"/> |
|||
</Style> |
|||
<Style Selector="ScrollBar:vertical"> |
|||
<Setter Property="Width" Value="10"/> |
|||
</Style> |
|||
<Style Selector="ScrollBar:vertical /template/ Thumb#thumb"> |
|||
<Setter Property="MinHeight" Value="10"/> |
|||
</Style> |
|||
<Style Selector="ScrollBar"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{DynamicResource ThemeControlMidBrush}"> |
|||
<Grid RowDefinitions="10,*,10"> |
|||
<RepeatButton Name="PART_LineUpButton" |
|||
Classes="repeat" |
|||
Grid.Row="0" |
|||
Grid.Column="0"> |
|||
<Path Data="M 0,4 C0,4 0,6 0,6 0,6 3.5,2.5 3.5,2.5 3.5,2.5 7,6 7,6 7,6 7,4 7,4 7,4 3.5,0.5 3.5,0.5 3.5,0.5 0,4 0,4 z" |
|||
Stretch="Uniform" |
|||
Fill="Gray" /> |
|||
</RepeatButton> |
|||
<Track Grid.Row="1" |
|||
Grid.Column="1" |
|||
Minimum="{TemplateBinding Minimum}" |
|||
Maximum="{TemplateBinding Maximum}" |
|||
Value="{TemplateBinding Path=Value, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding ViewportSize}" |
|||
Orientation="{TemplateBinding Orientation}"> |
|||
<Track.DecreaseButton> |
|||
<RepeatButton Name="PART_PageUpButton" |
|||
Classes="repeattrack" /> |
|||
</Track.DecreaseButton> |
|||
<Track.IncreaseButton> |
|||
<RepeatButton Name="PART_PageDownButton" |
|||
Classes="repeattrack" /> |
|||
</Track.IncreaseButton> |
|||
<Thumb Name="thumb"> |
|||
<Thumb.Template> |
|||
<ControlTemplate> |
|||
<Border Background="{DynamicResource ThemeControlDarkBrush}" /> |
|||
</ControlTemplate> |
|||
</Thumb.Template> |
|||
</Thumb> |
|||
</Track> |
|||
<RepeatButton Name="PART_LineDownButton" |
|||
Classes="repeat" |
|||
Grid.Row="2" |
|||
Grid.Column="2"> |
|||
<Path Data="M 0,2.5 C0,2.5 0,0.5 0,0.5 0,0.5 3.5,4 3.5,4 3.5,4 7,0.5 7,0.5 7,0.5 7,2.5 7,2.5 7,2.5 3.5,6 3.5,6 3.5,6 0,2.5 0,2.5 z" |
|||
Stretch="Uniform" |
|||
Fill="Gray" /> |
|||
</RepeatButton> |
|||
</Grid> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ScrollBar:horizontal"> |
|||
<Setter Property="Height" |
|||
Value="10" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{DynamicResource ThemeControlMidBrush}"> |
|||
<Grid ColumnDefinitions="10,*,10"> |
|||
<RepeatButton Name="PART_LineUpButton" |
|||
Classes="repeat" |
|||
Grid.Row="0" |
|||
Grid.Column="0"> |
|||
<Path Data="M 3.18,7 C3.18,7 5,7 5,7 5,7 1.81,3.5 1.81,3.5 1.81,3.5 5,0 5,0 5,0 3.18,0 3.18,0 3.18,0 0,3.5 0,3.5 0,3.5 3.18,7 3.18,7 z" |
|||
Stretch="Uniform" |
|||
Fill="Gray" /> |
|||
</RepeatButton> |
|||
<Track Grid.Row="1" |
|||
Grid.Column="1" |
|||
Minimum="{TemplateBinding Minimum}" |
|||
Maximum="{TemplateBinding Maximum}" |
|||
Value="{TemplateBinding Path=Value, Mode=TwoWay}" |
|||
ViewportSize="{TemplateBinding ViewportSize}" |
|||
Orientation="{TemplateBinding Orientation}"> |
|||
<Track.DecreaseButton> |
|||
<RepeatButton Name="PART_PageUpButton" |
|||
Classes="repeattrack" /> |
|||
</Track.DecreaseButton> |
|||
<Track.IncreaseButton> |
|||
<RepeatButton Name="PART_PageDownButton" |
|||
Classes="repeattrack" /> |
|||
</Track.IncreaseButton> |
|||
<Thumb Name="thumb"> |
|||
<Thumb.Template> |
|||
<ControlTemplate> |
|||
<Border Background="{DynamicResource ThemeControlDarkBrush}" /> |
|||
</ControlTemplate> |
|||
</Thumb.Template> |
|||
</Thumb> |
|||
</Track> |
|||
<RepeatButton Name="PART_LineDownButton" |
|||
Classes="repeat" |
|||
Grid.Row="2" |
|||
Grid.Column="2"> |
|||
<Path Data="M 1.81,7 C1.81,7 0,7 0,7 0,7 3.18,3.5 3.18,3.5 3.18,3.5 0,0 0,0 0,0 1.81,0 1.81,0 1.81,0 5,3.5 5,3.5 5,3.5 1.81,7 1.81,7 z" |
|||
Stretch="Uniform" |
|||
Fill="Gray" /> |
|||
</RepeatButton> |
|||
</Grid> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ScrollBar:horizontal /template/ Thumb#thumb"> |
|||
<Setter Property="MinWidth" |
|||
Value="10" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar:vertical"> |
|||
<Setter Property="Width" |
|||
Value="10" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar:vertical /template/ Thumb#thumb"> |
|||
<Setter Property="MinHeight" |
|||
Value="10" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ RepeatButton.repeat"> |
|||
<Setter Property="Padding" |
|||
Value="2" /> |
|||
<Setter Property="BorderThickness" |
|||
Value="0" /> |
|||
</Style> |
|||
<Style Selector="ScrollBar /template/ RepeatButton.repeattrack"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{TemplateBinding Background}" /> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
</Styles> |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue