Gradient editor - Initial implementation

This commit is contained in:
Robert committed 2022-02-23 21:34:55 +01:00
1 parent 09e7bb5168
commit 1262f84a56
13 files changed
+733 -7

No files matched your search

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Data.Converters;
namespace Artemis.UI.Shared.Converters;
/// <summary>
/// Converts the width in percentage to a real number based on the width of the given parent
/// </summary>
public class WidthNormalizedConverter : IMultiValueConverter
{
#region Implementation of IMultiValueConverter
/// <inheritdoc />
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
{
object? first = values.FirstOrDefault();
object? second = values.Skip(1).FirstOrDefault();
if (first is float value && second is double totalWidth)
return (totalWidth / 1.0) * value;
return 0.0;
}
#endregion
}