Remove unused controls
DELETE
WalletWasabi.Fluent/Controls/NonVirtualizingResponsiveLayout.cs
-using System.Collections.Generic;
-using Avalonia;
-using Avalonia.Collections;
-using Avalonia.Controls;
-using Avalonia.Layout;
-
-namespace WalletWasabi.Fluent.Controls;
-
-public class NonVirtualizingResponsiveLayout : NonVirtualizingLayout
-{
- public static readonly StyledProperty<double> ItemWidthProperty =
- AvaloniaProperty.Register<NonVirtualizingLayout, double>(nameof(ItemWidth), double.NaN);
-
- public static readonly StyledProperty<double> ItemHeightProperty =
- AvaloniaProperty.Register<NonVirtualizingLayout, double>(nameof(ItemHeight), double.NaN);
-
- public static readonly StyledProperty<double> WidthSourceProperty =
- AvaloniaProperty.Register<NonVirtualizingLayout, double>(nameof(WidthSource), double.NaN);
-
- public static readonly StyledProperty<double> AspectRatioProperty =
- AvaloniaProperty.Register<NonVirtualizingLayout, double>(nameof(AspectRatio), double.NaN);
-
- public static readonly StyledProperty<AvaloniaList<int>> ColumnHintsProperty =
- AvaloniaProperty.Register<NonVirtualizingLayout, AvaloniaList<int>>(nameof(ColumnHints),
- new AvaloniaList<int>() { 1 });
-
- public static readonly StyledProperty<AvaloniaList<double>> WidthTriggersProperty =
- AvaloniaProperty.Register<NonVirtualizingLayout, AvaloniaList<double>>(nameof(WidthTriggers),
- new AvaloniaList<double>() { 0.0 });
-
- public static readonly AttachedProperty<IList<int>?> ColumnSpanProperty =
- AvaloniaProperty.RegisterAttached<NonVirtualizingLayout, Control, IList<int>?>("ColumnSpan");
-
- public static readonly AttachedProperty<IList<int>?> RowSpanProperty =
- AvaloniaProperty.RegisterAttached<NonVirtualizingLayout, Control, IList<int>?>("RowSpan");
-
- public static IList<int>? GetColumnSpan(Control? element)
- {
- Contract.Requires<ArgumentNullException>(element != null);
- return element!.GetValue(ColumnSpanProperty);
- }
-
- public static void SetColumnSpan(Control? element, IList<int>? value)
- {
- Contract.Requires<ArgumentNullException>(element != null);
- element!.SetValue(ColumnSpanProperty, value);
- }
-
- public static IList<int>? GetRowSpan(Control? element)
- {
- Contract.Requires<ArgumentNullException>(element != null);
- return element!.GetValue(RowSpanProperty);
- }
-
- public static void SetRowSpan(Control? element, IList<int>? value)
- {
- Contract.Requires<ArgumentNullException>(element != null);
- element!.SetValue(RowSpanProperty, value);
- }
-
- public double ItemWidth
- {
- get => GetValue(ItemWidthProperty);
- set => SetValue(ItemWidthProperty, value);
- }
-
- public double ItemHeight
- {
- get => GetValue(ItemHeightProperty);
- set => SetValue(ItemHeightProperty, value);
- }
-
- public double WidthSource
- {
- get => GetValue(WidthSourceProperty);
- set => SetValue(WidthSourceProperty, value);
- }
-
- public double AspectRatio
- {
- get => GetValue(AspectRatioProperty);
- set => SetValue(AspectRatioProperty, value);
- }
-
- public AvaloniaList<int> ColumnHints
- {
- get => GetValue(ColumnHintsProperty);
- set => SetValue(ColumnHintsProperty, value);
- }
-
- public AvaloniaList<double> WidthTriggers
- {
- get => GetValue(WidthTriggersProperty);
- set => SetValue(WidthTriggersProperty, value);
- }
-
- private Size MeasureArrange(Size panelSize, NonVirtualizingLayoutContext context, bool isMeasure)
- {
- var state = new ResponsivePanelState(context.Children)
- {
- ItemWidth = ItemWidth,
- ItemHeight = ItemHeight,
- AspectRatio = double.IsNaN(AspectRatio) && (panelSize.Height == 0 || double.IsInfinity(panelSize.Height)) ? 1.0 : AspectRatio,
- ColumnHints = ColumnHints,
- WidthTriggers = WidthTriggers,
- Width = double.IsNaN(WidthSource) ? panelSize.Width : WidthSource,
- Height = panelSize.Height
- };
-
- return !state.Validate() ? Size.Empty : state.MeasureArrange(isMeasure);
- }
-
- protected override Size MeasureOverride(NonVirtualizingLayoutContext context, Size availableSize)
- {
- return MeasureArrange(availableSize, context, true);
- }
-
- protected override Size ArrangeOverride(NonVirtualizingLayoutContext context, Size finalSize)
- {
- return MeasureArrange(finalSize, context, false);
- }
-
- protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change)
- {
- InvalidateMeasure();
- }
-}

