C# Class Smrf.WpfGraphicsLib.WpfGraphicsUtil

Utility methods for drawing with WPF.
All methods are static.
Mostrar archivo Open project: 2014-sed-team3/term-project Class Usage Examples

Public Properties

Property Type Description
Cosine30Degrees Double
Tangent30Degrees Double

Public Methods

Method Description
BitmapToBitmapSource ( System bitmap ) : System.Windows.Media.Imaging.BitmapSource
ColorToWpfColor ( System color ) : Color
ColorToWpfColor ( System color, Byte newAlpha ) : Color
CreateOnePixelPen ( Visual visual, System.Windows.Media.Brush brush ) : System.Windows.Media.Pen
DrawPixelAlignedRectangle ( System.Windows.Media.DrawingContext drawingContext, System.Windows.Media.Brush brush, System.Windows.Media.Pen pen, Rect rect ) : void
FontToTypeface ( System font ) : System.Windows.Media.Typeface
FreezeIfFreezable ( System.Windows.Freezable freezable ) : System.Boolean
GetAngleBetweenPointsRadians ( Point point1, Point point2 ) : Double
GetContrastingColor ( System color ) : Color
GetContrastingColor ( System color, System.Boolean useMaximumContrast ) : Color
GetDistanceBetweenPoints ( Point point1, Point point2 ) : Double
GetFarthestRectangleEdge ( Point point, Rect rectangle ) : RectangleEdge
GetFormattedTextBounds ( System.Windows.Media.FormattedText formattedText, Point origin ) : Rect
GetFormattedTextSize ( System.Windows.Media.FormattedText formattedText ) : Size
GetRectCenter ( System rect ) : Point
GetRectangleMinusMargin ( Rect rectangle, Double margin ) : Rect
GetRotatedMatrix ( Point centerOfRotation, Double angleToRotateDegrees ) : Matrix
GetScreenDpi ( Visual visual ) : Size
MovePointWithinBounds ( Point point, Rect boundingRectangle ) : Point
MoveRectangleWithinBounds ( Rect rectangle, Rect boundingRectangle, System.Boolean resizeRectangleIfNecessary ) : Rect
PointFToWpfPoint ( System pointF ) : Point
RectToRectangle ( System rect ) : System.Drawing.Rectangle
RectangleToRect ( System rectangle ) : Rect
SetTextBlockFont ( System.Windows.Controls.TextBlock textBlock, System font ) : void
SetWpfColorAlpha ( System color, Byte newAlpha ) : Color
SquareFromCenterAndHalfWidth ( System center, Double halfWidth ) : Rect
SwapPoints ( Point &point1, Point &point2 ) : void
SystemDrawingFontSizeToWpfFontSize ( Double windowsFormsFontSize ) : Double
TransformLength ( Double length, Transform transform, System.Boolean transformAlongX ) : Double
TriangleBoundsFromCenterAndHalfWidth ( System center, Double halfWidth ) : Rect
VisualToBitmap ( Visual visual, Int32 bitmapWidthPx, Int32 bitmapHeightPx ) : System.Drawing.Bitmap
WpfFontSizeToSystemDrawingFontSize ( Double wpfFontSize ) : Double
WpfPointToPoint ( System point ) : System.Drawing.Point
WpfToPx ( Double lengthWpf, Double screenDpi ) : Double

Private Methods

Method Description
DeleteObject ( IntPtr hObject ) : System.Boolean
WpfGraphicsUtil ( ) : System

Static constructor for the WpfGraphicsUtil class.

Method Details

BitmapToBitmapSource() public static method

public static BitmapToBitmapSource ( System bitmap ) : System.Windows.Media.Imaging.BitmapSource
bitmap System
return System.Windows.Media.Imaging.BitmapSource

ColorToWpfColor() public static method

public static ColorToWpfColor ( System color ) : Color
color System
return System.Windows.Media.Color

ColorToWpfColor() public static method

public static ColorToWpfColor ( System color, Byte newAlpha ) : Color
color System
newAlpha Byte
return System.Windows.Media.Color

CreateOnePixelPen() public static method

public static CreateOnePixelPen ( Visual visual, System.Windows.Media.Brush brush ) : System.Windows.Media.Pen
visual Visual
brush System.Windows.Media.Brush
return System.Windows.Media.Pen

DrawPixelAlignedRectangle() public static method

public static DrawPixelAlignedRectangle ( System.Windows.Media.DrawingContext drawingContext, System.Windows.Media.Brush brush, System.Windows.Media.Pen pen, Rect rect ) : void
drawingContext System.Windows.Media.DrawingContext
brush System.Windows.Media.Brush
pen System.Windows.Media.Pen
rect System.Windows.Rect
return void

FontToTypeface() public static method

public static FontToTypeface ( System font ) : System.Windows.Media.Typeface
font System
return System.Windows.Media.Typeface

FreezeIfFreezable() public static method

public static FreezeIfFreezable ( System.Windows.Freezable freezable ) : System.Boolean
freezable System.Windows.Freezable
return System.Boolean

GetAngleBetweenPointsRadians() public static method

public static GetAngleBetweenPointsRadians ( Point point1, Point point2 ) : Double
point1 Point
point2 Point
return Double

GetContrastingColor() public static method

public static GetContrastingColor ( System color ) : Color
color System
return System.Windows.Media.Color

GetContrastingColor() public static method

public static GetContrastingColor ( System color, System.Boolean useMaximumContrast ) : Color
color System
useMaximumContrast System.Boolean
return System.Windows.Media.Color

GetDistanceBetweenPoints() public static method

public static GetDistanceBetweenPoints ( Point point1, Point point2 ) : Double
point1 Point
point2 Point
return Double

GetFarthestRectangleEdge() public static method

public static GetFarthestRectangleEdge ( Point point, Rect rectangle ) : RectangleEdge
point Point
rectangle System.Windows.Rect
return RectangleEdge

GetFormattedTextBounds() public static method

public static GetFormattedTextBounds ( System.Windows.Media.FormattedText formattedText, Point origin ) : Rect
formattedText System.Windows.Media.FormattedText
origin Point
return System.Windows.Rect

GetFormattedTextSize() public static method

public static GetFormattedTextSize ( System.Windows.Media.FormattedText formattedText ) : Size
formattedText System.Windows.Media.FormattedText
return System.Windows.Size

GetRectCenter() public static method

public static GetRectCenter ( System rect ) : Point
rect System
return Point

GetRectangleMinusMargin() public static method

public static GetRectangleMinusMargin ( Rect rectangle, Double margin ) : Rect
rectangle System.Windows.Rect
margin Double
return System.Windows.Rect

GetRotatedMatrix() public static method

public static GetRotatedMatrix ( Point centerOfRotation, Double angleToRotateDegrees ) : Matrix
centerOfRotation Point
angleToRotateDegrees Double
return Matrix

GetScreenDpi() public static method

public static GetScreenDpi ( Visual visual ) : Size
visual Visual
return System.Windows.Size

MovePointWithinBounds() public static method

public static MovePointWithinBounds ( Point point, Rect boundingRectangle ) : Point
point Point
boundingRectangle System.Windows.Rect
return Point

MoveRectangleWithinBounds() public static method

public static MoveRectangleWithinBounds ( Rect rectangle, Rect boundingRectangle, System.Boolean resizeRectangleIfNecessary ) : Rect
rectangle System.Windows.Rect
boundingRectangle System.Windows.Rect
resizeRectangleIfNecessary System.Boolean
return System.Windows.Rect

PointFToWpfPoint() public static method

public static PointFToWpfPoint ( System pointF ) : Point
pointF System
return System.Windows.Point

RectToRectangle() public static method

public static RectToRectangle ( System rect ) : System.Drawing.Rectangle
rect System
return System.Drawing.Rectangle

RectangleToRect() public static method

public static RectangleToRect ( System rectangle ) : Rect
rectangle System
return System.Windows.Rect

SetTextBlockFont() public static method

public static SetTextBlockFont ( System.Windows.Controls.TextBlock textBlock, System font ) : void
textBlock System.Windows.Controls.TextBlock
font System
return void

SetWpfColorAlpha() public static method

public static SetWpfColorAlpha ( System color, Byte newAlpha ) : Color
color System
newAlpha Byte
return System.Windows.Media.Color

SquareFromCenterAndHalfWidth() public static method

public static SquareFromCenterAndHalfWidth ( System center, Double halfWidth ) : Rect
center System
halfWidth Double
return System.Windows.Rect

SwapPoints() public static method

public static SwapPoints ( Point &point1, Point &point2 ) : void
point1 Point
point2 Point
return void

SystemDrawingFontSizeToWpfFontSize() public static method

public static SystemDrawingFontSizeToWpfFontSize ( Double windowsFormsFontSize ) : Double
windowsFormsFontSize Double
return Double

TransformLength() public static method

public static TransformLength ( Double length, Transform transform, System.Boolean transformAlongX ) : Double
length Double
transform System.Windows.Media.Transform
transformAlongX System.Boolean
return Double

TriangleBoundsFromCenterAndHalfWidth() public static method

public static TriangleBoundsFromCenterAndHalfWidth ( System center, Double halfWidth ) : Rect
center System
halfWidth Double
return System.Windows.Rect

VisualToBitmap() public static method

public static VisualToBitmap ( Visual visual, Int32 bitmapWidthPx, Int32 bitmapHeightPx ) : System.Drawing.Bitmap
visual Visual
bitmapWidthPx System.Int32
bitmapHeightPx System.Int32
return System.Drawing.Bitmap

WpfFontSizeToSystemDrawingFontSize() public static method

public static WpfFontSizeToSystemDrawingFontSize ( Double wpfFontSize ) : Double
wpfFontSize Double
return Double

WpfPointToPoint() public static method

public static WpfPointToPoint ( System point ) : System.Drawing.Point
point System
return System.Drawing.Point

WpfToPx() public static method

public static WpfToPx ( Double lengthWpf, Double screenDpi ) : Double
lengthWpf Double
screenDpi Double
return Double

Property Details

Cosine30Degrees public_oe static_oe property

public static Double Cosine30Degrees
return Double

Tangent30Degrees public_oe static_oe property

public static Double Tangent30Degrees
return Double