Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions CADability.Avalonia/CADability.Avalonia.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.3.10" />
<PackageReference Include="Avalonia.Desktop" Version="11.3.10" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.10" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.10" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.10">
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CADability\CADability.csproj" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions CADability.Avalonia/CadCanvas.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="CADability.Avalonia.CadCanvas">
<!-- Height="300"> -->
</UserControl>
83 changes: 83 additions & 0 deletions CADability.Avalonia/CadCanvas.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.OpenGL;
using Avalonia.OpenGL.Controls;
using CADability.GeoObject;
using CADability.Substitutes;
using CADability.UserInterface;
using System;
using System.Numerics;
using static Avalonia.OpenGL.GlConsts;

namespace CADability.Avalonia
{
public partial class CadCanvas: UserControl, ICanvas
{
private static CADability.Substitutes.Rectangle Subst(Rect v)
{
return new Substitutes.Rectangle((int)v.X, (int)v.Y, (int)v.Width, (int)v.Height);
}

private PaintToOpenGL paintTo3D;
private IFrame frame;
private IView view;
private String currentCursor;

public CadCanvas()
{
InitializeComponent();
// CadCanvasControl canvasControl = new CadCanvasControl();
paintTo3D = new PaintToOpenGL();
this.Content = paintTo3D;
}

void ICanvas.Invalidate() {}

Rectangle ICanvas.ClientRectangle => Subst(base.Bounds);

IFrame ICanvas.Frame
{
get { return frame; }
}

string ICanvas.Cursor
{
get { return currentCursor; }
set { currentCursor = value; } //TODO
}

IPaintTo3D ICanvas.PaintTo3D
{
get { return paintTo3D; }
}

public event Action<ICanvas> OnPaintDone;

void ICanvas.ShowView(IView toShow)
{
view = toShow;
// TODO init paintTo3D here or in constructor?
paintTo3D.View = view;
// TODO view.Connect needed?
}

IView ICanvas.GetView()
{
return view;
}

Substitutes.Point ICanvas.PointToClient(Substitutes.Point mousePosition)
{
throw new NotImplementedException();
}

void ICanvas.ShowContextMenu(MenuWithHandler[] contextMenu, Substitutes.Point viewPosition, System.Action<int> collapsed) {}

Substitutes.DragDropEffects ICanvas.DoDragDrop(GeoObjectList dragList, Substitutes.DragDropEffects all)
{
throw new NotImplementedException();
}

void ICanvas.ShowToolTip(string toDisplay) {}
}
}
14 changes: 14 additions & 0 deletions CADability.Avalonia/CadForm.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ca="using:CADability.Avalonia"
x:Class="CADability.Avalonia.CadForm">
<!-- <StackPanel> -->
<!-- <TextBlock -->
<!-- Margin="10" -->
<!-- FontSize="16" -->
<!-- HorizontalAlignment="Center" -->
<!-- Text="ShapeIt"> -->
<!-- </TextBlock> -->
<ca:CadCanvas/>
<!-- </StackPanel> -->
</UserControl>
13 changes: 13 additions & 0 deletions CADability.Avalonia/CadForm.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Avalonia.Controls;

namespace CADability.Avalonia
{
public partial class CadForm : UserControl
{
// TODO this class is currently unused, we directly use CadCanvas
public CadForm()
{
InitializeComponent();
}
}
}
Loading