DELETE
WalletWasabi.Fluent/Controls/ResponsivePanel.cs
-using Avalonia;
-using Avalonia.Collections;
-using Avalonia.Controls;
-
-namespace WalletWasabi.Fluent.Controls;
-
-public class ResponsivePanel : Panel
-{
- public static readonly StyledProperty<double> ItemWidthProperty =
- AvaloniaProperty.Register<ResponsivePanel, double>(nameof(ItemWidth), double.NaN);
-
- public static readonly StyledProperty<double> ItemHeightProperty =
- AvaloniaProperty.Register<ResponsivePanel, double>(nameof(ItemHeight), double.NaN);
-
- public static readonly StyledProperty<double> WidthSourceProperty =
- AvaloniaProperty.Register<ResponsivePanel, double>(nameof(WidthSource), double.NaN);
-
- public static readonly StyledProperty<double> AspectRatioProperty =
- AvaloniaProperty.Register<ResponsivePanel, double>(nameof(AspectRatio), double.NaN);
-
- public static readonly StyledProperty<AvaloniaList<int>> ColumnHintsProperty =
- AvaloniaProperty.Register<ResponsivePanel, AvaloniaList<int>>(nameof(ColumnHints),
- new AvaloniaList<int>() { 1 });
-
- public static readonly StyledProperty<AvaloniaList<double>> WidthTriggersProperty =
- AvaloniaProperty.Register<ResponsivePanel, AvaloniaList<double>>(nameof(WidthTriggers),
- new AvaloniaList<double>() { 0.0 });
-
- public static readonly AttachedProperty<AvaloniaList<int>?> ColumnSpanProperty =
- AvaloniaProperty.RegisterAttached<ResponsivePanel, Control, AvaloniaList<int>?>("ColumnSpan");
-
- public static readonly AttachedProperty<AvaloniaList<int>?> RowSpanProperty =
- AvaloniaProperty.RegisterAttached<ResponsivePanel, Control, AvaloniaList<int>?>("RowSpan");
-
- public static AvaloniaList<int>? GetColumnSpan(Control? element)
- {
- Contract.Requires<ArgumentNullException>(element is not null);
- return element!.GetValue(ColumnSpanProperty);
- }
-
- public static void SetColumnSpan(Control? element, AvaloniaList<int>? value)
- {
- Contract.Requires<ArgumentNullException>(element is not null);
- element!.SetValue(ColumnSpanProperty, value);
- }
-
- public static AvaloniaList<int>? GetRowSpan(Control? element)
- {
- Contract.Requires<ArgumentNullException>(element is not null);
- return element!.GetValue(RowSpanProperty);
- }
-
- public static void SetRowSpan(Control? element, AvaloniaList<int>? value)
- {
- Contract.Requires<ArgumentNullException>(element is not null);
- element!.SetValue(RowSpanProperty, value);
- }
-
- public double ItemWidth
- {
- get => GetValue(ItemWidthProperty);
- set => SetValue(ItemWidthProperty, value);
- }
-
- public double ItemHeight
- {
- get => GetValue(ItemHeightProperty);
- set => SetValue(ItemHeightProperty, value);
- }
-
- public double WidthSource
- {
- get => GetValue(WidthSourceProperty);
- set => SetValue(WidthSourceProperty, value);
- }
-
- public double AspectRatio
- {
- get => GetValue(AspectRatioProperty);
- set => SetValue(AspectRatioProperty, value);
- }
-
- public AvaloniaList<int> ColumnHints
- {
- get => GetValue(ColumnHintsProperty);
- set => SetValue(ColumnHintsProperty, value);
- }
-
- public AvaloniaList<double> WidthTriggers
- {
- get => GetValue(WidthTriggersProperty);
- set => SetValue(WidthTriggersProperty, value);
- }
-
- static ResponsivePanel()
- {
- AffectsParentMeasure<ResponsivePanel>(
- ItemWidthProperty,
- ItemHeightProperty,
- WidthSourceProperty,
- AspectRatioProperty,
- ColumnHintsProperty,
- WidthTriggersProperty,
- ColumnSpanProperty,
- RowSpanProperty);
- AffectsParentArrange<ResponsivePanel>(
- ItemWidthProperty,
- ItemHeightProperty,
- WidthSourceProperty,
- AspectRatioProperty,
- ColumnHintsProperty,
- WidthTriggersProperty,
- ColumnSpanProperty,
- RowSpanProperty);
- AffectsMeasure<ResponsivePanel>(
- ItemWidthProperty,
- ItemHeightProperty,
- WidthSourceProperty,
- AspectRatioProperty,
- ColumnHintsProperty,
- WidthTriggersProperty,
- ColumnSpanProperty,
- RowSpanProperty);
- AffectsArrange<ResponsivePanel>(
- ItemWidthProperty,
- ItemHeightProperty,
- WidthSourceProperty,
- AspectRatioProperty,
- ColumnHintsProperty,
- WidthTriggersProperty,
- ColumnSpanProperty,
- RowSpanProperty);
- }
-
- private Size MeasureArrange(Size panelSize, bool isMeasure)
- {
- var state = new ResponsivePanelState(Children)
- {
- ItemWidth = ItemWidth,
- ItemHeight = ItemHeight,
- AspectRatio = double.IsNaN(AspectRatio) && (panelSize.Height == 0 || double.IsInfinity(panelSize.Height)) ? 1.0 : AspectRatio,
- ColumnHints = ColumnHints,
- WidthTriggers = WidthTriggers,
- Width = double.IsNaN(WidthSource) ? panelSize.Width : WidthSource,
- Height = panelSize.Height
- };
-
- return !state.Validate() ? Size.Empty : state.MeasureArrange(isMeasure);
- }
-
- protected override Size MeasureOverride(Size availableSize)
- {
- return MeasureArrange(availableSize, true);
- }
-
- protected override Size ArrangeOverride(Size finalSize)
- {
- return MeasureArrange(finalSize, false);
- }
-}

