private Color RandomColor(DeterministicRandom random)
 {
     return(Color.FromArgb(unchecked ((byte)random.Next()),
                           unchecked ((byte)random.Next()),
                           unchecked ((byte)random.Next()),
                           unchecked ((byte)random.Next())));
 }
        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));
        }
Beispiel #3
0
        private void SetChildrenLayout(GridType grid, DeterministicRandom random)
        {
            int childrenCount = grid.Children.Count;

            //Add more rows and columns to make sure they are enough to set children layout.
            for (int i = 0; i < childrenCount; i++)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                grid.RowDefinitions.Add(new RowDefinition());
            }
            //Set children layout
            foreach (UIElement item in grid.Children)
            {
                int startRow    = random.Next() % grid.RowDefinitions.Count;
                int startColumn = random.Next() % grid.ColumnDefinitions.Count;

                Grid.SetColumn(item, startColumn);
                Grid.SetRow(item, startRow);

                if (random.NextBool())
                {
                    int spanColumn = random.Next() % (grid.ColumnDefinitions.Count - startColumn) + 1;
                    Grid.SetColumnSpan(item, spanColumn);
                }

                if (random.NextBool())
                {
                    int spanRow = random.Next() % (grid.RowDefinitions.Count - startRow) + 1;
                    Grid.SetRowSpan(item, spanRow);
                }
            }
        }
        public override InteropBitmap Create(DeterministicRandom random)
        {
            int  width             = random.Next(400) + 1;
            int  height            = random.Next(400) + 1;
            int  bytesPerPixel     = (int)((Format.BitsPerPixel + 7.0) / 8.0);
            uint bufferSizeInBytes = (uint)(width * height * bytesPerPixel);
            int  stride            = (int)(width * bytesPerPixel);

            IntPtr fileHandle = CreateFileMapping(INVALID_HANDLE_VALUE, IntPtr.Zero, PAGE_READWRITE, 0, bufferSizeInBytes, null);

            if (fileHandle == IntPtr.Zero)
            {
                throw new InvalidOperationException("Could not create a file mapping for the Interop Bitmap");
            }

            unsafe
            {
                IntPtr viewHandle = MapViewOfFile(fileHandle, FILE_MAP_ALL_ACCESS, 0, 0, bufferSizeInBytes);
                byte * pixels     = (byte *)viewHandle.ToPointer();

                DrawToBitmap(pixels, bufferSizeInBytes, random);

                UnmapViewOfFile(viewHandle);
            }

            InteropBitmap bitmap = (InteropBitmap)System.Windows.Interop.Imaging.CreateBitmapSourceFromMemorySection(fileHandle, width, height, Format, stride, 0);

            // store the file handle as a dependency property, so that the InteropBitmap action has access to it
            // and so that when the InteropBitmap is garbage collected, the handle will still be closed
            SafeFileHandle section = new SafeFileHandle(fileHandle, true);

            bitmap.SetValue(HandleProperty, section);

            return(bitmap);
        }
Beispiel #5
0
        /// <summary>
        /// The values in additionalValues that correspond to button properties must be 0 or 1.
        ///  -and-
        /// The number of values in additionalValues match the number of properties in stylusPointDescription minus 3.
        /// </summary>
        private int[] CreateAdditionalValues(IList <StylusPointPropertyInfo> properties, DeterministicRandom random)
        {
            if (StylusPointDescription == null)
            {
                return(null);
            }

            int arrayCount = StylusPointDescription.PropertyCount - 3;

            int[] additionalValues;
            if (arrayCount < 0)
            {
                return(null);
            }

            additionalValues = new int[arrayCount];

            for (int i = 0; i < arrayCount; i++)
            {
                if (properties[i].IsButton)
                {
                    additionalValues[i] = random.Next(2);
                }
                else
                {
                    additionalValues[i] = random.Next();
                }
            }

            return(additionalValues);
        }
Beispiel #6
0
        public static List <OrderEvent> GenerateSampleOrders(DateTime date, DeterministicRandom random, ILogger logger)
        {
            var orderList = new List <OrderEvent>();

            var startTime = date.Date.AddHours(9);

            var endTime = date.Date.AddHours(23);

            var currentTime = startTime;

            var ordernum = 0;

            while (currentTime < endTime)
            {
                if (random.Next(1, 101) > 55 && currentTime.Hour < 23)
                {
                    orderList.Add(CreateSampleOrder(
                                      TimeSpan.FromMinutes(random.Next(15, 31)), currentTime, ordernum, random));
                    ordernum++;
                }

                currentTime = currentTime.AddMinutes(1);
            }

            return(orderList);
        }
