From 98974af13e7e08662c32b4744e6df9f89490d97c Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 21 Oct 2020 14:44:24 +0200 Subject: [PATCH] Added cursor page to control catalog. --- samples/ControlCatalog/Assets/avalonia-32.png | Bin 0 -> 1322 bytes samples/ControlCatalog/MainView.xaml | 4 ++ samples/ControlCatalog/Pages/CursorPage.xaml | 29 ++++++++++++ .../ControlCatalog/Pages/CursorPage.xaml.cs | 20 +++++++++ .../ViewModels/CursorPageViewModel.cs | 42 ++++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 samples/ControlCatalog/Assets/avalonia-32.png create mode 100644 samples/ControlCatalog/Pages/CursorPage.xaml create mode 100644 samples/ControlCatalog/Pages/CursorPage.xaml.cs create mode 100644 samples/ControlCatalog/ViewModels/CursorPageViewModel.cs diff --git a/samples/ControlCatalog/Assets/avalonia-32.png b/samples/ControlCatalog/Assets/avalonia-32.png new file mode 100644 index 0000000000000000000000000000000000000000..7b443e7a250846dc898e6467cddeed8c55880766 GIT binary patch literal 1322 zcmV+_1=aeAP)A zL5V<&1`?F`W{`LZcsE5cBpMzF4;mv6L;;~9STsnu#G;m4u_XwFBGRT;C>`6GUgn(T zL)$4c=S({l;{UQ|_FDV=|6Y6Tb=DCggsQrL1;9dJ29OIR^qV_@TA&g*4xAK`-bkN4 z9C5m;mZ)ljMvf*`-Kwf%?}yk>)mK&3GXmmJbg1eZ{m~l{d7`S8-Uo3gep1zxNXaLv zYSjZIAHbigniI+=A>>IwIZ!Z^$o9rgT58+rX!W5AiD_}9PaZ`|X5w)By8#r7NUKeN zsv5v|z%r+mmfzx!BR9Bs_y#St?T$}Rn>32TB~y5G>114PBbTZ98d$;Vp#KA9s55xh1snb zVql0XA`$Lr7fUu3F?C*+li3I4iAdc*oHjU-H`Lr_?|aAS_Vr+?iKSLxRCGuI{vMMb zK0ZUk2-=%=h?IY zi`~EzPRh&oS7NDYn_skkCi9*z44TU>OeecAopT4SaeU`R+nUNljsgG{8T7qa0_gPk zXlwS6nU~go-h*d9ZQcYM`MsF6BA5Jy*|vF4lb7b}cb%5ZFn}oo|JrZ=!;Uw1vwh<( zW-ZO<@uv%dM9f`1WPJjlXysJL`Q~em0&)x>8Nl1o#aATvT{Op4xk1SOI5BuQ<-fC&z>p5V$uYLPByp$*GA{ zp16$P^aoYHvq!3^ID9EAdG)bc&K+_VkT53JX<7~XdN>>AE`KbD+)@+MviN388T+;# zrTOMyiM?Id&f(9>`L^T)rsa?TLqJqD7H9y1I+mWUUfx>%DV|nu*isxDAA`$q)9W*X zY)MfmgjVRHRe3B}Z@b2pAtGJC?odl~Y!ok+tVCScA~7&_dAsp-`bPYsx)%e5ejCso zYRoU1!kTxMgP~zX432}pM*;&tL~atM8JV+eCL4CFC1G@I#3CZ87oiaV_z*bhHmSh z$FX-7ktX^Yl}~^N^O5O{ABXi&)f`p*LRC8-@RyQDRdXYjs;Wt<`dq)5v#Q$iA4n}# g?NZe;Rhb%7 literal 0 HcmV?d00001 diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml index bd5beafe29..34ff4b1a54 100644 --- a/samples/ControlCatalog/MainView.xaml +++ b/samples/ControlCatalog/MainView.xaml @@ -22,6 +22,10 @@ + + + diff --git a/samples/ControlCatalog/Pages/CursorPage.xaml b/samples/ControlCatalog/Pages/CursorPage.xaml new file mode 100644 index 0000000000..a28039ea3f --- /dev/null +++ b/samples/ControlCatalog/Pages/CursorPage.xaml @@ -0,0 +1,29 @@ + + + + Cursor + Defines a cursor (mouse pointer) + + + + + + + + + + + + + + + + + + diff --git a/samples/ControlCatalog/Pages/CursorPage.xaml.cs b/samples/ControlCatalog/Pages/CursorPage.xaml.cs new file mode 100644 index 0000000000..9e9e9ba8b9 --- /dev/null +++ b/samples/ControlCatalog/Pages/CursorPage.xaml.cs @@ -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); + } + } +} diff --git a/samples/ControlCatalog/ViewModels/CursorPageViewModel.cs b/samples/ControlCatalog/ViewModels/CursorPageViewModel.cs new file mode 100644 index 0000000000..a4c643dd04 --- /dev/null +++ b/samples/ControlCatalog/ViewModels/CursorPageViewModel.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Avalonia; +using Avalonia.Input; +using Avalonia.Media.Imaging; +using Avalonia.Platform; +using ReactiveUI; + +namespace ControlCatalog.ViewModels +{ + public class CursorPageViewModel : ReactiveObject + { + public CursorPageViewModel() + { + StandardCursors = Enum.GetValues(typeof(StandardCursorType)) + .Cast() + .Select(x => new StandardCursorModel(x)) + .ToList(); + + var loader = AvaloniaLocator.Current.GetService(); + 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 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; } + } + } +}