Пример #1
0
        private void OnFrame(object sender, EventArgs e)
        {
            this.currentTick = System.Environment.TickCount;
            this.elapsed     = (double)(this.currentTick - this.lastTick) / 1000.0;
            this.lastTick    = this.currentTick;

            frameCount++;
            frameCountTime += elapsed;
            if (frameCountTime >= 1.0)
            {
                frameCountTime -= 1.0;
                Context.IncrementCounter(frameCount);
                frameCount = 0;
            }

            for (int index = 0; index < _images.Length; index++)
            {
                if (!DefaultSize)
                {
                    _images[index].Width  = RandomInteger.NextInteger(200);
                    _images[index].Height = RandomInteger.NextInteger(200);
                }

                Canvas.SetLeft(_images[index], RandomInteger.NextInteger(Width / 2));
                Canvas.SetTop(_images[index], RandomInteger.NextInteger(Height / 2));
            }
        }
Пример #2
0
        public void ExecuteWrites()
        {
            lock (_syncRoot)
            {
                int position;

                if (_fileStream.Length < FileSize)
                {
                    position = Math.Min(FileSize - ChunkSize, (int)_fileStream.Length);
                }
                else
                {
                    position = RandomInteger.NextInteger(FileSize - ChunkSize);
                }

                _fileStream.Seek(position, SeekOrigin.Begin);
                int sizeToWrite = ChunkSize;
                while (sizeToWrite > 0)
                {
                    _fileStream.Write(_buffer, 0, Math.Min(BufferSize, sizeToWrite));
                    sizeToWrite -= BufferSize;
                }
                _fileStream.Flush();
            }
        }
        public override void SetUp()
        {
            _canvas            = new Canvas();
            _canvas.Background = new SolidColorBrush(Colors.White);
            _labels            = new Label[LinesCount];

            _window            = new Window();
            _window.Width      = Width;
            _window.Height     = Height;
            _window.Content    = _canvas;
            _window.Background = new SolidColorBrush(Colors.Black);
            _window.Closed    += OnWindowClosed;
            _window.Show();

            for (int index = 0; index < _labels.Length; index++)
            {
                Color color = Color.FromArgb((byte)RandomInteger.NextInteger(255),
                                             (byte)RandomInteger.NextInteger(255), (byte)RandomInteger.NextInteger(255), (byte)RandomInteger.NextInteger(255));

                _labels[index] = new Label();
                _canvas.Children.Add(_labels[index]);
                _labels[index].Content = RandomDouble.NextDouble(1.0).ToString();
                Canvas.SetLeft(_labels[index], RandomInteger.NextInteger(Width));
                Canvas.SetTop(_labels[index], RandomInteger.NextInteger(Height));
            }

            lastTick             = System.Environment.TickCount;
            _frameTimer          = new System.Windows.Threading.DispatcherTimer();
            _frameTimer.Tick    += OnFrame;
            _frameTimer.Interval = TimeSpan.FromSeconds(1.0 / 60.0);
            _frameTimer.Start();
        }
Пример #4
0
        public IActionResult Index()
        {
            var client = new HttpClient();

            // Creating a new HttpClient instance per request can exhaust the available sockets). So you should consider removing Using(). using(var cli = new HttpClient()){//....}

            client.BaseAddress = new Uri(BASE_URL);

            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // BAAKK

            HttpResponseMessage responseRandom = client.GetAsync("api/random").GetAwaiter().GetResult();

            if (responseRandom.IsSuccessStatusCode)
            {
                var responseAPI = responseRandom.Content.ReadAsStringAsync().Result;

                RandomInteger random = new RandomInteger();
                random.RandomInt = Convert.ToInt32(responseAPI);

                return(View(random));
            }

            return(View());
        }
Пример #5
0
        public void ExecuteDrawBitmapFast()
        {
            lock (_syncRoot)
            {
                int x = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowWidth + MaxLength);
                int y = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowHeight + MaxLength);

                _outputGraphics.DrawImage(Images[RandomInteger.NextInteger(0, Images.Length)], x, y);
            }
        }
        protected string GetMemoValue()
        {
            StringBuilder builder = new StringBuilder();

            while (builder.Length < BlobFieldSize)
            {
                builder.Append(_memoValues[RandomInteger.NextInteger(0, _memoValues.Count)]);
            }
            builder.Length = BlobFieldSize;
            return(builder.ToString());
        }
