-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into rect-based-undo-fixes
- Loading branch information
Showing
79 changed files
with
1,701 additions
and
329 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace PixiEditor.Helpers.Converters | ||
{ | ||
public class EnumBooleanConverter : SingleInstanceConverter<EnumBooleanConverter> | ||
{ | ||
#region IValueConverter Members | ||
public override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
string parameterString = parameter as string; | ||
if (parameterString == null) | ||
return DependencyProperty.UnsetValue; | ||
|
||
if (Enum.IsDefined(value.GetType(), value) == false) | ||
return DependencyProperty.UnsetValue; | ||
|
||
object parameterValue = Enum.Parse(value.GetType(), parameterString); | ||
|
||
return parameterValue.Equals(value); | ||
} | ||
|
||
public override object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
string parameterString = parameter as string; | ||
if (parameterString == null) | ||
return DependencyProperty.UnsetValue; | ||
|
||
return Enum.Parse(targetType, parameterString); | ||
} | ||
#endregion | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using PixiEditor.Models.Enums; | ||
using System; | ||
|
||
namespace PixiEditor.Helpers.Converters | ||
{ | ||
internal class EnumToStringConverter : SingleInstanceConverter<EnumToStringConverter> | ||
{ | ||
public override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
{ | ||
try | ||
{ | ||
var type = value.GetType(); | ||
if (type == typeof(SizeUnit)) | ||
{ | ||
var valueCasted = (SizeUnit)value; | ||
if (valueCasted == SizeUnit.Percentage) | ||
return "%"; | ||
|
||
return "px"; | ||
} | ||
return Enum.GetName((value.GetType()), value); | ||
} | ||
catch | ||
{ | ||
return string.Empty; | ||
} | ||
} | ||
} | ||
} |
46 changes: 24 additions & 22 deletions
46
PixiEditor/Helpers/Converters/FileExtensionToColorConverter.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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace PixiEditor.Helpers | ||
{ | ||
public static class ProcessHelpers | ||
{ | ||
public static void ShellExecute(string url) | ||
{ | ||
Process.Start(new ProcessStartInfo | ||
{ | ||
FileName = url, | ||
UseShellExecute = true | ||
}); | ||
} | ||
|
||
public static void ShellExecuteEV(string path) => ShellExecute(Environment.ExpandEnvironmentVariables(path)); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
|
||
namespace PixiEditor.Helpers | ||
{ | ||
public static class SizeCalculator | ||
{ | ||
public static System.Drawing.Size CalcAbsoluteFromPercentage(float percentage, System.Drawing.Size currentSize) | ||
{ | ||
float percFactor = percentage / 100f; | ||
float newWidth = currentSize.Width * percFactor; | ||
float newHeight = currentSize.Height * percFactor; | ||
return new System.Drawing.Size((int)MathF.Round(newWidth), (int)MathF.Round(newHeight)); | ||
} | ||
|
||
public static int CalcPercentageFromAbsolute(int initAbsoluteSize, int currentAbsoluteSize) | ||
{ | ||
return (int)((float)currentAbsoluteSize * 100) / initAbsoluteSize; | ||
} | ||
} | ||
} |
Oops, something went wrong.