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); } } } }
public override unsafe 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); } } } }
private void Init() { double timerInterval = _exchangeType == ExchangeType.BinanceExchange ? RandomFast.Next(_settings.TimerInterval * 60, 2 * _settings.TimerInterval * 60) * 1000 : 1; switch (_settings.BotMode) { case BotMode.FixedProfit: _marketTimer.Interval = timerInterval; Strategy = new FixedProfitStrategy(_exchangeType, _settings); break; case BotMode.FixedPriceChange: _marketTimer.Interval = timerInterval; Strategy = new FixedPriceChangeStrategy(_exchangeType, _settings); break; case BotMode.TradingViewSignal: _marketTimer.Interval = 5000; // Every 5 seconds Strategy = new TradingViewAlertStrategy(_exchangeType, _settings); break; case BotMode.Futures: _marketTimer.Interval = 10000; _exchangeType = ExchangeType.BinanceFuturesExchange; Strategy = new FuturesStrategy(_exchangeType, _settings); break; default: Console.WriteLine("Unhandled Bot Mode."); Console.ReadLine(); return; } }
private GradientInfo AddDefaultGradient() { GradientInfo gradientInfo = new 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; } return(gradientInfo); }
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())); } }
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); } }
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); }
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; }