DELETE
WalletWasabi.Fluent/Controls/ResponsivePanelState.cs
-using System.Collections.Generic;
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Layout;
-
-namespace WalletWasabi.Fluent.Controls;
-
-internal class ResponsivePanelState
-{
- private readonly IReadOnlyList<ILayoutable> _children;
-
- public ResponsivePanelState(IReadOnlyList<ILayoutable> children)
- {
- _children = children;
- }
-
- public double ItemWidth { get; set; }
-
- public double ItemHeight { get; set; }
-
- public double AspectRatio { get; set; }
-
- public IList<int>? ColumnHints { get; set; }
-
- public IList<double>? WidthTriggers { get; set; }
-
- public double Width { get; set; }
-
- public double Height { get; set; }
-
- public int ItemCount => _children.Count;
-
- public ILayoutable GetItemAt(int index) => _children[index];
-
- public bool Validate()
- {
- if (WidthTriggers is null || ColumnHints is null)
- {
- return false;
- }
-
- if (WidthTriggers.Count <= 0)
- {
- // TODO: throw new Exception($"No width trigger specified in {nameof(WidthTriggers)} property.");
- return false;
- }
-
- if (ColumnHints.Count <= 0)
- {
- // No column hints specified in ColumnHints property.
- return false;
- }
-
- if (WidthTriggers.Count != ColumnHints.Count)
- {
- // Number of width triggers must be equal to the number of column triggers.
- return false;
- }
-
- if (double.IsNaN(ItemWidth) && double.IsInfinity(Width))
- {
- // The ItemWidth can't be NaN and panel width can't be infinity at same time.
- return false;
- }
-
- if (double.IsNaN(ItemHeight) && double.IsInfinity(Height))
- {
- // The ItemHeight can't be NaN and panel height can't be infinity at same time.
- return false;
- }
-
- return true;
- }
-
- public Size MeasureArrange(bool isMeasure)
- {
- if (ColumnHints is null)
- {
- return Size.Empty;
- }
-
- var layoutIndex = 0;
- var totalColumns = ColumnHints[layoutIndex];
-
- if (!double.IsInfinity(Width) && WidthTriggers is { })
- {
- for (var i = WidthTriggers.Count - 1; i >= 0; i--)
- {
- if (Width >= WidthTriggers[i])
- {
- totalColumns = ColumnHints[i];
- layoutIndex = i;
- break;
- }
- }
- }
-
- var currentColumn = 0;
- var totalRows = 0;
- var rowIncrement = 1;
- var items = new Item[ItemCount];
-
- for (var i = 0; i < ItemCount; i++)
- {
- var element = GetItemAt(i);
- var columnSpanPropertyValue = NonVirtualizingResponsiveLayout.GetColumnSpan((Control)element);
- var rowSpanPropertyValue = NonVirtualizingResponsiveLayout.GetRowSpan((Control)element);
- var columnSpan = columnSpanPropertyValue is not null && columnSpanPropertyValue.Count - 1 >= layoutIndex ? columnSpanPropertyValue[layoutIndex] : 1;
- var rowSpan = rowSpanPropertyValue is not null && rowSpanPropertyValue.Count - 1 >= layoutIndex ? rowSpanPropertyValue[layoutIndex] : 1;
-
- items[i] = new Item()
- {
- Column = currentColumn,
- Row = totalRows,
- ColumnSpan = columnSpan,
- RowSpan = rowSpan
- };
-
- rowIncrement = Math.Max(rowSpan, rowIncrement);
- currentColumn += columnSpan;
-
- if (currentColumn >= totalColumns || i == ItemCount - 1)
- {
- currentColumn = 0;
- totalRows += rowIncrement;
- rowIncrement = 1;
- }
- }
-
- var columnWidth = double.IsNaN(ItemWidth) ? Width / totalColumns : ItemWidth;
- var rowHeight = double.IsNaN(ItemHeight)
- ? double.IsNaN(AspectRatio) ? Height / totalRows : columnWidth * AspectRatio
- : ItemHeight;
-
- for (var i = 0; i < ItemCount; i++)
- {
- var element = GetItemAt(i);
- var size = new Size(columnWidth * items[i].ColumnSpan, rowHeight * items[i].RowSpan);
- var position = new Point(items[i].Column * columnWidth, items[i].Row * rowHeight);
- var rect = new Rect(position, size);
-
- if (isMeasure)
- {
- element.Measure(size);
- }
- else
- {
- element.Arrange(rect);
- }
- }
-
- return new Size(columnWidth * totalColumns, rowHeight * totalRows);
- }
-
- private struct Item
- {
- internal int Column;
- internal int Row;
- internal int ColumnSpan;
- internal int RowSpan;
- }
-}

DELETE
WalletWasabi.Fluent/Controls/RingChartControl.cs
-using System.Collections.Generic;
-using System.Linq;
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Media;
-using Avalonia.Media.Immutable;
-
-namespace WalletWasabi.Fluent.Controls;
-
-public class RingChartControl : Control
-{
- public static readonly StyledProperty<IList<(string ColorHex, double PercentShare)>> DataPointsProperty =
- AvaloniaProperty.Register<RingChartControl, IList<(string ColorHex, double PercentShare)>>("DataPoints");
-
- public static readonly StyledProperty<double> StartAngleProperty =
- AvaloniaProperty.Register<RingChartControl, double>("StartAngle", 0);
-
- public static readonly StyledProperty<double> EndAngleProperty =
- AvaloniaProperty.Register<RingChartControl, double>("EndAngle", 360);
-
- public static readonly StyledProperty<double> ThicknessProperty =
- AvaloniaProperty.Register<RingChartControl, double>("Thickness", 6);
-
- static RingChartControl()
- {
- AffectsRender<RingChartControl>(DataPointsProperty, ThicknessProperty, StartAngleProperty, EndAngleProperty);
- AffectsMeasure<RingChartControl>(DataPointsProperty, ThicknessProperty, StartAngleProperty, EndAngleProperty);
- }
-
- public IList<(string ColorHex, double PercentShare)> DataPoints
- {
- get => GetValue(DataPointsProperty);
- set => SetValue(DataPointsProperty, value);
- }
-
- private double Radius { get; set; }
-
- public double StartAngle
- {
- get => GetValue(StartAngleProperty);
- set => SetValue(StartAngleProperty, value);
- }
-
- public double EndAngle
- {
- get => GetValue(EndAngleProperty);
- set => SetValue(EndAngleProperty, value);
- }
-
- public double Thickness
- {
- get => GetValue(ThicknessProperty);
- set => SetValue(ThicknessProperty, value);
- }
-
- public double Map(double value, double from1, double to1, double from2, double to2)
- {
- return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
- }
-
- protected override Size MeasureOverride(Size availableSize)
- {
- Radius = (Math.Min(availableSize.Height, availableSize.Width) / 2) - Thickness;
- var s = new Size((Radius * 2) + Thickness, (Radius * 2) + Thickness);
- return s;
- }
-
- private Geometry GetArcGeometry(double startAngle, double endAngle, bool isPathClosed = false)
- {
- var startRadians = ConvertToRadians(startAngle) - (Math.PI / 2);
- var endRadians = ConvertToRadians(endAngle) - (Math.PI / 2);
-
- var center = new Point(Radius + (Thickness / 2), Radius + (Thickness / 2));
-
- if (endRadians < startRadians)
- {
- endRadians += Math.PI * 2;
- }
-
- var d = SweepDirection.Clockwise;
- var largeArc = (endAngle - startAngle) > 180.0;
-
- Point p0 = center + new Vector(Math.Cos(startRadians), Math.Sin(startRadians)) * Radius;
- Point p1 = center + new Vector(Math.Cos(endRadians), Math.Sin(endRadians)) * Radius;
-
- PathSegments segments = new()
- {
- new ArcSegment
- {
- IsLargeArc = largeArc,
- Size = new Size(Radius, Radius),
- Point = p1,
- SweepDirection = d
- }
- };
-
- PathFigures figures = new()
- {
- new PathFigure
- {
- StartPoint = p0,
- Segments = segments,
- IsClosed = isPathClosed
- }
- };
-
- return new PathGeometry
- {
- Figures = figures,
- FillRule = FillRule.EvenOdd
- };
- }
-
- private double ConvertToRadians(double angle)
- {
- return (Math.PI / 180d) * angle;
- }
-
- public override void Render(DrawingContext context)
- {
- if (DataPoints is null)
- {
- return;
- }
-
- var total = DataPoints.Sum(x => x.PercentShare);
-
- if (total <= 1.0)
- {
- var lastAngle = StartAngle;
- var lastData = 0d;
-
- foreach (var dataPoint in DataPoints.OrderBy(x => x.PercentShare))
- {
- var brush = new ImmutableSolidColorBrush(Color.Parse(dataPoint.ColorHex));
-
- lastData += dataPoint.PercentShare;
- var curValue = Map((dataPoint.PercentShare == 1.0 ? 0.99 : lastData), 0, 1, StartAngle, EndAngle);
-
- context.DrawGeometry(
- null,
- new ImmutablePen(brush, Thickness),
- GetArcGeometry(lastAngle, curValue, dataPoint.PercentShare == 1.0d));
-
- lastAngle = curValue;
- }
- }
-
- base.Render(context);
- }
-}

Remove unused controls