本文整理汇总了C#中System.Windows.Media.CompositeTransform.TransformBounds方法的典型用法代码示例。如果您正苦于以下问题:C# CompositeTransform.TransformBounds方法的具体用法?C# CompositeTransform.TransformBounds怎么用?C# CompositeTransform.TransformBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.CompositeTransform
的用法示例。
在下文中一共展示了CompositeTransform.TransformBounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CorrectViewfinderOrientation
// Ensure that the viewfinder is upright in LandscapeRight.
private void CorrectViewfinderOrientation(PageOrientation orientation)
{
if (cam != null)
{
double ang;
// LandscapeRight rotation when camera is on back of phone.
int landscapeRightRotation = 180;
int portraitRotation = 90;
// Change LandscapeRight rotation for front-facing camera.
if (cam.SensorLocation == CameraSensorLocation.Front)
{
portraitRotation = -90;
landscapeRightRotation = -180;
}
// Rotate video brush from camera.
if (orientation == PageOrientation.PortraitUp || orientation == PageOrientation.PortraitDown)
{
ang = portraitRotation;
}
else if (orientation == PageOrientation.LandscapeRight)
{
ang = landscapeRightRotation;
}
else
{
ang = 0;
}
var tf = new CompositeTransform() { Rotation = ang };
var previewSize = tf.TransformBounds(new System.Windows.Rect(new System.Windows.Point(), new System.Windows.Size(cam.PreviewResolution.Width, cam.PreviewResolution.Height)));
double s1 = Viewfinder.ActualWidth / (double)previewSize.Width;
double s2 = Viewfinder.ActualHeight / (double)previewSize.Height;
double scale = Math.Min(s1, s2);
if (cam.SensorLocation == CameraSensorLocation.Back)
{
ViewfinderBrush.Transform = new CompositeTransform()
{
Rotation = ang,
CenterX = Viewfinder.ActualWidth / 2,
CenterY = Viewfinder.ActualHeight / 2,
ScaleX = scale,
ScaleY = scale
};
}
else
{
double scaleY = scale;
double scaleX = scale;
if ((orientation & PageOrientation.Portrait) == PageOrientation.Portrait)
{
scaleY = scale * -1;
}
else
{
scaleX = scale * -1;
}
ViewfinderBrush.Transform = new CompositeTransform()
{
Rotation = ang,
CenterX = Viewfinder.ActualWidth / 2,
CenterY = Viewfinder.ActualHeight / 2,
ScaleX = scaleX,
ScaleY = scaleY
};
}
}
}