Can you convert this C# XAML WPF code into F# Avalonia code (using funcUI library). most of the differences will be in DrawingGroup creation, if it even exists in Avalonia
select (new MCDto( i, j, _cellColors[i, j]) ))
.Select( aobj =>
{
var pt1 = new Point( 0,0);
int n = aobj.ilist.Count;
if (n == 1)
{
var res = new CellColor
{
ColorIndex = aobj.ilist.FirstOrDefault(),
Top = aobj.y * PropCellSize,
Left = aobj.x * PropCellSize,
X = 0,
Y = 0
};
return (GridLine)res;
}
var listOfSubpoligons = RenderHelpers.DivideRectangle(PropCellSize, n:n, startAngle:110);
DrawingGroup aDrawingGroup = new DrawingGroup();
foreach (var (i,poli) in listOfSubpoligons.Index() )
{
//var poli = listOfSubpoligons[0];
pt1 = new Point(poli[0].x, poli[0].y);
StreamGeometry triangleGeometry = new StreamGeometry();
using (StreamGeometryContext ctx = triangleGeometry.Open())
{
ctx.BeginFigure(pt1, isFilled: true, isClosed: true);
poli.Skip(1).Select(e =>
{
ctx.LineTo(new Point(e.x, e.y), isStroked: true, isSmoothJoin: false);
return 0;
}
).ToList();
// Define the other two points of the triangle
//ctx.LineTo(new Point(100, 100), isStroked: true, isSmoothJoin: false);
//ctx.LineTo(new Point(100, 0), isStroked: true, isSmoothJoin: false);
//ctx.LineTo(new Point(0, 0), isStroked: true, isSmoothJoin: false);
}
triangleGeometry.Freeze();
var colorIdx = aobj.ilist[i];
GeometryDrawing subrect =
new GeometryDrawing(
MultiColorDrawing.Colors[colorIdx], //was i%2 for debug
null,
triangleGeometry
);
subrect.Freeze();
aDrawingGroup.Children.Add(subrect);
}
aDrawingGroup.Freeze();
//Debug.WriteLine($"group {x}");
var mcd = new MultiColorDrawing()
{
Top = aobj.y * PropCellSize,
Left = aobj.x * PropCellSize,
X = 0,
Y = 0,
DrGr = aDrawingGroup
};
return (GridLine)mcd;
}))