本文整理匯總了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
};
}
}
}