-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
69 changed files
with
997 additions
and
1,337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
|
||
namespace PixiEditor.Helpers.Converters | ||
{ | ||
public class BoolToBrushConverter : IValueConverter | ||
public class BoolToBrushConverter | ||
: SingleInstanceConverter<BoolToBrushConverter> | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
BrushTuple tuple = (BrushTuple)parameter; | ||
return (bool)value ? tuple.FirstBrush : tuple.SecondBrush; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
|
||
namespace PixiEditor.Helpers.Converters | ||
{ | ||
public class DoubleToIntConverter : IValueConverter | ||
public class DoubleToIntConverter : | ||
SingleInstanceConverter<DoubleToIntConverter> | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (value is double || value is float) | ||
if (value is double or float) | ||
{ | ||
double val = (double)value; | ||
return (int)val; | ||
} | ||
|
||
return value; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
22 changes: 7 additions & 15 deletions
22
PixiEditor/Helpers/Converters/EmptyStringToVisibilityConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace PixiEditor.Helpers.Converters | ||
{ | ||
public class EmptyStringToVisibilityConverter : IValueConverter | ||
public class EmptyStringToVisibilityConverter : | ||
SingleInstanceConverter<EmptyStringToVisibilityConverter> | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
string s = (string)value; | ||
|
||
return !string.IsNullOrEmpty(s) ? Visibility.Visible : Visibility.Collapsed; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
return | ||
string.IsNullOrEmpty((string)value) | ||
? Visibility.Collapsed | ||
: Visibility.Visible; | ||
} | ||
} | ||
} |
11 changes: 3 additions & 8 deletions
11
PixiEditor/Helpers/Converters/EqualityBoolToVisibilityConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,15 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace PixiEditor.Helpers.Converters | ||
{ | ||
public class EqualityBoolToVisibilityConverter : IValueConverter | ||
public class EqualityBoolToVisibilityConverter : | ||
SingleInstanceConverter<EqualityBoolToVisibilityConverter> | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return value.Equals(parameter) ? Visibility.Visible : Visibility.Collapsed; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,28 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
using System.Windows.Markup; | ||
using System.Windows.Media; | ||
|
||
namespace PixiEditor.Helpers.Converters | ||
{ | ||
public class FormattedColorConverter : MarkupExtension, IMultiValueConverter | ||
public class FormattedColorConverter | ||
: SingleInstanceMultiValueConverter<FormattedColorConverter> | ||
{ | ||
private static FormattedColorConverter converter; | ||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) | ||
public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if(values != null && values.Length > 1 && values[0] is Color color && values[1] is string format) | ||
if (values == null || | ||
values.Length <= 1 || | ||
values[0] is not Color color || | ||
values[1] is not string format) | ||
{ | ||
switch (format.ToLower()) | ||
{ | ||
case "hex": | ||
return color.ToString(); | ||
case "rgba": | ||
return $"({color.R}, {color.G}, {color.B}, {color.A})"; | ||
default: | ||
break; | ||
} | ||
return ""; | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override object ProvideValue(IServiceProvider serviceProvider) | ||
{ | ||
if(converter == null) | ||
return format.ToLowerInvariant() switch | ||
{ | ||
converter = new FormattedColorConverter(); | ||
} | ||
return converter; | ||
"hex" => color.ToString(), | ||
"rgba" => $"({color.R}, {color.G}, {color.B}, {color.A})", | ||
_ => "", | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.