private bool calibrate(Sliver sl) { int xx; var sp = new System.Drawing.Point(sl.left - 20, top); var dp = new System.Drawing.Point(sl.left + 20, top + height); calBitmap = (Bitmap)sc.Capture(sp, dp); for (int x = 0; x < calBitmap.Width; x++) { for (int y = 0; y < 200; y++) { var pixel = calBitmap.GetPixel(x, y); if (pixel.R == 255 && pixel.G == 255 && pixel.B == 255) { pixel = calBitmap.GetPixel(x, y + 1); if (pixel.R == 255 && pixel.G == 255 && pixel.B == 255) { sl.left += (x - 20); sl.calibrated = true; return(true); } pixel = calBitmap.GetPixel(x, y + 2); if (pixel.R == 255 && pixel.G == 255 && pixel.B == 255) { sl.left += (x - 20); sl.calibrated = true; return(true); } } } } sl.calibrated = false; return(false); }
private void setSliver(Sliver lv) { lv.left = left; lv.top = top; lv.width = width; lv.height = height; }
private void pullSliver(Sliver lv) { left = lv.left; top = lv.top; width = lv.width; height = lv.height; }
private void SaveAdd_Click(object sender, RoutedEventArgs e) { var sl = new Sliver(); width = 300; sl.Active = true; setSliver(sl); sliverList.Add(sl); currentIdx++; CurrentIndex.Text = $"{currentIdx}"; Saved.Text = $"{sliverList.Count}"; setData(); }
private void Dtimer_Tick(object sender, EventArgs e) { dtimer.Stop(); Sliver sl = pullSliverAdvance(); if (sl == null) { setUpRectangle(); return; } width = 3; if (waitIterations > 0) { waitIterations--; dtimer.Stop(); } if (waitASecond) { waitIterations = 5; waitASecond = false; } if (populateResult) { populateRedLine(); populateResult = false; } if ((DateTime.Now - RedCheckStart).TotalSeconds > 6) { sl.reds = CheckRed(); colorTextOn = false; } sl.redsPrev = sl.reds; if (sl.reds > 0 && sl.hasRed == false) { sl.hasRed = true; RedCheckStart = DateTime.Now; PlaySound(sl); } if (sl.reds == 0 && sl.hasRed) { sl.hasRed = false; PlaySound(sl); } cnt = 0; iteration = 0; dtimer.Start(); }
private void PlaySound(Sliver sl) { try { bool allclear = true; foreach (var s3 in sliverListActive) { if (s3.hasRed) { allclear = false; } } if (allclear) { player.SoundLocation = Properties.Settings.Default.AllClearSoundFile; } else if (sl.hasRed) { copyForDiscord(); player.SoundLocation = sl.alertSoundFilename; // player.SoundLocation = Properties.Settings.Default.AlertSoundFile; } if (player.SoundLocation == null || player.SoundLocation.Length < 2) { return; } if (!File.Exists(player.SoundLocation)) { return; } if (File.Exists(player.SoundLocation)) { player.Load(); player.Play(); } } catch (Exception ex) { MessageBox.Show(ex.Message + " could not find sound file:" + Properties.Settings.Default.AlertSoundFile); } }
private Sliver pullSliverAdvance() { if (sliverListActive.Count == 0) { this.setUpRectangle(); } Sliver sl = sliverListActive[cidxCheck]; if (sliverListActive.Count > 0) { pullSliver(sl); cidxCheck++; if (sliverListActive.Count <= cidxCheck) { cidxCheck = 0; } return(sl); } return(null); }