Пример #7
0
 public void ExecuteReadsAndWrites()
 {
     if (_fileStream.Length == 0 || RandomInteger.NextInteger(2) == 0)
     {
         ExecuteWrites();
     }
     else
     {
         ExecuteReads();
     }
 }
Пример #8
0
        public static BeaconV1[] CreateBeacons()
        {
            var result = new List <BeaconV1>();
            var count  = RandomInteger.NextInteger(1, 5);

            for (var i = 0; i < count; i++)
            {
                result.Add(CreateBeacon());
            }
            return(result.ToArray());
        }
        public static string[] Tags()
        {
            var count = RandomInteger.NextInteger(0, 5);
            var tags  = new string[count];

            for (var index = 0; index < count; index++)
            {
                tags[index] = RandomText.Word().ToLower();
            }

            return(tags);
        }
        private static List <string> RandomStringList(int minCount, int maxCount, int itemSize)
        {
            int count  = Math.Max(0, minCount + RandomInteger.NextInteger(maxCount - minCount));
            var result = new List <string>(count);

            for (int index = 0; index < count; index++)
            {
                result.Add(RandomString.NextString(itemSize, itemSize));
            }

            return(result);
        }
 private void AppendNewDataItems(int count)
 {
     for (int index = 0; index < count; index++)
     {
         _dataItems.Add(new DataItem()
         {
             Age          = RandomInteger.NextInteger(100),
             Name         = "Name #" + _dataItems.Count,
             RandomNumber = RandomDouble.NextDouble(1.0) * 1000
         });
     }
 }
        public async Task OpenAsync(string correlationId)
        {
            if (_timer != null)
            {
                await Task.Run(() => _timer.Dispose());
            }

            var timeout = RandomInteger.NextInteger(this._minTimeout, this._maxTimeout);

            TimerCallback callback = new TimerCallback((object state) => Shutdowns());

            _timer = new Timer(callback, null, 0, timeout);
        }
Пример #13
0
 public static BeaconV1 CreateBeacon()
 {
     return(new BeaconV1()
     {
         Id = RandomString.NextString(10, 20),
         SiteId = RandomString.NextString(10, 20),
         Type = RandomText.Word(),
         Udi = RandomString.NextString(10, 20),
         Label = RandomText.Word(),
         Center = new CenterObject(RandomText.Word(), new int[] { RandomInteger.NextInteger(1, 10), RandomInteger.NextInteger(1, 10) }),
         Radius = RandomDouble.NextDouble(100.0)
     });
 }
Пример #14
0
        public void ExecuteDrawBitmap()
        {
            lock (_syncRoot)
            {
                int x = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowWidth + MaxLength);
                int y = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowHeight + MaxLength);

#if !CompactFramework
                _outputGraphics.DrawImageUnscaled(Images[RandomInteger.NextInteger(0, Images.Length)], x, y);
#else
                _outputGraphics.DrawImage(Images[RandomInteger.NextInteger(0, Images.Length)], x, y);
#endif
            }
        }
Пример #15
0
        public void ExecuteDrawLine()
        {
            lock (_syncRoot)
            {
                int xStart = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowWidth + MaxLength);
                int yStart = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowHeight + MaxLength);
                int xEnd   = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowWidth + MaxLength);
                int yEnd   = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowHeight + MaxLength);

                using (Pen pen = new Pen(GetRandomColor(), 1 + RandomInteger.NextInteger(5)))
                {
                    _outputGraphics.DrawLine(pen, xStart, yStart, xEnd, yEnd);
                }
            }
        }