Beispiel #7
0
        public override GestureRecognizer Create(DeterministicRandom random)
        {
            ApplicationGesture[] allAppGestures = (ApplicationGesture[])Enum.GetValues(random.NextEnum <ApplicationGesture>().GetType());

            //Get a number of gestures we will enable
            int gestureCount = random.Next(allAppGestures.Length - 2) + 1;

            ArrayList enableGesturesArrayList = new ArrayList();

            //Fill the arraylist with the number of gestures we want to enable
            while (gestureCount > 0)
            {
                int index = random.Next(allAppGestures.Length);

                //If adding an AllGestures,reject it and continue to get the next gesture to add
                if (allAppGestures[index] == ApplicationGesture.AllGestures)
                {
                    continue;
                }

                bool gestureExists = false;

                //Check if the appgesture is already added. if there are duplicates, API throws exception
                for (int i = 0; i < enableGesturesArrayList.Count; i++)
                {
                    ApplicationGesture currentGesture = (ApplicationGesture)enableGesturesArrayList[i];
                    //Don't add something that already exists in the enableGestures list
                    if (allAppGestures[index] == currentGesture)
                    {
                        gestureExists = true;
                        break;
                    }
                }
                //Not added so far, add and continue
                if (gestureExists == false)
                {
                    enableGesturesArrayList.Add(allAppGestures[index]);
                    gestureCount--; //One less thing to add
                }
            }

            ApplicationGesture[] applicationGestureArray = (ApplicationGesture[])enableGesturesArrayList.ToArray(random.NextEnum <ApplicationGesture>().GetType());

            GestureRecognizer gestureRecognizer;

            if (random.NextBool())
            {
                gestureRecognizer = new GestureRecognizer(applicationGestureArray);
            }
            else
            {
                gestureRecognizer = new GestureRecognizer();
                gestureRecognizer.SetEnabledGestures(applicationGestureArray);
            }

            return(gestureRecognizer);
        }
Beispiel #8
0
        public override Int32Collection Create(DeterministicRandom random)
        {
            Int32Collection col = new Int32Collection();

            for (int i = 0; i < random.Next(20); i++)
            {
                col.Add(random.Next(100));
            }
            return(col);
        }
Beispiel #9
0
        public override RepeatButton Create(DeterministicRandom random)
        {
            RepeatButton repeatButton = new RepeatButton();

            ApplyContentControlProperties(repeatButton);
            repeatButton.Delay = random.Next(1000);
            // Interval need > 0
            repeatButton.Interval = random.Next(500) + 1;
            return(repeatButton);
        }
Beispiel #10
0
        /// <summary>
        /// Create a UniformGrid.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override UniformGrid Create(DeterministicRandom random)
        {
            UniformGrid grid = new UniformGrid();

            ApplyCommonProperties(grid, random);
            grid.Columns     = random.Next();
            grid.FirstColumn = random.Next(grid.Columns);
            grid.Rows        = random.Next();

            return(grid);
        }
        public override WriteableBitmap Create(DeterministicRandom random)
        {
            int width  = random.Next(400) + 1;
            int height = random.Next(400) + 1;

            WriteableBitmap       wbmp   = new WriteableBitmap(width, height, DpiX, DpiY, PixelFormat, GetPalette(PixelFormat, random));
            WriteableBitmapWriter writer = WriteableBitmapWriter.CreateWriter(height, wbmp.BackBufferStride, PixelFormat);

            writer.SetWriteableBitmapPixels(wbmp, new Int32Rect(0, 0, width, height), random);

            return(wbmp);
        }
        /// <summary>
        /// Create a StylusPointPropertyInfo.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override StylusPointPropertyInfo Create(DeterministicRandom random)
        {
            StylusPointProperty stylusPointProperty = random.NextStaticField <StylusPointProperty>(typeof(StylusPointProperties));
            int minimum = random.Next(10000);
            int maximum = random.Next(10000) + minimum;
            StylusPointPropertyUnit unit = random.NextEnum <StylusPointPropertyUnit>();
            float resolution             = random.Next(100) / 10f;

            StylusPointPropertyInfo stylusPointPropertyInfo = new StylusPointPropertyInfo(stylusPointProperty, minimum, maximum, unit, resolution);

            return(stylusPointPropertyInfo);
        }
Beispiel #13
0
        /// <summary>
        /// Creates a new Window with random size, position, style, and background.
        /// Currently only used to create an Owner window for the window we are started with.
        /// </summary>
        public override Window Create(DeterministicRandom random)
        {
            Window window = new Window();

            window.Top         = random.Next((int)(SystemParameters.PrimaryScreenHeight * 0.8));
            window.Left        = random.Next((int)(SystemParameters.PrimaryScreenWidth * 0.8));
            window.Height      = random.Next((int)(SystemParameters.PrimaryScreenHeight * 0.4));
            window.Width       = random.Next((int)(SystemParameters.PrimaryScreenWidth * 0.4));
            window.WindowStyle = random.NextEnum <WindowStyle>();
            window.Background  = Brush;
            window.Show();

            return(window);
        }
Beispiel #14
0
        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);
        }
Beispiel #15
0
        public bool CheckOrder(Order order)
        {
            if (!Busy)
            {
                if (OrdersDone > 15)
                {
                    if (OrdersDone > 30)
                    {
                        ForgotToTake = rnd.Next(0, 25) != 0;
                    }
                    else
                    {
                        ForgotToTake = rnd.Next(0, 4) != 0;
                    }
                }
                else
                {
                    ForgotToTake = rnd.Next(0, 2) == 0;
                }

                if (!ForgotToTake)
                {
                    if (order.State == "Is Waiting To Be Cooked")
                    {
                        if (!order.TakenToCook)
                        {
                            _logger.Log($"Pizzamaker number {PizzamakerNum} Took Order number{order.OrderNumber} ");
                            order.TakenToCook = true;
                            Busy = true;
                            order.OrderTakenForCookingTime = order.CurrentTime;
                            return(true);
                        }
                    }
                }
            }
            else
            {
                if (order.CurrentTime != order.OrderTakenForCookingTime + order.TimeToCook)
                {
                    return(false);
                }
                Busy = false;
                OrdersDone++;
                _logger.Log($"Pizzamaker number {PizzamakerNum} is free.");
                return(true);
            }

            return(false);
        }
Beispiel #16
0
 private unsafe void DrawToBitmap(byte *buffer, uint size, DeterministicRandom random)
 {
     for (uint i = 0; i < size; i++)
     {
         buffer[i] = unchecked ((byte)random.Next());
     }
 }
Beispiel #17
0
        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;
                }
            }
        }
Beispiel #18
0
        public override MeshGeometry3D Create(DeterministicRandom random)
        {
            MeshGeometry3D mesh = new MeshGeometry3D();

            switch (random.Next(5))
            {
            case 0:
                mesh = CreatePlane(random);
                break;

            case 1:
                mesh = CreatePyramid(random);
                break;

            case 2:
                mesh = CreateCube(random);
                break;

            case 3:
                mesh = CreateSphere(random);
                break;

            case 4:
                mesh = CreateCylinder(random);
                break;

            default:
                goto case 0;
            }
            return(mesh);
        }
Beispiel #19
0
        private static object MakeList(Type consumedType, ConvenienceStressState state, DeterministicRandom random, int recursionDepth, int minListSize, int maxListSize)
        {
            //The Stress consumer is asking for a list of objects. This is a bit of a complicated topic. Refer to:
            //Reflecting on Generics - This explains how I am identifying List Generic
            //http://cc.msnscache.com/cache.aspx?q=72938808547333&mkt=en-US&lang=en-US&w=d704070d&FORM=CVRE7
            //
            //From there, we need to create an instance of the requested generic, as explained here.
            //http://www.codeproject.com/KB/cs/ReflectGenerics.aspx

            //The type of objects instantiated in the list is instanceType:
            Type[] genericArguments = consumedType.GetGenericArguments();
            Type   instanceType     = genericArguments[0];

            //Prepare our List
            object list = Activator.CreateInstance(consumedType, 1);

            //Create a single element  array as payload for adding objects to list via reflection
            object[] methodCallPayload = new object[1];

            int count = random.Next(maxListSize - minListSize) + minListSize;

            for (int i = 0; i < count; i++)
            {
                //We produce an item from a differently selected factory each time.
                methodCallPayload[0] = MakeItem(instanceType, state, random, recursionDepth);
                consumedType.InvokeMember("Add", BindingFlags.InvokeMethod, null, list, methodCallPayload);
            }
            return(list);
        }
Beispiel #20
0
        /// <summary>
        /// Create a Uri using one of the files specified in ListOfFilesOnFileHost.xml.
        /// For Uris created with different files, modify ListOfFilesOnFileHost.xml.
        /// </summary>
        /// <param name="random"></param>
        /// <returns></returns>
        public override Uri Create(DeterministicRandom random)
        {
            XmlDocument document = new XmlDocument();

            document.Load(filesOnFileHost);
            XmlNodeList files     = document.GetElementsByTagName("File");
            int         fileCount = files.Count;

            if (fileCount == 0)
            {
                throw new InvalidOperationException(String.Format("File: {0} doesn't contain any File node.", filesOnFileHost));
            }

            int fileIndex = random.Next(fileCount);

            XmlElement fileNode = files[fileIndex] as XmlElement;
            string     filename = fileNode.GetAttribute("Name");

            if (String.IsNullOrEmpty(filename))
            {
                throw new InvalidOperationException(String.Format("File node : \n {0} doesn't have Name attribute.", fileNode.OuterXml));
            }

            FileHost fileHost = new FileHost();

            Uri uri = fileHost.GetUri(filename, Scheme);

            return(uri);
        }
        public override DispatcherOperation Create(DeterministicRandom random)
        {
            DispatcherPriority  priority  = ChooseValidPriority(PriorityValue);
            DispatcherOperation operation = null;

            switch (InvokeCallbackType)
            {
            case InvokeCallbackTypes.DispatcherOperationCallback:
                operation = Dispatcher.BeginInvoke(priority, new DispatcherOperationCallback(DispatcherOperationCallbackMethod), this);
                break;

            case InvokeCallbackTypes.SendOrPostCallback:
                operation = Dispatcher.BeginInvoke(priority, new SendOrPostCallback(SendOrPostMethod), this);
                break;

            case InvokeCallbackTypes.OneParamGeneric:
                operation = Dispatcher.BeginInvoke(priority, new OneParamGeneric(OneParamMethod), this);
                break;

            case InvokeCallbackTypes.TwoParamGeneric:
                operation = Dispatcher.BeginInvoke(priority, new TwoParamGeneric(TwoParamMethod), this, new object());
                break;

            case InvokeCallbackTypes.ThreeParamGeneric:
                operation = Dispatcher.BeginInvoke(priority, new ThreeParamGeneric(ThreeParamMethod), this, new object(), new object());
                break;

            case InvokeCallbackTypes.ZeroParamGeneric:
                operation = Dispatcher.BeginInvoke(priority, new ZeroParamGeneric(ZeroParamMethod));
                break;
            }

            operation.Aborted   += new EventHandler(OperationAborted);
            operation.Completed += new EventHandler(OperationCompleted);

            //Save the DispatcherOperation, Some combinations of actions need do on the same DispatcherOperation.
            lock (DispatcherOperations)
            {
                DispatcherOperations.Add(operation);
                if (DispatcherOperations.Count > 10)
                {
                    DispatcherOperations.RemoveAt(random.Next(DispatcherOperations.Count));
                }

                return(DispatcherOperations[random.Next(DispatcherOperations.Count)]);
            }
        }
