committed by
GitHub
50 changed files with 500 additions and 112 deletions
|
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,29 @@ |
|||||
|
<UserControl xmlns="https://github.com/avaloniaui" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
x:Class="ControlCatalog.Pages.CursorPage"> |
||||
|
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,*"> |
||||
|
<StackPanel Grid.ColumnSpan="2" Orientation="Vertical" Spacing="4"> |
||||
|
<TextBlock Classes="h1">Cursor</TextBlock> |
||||
|
<TextBlock Classes="h2">Defines a cursor (mouse pointer)</TextBlock> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<ListBox Grid.Row="1" Items="{Binding StandardCursors}" Margin="0 8 8 8"> |
||||
|
<ListBox.Styles> |
||||
|
<Style Selector="ListBoxItem"> |
||||
|
<Setter Property="Cursor" Value="{Binding Cursor}"/> |
||||
|
</Style> |
||||
|
</ListBox.Styles> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<TextBlock Text="{Binding Type}"/> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
|
||||
|
<StackPanel Grid.Column="1" Grid.Row="1" Margin="8 8 0 8"> |
||||
|
<Button Cursor="{Binding CustomCursor}" Margin="0 8" Padding="16"> |
||||
|
<TextBlock>Custom Cursor</TextBlock> |
||||
|
</Button> |
||||
|
</StackPanel> |
||||
|
</Grid> |
||||
|
</UserControl> |
||||
@ -0,0 +1,20 @@ |
|||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
using ControlCatalog.ViewModels; |
||||
|
|
||||
|
namespace ControlCatalog.Pages |
||||
|
{ |
||||
|
public class CursorPage : UserControl |
||||
|
{ |
||||
|
public CursorPage() |
||||
|
{ |
||||
|
this.InitializeComponent(); |
||||
|
DataContext = new CursorPageViewModel(); |
||||
|
} |
||||
|
|
||||
|
private void InitializeComponent() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,44 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Avalonia; |
||||
|
using Avalonia.Input; |
||||
|
using Avalonia.Media.Imaging; |
||||
|
using Avalonia.Platform; |
||||
|
using MiniMvvm; |
||||
|
|
||||
|
namespace ControlCatalog.ViewModels |
||||
|
{ |
||||
|
public class CursorPageViewModel : ViewModelBase |
||||
|
{ |
||||
|
public CursorPageViewModel() |
||||
|
{ |
||||
|
StandardCursors = Enum.GetValues(typeof(StandardCursorType)) |
||||
|
.Cast<StandardCursorType>() |
||||
|
.Select(x => new StandardCursorModel(x)) |
||||
|
.ToList(); |
||||
|
|
||||
|
var loader = AvaloniaLocator.Current.GetService<IAssetLoader>(); |
||||
|
var s = loader.Open(new Uri("avares://ControlCatalog/Assets/avalonia-32.png")); |
||||
|
var bitmap = new Bitmap(s); |
||||
|
CustomCursor = new Cursor(bitmap, new PixelPoint(16, 16)); |
||||
|
} |
||||
|
|
||||
|
public IEnumerable<StandardCursorModel> StandardCursors { get; } |
||||
|
|
||||
|
public Cursor CustomCursor { get; } |
||||
|
|
||||
|
public class StandardCursorModel |
||||
|
{ |
||||
|
public StandardCursorModel(StandardCursorType type) |
||||
|
{ |
||||
|
Type = type; |
||||
|
Cursor = new Cursor(type); |
||||
|
} |
||||
|
|
||||
|
public StandardCursorType Type { get; } |
||||
|
|
||||
|
public Cursor Cursor { get; } |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,6 @@ |
|||||
|
Compat issues with assembly Avalonia.Controls: |
||||
|
MembersMustExist : Member 'public void Avalonia.Controls.Embedding.Offscreen.OffscreenTopLevelImplBase.SetCursor(Avalonia.Platform.IPlatformHandle)' does not exist in the implementation but it does exist in the contract. |
||||
|
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.Platform.ITopLevelImpl.SetCursor(Avalonia.Platform.ICursorImpl)' is present in the implementation but not in the contract. |
||||
|
InterfacesShouldHaveSameMembers : Interface member 'public void Avalonia.Platform.ITopLevelImpl.SetCursor(Avalonia.Platform.IPlatformHandle)' is present in the contract but not in the implementation. |
||||
|
MembersMustExist : Member 'public void Avalonia.Platform.ITopLevelImpl.SetCursor(Avalonia.Platform.IPlatformHandle)' does not exist in the implementation but it does exist in the contract. |
||||
|
Total Issues: 4 |
||||
@ -0,0 +1,4 @@ |
|||||
|
Compat issues with assembly Avalonia.Input: |
||||
|
MembersMustExist : Member 'public Avalonia.Platform.IPlatformHandle Avalonia.Input.Cursor.PlatformCursor.get()' does not exist in the implementation but it does exist in the contract. |
||||
|
TypesMustExist : Type 'Avalonia.Platform.IStandardCursorFactory' does not exist in the implementation but it does exist in the contract. |
||||
|
Total Issues: 2 |
||||
@ -0,0 +1,12 @@ |
|||||
|
using Avalonia.Input; |
||||
|
|
||||
|
#nullable enable |
||||
|
|
||||
|
namespace Avalonia.Platform |
||||
|
{ |
||||
|
public interface ICursorFactory |
||||
|
{ |
||||
|
ICursorImpl GetCursor(StandardCursorType cursorType); |
||||
|
ICursorImpl CreateCursor(IBitmapImpl cursor, PixelPoint hotSpot); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using System; |
||||
|
using Avalonia.Input; |
||||
|
|
||||
|
#nullable enable |
||||
|
|
||||
|
namespace Avalonia.Platform |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Represents a platform implementation of a <see cref="Cursor"/>.
|
||||
|
/// </summary>
|
||||
|
public interface ICursorImpl : IDisposable |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -1,9 +0,0 @@ |
|||||
using Avalonia.Input; |
|
||||
|
|
||||
namespace Avalonia.Platform |
|
||||
{ |
|
||||
public interface IStandardCursorFactory |
|
||||
{ |
|
||||
IPlatformHandle GetCursor(StandardCursorType cursorType); |
|
||||
} |
|
||||
} |
|
||||
@ -1,14 +1,25 @@ |
|||||
using System; |
|
||||
using Avalonia.Input; |
using Avalonia.Input; |
||||
using Avalonia.Platform; |
using Avalonia.Platform; |
||||
|
|
||||
namespace Avalonia.Controls.UnitTests |
namespace Avalonia.Controls.UnitTests |
||||
{ |
{ |
||||
public class CursorFactoryMock : IStandardCursorFactory |
public class CursorFactoryMock : ICursorFactory |
||||
{ |
{ |
||||
public IPlatformHandle GetCursor(StandardCursorType cursorType) |
public ICursorImpl GetCursor(StandardCursorType cursorType) |
||||
{ |
{ |
||||
return new PlatformHandle(IntPtr.Zero, cursorType.ToString()); |
return new MockCursorImpl(); |
||||
|
} |
||||
|
|
||||
|
public ICursorImpl CreateCursor(IBitmapImpl cursor, PixelPoint hotSpot) |
||||
|
{ |
||||
|
return new MockCursorImpl(); |
||||
|
} |
||||
|
|
||||
|
private class MockCursorImpl : ICursorImpl |
||||
|
{ |
||||
|
public void Dispose() |
||||
|
{ |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue