本文整理汇总了C#中System.Windows.Media.RotateTransform.TransformBounds方法的典型用法代码示例。如果您正苦于以下问题:C# RotateTransform.TransformBounds方法的具体用法?C# RotateTransform.TransformBounds怎么用?C# RotateTransform.TransformBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.RotateTransform
的用法示例。
在下文中一共展示了RotateTransform.TransformBounds方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: computeVideoBruchTransform
void computeVideoBruchTransform()
{
if (m_captureDevice == null)
return;
var tmptransform = new RotateTransform() { Angle = m_orientationAngle + m_captureDevice.SensorRotationInDegrees };
var previewSize = tmptransform.TransformBounds(new Rect(new Point(), new Size(m_captureDevice.PreviewResolution.Width, m_captureDevice.PreviewResolution.Height)));
double s1 = viewfinderCanvas.ActualWidth / previewSize.Width;
double s2 = viewfinderCanvas.ActualHeight / previewSize.Height;
//fit out
double scale = m_Mode == StrechMode.UniformFill ? Math.Max(s1, s2) : Math.Min(s1, s2);
var t = new TransformGroup();
if (m_sensorLocation == CameraSensorLocation.Front)
{
t.Children.Add(new CompositeTransform() { Rotation = -(m_orientationAngle + m_captureDevice.SensorRotationInDegrees), CenterX = viewfinderCanvas.ActualWidth / 2, CenterY = viewfinderCanvas.ActualHeight / 2, ScaleX = scale, ScaleY = scale });
t.Children.Add(new ScaleTransform() { ScaleX = -1, CenterX = viewfinderCanvas.ActualWidth / 2, CenterY = viewfinderCanvas.ActualHeight / 2 });
}
else
{
t.Children.Add(new CompositeTransform() { Rotation = m_orientationAngle + m_captureDevice.SensorRotationInDegrees, CenterX = viewfinderCanvas.ActualWidth / 2, CenterY = viewfinderCanvas.ActualHeight / 2, ScaleX = scale, ScaleY = scale });
}
viewfinderBrush.Transform = t;
}
示例2: DrawLineArrowInternal
private static Point DrawLineArrowInternal(DrawingContext dc, double half, Pen pen, Brush brush, double x, double y, double angle, ArrowStyle style)
{
Point pt;
bool doRectTransform = angle % 90.0 != 0.0;
var rt = new RotateTransform(angle, x, y);
double rx = style.RadiusX;
double ry = style.RadiusY;
double sx = 2.0 * rx;
double sy = 2.0 * ry;
switch (style.ArrowType)
{
default:
case ArrowType.None:
{
pt = new Point(x, y);
}
break;
case ArrowType.Rectangle:
{
pt = rt.Transform(new Point(x - sx, y));
var rect = new Rect(x - sx, y - ry, sx, sy);
if (doRectTransform)
{
dc.PushTransform(rt);
DrawRectangleInternal(dc, half, brush, pen, style.IsStroked, style.IsFilled, ref rect);
dc.Pop();
}
else
{
var bounds = rt.TransformBounds(rect);
DrawRectangleInternal(dc, half, brush, pen, style.IsStroked, style.IsFilled, ref bounds);
}
}
break;
case ArrowType.Ellipse:
{
pt = rt.Transform(new Point(x - sx, y));
dc.PushTransform(rt);
var c = new Point(x - rx, y);
DrawEllipseInternal(dc, half, brush, pen, style.IsStroked, style.IsFilled, ref c, rx, ry);
dc.Pop();
}
break;
case ArrowType.Arrow:
{
pt = rt.Transform(new Point(x, y));
var p11 = rt.Transform(new Point(x - sx, y + sy));
var p21 = rt.Transform(new Point(x, y));
var p12 = rt.Transform(new Point(x - sx, y - sy));
var p22 = rt.Transform(new Point(x, y));
DrawLineInternal(dc, half, pen, style.IsStroked, ref p11, ref p21);
DrawLineInternal(dc, half, pen, style.IsStroked, ref p12, ref p22);
}
break;
}
return pt;
}
示例3: AdjustOrientation
private void AdjustOrientation()
{
if (_photoCaptureDevice != null)
{
double canvasAngle;
if (Orientation.HasFlag(PageOrientation.LandscapeLeft))
{
canvasAngle = _photoCaptureDevice.SensorRotationInDegrees - 90;
}
else if (Orientation.HasFlag(PageOrientation.LandscapeRight))
{
canvasAngle = _photoCaptureDevice.SensorRotationInDegrees + 90;
}
else // PageOrientation.PortraitUp
{
canvasAngle = _photoCaptureDevice.SensorRotationInDegrees;
}
var tmptransform = new RotateTransform() { Angle = canvasAngle };
var previewSize = tmptransform.TransformBounds(
new System.Windows.Rect(
new System.Windows.Point(),
new System.Windows.Size(_photoCaptureDevice.PreviewResolution.Width, _photoCaptureDevice.PreviewResolution.Height)
)
);
double s1 = viewfinderCanvas.ActualWidth / previewSize.Width;
double s2 = viewfinderCanvas.ActualHeight / previewSize.Height;
//video center match Viewfinder canvas center center
BackgroundVideoBrush.AlignmentX = AlignmentX.Center;
BackgroundVideoBrush.AlignmentY = AlignmentY.Center;
//Don't use a strech strategie.
BackgroundVideoBrush.Stretch = Stretch.None;
double scale = Math.Max(s1, s2); //UniformFill
// double scale = Math.Min(s1, s2); // Uniform
var t = new TransformGroup();
if (_cameraLocation == CameraSensorLocation.Front)
{
t.Children.Add(new CompositeTransform() { Rotation = -canvasAngle, CenterX = viewfinderCanvas.ActualWidth / 2, CenterY = viewfinderCanvas.ActualHeight / 2, ScaleX = scale, ScaleY = scale });
t.Children.Add(new ScaleTransform() { ScaleX = -1, CenterX = viewfinderCanvas.ActualWidth / 2, CenterY = viewfinderCanvas.ActualHeight / 2 });
}
else
{
t.Children.Add(new CompositeTransform() { Rotation = canvasAngle, CenterX = viewfinderCanvas.ActualWidth / 2, CenterY = viewfinderCanvas.ActualHeight / 2, ScaleX = scale, ScaleY = scale });
}
BackgroundVideoBrush.Transform = t;
}
}
示例4: Draw
//.........这里部分代码省略.........
var t1 = new RotateTransform(a1, x1, y1);
var t2 = new RotateTransform(a2, x2, y2);
Point pt1;
Point pt2;
// draw start arrow
double radiusX1 = sas.RadiusX;
double radiusY1 = sas.RadiusY;
double sizeX1 = 2.0 * radiusX1;
double sizeY1 = 2.0 * radiusY1;
switch (sas.ArrowType)
{
default:
case ArrowType.None:
{
pt1 = new Point(x1, y1);
}
break;
case ArrowType.Rectangle:
{
pt1 = t1.Transform(new Point(x1 - sizeX1, y1));
var rect = new Rect(x1 - sizeX1, y1 - radiusY1, sizeX1, sizeY1);
if (doRectTransform1)
{
_dc.PushTransform(t1);
DrawRectangleInternal(_dc, halfStartArrow, fillStartArrow, strokeStartArrow, sas.IsStroked, sas.IsFilled, ref rect);
_dc.Pop();
}
else
{
var bounds = t1.TransformBounds(rect);
DrawRectangleInternal(_dc, halfStartArrow, fillStartArrow, strokeStartArrow, sas.IsStroked, sas.IsFilled, ref bounds);
}
}
break;
case ArrowType.Ellipse:
{
pt1 = t1.Transform(new Point(x1 - sizeX1, y1));
_dc.PushTransform(t1);
var c = new Point(x1 - radiusX1, y1);
DrawEllipseInternal(_dc, halfStartArrow, fillStartArrow, strokeStartArrow, sas.IsStroked, sas.IsFilled, ref c, radiusX1, radiusY1);
_dc.Pop();
}
break;
case ArrowType.Arrow:
{
pt1 = t1.Transform(new Point(x1, y1));
var p11 = t1.Transform(new Point(x1 - sizeX1, y1 + sizeY1));
var p21 = t1.Transform(new Point(x1, y1));
var p12 = t1.Transform(new Point(x1 - sizeX1, y1 - sizeY1));
var p22 = t1.Transform(new Point(x1, y1));
DrawLineInternal(_dc, halfStartArrow, strokeStartArrow, sas.IsStroked, ref p11, ref p21);
DrawLineInternal(_dc, halfStartArrow, strokeStartArrow, sas.IsStroked, ref p12, ref p22);
}
break;
}
// draw end arrow
double radiusX2 = eas.RadiusX;
double radiusY2 = eas.RadiusY;
double sizeX2 = 2.0 * radiusX2;
double sizeY2 = 2.0 * radiusY2;
示例5: AdjustOrientation
private void AdjustOrientation()
{
if (_photoCaptureDevice != null)
{
double canvasAngle;
if (Orientation.HasFlag(PageOrientation.LandscapeLeft))
{
canvasAngle = _photoCaptureDevice.SensorRotationInDegrees - 90;
}
else if (Orientation.HasFlag(PageOrientation.LandscapeRight))
{
canvasAngle = _photoCaptureDevice.SensorRotationInDegrees + 90;
}
else // PageOrientation.PortraitUp
{
canvasAngle = _photoCaptureDevice.SensorRotationInDegrees;
}
var tmptransform = new RotateTransform() { Angle = canvasAngle };
var previewSize = tmptransform.TransformBounds(
new System.Windows.Rect(
new System.Windows.Point(),
new System.Windows.Size(_photoCaptureDevice.PreviewResolution.Width, _photoCaptureDevice.PreviewResolution.Height)
)
);
double s1 = viewfinderCanvas.ActualWidth / previewSize.Width;
double s2 = viewfinderCanvas.ActualHeight / previewSize.Height;
//video center match Viewfinder canvas center center
BackgroundVideoBrush.AlignmentX = AlignmentX.Center;
BackgroundVideoBrush.AlignmentY = AlignmentY.Center;
//Don't use a strech strategie.
BackgroundVideoBrush.Stretch = Stretch.None;
double scale = Math.Max(s1, s2); //UniformFill
// double scale = Math.Min(s1, s2); // Uniform
if (_photoCaptureDevice.SensorLocation == CameraSensorLocation.Back)
{
BackgroundVideoBrush.Transform = new CompositeTransform() { Rotation = canvasAngle, CenterX = viewfinderCanvas.ActualWidth / 2, CenterY = viewfinderCanvas.ActualHeight / 2, ScaleX = scale, ScaleY = scale };
}
else
{
//Front viewfinder need to be flipped
BackgroundVideoBrush.Transform = new CompositeTransform() { Rotation = canvasAngle, CenterX = viewfinderCanvas.ActualWidth / 2, CenterY = viewfinderCanvas.ActualHeight / 2, ScaleX = -scale, ScaleY = scale };
}
_photoCaptureDevice.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation, canvasAngle);
}
}