当前位置: 首页>>代码示例>>C#>>正文


C# RotateTransform.TransformBounds方法代码示例

本文整理汇总了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;
            


        }
开发者ID:Nokia-Developer-Community-Projects,项目名称:wp8-sample,代码行数:33,代码来源:ViewFinder.xaml.cs

示例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;
        }
开发者ID:Core2D,项目名称:Core2D,代码行数:59,代码来源:WpfRenderer.cs

示例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;

            }
        }
开发者ID:Nokia-Developer-Community-Projects,项目名称:wp8-sample,代码行数:59,代码来源:LIve.xaml.cs

示例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;
开发者ID:3DInstruments,项目名称:Kaliber3D,代码行数:66,代码来源:WpfRenderer.cs

示例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);
            }
        }
开发者ID:Nokia-Developer-Community-Projects,项目名称:real-time-filter-demo,代码行数:60,代码来源:MainPage.xaml.cs


注:本文中的System.Windows.Media.RotateTransform.TransformBounds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。