committed by
GitHub
1061 changed files with 25624 additions and 13136 deletions
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<InstrumentOutputAssembly>False</InstrumentOutputAssembly> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<InstrumentOutputAssembly>False</InstrumentOutputAssembly> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<InstrumentOutputAssembly>False</InstrumentOutputAssembly> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<InstrumentOutputAssembly>False</InstrumentOutputAssembly> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -1,7 +1,3 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<AdditionalFilesToIncludeForProject> |
|||
<Value>..\..\tools\MicroComGenerator\bin\Debug\net6.0\**.*</Value> |
|||
</AdditionalFilesToIncludeForProject> |
|||
</Settings> |
|||
<Settings /> |
|||
</ProjectConfiguration> |
|||
@ -1,7 +1,3 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<AdditionalFilesToIncludeForProject> |
|||
<Value>..\..\tools\MicroComGenerator\bin\Debug\net6.0\**.*</Value> |
|||
</AdditionalFilesToIncludeForProject> |
|||
</Settings> |
|||
<Settings /> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -1,8 +1,10 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' |
|||
x:Class="BindingDemo.TestItemView"> |
|||
xmlns:viewModels="using:BindingDemo.ViewModels" |
|||
x:Class="BindingDemo.TestItemView" |
|||
x:DataType="viewModels:TestItem"> |
|||
<StackPanel> |
|||
<TextBlock Classes="h1" Text="{Binding StringValue}"/> |
|||
<TextBox Text="{Binding Detail}" AcceptsReturn="True"/> |
|||
</StackPanel> |
|||
</UserControl> |
|||
</UserControl> |
|||
|
|||
@ -1,7 +1,7 @@ |
|||
using Avalonia; |
|||
using Avalonia.Web.Blazor; |
|||
using Avalonia.Browser.Blazor; |
|||
|
|||
namespace ControlCatalog.Blazor.Web; |
|||
namespace ControlCatalog.Browser.Blazor; |
|||
|
|||
public partial class App |
|||
{ |
|||
@ -1,5 +1,5 @@ |
|||
@page "/" |
|||
|
|||
@using Avalonia.Web.Blazor |
|||
@using Avalonia.Browser.Blazor |
|||
|
|||
<AvaloniaView /> |
|||
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
@ -1,11 +1,11 @@ |
|||
using System; |
|||
using System.Runtime.InteropServices.JavaScript; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Web; |
|||
using Avalonia.Browser; |
|||
|
|||
using ControlCatalog.Pages; |
|||
|
|||
namespace ControlCatalog.Web; |
|||
namespace ControlCatalog.Browser; |
|||
|
|||
public class EmbedSampleWeb : INativeDemoControl |
|||
{ |
|||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@ -1,8 +1,8 @@ |
|||
using System.Runtime.Versioning; |
|||
using Avalonia; |
|||
using Avalonia.Web; |
|||
using Avalonia.Browser; |
|||
using ControlCatalog; |
|||
using ControlCatalog.Web; |
|||
using ControlCatalog.Browser; |
|||
|
|||
[assembly:SupportedOSPlatform("browser")] |
|||
|
|||
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
@ -0,0 +1,11 @@ |
|||
{ |
|||
"profiles": { |
|||
"ControlCatalog.NetCore": { |
|||
"commandName": "Project" |
|||
}, |
|||
"Dxgi": { |
|||
"commandName": "Project", |
|||
"commandLineArgs": "--dxgi" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Globalization; |
|||
using System.Text; |
|||
using Avalonia.Data.Converters; |
|||
|
|||
namespace ControlCatalog.Converter |
|||
{ |
|||
public class DegToRadConverter : IValueConverter |
|||
{ |
|||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) |
|||
{ |
|||
if (value is double rad) |
|||
{ |
|||
return rad * 180.0d / Math.PI; |
|||
} |
|||
return 0.0d; |
|||
} |
|||
|
|||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) |
|||
{ |
|||
if (value is double deg) |
|||
{ |
|||
return deg / 180.0d * Math.PI; |
|||
} |
|||
return 0.0d; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
namespace ControlCatalog.Models; |
|||
|
|||
public class StateData |
|||
{ |
|||
public string Name { get; private set; } |
|||
public string Abbreviation { get; private set; } |
|||
public string Capital { get; private set; } |
|||
|
|||
public StateData(string name, string abbreviatoin, string capital) |
|||
{ |
|||
Name = name; |
|||
Abbreviation = abbreviatoin; |
|||
Capital = capital; |
|||
} |
|||
|
|||
public override string ToString() |
|||
{ |
|||
return Name; |
|||
} |
|||
} |
|||
@ -0,0 +1,107 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:local="using:ControlCatalog.Pages" |
|||
xmlns:converters="using:ControlCatalog.Converter" |
|||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
|||
x:Class="ControlCatalog.Pages.CustomDrawing"> |
|||
|
|||
<UserControl.Resources> |
|||
<converters:DegToRadConverter x:Key="DegToRadConverter"/> |
|||
</UserControl.Resources> |
|||
|
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition/> |
|||
<ColumnDefinition/> |
|||
<ColumnDefinition/> |
|||
</Grid.ColumnDefinitions> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="Auto"/> |
|||
<RowDefinition/> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<StackPanel Orientation="Vertical"> |
|||
<TextBlock Text="Translation" HorizontalAlignment="Center"/> |
|||
<Grid ColumnDefinitions="*,*" |
|||
RowDefinitions="Auto,Auto" |
|||
> |
|||
<TextBlock Text="Horizontal"/> |
|||
<TextBlock Text="Vertical" Grid.Column="1"/> |
|||
<TextBox IsEnabled="False" |
|||
Text="{Binding ElementName=CustomDrawingControl, |
|||
Path=ViewportCenterX, |
|||
Mode=OneWay, |
|||
StringFormat=\{0:g4\}}" |
|||
Grid.Row="1" |
|||
/> |
|||
<TextBox IsEnabled="False" |
|||
Text="{Binding ElementName=CustomDrawingControl, |
|||
Path=ViewportCenterY, |
|||
Mode=OneWay, |
|||
StringFormat=\{0:g4\}}" |
|||
Grid.Row="1" Grid.Column="1" |
|||
/> |
|||
</Grid> |
|||
</StackPanel> |
|||
|
|||
<StackPanel Orientation="Vertical" Grid.Column="1" |
|||
> |
|||
<TextBlock Text="Rotation" HorizontalAlignment="Center"/> |
|||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" |
|||
> |
|||
<Button Content="➖" Width="40" Height="40" |
|||
VerticalContentAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
Click="RotateMinus" |
|||
/> |
|||
<TextBox IsEnabled="False" |
|||
Text="{Binding ElementName=CustomDrawingControl, |
|||
Path=Rotation, |
|||
Converter={StaticResource DegToRadConverter}, |
|||
Mode=OneWay, |
|||
StringFormat=\{0:g4\}}" |
|||
Grid.Row="1" Grid.Column="1" |
|||
/> |
|||
<Button Content="➕" Width="40" Height="40" |
|||
VerticalContentAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
Click="RotatePlus" |
|||
/> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
|
|||
<StackPanel Orientation="Vertical" Grid.Column="2" |
|||
> |
|||
<TextBlock Text="Scale" HorizontalAlignment="Center"/> |
|||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" |
|||
> |
|||
<Button Content="➖" Width="40" Height="40" |
|||
VerticalContentAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
Click="ZoomOut" |
|||
/> |
|||
<TextBox IsEnabled="False" |
|||
Text="{Binding ElementName=CustomDrawingControl, |
|||
Path=Scale, |
|||
Mode=OneWay, |
|||
StringFormat=\{0:g4\}}" |
|||
Grid.Row="1" Grid.Column="1" |
|||
/> |
|||
<Button Content="➕" Width="40" Height="40" |
|||
VerticalContentAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
Click="ZoomIn" |
|||
/> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
|
|||
<Grid Grid.Row="1" Grid.ColumnSpan="3" ClipToBounds="True"> |
|||
<local:CustomDrawingExampleControl |
|||
x:Name="CustomDrawingControl" |
|||
/> |
|||
</Grid> |
|||
</Grid> |
|||
|
|||
</UserControl> |
|||
@ -0,0 +1,67 @@ |
|||
using System; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public partial class CustomDrawing : UserControl |
|||
{ |
|||
public CustomDrawing() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private CustomDrawingExampleControl? _customControl; |
|||
public CustomDrawingExampleControl CustomDrawingControl |
|||
{ |
|||
get |
|||
{ |
|||
if (_customControl is not null) |
|||
return _customControl; |
|||
throw new System.Exception("Control did not get initialized"); |
|||
} |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
var cntrl = this.FindControl<CustomDrawingExampleControl>("CustomDrawingControl"); |
|||
if (cntrl != null) |
|||
{ |
|||
_customControl = cntrl; |
|||
} |
|||
else |
|||
{ |
|||
// be sad about it
|
|||
} |
|||
} |
|||
|
|||
private void RotateMinus (object? sender, RoutedEventArgs e) |
|||
{ |
|||
if (_customControl is null) return; |
|||
_customControl.Rotation -= Math.PI / 20.0d; |
|||
} |
|||
|
|||
private void RotatePlus(object? sender, RoutedEventArgs e) |
|||
{ |
|||
if (_customControl is null) |
|||
return; |
|||
_customControl.Rotation += Math.PI / 20.0d; |
|||
} |
|||
|
|||
private void ZoomIn(object? sender, RoutedEventArgs e) |
|||
{ |
|||
if (_customControl is null) |
|||
return; |
|||
_customControl.Scale *= 1.2d; |
|||
} |
|||
|
|||
private void ZoomOut(object? sender, RoutedEventArgs e) |
|||
{ |
|||
if (_customControl is null) |
|||
return; |
|||
_customControl.Scale /= 1.2d; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,215 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Globalization; |
|||
using System.Text; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Media; |
|||
using Avalonia.Input; |
|||
using Avalonia.Threading; |
|||
using Avalonia.Controls.Shapes; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class CustomDrawingExampleControl : Control |
|||
{ |
|||
private Point _cursorPoint; |
|||
|
|||
|
|||
public StyledProperty<double> ScaleProperty = AvaloniaProperty.Register<CustomDrawingExampleControl, double>(nameof(Scale), 1.0d); |
|||
public double Scale { get => GetValue(ScaleProperty); set => SetValue(ScaleProperty, value); } |
|||
|
|||
public StyledProperty<double> RotationProperty = AvaloniaProperty.Register<CustomDrawingExampleControl, double>(nameof(Rotation)); |
|||
/// <summary>
|
|||
/// Rotation, measured in Radians!
|
|||
/// </summary>
|
|||
public double Rotation |
|||
{ |
|||
get => GetValue(RotationProperty); |
|||
set |
|||
{ |
|||
double valueToUse = value % (Math.PI * 2); |
|||
SetValue(RotationProperty, valueToUse); |
|||
} |
|||
} |
|||
|
|||
public StyledProperty<double> ViewportCenterYProperty = AvaloniaProperty.Register<CustomDrawingExampleControl, double>(nameof(ViewportCenterY), 0.0d); |
|||
public double ViewportCenterY { get => GetValue(ViewportCenterYProperty); set => SetValue(ViewportCenterYProperty, value); } |
|||
|
|||
public StyledProperty<double> ViewportCenterXProperty = AvaloniaProperty.Register<CustomDrawingExampleControl, double>(nameof(ViewportCenterX), 0.0d); |
|||
public double ViewportCenterX { get => GetValue(ViewportCenterXProperty); set => SetValue(ViewportCenterXProperty, value); } |
|||
|
|||
private IPen _pen; |
|||
|
|||
private System.Diagnostics.Stopwatch _timeKeeper = System.Diagnostics.Stopwatch.StartNew(); |
|||
|
|||
private bool _isPointerCaptured = false; |
|||
|
|||
public CustomDrawingExampleControl() |
|||
{ |
|||
_pen = new Pen(new SolidColorBrush(Colors.Black), lineCap: PenLineCap.Round); |
|||
|
|||
var _arc = new ArcSegment() |
|||
{ |
|||
IsLargeArc = false, |
|||
Point = new Point(0, 0), |
|||
RotationAngle = 0, |
|||
Size = new Size(25, 25), |
|||
SweepDirection = SweepDirection.Clockwise, |
|||
|
|||
}; |
|||
StreamGeometry sg = new StreamGeometry(); |
|||
var cntx = sg.Open(); |
|||
cntx.BeginFigure(new Point(-25.0d, -10.0d), false); |
|||
cntx.ArcTo(new Point(25.0d, -10.0d), new Size(10.0d, 10.0d), 0.0d, false, SweepDirection.Clockwise); |
|||
cntx.EndFigure(true); |
|||
_smileGeometry = sg.Clone(); |
|||
} |
|||
|
|||
private Geometry _smileGeometry; |
|||
|
|||
protected override void OnPointerMoved(PointerEventArgs e) |
|||
{ |
|||
base.OnPointerMoved(e); |
|||
|
|||
Point previousPoint = _cursorPoint; |
|||
|
|||
_cursorPoint = e.GetPosition(this); |
|||
|
|||
if (_isPointerCaptured) |
|||
{ |
|||
Point oldWorldPoint = UIPointToWorldPoint(previousPoint, ViewportCenterX, ViewportCenterY, Scale, Rotation); |
|||
Point newWorldPoint = UIPointToWorldPoint(_cursorPoint, ViewportCenterX, ViewportCenterY, Scale, Rotation); |
|||
|
|||
Vector diff = newWorldPoint - oldWorldPoint; |
|||
|
|||
ViewportCenterX -= diff.X; |
|||
ViewportCenterY -= diff.Y; |
|||
} |
|||
} |
|||
|
|||
protected override void OnPointerPressed(PointerPressedEventArgs e) |
|||
{ |
|||
e.Handled = true; |
|||
e.Pointer.Capture(this); |
|||
_isPointerCaptured = true; |
|||
base.OnPointerPressed(e); |
|||
} |
|||
|
|||
protected override void OnPointerWheelChanged(PointerWheelEventArgs e) |
|||
{ |
|||
base.OnPointerWheelChanged(e); |
|||
var oldScale = Scale; |
|||
Scale *= (1.0d + e.Delta.Y / 12.0d); |
|||
|
|||
Point oldWorldPoint = UIPointToWorldPoint(_cursorPoint, ViewportCenterX, ViewportCenterY, oldScale, Rotation); |
|||
Point newWorldPoint = UIPointToWorldPoint(_cursorPoint, ViewportCenterX, ViewportCenterY, Scale, Rotation); |
|||
|
|||
Vector diff = newWorldPoint - oldWorldPoint; |
|||
|
|||
ViewportCenterX -= diff.X; |
|||
ViewportCenterY -= diff.Y; |
|||
} |
|||
|
|||
protected override void OnPointerReleased(PointerReleasedEventArgs e) |
|||
{ |
|||
e.Pointer.Capture(null); |
|||
_isPointerCaptured = false; |
|||
base.OnPointerReleased(e); |
|||
} |
|||
|
|||
public override void Render(DrawingContext context) |
|||
{ |
|||
var localBounds = new Rect(new Size(this.Bounds.Width, this.Bounds.Height)); |
|||
var clip = context.PushClip(this.Bounds); |
|||
context.DrawRectangle(Brushes.White, _pen, localBounds, 1.0d); |
|||
|
|||
var halfMax = Math.Max(this.Bounds.Width / 2.0d, this.Bounds.Height / 2.0d) * Math.Sqrt(2.0d); |
|||
var halfMin = Math.Min(this.Bounds.Width / 2.0d, this.Bounds.Height / 2.0d) / 1.3d; |
|||
var halfWidth = this.Bounds.Width / 2.0d; |
|||
var halfHeight = this.Bounds.Height / 2.0d; |
|||
|
|||
// 0,0 refers to the top-left of the control now. It is not prime time to draw gui stuff because it'll be under the world
|
|||
|
|||
var translateModifier = context.PushPreTransform(Avalonia.Matrix.CreateTranslation(new Avalonia.Vector(halfWidth, halfHeight))); |
|||
|
|||
// now 0,0 refers to the ViewportCenter(X,Y).
|
|||
var rotationMatrix = Avalonia.Matrix.CreateRotation(Rotation); |
|||
var rotationModifier = context.PushPreTransform(rotationMatrix); |
|||
|
|||
// everything is rotated but not scaled
|
|||
|
|||
var scaleModifier = context.PushPreTransform(Avalonia.Matrix.CreateScale(Scale, -Scale)); |
|||
|
|||
var mapPositionModifier = context.PushPreTransform(Matrix.CreateTranslation(new Vector(-ViewportCenterX, -ViewportCenterY))); |
|||
|
|||
// now everything is rotated and scaled, and at the right position, now we're drawing strictly in world coordinates
|
|||
|
|||
context.DrawEllipse(Brushes.White, _pen, new Point(0.0d, 0.0d), 50.0d, 50.0d); |
|||
context.DrawLine(_pen, new Point(-25.0d, -5.0d), new Point(-25.0d, 15.0d)); |
|||
context.DrawLine(_pen, new Point(25.0d, -5.0d), new Point(25.0d, 15.0d)); |
|||
context.DrawGeometry(null, _pen, _smileGeometry); |
|||
|
|||
Point cursorInWorldPoint = UIPointToWorldPoint(_cursorPoint, ViewportCenterX, ViewportCenterY, Scale, Rotation); |
|||
context.DrawEllipse(Brushes.Gray, _pen, cursorInWorldPoint, 20.0d, 20.0d); |
|||
|
|||
|
|||
for (int i = 0; i < 10; i++) |
|||
{ |
|||
double orbitRadius = i * 100 + 200; |
|||
var orbitInput = ((_timeKeeper.Elapsed.TotalMilliseconds + 987654d) / orbitRadius) / 10.0d; |
|||
if (i % 3 == 0) |
|||
orbitInput *= -1; |
|||
Point orbitPosition = new Point(Math.Sin(orbitInput) * orbitRadius, Math.Cos(orbitInput) * orbitRadius); |
|||
context.DrawEllipse(Brushes.Gray, _pen, orbitPosition, 20.0d, 20.0d); |
|||
} |
|||
|
|||
|
|||
// end drawing the world
|
|||
|
|||
mapPositionModifier.Dispose(); |
|||
|
|||
scaleModifier.Dispose(); |
|||
|
|||
rotationModifier.Dispose(); |
|||
translateModifier.Dispose(); |
|||
|
|||
// this is prime time to draw gui stuff
|
|||
|
|||
context.DrawLine(_pen, _cursorPoint + new Vector(-20, 0), _cursorPoint + new Vector(20, 0)); |
|||
context.DrawLine(_pen, _cursorPoint + new Vector(0, -20), _cursorPoint + new Vector(0, 20)); |
|||
|
|||
clip.Dispose(); |
|||
|
|||
// oh and draw again when you can, no rush, right?
|
|||
Dispatcher.UIThread.Post(InvalidateVisual, DispatcherPriority.Background); |
|||
} |
|||
|
|||
private Point UIPointToWorldPoint(Point inPoint, double viewportCenterX, double viewportCenterY, double scale, double rotation) |
|||
{ |
|||
Point workingPoint = new Point(inPoint.X, -inPoint.Y); |
|||
workingPoint += new Vector(-this.Bounds.Width / 2.0d, this.Bounds.Height / 2.0d); |
|||
workingPoint /= scale; |
|||
|
|||
workingPoint = Matrix.CreateRotation(rotation).Transform(workingPoint); |
|||
|
|||
workingPoint += new Vector(viewportCenterX, viewportCenterY); |
|||
|
|||
return workingPoint; |
|||
} |
|||
|
|||
private Point WorldPointToUIPoint(Point inPoint, double viewportCenterX, double viewportCenterY, double scale, double rotation) |
|||
{ |
|||
Point workingPoint = new Point(inPoint.X, inPoint.Y); |
|||
|
|||
workingPoint -= new Vector(viewportCenterX, viewportCenterY); |
|||
// undo rotation
|
|||
workingPoint = Matrix.CreateRotation(-rotation).Transform(workingPoint); |
|||
workingPoint *= scale; |
|||
workingPoint -= new Vector(-this.Bounds.Width / 2.0d, this.Bounds.Height / 2.0d); |
|||
workingPoint = new Point(workingPoint.X, -workingPoint.Y); |
|||
|
|||
return workingPoint; |
|||
} |
|||
} |
|||
} |
|||
@ -1,18 +1,33 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
using ControlCatalog.ViewModels; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class NotificationsPage : UserControl |
|||
{ |
|||
private NotificationViewModel _viewModel; |
|||
|
|||
public NotificationsPage() |
|||
{ |
|||
this.InitializeComponent(); |
|||
|
|||
_viewModel = new NotificationViewModel(); |
|||
|
|||
DataContext = _viewModel; |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) |
|||
{ |
|||
base.OnAttachedToVisualTree(e); |
|||
|
|||
_viewModel.NotificationManager = new Avalonia.Controls.Notifications.WindowNotificationManager(VisualRoot as TopLevel); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,53 @@ |
|||
<UserControl x:Class="ControlCatalog.Pages.PlatformInfoPage" |
|||
xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:viewModels="using:ControlCatalog.ViewModels" |
|||
d:DesignHeight="800" |
|||
d:DesignWidth="400" |
|||
mc:Ignorable="d" |
|||
x:DataType="viewModels:PlatformInformationViewModel"> |
|||
<StackPanel Spacing="20"> |
|||
<TextBlock Text="{Binding PlatformInfo}" /> |
|||
|
|||
<StackPanel TextElement.Foreground="White"> |
|||
<StackPanel Orientation="Horizontal"> |
|||
<Border Height="100" Width="100" Background="{OnFormFactor Gray, Desktop=Green}"> |
|||
<TextBlock Text="Desktop" /> |
|||
</Border> |
|||
<Border Height="100" Width="100" Background="{OnFormFactor Gray, Mobile=Green}"> |
|||
<TextBlock Text="Mobile" /> |
|||
</Border> |
|||
</StackPanel> |
|||
<WrapPanel> |
|||
<Border Height="100" Width="100" Background="{OnPlatform Gray, Windows=Green}"> |
|||
<TextBlock Text="Windows" /> |
|||
</Border> |
|||
<Border Height="100" Width="100" Background="{OnPlatform Gray, macOS=Green}"> |
|||
<TextBlock Text="macOS" /> |
|||
</Border> |
|||
<Border Height="100" Width="100" Background="{OnPlatform Gray, Linux=Green}"> |
|||
<TextBlock Text="Linux" /> |
|||
</Border> |
|||
<Border Height="100" Width="100" Background="{OnPlatform Gray, Browser=Green}"> |
|||
<TextBlock Text="Browser" /> |
|||
</Border> |
|||
<Border Height="100" Width="100" Background="{OnPlatform Gray, iOS=Green}"> |
|||
<TextBlock Text="iOS" /> |
|||
</Border> |
|||
<Border Height="100" Width="100" Background="{OnPlatform Gray, Android=Green}"> |
|||
<TextBlock Text="Android" /> |
|||
</Border> |
|||
<Border Height="100" Width="100"> |
|||
<Border.Background> |
|||
<OnPlatform Default="Gray" > |
|||
<On Options="macOS, Linux, Windows" Content="Green" /> |
|||
</OnPlatform> |
|||
</Border.Background> |
|||
<TextBlock Text="Win, Lin or Mac" /> |
|||
</Border> |
|||
</WrapPanel> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</UserControl> |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue