コード例 #1
0
ファイル: UIElementFactory.cs プロジェクト: dotnet/wpf-test
        public override UIElement Create(DeterministicRandom random)
        {
            UIElement uIElement = new UIElement();

            uIElement.AllowDrop        = random.NextBool();
            uIElement.ClipToBounds     = random.NextBool();
            uIElement.Focusable        = random.NextBool();
            uIElement.IsEnabled        = random.NextBool();
            uIElement.IsHitTestVisible = random.NextBool();
#if TESTBUILD_CLR40
            uIElement.IsManipulationEnabled = random.NextBool();
#endif
            uIElement.Opacity               = random.NextDouble();
            uIElement.Visibility            = random.NextEnum <Visibility>();
            uIElement.Effect                = Effect;
            uIElement.Clip                  = Geometry;
            uIElement.Opacity               = random.NextDouble();
            uIElement.OpacityMask           = Brush;
            uIElement.RenderSize            = Size;
            uIElement.RenderTransform       = Transform;
            uIElement.RenderTransformOrigin = Point;
            uIElement.SnapsToDevicePixels   = random.NextBool();

#if TESTBUILD_CLR40
            uIElement.CacheMode = BitmapCache;
#endif

            return(uIElement);
        }
コード例 #2
0
        public override object GetData(DeterministicRandom r)
        {
            double rangeX = MaxX - MinX;
            double rangeY = MaxY - MinY;

            return(new Point(MinX + rangeX * r.NextDouble(), MinY + rangeY * r.NextDouble()));
        }
コード例 #3
0
        public override BitmapPalette Create(DeterministicRandom random)
        {
            if (Colors == null)
            {
                Colors = new List <Color>();
            }

            if (random.NextBool())
            {
                for (int i = 1; i <= random.Next(256) + 1; i++)
                {
                    Colors.Add(Color.FromScRgb(
                                   (float)random.NextDouble(),
                                   (float)random.NextDouble(),
                                   (float)random.NextDouble(),
                                   (float)random.NextDouble()));
                }
            }
            else
            {
                for (int i = 1; i <= random.Next(256) + 1; i++)
                {
                    Colors.Add(random.NextStaticProperty <Colors, Color>());
                }
            }

            return(new BitmapPalette(Colors));
        }
コード例 #4
0
ファイル: Geometry3DFactory.cs プロジェクト: dotnet/wpf-test
        private MeshGeometry3D CreatePyramid(DeterministicRandom random)
        {
            Point3D point0 = new Point3D(0, 0, 5);
            Point3D point1 = new Point3D(5, 0, 0);
            Point3D point2 = new Point3D(0, 5, 0);
            Point3D point3 = new Point3D(0, 0, 0);

            MeshGeometry3D mesh = new MeshGeometry3D();

            mesh.Positions.Add(point0);
            mesh.Positions.Add(point1);
            mesh.Positions.Add(point2);
            mesh.Positions.Add(point3);

            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(2);
            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(2);
            mesh.TriangleIndices.Add(3);

            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(3);
            mesh.TriangleIndices.Add(2);
            mesh.TriangleIndices.Add(1);
            mesh.TriangleIndices.Add(0);
            mesh.TriangleIndices.Add(3);

            Vector3D normal0 = CalculateNormal(point0, point1, point2);

            mesh.Normals.Add(normal0);
            mesh.Normals.Add(normal0);
            mesh.Normals.Add(normal0);

            Vector3D normal1 = CalculateNormal(point0, point2, point3);

            mesh.Normals.Add(normal1);
            mesh.Normals.Add(normal1);
            mesh.Normals.Add(normal1);

            Vector3D normal2 = CalculateNormal(point1, point3, point2);

            mesh.Normals.Add(normal2);
            mesh.Normals.Add(normal2);
            mesh.Normals.Add(normal2);

            Vector3D normal3 = CalculateNormal(point1, point0, point3);

            mesh.Normals.Add(normal3);
            mesh.Normals.Add(normal3);
            mesh.Normals.Add(normal3);

            for (int i = 0; i < 12; i++)
            {
                mesh.TextureCoordinates.Add(new Point(random.NextDouble(), random.NextDouble()));
            }

            return(mesh);
        }
