Browse Source

Fixed PixelSnapHelpers - don't crash when measuring a visual without PresentationSource.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5250 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 17 years ago
parent
commit
0d217472ff
  1. 13
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/PixelSnapHelpers.cs

13
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/PixelSnapHelpers.cs

@ -12,7 +12,7 @@ using System.Windows.Media; @@ -12,7 +12,7 @@ using System.Windows.Media;
namespace ICSharpCode.AvalonEdit.Utils
{
/// <summary>
/// Contains static helper methods for aligning stuff on a whole number of
/// Contains static helper methods for aligning stuff on a whole number of pixels.
/// </summary>
public static class PixelSnapHelpers
{
@ -22,8 +22,15 @@ namespace ICSharpCode.AvalonEdit.Utils @@ -22,8 +22,15 @@ namespace ICSharpCode.AvalonEdit.Utils
/// </summary>
public static Size GetPixelSize(Visual visual)
{
Matrix matrix = PresentationSource.FromVisual(visual).CompositionTarget.TransformFromDevice;
return new Size(matrix.M11, matrix.M22);
if (visual == null)
throw new ArgumentNullException("visual");
PresentationSource source = PresentationSource.FromVisual(visual);
if (source != null) {
Matrix matrix = source.CompositionTarget.TransformFromDevice;
return new Size(matrix.M11, matrix.M22);
} else {
return new Size(1, 1);
}
}
/// <summary>

Loading…
Cancel
Save