コード例 #1
0
        public unsafe override void Generate()
        {
            int generated = 0, x1 = 0, y1 = 0;
            RandomFast r1 = new RandomFast(), r2 = new RandomFast(r1.Next());

            while (generated < minesCount)
            {
                x1 = r1.Next((int)fieldSize.X);
                y1 = r2.Next((int)fieldSize.Y);
                if (tiles[x1][y1][0].CurrentState != -1)
                {
                    tiles[x1][y1][0].CurrentState = -1;
                    generated++;
                }
            }

            for (int x = 0; x < fieldSize.X; x++)
            {
                for (int y = 0; y < fieldSize.Y; y++)
                {
                    if (tiles[x][y][0].CurrentState != -1)
                    {
                        tiles[x][y][0].CurrentState = GetSurroundingMinesCount(x, y, 0);
                    }
                }
            }
        }
コード例 #2
0
        public void Start()
        {
            if (!IsWorking)
            {
                IsWorking = true;

                velocity = new Point(RandomFast.Pick(-Speed, Speed), ApplyGravity ? GravityPower : RandomFast.Pick(-Speed, Speed));
                timer.Start();
            }
        }
コード例 #3
0
ファイル: VideoThumbnailer.cs プロジェクト: McoreD/ShareX
        private int GetRandomTimeSlice(int start)
        {
            List <int> mediaSeekTimes = new List <int>();

            for (int i = 1; i < Options.ThumbnailCount + 2; i++)
            {
                mediaSeekTimes.Add(GetTimeSlice(Options.ThumbnailCount + 2) * i);
            }

            return((int)((RandomFast.NextDouble() * (mediaSeekTimes[start + 1] - mediaSeekTimes[start])) + mediaSeekTimes[start]));
        }
コード例 #4
0
ファイル: CoinPairHelper.cs プロジェクト: wawah/BinanceBot-2
 public int GetCoinPairIndex()
 {
     if (_settings.RandomNewCoinPair)
     {
         return(RandomFast.Next(0, ExchangeClient.CoinPairsList.Count - 1));
     }
     else
     {
         return(ExchangeClient.CoinPairsList.FindIndex(x => x.ToString() == _settings.CoinPair.ToString()));
     }
 }
コード例 #5
0
        private string ParseSyntaxRandom(string syntax)
        {
            if (!string.IsNullOrEmpty(syntax))
            {
                string[] values = syntax.Split(SyntaxParameterChar);

                if (values.Length > 0)
                {
                    return(RandomFast.Pick(values));
                }
            }

            return(null);
        }
コード例 #6
0
ファイル: EasterEggBounce.cs プロジェクト: McoreD/ShareX
        private void bounceTimer_Tick(object sender, EventArgs e)
        {
            if (Form != null && !Form.IsDisposed)
            {
                int x           = Form.Left + velocity.X;
                int windowRight = BounceRectangle.X + BounceRectangle.Width - Form.Width - 1;

                if (x <= BounceRectangle.X)
                {
                    x          = BounceRectangle.X;
                    velocity.X = Speed;
                }
                else if (x >= windowRight)
                {
                    x          = windowRight;
                    velocity.X = -Speed;
                }

                int y            = Form.Top + velocity.Y;
                int windowBottom = BounceRectangle.Y + BounceRectangle.Height - Form.Height - 1;

                if (ApplyGravity)
                {
                    if (y >= windowBottom)
                    {
                        y          = windowBottom;
                        velocity.Y = -BouncePower + RandomFast.Next(-10, 10);
                    }
                    else
                    {
                        velocity.Y += GravityPower;
                    }
                }
                else
                {
                    if (y <= BounceRectangle.Y)
                    {
                        y          = BounceRectangle.Y;
                        velocity.Y = Speed;
                    }
                    else if (y >= windowBottom)
                    {
                        y          = windowBottom;
                        velocity.Y = -Speed;
                    }
                }

                Form.Location = new Point(x, y);
            }
        }