Beispiel #22
0
        private MeshGeometry3D CreateSphere(DeterministicRandom random)
        {
            int    thetaDiv = random.Next(80) + 20;
            int    phiDiv   = random.Next(40) + 10;
            double radius   = random.NextDouble() * 20 + 1.0;

            double divTheta = DegreeToRadian(360.0) / thetaDiv;
            double divPhi   = DegreeToRadian(180.0) / phiDiv;

            MeshGeometry3D mesh = new MeshGeometry3D();

            for (int pi = 0; pi <= phiDiv; pi++)
            {
                double phi = pi * divPhi;

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

                    mesh.Positions.Add(GetSphereVertexPosition(theta, phi, radius));
                    mesh.Normals.Add((Vector3D)GetSphereVertexPosition(theta, phi, 1.0));
                    mesh.TextureCoordinates.Add(new Point(random.NextDouble(), random.NextDouble()));
                }
            }

            for (int pi = 0; pi < phiDiv; pi++)
            {
                for (int ti = 0; ti < thetaDiv; ti++)
                {
                    int x0 = ti;
                    int x1 = (ti + 1);
                    int y0 = pi * (thetaDiv + 1);
                    int y1 = (pi + 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);
        }
Beispiel #23
0
 /// <summary>
 /// Apply common Selector properties.
 /// </summary>
 /// <param name="selector"></param>
 /// <param name="random"></param>
 protected void ApplySelectorProperties(T selector, DeterministicRandom random)
 {
     ApplyItemsControlProperties(selector, random);
     selector.IsSynchronizedWithCurrentItem = random.NextBool();
     selector.SelectedIndex = random.Next(selector.Items.Count);
     selector.SelectedItem  = SelectedItem;
     selector.SelectedValue = SelectedValue;
 }
 /// <summary>
 /// Apply common TextBox properties.
 /// </summary>
 /// <param name="textBox"></param>
 /// <param name="random"></param>
 protected void ApplyTextBoxProperties(TextBoxType textBox, DeterministicRandom random)
 {
     ApplyTextBoxBaseProperties(textBox, random);
     textBox.MinLines  = MinLines;
     textBox.MaxLines  = MinLines + random.Next(50);
     textBox.MaxLength = MaxLength;
     textBox.Text      = Text;
 }
Beispiel #25
0
        public override DispatcherTimer Create(DeterministicRandom random)
        {
            //DispatcherTimer timer = null;
            DispatcherPriority priority = ChooseValidPriority(PriorityValue);

            switch (DispatcherTimerConstructorType % 4)
            {
            case 0:
                timer          = new DispatcherTimer();
                timer.Tick    += new EventHandler(DispatcherTimerTick);
                timer.Interval = TimeSpan;
                break;

            case 1:
                timer          = new DispatcherTimer(priority);
                timer.Tick    += new EventHandler(DispatcherTimerTick);
                timer.Interval = TimeSpan;
                break;

            case 2:
                timer          = new DispatcherTimer(priority, Dispatcher);
                timer.Tick    += new EventHandler(DispatcherTimerTick);
                timer.Interval = TimeSpan;
                break;

            case 3:
                timer = new DispatcherTimer(TimeSpan, priority, new EventHandler(DispatcherTimerTick), Dispatcher);
                break;
            }

            //Save the DispatcherTimer, Some combinations of actions need do on the same DispatcherTimer.
            lock (DispatcherTimers)
            {
                DispatcherTimers.Add(timer);
                if (DispatcherTimers.Count > 10)
                {
                    int             removeIndex = random.Next(DispatcherTimers.Count);
                    DispatcherTimer removeTimer = DispatcherTimers[removeIndex];
                    //Stop the DispatcherTimer before remove it.
                    removeTimer.Stop();
                    DispatcherTimers.Remove(removeTimer);
                }

                return(DispatcherTimers[random.Next(DispatcherTimers.Count)]);
            }
        }
Beispiel #26
0
        public Library(double revision, DeterministicRandom random)
        {
            int books = random.Next(10);

            for (int i = 0; i < books; i++)
            {
                Add(new Book(i + revision, random));
            }
        }
        public override void SetWriteableBitmapPixels(WriteableBitmap wbmp, Int32Rect rect, DeterministicRandom random)
        {
            for (int i = 0; i < pixels.Length; i++)
            {
                pixels[i] = unchecked ((byte)random.Next());
            }

            wbmp.WritePixels(rect, pixels, strideInBytes, rect.X, rect.Y);
        }
Beispiel #28
0
        public override CroppedBitmap Create(DeterministicRandom random)
        {
            int maxX   = BitmapSource.PixelWidth;
            int maxY   = BitmapSource.PixelHeight;
            int width  = random.Next(maxX) + 1;
            int height = random.Next(maxY) + 1;
            int x      = maxX - width;
            int y      = maxY - height;

            CroppedBitmap croppedBitmap = new CroppedBitmap();

            croppedBitmap.BeginInit();
            croppedBitmap.Source     = BitmapSource;
            croppedBitmap.SourceRect = new Int32Rect(x, y, width, height);
            croppedBitmap.EndInit();
            croppedBitmap.Freeze();
            return(croppedBitmap);
        }
Beispiel #29
0
        public override PrintDialog Create(DeterministicRandom random)
        {
            PrintDialog printDialog = new PrintDialog();

            printDialog.MinPage              = (uint)MinPage;
            printDialog.MaxPage              = (uint)(MinPage + random.Next(10));
            printDialog.PageRangeSelection   = random.NextEnum <PageRangeSelection>();
            printDialog.UserPageRangeEnabled = random.NextBool();
            return(printDialog);
        }
Beispiel #30
0
        Double[] CreateAxisLines(DeterministicRandom random)
        {
            int size = random.Next(10);

            Double[] axisline = new Double[size];
            for (int i = 0; i < size; i++)
            {
                axisline[i] = random.NextDouble() * 10;
            }
            return(axisline);
        }