-
Notifications
You must be signed in to change notification settings - Fork 0
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
24 changed files
with
384 additions
and
81 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
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
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,28 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
using System.Windows.Markup; | ||
|
||
namespace Wims.Ui.Converters | ||
{ | ||
public class ObjectIsEqualConverter : MarkupExtension, IValueConverter | ||
{ | ||
private static Lazy<ObjectIsEqualConverter> _instance = | ||
new Lazy<ObjectIsEqualConverter>(() => new ObjectIsEqualConverter()); | ||
|
||
public override object ProvideValue(IServiceProvider serviceProvider) | ||
{ | ||
return _instance.Value; | ||
} | ||
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return value?.Equals(parameter); | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
return new NotSupportedException(); | ||
} | ||
} | ||
} |
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,44 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
using System.Windows.Markup; | ||
using System.Windows.Media; | ||
using MaterialDesignThemes.Wpf; | ||
|
||
namespace Wims.Ui.Converters | ||
{ | ||
/// <summary> | ||
/// Converts a <see cref="PackIcon" /> to an DrawingImage. | ||
/// Use the ConverterParameter to pass a Brush. | ||
/// </summary> | ||
public class PackIconToImageConverter : MarkupExtension, IValueConverter | ||
{ | ||
private static Lazy<PackIconToImageConverter> _instance = | ||
new Lazy<PackIconToImageConverter>(() => new PackIconToImageConverter()); | ||
|
||
public override object ProvideValue(IServiceProvider serviceProvider) | ||
{ | ||
return _instance.Value; | ||
} | ||
|
||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
if (!(value is PackIcon icon)) return value; | ||
|
||
GeometryDrawing geoDrawing = new GeometryDrawing(); | ||
|
||
geoDrawing.Brush = parameter as Brush ?? Brushes.Black; | ||
geoDrawing.Pen = new Pen(geoDrawing.Brush, 0.25); | ||
geoDrawing.Geometry = Geometry.Parse(icon.Data); | ||
|
||
var drawingGroup = new DrawingGroup {Children = {geoDrawing}, Transform = new ScaleTransform(1, -1)}; | ||
|
||
return new DrawingImage {Drawing = drawingGroup}; | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Windows; | ||
|
||
namespace Wims.Ui | ||
{ | ||
public interface IErrorHandler | ||
{ | ||
void OnError(Exception e); | ||
} | ||
|
||
public class ErrorHandler : IErrorHandler | ||
{ | ||
public void OnError(Exception e) | ||
{ | ||
Application.Current.Dispatcher.Invoke(() => | ||
{ | ||
var window = new ErrorWindow(e); | ||
window.ShowDialog(); | ||
}); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.