コード例 #7
0
ファイル: HistoryManagerMock.cs プロジェクト: ywscr/ShareX
        private HistoryItem CreateMockHistoryItem()
        {
            string fileName = $"ShareX_{Helpers.GetRandomAlphanumeric(10)}.png";

            HistoryItem historyItem = new HistoryItem()
            {
                FileName     = fileName,
                FilePath     = @"..\..\..\ShareX.HelpersLib\Resources\ShareX_Logo.png",
                DateTime     = DateTime.Now.AddSeconds(-RandomFast.Next(0, 1000000)),
                Type         = "Image",
                Host         = "Amazon S3",
                URL          = "https://i.example.com/" + fileName,
                ThumbnailURL = "https://t.example.com/" + fileName,
                DeletionURL  = "https://d.example.com/" + fileName,
                ShortenedURL = "https://s.example.com/" + fileName
            };

            return(historyItem);
        }
コード例 #8
0
        private void AddDefaultGradient(GradientInfo gradientInfo)
        {
            gradientInfo.Type = LinearGradientMode.Horizontal;

            switch (RandomFast.Next(0, 2))
            {
            case 0:
                gradientInfo.Colors.Add(new GradientStop(Color.FromArgb(0, 187, 138), 0f));
                gradientInfo.Colors.Add(new GradientStop(Color.FromArgb(0, 105, 163), 100f));
                break;

            case 1:
                gradientInfo.Colors.Add(new GradientStop(Color.FromArgb(255, 3, 135), 0f));
                gradientInfo.Colors.Add(new GradientStop(Color.FromArgb(255, 143, 3), 100f));
                break;

            case 2:
                gradientInfo.Colors.Add(new GradientStop(Color.FromArgb(184, 11, 195), 0f));
                gradientInfo.Colors.Add(new GradientStop(Color.FromArgb(98, 54, 255), 100f));
                break;
            }
        }
コード例 #9
0
        private void DrawImage(Image img, Image img2, Graphics g)
        {
            int width, height;

            if (RandomSize)
            {
                int size = RandomFast.Next(Math.Min(RandomSizeMin, RandomSizeMax), Math.Max(RandomSizeMin, RandomSizeMax));
                width  = size;
                height = size;

                if (img2.Width > img2.Height)
                {
                    height = (int)Math.Round(size * ((double)img2.Height / img2.Width));
                }
                else if (img2.Width < img2.Height)
                {
                    width = (int)Math.Round(size * ((double)img2.Width / img2.Height));
                }
            }
            else
            {
                width  = img2.Width;
                height = img2.Height;
            }

            if (width < 1 || height < 1)
            {
                return;
            }

            int xOffset = img.Width - width - 1;
            int yOffset = img.Height - height - 1;

            Rectangle rect, overlapRect;
            int       attemptCount = 0;

            do
            {
                attemptCount++;
                if (attemptCount > 1000)
                {
                    return;
                }

                rect = new Rectangle(RandomFast.Next(Math.Min(0, xOffset), Math.Max(0, xOffset)),
                                     RandomFast.Next(Math.Min(0, yOffset), Math.Max(0, yOffset)), width, height);

                overlapRect = rect.Offset(NoOverlapOffset);
            } while (NoOverlap && imageRectangles.Any(x => x.IntersectsWith(overlapRect)));

            imageRectangles.Add(rect);

            if (RandomAngle)
            {
                float moveX  = rect.X + (rect.Width / 2f);
                float moveY  = rect.Y + (rect.Height / 2f);
                int   rotate = RandomFast.Next(Math.Min(RandomAngleMin, RandomAngleMax), Math.Max(RandomAngleMin, RandomAngleMax));

                g.TranslateTransform(moveX, moveY);
                g.RotateTransform(rotate);
                g.TranslateTransform(-moveX, -moveY);
            }

            g.PixelOffsetMode = PixelOffsetMode.Half;

            if (RandomOpacity)
            {
                float opacity = RandomFast.Next(Math.Min(RandomOpacityMin, RandomOpacityMax), Math.Max(RandomOpacityMin, RandomOpacityMax)).Clamp(0, 100) / 100f;

                ColorMatrix matrix = new ColorMatrix();
                matrix.Matrix33 = opacity;
                using (ImageAttributes attributes = new ImageAttributes())
                {
                    attributes.SetColorMatrix(matrix);
                    g.DrawImage(img2, rect, 0, 0, img2.Width, img2.Height, GraphicsUnit.Pixel, attributes);
                }
            }
            else
            {
                g.DrawImage(img2, rect);
            }

            if (RandomAngle)
            {
                g.ResetTransform();
            }

            g.PixelOffsetMode = PixelOffsetMode.Default;
        }
コード例 #10
0
 public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] parameters)
 {
     return(RandomFast.Pick(parameters));
 }