Пример #16
0
        public void ExecuteDrawRectangle()
        {
            lock (_syncRoot)
            {
                int xStart = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowWidth + MaxLength);
                int yStart = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowHeight + MaxLength);
                int xEnd   = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowWidth + MaxLength);
                int yEnd   = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowHeight + MaxLength);

                using (Brush brush = new SolidBrush(GetRandomColor()))
                {
                    _outputGraphics.FillRectangle(brush, Math.Min(xStart, xEnd),
                                                  Math.Min(yStart, yEnd), Math.Abs(xEnd - xStart), Math.Abs(yEnd - yStart));
                }
            }
        }
Пример #17
0
        public void ExecuteDrawBitmapScaled()
        {
            lock (_syncRoot)
            {
                Image image  = Images[RandomInteger.NextInteger(0, Images.Length)];
                int   x      = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowWidth + MaxLength);
                int   y      = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowHeight + MaxLength);
                int   width  = RandomInteger.NextInteger(10, image.Width);
                int   height = RandomInteger.NextInteger(10, image.Height);

#if !CompactFramework
                _outputGraphics.DrawImage(image, x, y, width, height);
#else
                _outputGraphics.DrawImage(image, x, y);
#endif
            }
        }
Пример #18
0
        public override void Execute()
        {
            if (_fileStream == null)
            {
                return;
            }

            lock (_syncRoot)
            {
                if (_fileStream.Length == 0 || RandomInteger.NextInteger(2) == 0)
                {
                    int position;

                    if (_fileStream.Length < FileSize)
                    {
                        position = Math.Min(FileSize - ChunkSize, (int)_fileStream.Length);
                    }
                    else
                    {
                        position = RandomInteger.NextInteger(FileSize - ChunkSize);
                    }

                    _fileStream.Seek(position, SeekOrigin.Begin);
                    int sizeToWrite = ChunkSize;
                    while (sizeToWrite > 0)
                    {
                        _fileStream.Write(_buffer, 0, Math.Min(BufferSize, sizeToWrite));
                        sizeToWrite -= BufferSize;
                    }
                    _fileStream.Flush();
                }
                else
                {
                    int position = RandomInteger.NextInteger((int)_fileStream.Length - ChunkSize);
                    _fileStream.Seek(position, SeekOrigin.Begin);

                    int sizeToRead = ChunkSize;
                    while (sizeToRead > 0)
                    {
                        _fileStream.Read(_buffer, 0, Math.Min(BufferSize, sizeToRead));
                        sizeToRead -= BufferSize;
                    }
                }
            }
        }
Пример #19
0
        public void ExecuteReads()
        {
            lock (_syncRoot)
            {
                if (_fileStream.Length > 0)
                {
                    int position = RandomInteger.NextInteger((int)_fileStream.Length - ChunkSize);
                    _fileStream.Seek(position, SeekOrigin.Begin);

                    int sizeToRead = ChunkSize;
                    while (sizeToRead > 0)
                    {
                        _fileStream.Read(_buffer, 0, Math.Min(BufferSize, sizeToRead));
                        sizeToRead -= BufferSize;
                    }
                }
            }
        }
Пример #20
0
        private static string RandomGuideType()
        {
            var num = RandomInteger.NextInteger(1, 3);

            switch (num)
            {
            case 1:
                return(GuideTypeV1.Home);

            case 2:
                return(GuideTypeV1.Introduction);

            case 3:
                return(GuideTypeV1.NewRelease);

            default:
                return(null);
            }
        }
Пример #21
0
        public override void Execute()
        {
            if (_outputGraphics == null)
            {
                return;
            }

#if !CompactFramework
            int windowWidth  = _outputForm.Width;
            int windowHeight = _outputForm.Height;
#else
            int windowWidth  = Screen.PrimaryScreen.Bounds.Width;
            int windowHeight = Screen.PrimaryScreen.Bounds.Height;
#endif

            int xStart = -MaxLength / 2 + RandomInteger.NextInteger(windowWidth + MaxLength);
            int yStart = -MaxLength / 2 + RandomInteger.NextInteger(windowHeight + MaxLength);
            int xEnd   = -MaxLength / 2 + RandomInteger.NextInteger(windowWidth + MaxLength);
            int yEnd   = -MaxLength / 2 + RandomInteger.NextInteger(windowHeight + MaxLength);

            if (RandomInteger.NextInteger(2) == 0)
            {
                lock (_syncRoot)
                {
                    using (Pen pen = new Pen(GetRandomColor(), 1 + RandomInteger.NextInteger(5)))
                    {
                        _outputGraphics.DrawLine(pen, xStart, yStart, xEnd, yEnd);
                    }
                }
            }
            else
            {
                lock (_syncRoot)
                {
                    using (Brush brush = new SolidBrush(GetRandomColor()))
                    {
                        _outputGraphics.FillRectangle(brush, Math.Min(xStart, xEnd),
                                                      Math.Min(yStart, yEnd), Math.Abs(xEnd - xStart), Math.Abs(yEnd - yStart));
                    }
                }
            }
        }