コード例 #5
0
        public override DirectionalLight Create(DeterministicRandom random)
        {
            DirectionalLight directionalLight = new DirectionalLight();

            ApplyLightProperties(directionalLight, random);
            directionalLight.Direction = new Vector3D(random.NextDouble() * 50, random.NextDouble() * 50, random.NextDouble() * 50);
            return(directionalLight);
        }
コード例 #6
0
        public override EmbossBitmapEffect Create(DeterministicRandom random)
        {
            EmbossBitmapEffect embossBitmapEffect = new EmbossBitmapEffect();

            embossBitmapEffect.LightAngle = random.NextDouble() * 360;
            embossBitmapEffect.Relief     = random.NextDouble() * 50;
            return(embossBitmapEffect);
        }
コード例 #7
0
ファイル: ShapeFactory.cs プロジェクト: dotnet/wpf-test
        public override Ellipse Create(DeterministicRandom random)
        {
            Ellipse shape = new Ellipse();

            ApplyShapeProperties(shape, random);
            shape.Width  = random.NextDouble() * 200;
            shape.Height = random.NextDouble() * 200;
            return(shape);
        }
コード例 #8
0
ファイル: TransformFactory.cs プロジェクト: dotnet/wpf-test
        public override RotateTransform Create(DeterministicRandom random)
        {
            RotateTransform rotateTransform = new RotateTransform();

            rotateTransform.Angle   = random.NextDouble() * 360;
            rotateTransform.CenterX = random.NextDouble() * 10;
            rotateTransform.CenterY = random.NextDouble() * 10;
            return(rotateTransform);
        }
コード例 #9
0
ファイル: TransformFactory.cs プロジェクト: dotnet/wpf-test
        public override SkewTransform Create(DeterministicRandom random)
        {
            SkewTransform skewTransform = new SkewTransform();

            skewTransform.AngleX  = random.NextDouble() * 30;
            skewTransform.AngleY  = random.NextDouble() * 30;
            skewTransform.CenterX = random.NextDouble() * 50;
            skewTransform.CenterY = random.NextDouble() * 50;
            return(skewTransform);
        }
コード例 #10
0
        public override OuterGlowBitmapEffect Create(DeterministicRandom random)
        {
            OuterGlowBitmapEffect outerGlowBitmapEffect = new OuterGlowBitmapEffect();

            outerGlowBitmapEffect.GlowColor = Color;
            outerGlowBitmapEffect.GlowSize  = random.NextDouble() * 40;
            outerGlowBitmapEffect.Noise     = random.NextDouble() * 40;
            outerGlowBitmapEffect.Opacity   = random.NextDouble();
            return(outerGlowBitmapEffect);
        }
コード例 #11
0
ファイル: TransformFactory.cs プロジェクト: dotnet/wpf-test
        public override ScaleTransform Create(DeterministicRandom random)
        {
            ScaleTransform scaleTransform = new ScaleTransform();

            scaleTransform.ScaleX  = random.NextDouble();
            scaleTransform.ScaleY  = random.NextDouble();
            scaleTransform.CenterX = random.NextDouble() * 10;
            scaleTransform.CenterY = random.NextDouble() * 10;
            return(scaleTransform);
        }
コード例 #12
0
        public override BevelBitmapEffect Create(DeterministicRandom random)
        {
            BevelBitmapEffect bevelBitmapEffect = new BevelBitmapEffect();

            bevelBitmapEffect.BevelWidth  = random.NextDouble() * 40;
            bevelBitmapEffect.EdgeProfile = random.NextEnum <EdgeProfile>();
            bevelBitmapEffect.LightAngle  = random.NextDouble() * 360;
            bevelBitmapEffect.Relief      = random.NextDouble() * 40;
            bevelBitmapEffect.Smoothness  = random.NextDouble() * 100;
            return(bevelBitmapEffect);
        }
コード例 #13
0
        public override SpotLight Create(DeterministicRandom random)
        {
            SpotLight light = new SpotLight();

            ApplyLightProperties(light, random);
            ApplyPointLightBaseProperties(light, random);
            light.Direction      = new Vector3D(random.NextDouble() * 10, random.NextDouble() * 10, random.NextDouble() * 10);
            light.InnerConeAngle = random.NextDouble() * 180;
            light.OuterConeAngle = random.NextDouble() * 180;
            return(light);
        }
コード例 #14
0
ファイル: ShapeFactory.cs プロジェクト: dotnet/wpf-test
        public override Rectangle Create(DeterministicRandom random)
        {
            Rectangle shape = new Rectangle();

            ApplyShapeProperties(shape, random);
            shape.Width   = random.NextDouble() * 200;
            shape.Height  = random.NextDouble() * 200;
            shape.RadiusX = random.NextDouble() * 100;
            shape.RadiusY = random.NextDouble() * 200;
            return(shape);
        }
コード例 #15
0
ファイル: ShapeFactory.cs プロジェクト: dotnet/wpf-test
        public override Line Create(DeterministicRandom random)
        {
            Line shape = new Line();

            ApplyShapeProperties(shape, random);
            shape.X1 = random.NextDouble() * 10;
            shape.Y1 = random.NextDouble() * 20;
            shape.X2 = random.NextDouble() * 100;
            shape.Y2 = random.NextDouble() * 100;
            return(shape);
        }
コード例 #16
0
        /// <summary>
        /// Create a RectangleStylusShape.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override RectangleStylusShape Create(DeterministicRandom random)
        {
            //Set Width and Height value (0, 10000].
            double width  = (1 - random.NextDouble()) * 10000;
            double height = (1 - random.NextDouble()) * 10000;
            //Set Rotation value [-720, 720).
            double rotation = (random.NextDouble() - 0.5) * 1440;

            RectangleStylusShape rectangleStylusShpae = new RectangleStylusShape(width, height, rotation);

            return(rectangleStylusShpae);
        }
コード例 #17
0
        public override DropShadowBitmapEffect Create(DeterministicRandom random)
        {
            DropShadowBitmapEffect dropShadowBitmapEffect = new DropShadowBitmapEffect();

            dropShadowBitmapEffect.Color       = Color;
            dropShadowBitmapEffect.Direction   = random.NextDouble() * 50;
            dropShadowBitmapEffect.Noise       = random.NextDouble() * 40;
            dropShadowBitmapEffect.Opacity     = random.NextDouble();
            dropShadowBitmapEffect.ShadowDepth = random.NextDouble();
            dropShadowBitmapEffect.Softness    = random.NextDouble();
            return(dropShadowBitmapEffect);
        }
コード例 #18
0
        /// <summary/>
        /// <param name="random"/>
        /// <returns>Return a new RadialGradientBrush</returns>
        public override RadialGradientBrush Create(DeterministicRandom random)
        {
            RadialGradientBrush brush = new RadialGradientBrush();

            ApplyGradientBrushProperties(brush, random);

            brush.Center         = Center;
            brush.GradientOrigin = GradientOrigin;
            brush.RadiusX        = GradientOrigin.X * 2 * random.NextDouble();
            brush.RadiusY        = GradientOrigin.Y * 2 * random.NextDouble();
            return(brush);
        }
コード例 #19
0
        public override object GetData(DeterministicRandom r)
        {
            if (r.NextBool())
            {
                Transform = new RotateTransform(r.Next(4) * 90, r.NextDouble() * 10, r.NextDouble() * 10);
            }
            else
            {
                Transform = new ScaleTransform(r.NextDouble(), r.NextDouble(), r.NextDouble() * 10, r.NextDouble() * 10);
            }

            return(Transform);
        }
コード例 #20
0
ファイル: CanvasFactory.cs プロジェクト: dotnet/wpf-test
        private void SetChildrenLayout(Canvas canvas, DeterministicRandom random)
        {
            foreach (UIElement item in canvas.Children)
            {
                switch (random.Next() % 4)
                {
                case 0:
                    Canvas.SetLeft(item, (random.NextDouble() - 0.5) * canvas.ActualWidth * 2);
                    Canvas.SetBottom(item, (random.NextDouble() - 0.5) * canvas.ActualHeight * 2);
                    break;

                case 1:
                    Canvas.SetLeft(item, (random.NextDouble() - 0.5) * canvas.ActualWidth * 2);
                    Canvas.SetTop(item, (random.NextDouble() - 0.5) * canvas.ActualHeight * 2);
                    break;

                case 2:
                    Canvas.SetRight(item, (random.NextDouble() - 0.5) * canvas.ActualWidth * 2);
                    Canvas.SetBottom(item, (random.NextDouble() - 0.5) * canvas.ActualHeight * 2);
                    break;

                case 3:
                    Canvas.SetRight(item, (random.NextDouble() - 0.5) * canvas.ActualWidth * 2);
                    Canvas.SetTop(item, (random.NextDouble() - 0.5) * canvas.ActualHeight * 2);
                    break;
                }
            }
        }
