Skip to content

Commit

Permalink
New sample: Style geometry types with symbols (#1524)
Browse files Browse the repository at this point in the history
  • Loading branch information
williambohrmann3 authored Sep 16, 2024
1 parent 55544ca commit a529c2a
Show file tree
Hide file tree
Showing 51 changed files with 1,814 additions and 980 deletions.
24 changes: 22 additions & 2 deletions src/MAUI/Maui.Samples/Converters/ColorConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,28 @@ internal class ColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || value.GetType() != typeof(string)) { return null; }
return Microsoft.Maui.Graphics.Color.FromArgb((string)value);
if (value == null) return null;

// Determine the object type.
Type type = value.GetType();

if (type == typeof(string))
{
string colorString = value as string;

// Color needs to be in hex format or else it will throw.
return Color.FromArgb(colorString);
}
else if (type == typeof(System.Drawing.Color))
{
var color = (System.Drawing.Color)value;

return new Color(color.R, color.G, color.B, color.A);
}
else
{
return null;
}
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Loading

0 comments on commit a529c2a

Please sign in to comment.