mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Gradient editor - Initial implementation
This commit is contained in:
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
|
||||
}
|
||||
Reference in new issue
Block a user