コード例 #21
0
ファイル: TimelineFactory.cs プロジェクト: dotnet/wpf-test
        protected void ApplyTimelineProperties(Timeline timeline, DeterministicRandom random)
        {
            //The sum of AccelerationRatio and DecelerationRatio must be less than or equal to 1.
            double accelerationRatio = random.NextDouble();
            double decelerationRatio = (1 - accelerationRatio) * random.NextDouble();

            timeline.AccelerationRatio = accelerationRatio;
            timeline.DecelerationRatio = decelerationRatio;
            timeline.AutoReverse       = random.NextBool();
            timeline.Duration          = TimeSpan.FromSeconds(random.Next(60));
            //Change value to (0,10];
            timeline.SpeedRatio     = 10 * random.NextDouble();
            timeline.RepeatBehavior = RepeatBehavior;
        }
コード例 #22
0
ファイル: Geometry3DFactory.cs プロジェクト: dotnet/wpf-test
        private MeshGeometry3D CreateCylinder(DeterministicRandom random)
        {
            int    thetaDiv = random.Next(40) + 10;
            int    yDiv     = random.Next(40) + 10;
            double radius   = random.NextDouble() * 20 + 1.0;

            double maxTheta = DegreeToRadian(360.0);
            double maxY     = random.Next(10) + 1;
            double minY     = -1 * maxY;

            double dt = maxTheta / thetaDiv;
            double dy = (maxY - minY) / yDiv;

            MeshGeometry3D mesh = new MeshGeometry3D();

            for (int yi = 0; yi <= yDiv; yi++)
            {
                double y = minY + yi * dy;

                for (int ti = 0; ti <= thetaDiv; ti++)
                {
                    double theta = ti * dt;

                    mesh.Positions.Add(GetCylinderVertexPosition(theta, y, radius));
                    mesh.Normals.Add((Vector3D)GetCylinderVertexPosition(theta, 0, 1.0));
                    mesh.TextureCoordinates.Add(new Point(random.NextDouble(), random.NextDouble()));
                }
            }

            for (int yi = 0; yi < yDiv; yi++)
            {
                for (int ti = 0; ti < thetaDiv; ti++)
                {
                    int x0 = ti;
                    int x1 = (ti + 1);
                    int y0 = yi * (thetaDiv + 1);
                    int y1 = (yi + 1) * (thetaDiv + 1);

                    mesh.TriangleIndices.Add(x0 + y0);
                    mesh.TriangleIndices.Add(x0 + y1);
                    mesh.TriangleIndices.Add(x1 + y0);

                    mesh.TriangleIndices.Add(x1 + y0);
                    mesh.TriangleIndices.Add(x0 + y1);
                    mesh.TriangleIndices.Add(x1 + y1);
                }
            }

            return(mesh);
        }
コード例 #23
0
 public override Color Create(DeterministicRandom random)
 {
     if (random.NextBool())
     {
         return(random.NextStaticProperty <Colors, Color>());
     }
     else
     {
         return(Color.FromScRgb(
                    (float)random.NextDouble(),
                    (float)random.NextDouble(),
                    (float)random.NextDouble(),
                    (float)random.NextDouble()));
     }
 }
コード例 #24
0
ファイル: ConstrainedSize.cs プロジェクト: dotnet/wpf-test
        public override object GetData(DeterministicRandom r)
        {
            double rangeWidth  = MaxWidth - MinWidth;
            double rangeHeight = MaxHeight - MinHeight;

            return(new Size(MinWidth + rangeWidth * r.NextDouble(), MinHeight + rangeHeight * r.NextDouble()));
        }
コード例 #25
0
ファイル: AccessTextFactory.cs プロジェクト: dotnet/wpf-test
        /// <summary>
        /// Create an AccessText.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override AccessText Create(DeterministicRandom random)
        {
            AccessText accessText = new AccessText();

            accessText.Background = Background;
            //Set BaselineOffset value [-10000, 10000).
            double baselineOffset = (random.NextDouble() - 0.5) * 20000;

            accessText.BaselineOffset       = baselineOffset;
            accessText.FontFamily           = FontFamily;
            accessText.FontSize             = FontSize;
            accessText.FontStretch          = random.NextStaticProperty <FontStretch>(typeof(FontStretches));
            accessText.FontStyle            = random.NextStaticProperty <FontStyle>(typeof(FontStyles));
            accessText.FontWeight           = random.NextStaticProperty <FontWeight>(typeof(FontWeights));
            accessText.Foreground           = Foreground;
            accessText.LineHeight           = GenerateLineHeightValue(random);
            accessText.LineStackingStrategy = random.NextEnum <LineStackingStrategy>();
            accessText.Text            = Text;
            accessText.TextAlignment   = random.NextEnum <TextAlignment>();
            accessText.TextDecorations = TextDecorations;
            accessText.TextEffects     = TextEffects;
            accessText.TextTrimming    = random.NextEnum <TextTrimming>();
            accessText.TextWrapping    = random.NextEnum <TextWrapping>();

            return(accessText);
        }
コード例 #26
0
        public override Figure Create(DeterministicRandom random)
        {
            Figure figure = new Figure();

            ApplyAnchoredBlockProperties(figure, random);
            figure.CanDelayPlacement = random.NextBool();
            figure.HorizontalAnchor  = random.NextEnum <FigureHorizontalAnchor>();
            figure.VerticalAnchor    = random.NextEnum <FigureVerticalAnchor>();
            figure.HorizontalOffset  = random.NextDouble() * 10;
            figure.VerticalOffset    = random.NextDouble() * 10;
            figure.Width             = Width;
            figure.Height            = Height;
            figure.WrapDirection     = random.NextEnum <WrapDirection>();

            return(figure);
        }
コード例 #27
0
        public override MediaElement Create(DeterministicRandom random)
        {
            MediaElement mediaElement = new MediaElement();

            mediaElement.Source = Uri;

            mediaElement.Volume           = random.NextDouble();
            mediaElement.ScrubbingEnabled = random.NextBool();

            if (IsControledWithClock && Timeline != null)
            {
                mediaElement.Clock = Timeline.CreateClock();
            }
            else
            {
                mediaElement.Source = Uri;
            }

            //Events

            mediaElement.BufferingEnded   += new System.Windows.RoutedEventHandler(BufferingEnded);
            mediaElement.BufferingStarted += new System.Windows.RoutedEventHandler(BufferingStarted);
            mediaElement.MediaOpened      += new System.Windows.RoutedEventHandler(MediaOpened);
            mediaElement.MediaFailed      += new EventHandler <System.Windows.ExceptionRoutedEventArgs>(MediaFailed);
            mediaElement.MediaEnded       += new System.Windows.RoutedEventHandler(MediaEnded);
            return(mediaElement);
        }
コード例 #28
0
        public override FigureLength Create(DeterministicRandom random)
        {
            double randomDouble = random.NextDouble();

            switch (random.NextEnum <FigureUnitType>())
            {
            case FigureUnitType.Auto:
                return(new FigureLength());

            case FigureUnitType.Pixel:
                return(new FigureLength(randomDouble * 300, FigureUnitType.Pixel));

            case FigureUnitType.Column:
                return(new FigureLength(randomDouble * 3, FigureUnitType.Column));

            case FigureUnitType.Content:
                return(new FigureLength(randomDouble, FigureUnitType.Content));

            case FigureUnitType.Page:
                return(new FigureLength(randomDouble, FigureUnitType.Page));

            default:
                goto case 0;
            }
        }
コード例 #29
0
ファイル: CameraFactory.cs プロジェクト: dotnet/wpf-test
        public override PerspectiveCamera Create(DeterministicRandom random)
        {
            PerspectiveCamera camera = new PerspectiveCamera();

            ApplyProjectionCameraProperties(camera, random);
            camera.FieldOfView = random.NextDouble() * 60;
            return(camera);
        }
コード例 #30
0
        public override BlurBitmapEffect Create(DeterministicRandom random)
        {
            BlurBitmapEffect blurBitmapEffect = new BlurBitmapEffect();

            blurBitmapEffect.Radius     = random.NextDouble() * 40;
            blurBitmapEffect.KernelType = random.NextEnum <KernelType>();
            return(blurBitmapEffect);
        }