Пример #22
0
        public void ExecuteDrawText()
        {
            lock (_syncRoot)
            {
                int x = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowWidth + MaxLength);
                int y = -MaxLength / 2 + RandomInteger.NextInteger(MaxWindowHeight + MaxLength);

                using (Brush brush = new SolidBrush(GetRandomColor()))
                {
                    FontFamily fontFamily;
#if !CompactFramework
                    do
                    {
                        fontFamily = FontFamily.Families[
                            RandomInteger.NextInteger(0, FontFamily.Families.Length)];
                    } while (!fontFamily.IsStyleAvailable(FontStyle.Regular));
#else
                    switch (RandomInteger.NextInteger(3))
                    {
                    case 0:
                        fontFamily = FontFamily.GenericSansSerif;
                        break;

                    case 1:
                        fontFamily = FontFamily.GenericSerif;
                        break;

                    default:
                        fontFamily = FontFamily.GenericMonospace;
                        break;
                    }
#endif

                    using (Font font = new Font(fontFamily,
                                                RandomInteger.NextInteger(6, 32), FontStyle.Regular))
                    {
                        _outputGraphics.DrawString("Draw Text", font, brush, x, y);
                    }
                }
            }
        }
Пример #23
0
        private void OnFrame(object sender, EventArgs e)
        {
            currentTick = System.Environment.TickCount;
            elapsed     = (double)(this.currentTick - this.lastTick) / 1000.0;
            lastTick    = this.currentTick;

            frameCount++;
            frameCountTime += elapsed;
            if (frameCountTime >= 1.0)
            {
                frameCountTime -= 1.0;
                Context.IncrementCounter(frameCount);
                frameCount = 0;
            }

            for (int index = 0; index < _labels.Length; index++)
            {
                _labels[index].Content = RandomDouble.NextDouble(1.0).ToString();
                Canvas.SetLeft(_labels[index], RandomInteger.NextInteger(Width));
                Canvas.SetTop(_labels[index], RandomInteger.NextInteger(Height));
            }
        }
        public static string NextBeaconType()
        {
            var choice = RandomInteger.NextInteger(0, 3);

            switch (choice)
            {
            case 0:
                return(BeaconTypeV1.iBeacon);

            case 1:
                return(BeaconTypeV1.AltBeacon);

            case 2:
                return(BeaconTypeV1.EddyStoneUdi);

            case 3:
                return(BeaconTypeV1.Unknown);

            default:
                return(BeaconTypeV1.Unknown);
            }
        }
        public override void Execute()
        {
            if (_fileStream == null)
            {
                return;
            }

            lock (_syncRoot)
            {
                if (_fileStream.Length == 0 || (_testWrites && (!_testReads || RandomInteger.NextInteger(2) == 0)))
                {
                    var position = _fileStream.Length < _fileSize
                        ? Math.Min(_fileSize - _chunkSize, (int)_fileStream.Length)
                        : RandomInteger.NextInteger(_fileSize - _chunkSize);

                    _fileStream.Seek(position, SeekOrigin.Begin);
                    int sizeToWrite = _chunkSize;
                    while (sizeToWrite > 0)
                    {
                        _fileStream.Write(_buffer, 0, Math.Min(BufferSize, sizeToWrite));
                        sizeToWrite -= BufferSize;
                    }
                    _fileStream.Flush();
                }
                else
                {
                    int position = RandomInteger.NextInteger((int)_fileStream.Length - _chunkSize);
                    _fileStream.Seek(position, SeekOrigin.Begin);

                    int sizeToRead = _chunkSize;
                    while (sizeToRead > 0)
                    {
                        _fileStream.Read(_buffer, 0, Math.Min(BufferSize, sizeToRead));
                        sizeToRead -= BufferSize;
                    }
                }
            }
        }
        private void OnFrame(object sender, EventArgs e)
        {
            this.currentTick = System.Environment.TickCount;
            this.elapsed     = (double)(this.currentTick - this.lastTick) / 1000.0;
            this.lastTick    = this.currentTick;

            frameCount++;
            frameCountTime += elapsed;
            if (frameCountTime >= 1.0)
            {
                frameCountTime -= 1.0;
                Context.IncrementCounter(frameCount);
                frameCount = 0;
            }

            for (int index = 0; index < _lines.Length; index++)
            {
                _lines[index].X1 = RandomInteger.NextInteger(Width);
                _lines[index].X2 = RandomInteger.NextInteger(Width);
                _lines[index].Y1 = RandomInteger.NextInteger(Height);
                _lines[index].Y2 = RandomInteger.NextInteger(Height);
            }
        }
        public override void SetUp()
        {
            _canvas            = new Canvas();
            _canvas.Background = new SolidColorBrush(Colors.White);

            _window            = new Window();
            _window.Width      = Width;
            _window.Height     = Height;
            _window.Content    = _canvas;
            _window.Background = new SolidColorBrush(Colors.Black);
            _window.Closed    += OnWindowClosed;
            _window.Show();

            _lines = new Line[LinesCount];

            for (int index = 0; index < _lines.Length; index++)
            {
                Color color = Color.FromArgb((byte)RandomInteger.NextInteger(255),
                                             (byte)RandomInteger.NextInteger(255), (byte)RandomInteger.NextInteger(255), (byte)RandomInteger.NextInteger(255));

                _lines[index]                 = new Line();
                _lines[index].X1              = RandomInteger.NextInteger(Width);
                _lines[index].X2              = RandomInteger.NextInteger(Width);
                _lines[index].Y1              = RandomInteger.NextInteger(Height);
                _lines[index].Y2              = RandomInteger.NextInteger(Height);
                _lines[index].Stroke          = new SolidColorBrush(color);
                _lines[index].StrokeThickness = 2;
                _canvas.Children.Add(_lines[index]);
            }

            lastTick             = System.Environment.TickCount;
            _frameTimer          = new System.Windows.Threading.DispatcherTimer();
            _frameTimer.Tick    += OnFrame;
            _frameTimer.Interval = TimeSpan.FromSeconds(1.0 / 60.0);
            _frameTimer.Start();
        }
        private void OnFrame(object sender, EventArgs e)
        {
            this.currentTick = System.Environment.TickCount;
            this.elapsed     = (double)(this.currentTick - this.lastTick) / 1000.0;
            this.lastTick    = this.currentTick;

            frameCount++;
            frameCountTime += elapsed;
            if (frameCountTime >= 1.0)
            {
                frameCountTime -= 1.0;
                Context.IncrementCounter(frameCount);
                frameCount = 0;
            }

            if (GrowListOnly)
            {
                AppendNewDataItems(10);
                _window.ScrollTo(_dataItems.Count - 1);

                if (_dataItems.Count > ItemsCount)
                {
                    _dataItems.Clear();
                }
            }
            else
            {
                for (int index = 0; index < ItemsCount; index++)
                {
                    _dataItems[index].Age          = RandomInteger.NextInteger(100);
                    _dataItems[index].Name         = "Name #" + index + " - " + RandomInteger.NextInteger(1000);
                    _dataItems[index].RandomNumber = RandomDouble.NextDouble(1.0) * 1000;
                }
                _window.ScrollTo(RandomInteger.NextInteger(ItemsCount - 1));
            }
        }
Пример #29
0
 public void ExecuteRandomDelay()
 {
     Thread.Sleep(RandomInteger.NextInteger(0, 1000));
 }
        public static string Theme()
        {
            var value = RandomInteger.NextInteger(1) > 0 ? "green" : "blue";

            return(value);
        }