private List <OCR> PopulateResolutions() { log.Info("Reading TemResolutions.csv"); List <OCR> tempTemResolutions = File.ReadAllLines("Resources\\TemResolutions.csv") .Skip(1) .Select(v => OCR.FromCsv(v, enEn)) .ToList(); return(tempTemResolutions); }
private void ComboBoxResolution_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (ComboBoxResolution.SelectedValue != null && ComboBoxResolution.SelectedValue.ToString() != "") { string[] resolution = ComboBoxResolution.SelectedValue.ToString().Split('x'); log.Info($"Changed resolution: {resolution[0]}x{resolution[1]}"); ResolutionSettings = TemResolutions.Find(x => x.Resolution.Equals($"{resolution[0]}x{resolution[1]}")); Properties.Settings.Default.Resolution = $"{resolution[0]}x{resolution[1]}"; Properties.Settings.Default.Save(); } }
public static OCR FromCsv(string csvLine, CultureInfo cultureInfo) { string[] values = csvLine.Split(','); OCR ocrValues = new OCR(); ocrValues.Width = Convert.ToInt32(values[0], cultureInfo); ocrValues.Height = Convert.ToInt32(values[1], cultureInfo); ocrValues.SnipW = Convert.ToInt32(values[2], cultureInfo); ocrValues.SnipH = Convert.ToInt32(values[3], cultureInfo); ocrValues.TemLeftX = Convert.ToInt32(values[4], cultureInfo); ocrValues.TemLeftY = Convert.ToInt32(values[5], cultureInfo); ocrValues.TemRightX = Convert.ToInt32(values[6], cultureInfo); ocrValues.TemRightY = Convert.ToInt32(values[7], cultureInfo); ocrValues.AspectRatio = Convert.ToString(values[8], cultureInfo); ocrValues.Resolution = Convert.ToString(values[9], cultureInfo); return(ocrValues); }
private bool HandleResolution() { double dWidth = -1; double dHeight = -1; if (Properties.Settings.Default.Resolution == "None") { //Get Resolution dWidth = SystemParameters.PrimaryScreenWidth; dHeight = SystemParameters.PrimaryScreenHeight; log.Info($"Found resolution: {dWidth}x{dHeight}"); //Check if Resolution is supported //var TemSettings = TemResolutions.Where(x => x.Height.Equals(dHeight) && x.Width.Equals(dWidth)); if (SupportedResolutions.FindIndex(x => x.Equals($"{dWidth}x{dHeight}")) != -1) { Properties.Settings.Default.Resolution = $"{dWidth}x{dHeight}"; Properties.Settings.Default.Save(); ResolutionSettings = TemResolutions.Find(x => x.Resolution.Equals($"{dWidth}x{dHeight}")); ComboBoxResolution.SelectedValue = $"{dWidth}x{dHeight}"; return(true); } else { System.Windows.MessageBox.Show($"{dWidth}x{dHeight} is currently not supported.\nFor more information visit 'www.temporium.gg'", "TemTacO"); return(false); } } string[] resolution = Properties.Settings.Default.Resolution.Split('x'); dWidth = Convert.ToInt32(resolution[0]); dHeight = Convert.ToInt32(resolution[1]); log.Info($"Settings resolution: {dWidth}x{dHeight}"); ResolutionSettings = TemResolutions.Find(x => x.Resolution.Equals($"{dWidth}x{dHeight}")); ComboBoxResolution.SelectedValue = $"{dWidth}x{dHeight}"; return(true); }
private void ScanScreenTem(bool save) { //Init Bitmap memoryImageLeft; memoryImageLeft = new Bitmap(ResolutionSettings.SnipW, ResolutionSettings.SnipH); System.Drawing.Size sL = new System.Drawing.Size(ResolutionSettings.SnipW, ResolutionSettings.SnipH); Graphics memoryGraphicsLeft = Graphics.FromImage(memoryImageLeft); //Scan TemTem Left memoryGraphicsLeft.CopyFromScreen(ResolutionSettings.TemLeftX, ResolutionSettings.TemLeftY, 0, 0, sL); //Tesseract OCR memoryImageLeft = OCR.Whitify(memoryImageLeft); string temOCR = OCR.Tesseract(memoryImageLeft); //log.Info($"FoundOCR-L:{temOCR}"); temOCR = temOCR.Split(' ')[0]; temOCR = new String(temOCR.Where(Char.IsLetter).ToArray()); int temOCRindex = TemTems.FindIndex(x => x.Name.Contains(temOCR)); //Set left Tem label text if (!OCR.ScanForMenu() || (EnemyTemLeft.Content.ToString() != temOCR && temOCR != "" && temOCRindex > 0)) { if (TemValid(temOCR)) { EnemyTemLeft.Content = temOCR; } } //If we found a tem update the table if (EnemyTemLeft.Content.ToString() != "") { //Get Tem Details TemLeft = GetMatchup(EnemyTemLeft.Content.ToString()); if (!TemLeft.Type2.Equals("None")) { EnemyTemLeftType.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("Resources/" + TemLeft.Type2 + ".png", UriKind.Relative)); EnemyTemLeftType2.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("Resources/" + TemLeft.Type1 + ".png", UriKind.Relative)); } else { EnemyTemLeftType.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("Resources/" + TemLeft.Type1 + ".png", UriKind.Relative)); EnemyTemLeftType2.Source = null; } //Get Type Defense LMNeutral.Content = TypeString(TemLeft.TypeNeutral); LMFire.Content = TypeString(TemLeft.TypeFire); LMWater.Content = TypeString(TemLeft.TypeWater); LMNature.Content = TypeString(TemLeft.TypeNature); LMElectric.Content = TypeString(TemLeft.TypeElectric); LMEarth.Content = TypeString(TemLeft.TypeEarth); LMMental.Content = TypeString(TemLeft.TypeMental); LMWind.Content = TypeString(TemLeft.TypeWind); LMDigital.Content = TypeString(TemLeft.TypeDigital); LMMelee.Content = TypeString(TemLeft.TypeMelee); LMCrystal.Content = TypeString(TemLeft.TypeCrystal); LMToxic.Content = TypeString(TemLeft.TypeToxic); //Add Green/Red background color AddColor(LeftMatchup.Children); LeftMatchup.Visibility = Visibility.Visible; LeftType.Visibility = Visibility.Visible; } else { LeftMatchup.Visibility = Visibility.Collapsed; LeftType.Visibility = Visibility.Collapsed; } //Init Bitmap memoryImageRight; memoryImageRight = new Bitmap(ResolutionSettings.SnipW, ResolutionSettings.SnipH); System.Drawing.Size sR = new System.Drawing.Size(ResolutionSettings.SnipW, ResolutionSettings.SnipH); Graphics memoryGraphicsRight = Graphics.FromImage(memoryImageRight); //Scan TemTem Right memoryGraphicsRight.CopyFromScreen(ResolutionSettings.TemRightX, ResolutionSettings.TemRightY, 0, 0, sR); //Tesseract OCR memoryImageRight = OCR.Whitify(memoryImageRight); //string fileName = string.Format(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + // @"\TemTem\" + // DateTime.Now.ToString("(dd_MMMM_hh_mm_ss_tt)") + "R.png"); //memoryImageRight.Save(fileName); temOCR = OCR.Tesseract(memoryImageRight); //log.Info($"FoundOCR-R:{temOCR}"); temOCR = temOCR.Split(' ')[0]; temOCR = new String(temOCR.Where(Char.IsLetter).ToArray()); temOCRindex = TemTems.FindIndex(x => x.Name.Contains(temOCR)); //Set left Tem label text if (!OCR.ScanForMenu() || (EnemyTemRight.Content.ToString() != temOCR && temOCR != "" && temOCRindex > 0)) { if (TemValid(temOCR)) { EnemyTemRight.Content = temOCR; } } ; //If we found a Tem update the table if (EnemyTemRight.Content.ToString() != "") { //Get Tem Details TemRight = GetMatchup(EnemyTemRight.Content.ToString()); if (!TemRight.Type2.Equals("None")) { EnemyTemRightType.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("Resources/" + TemRight.Type2 + ".png", UriKind.Relative)); EnemyTemRightType2.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("Resources/" + TemRight.Type1 + ".png", UriKind.Relative)); } else { EnemyTemRightType.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("Resources/" + TemRight.Type1 + ".png", UriKind.Relative)); EnemyTemRightType2.Source = null; } //Get Type Defense RMNeutral.Content = TypeString(TemRight.TypeNeutral); RMFire.Content = TypeString(TemRight.TypeFire); RMWater.Content = TypeString(TemRight.TypeWater); RMNature.Content = TypeString(TemRight.TypeNature); RMElectric.Content = TypeString(TemRight.TypeElectric); RMEarth.Content = TypeString(TemRight.TypeEarth); RMMental.Content = TypeString(TemRight.TypeMental); RMWind.Content = TypeString(TemRight.TypeWind); RMDigital.Content = TypeString(TemRight.TypeDigital); RMMelee.Content = TypeString(TemRight.TypeMelee); RMCrystal.Content = TypeString(TemRight.TypeCrystal); RMToxic.Content = TypeString(TemRight.TypeToxic); //Add Green/Red Background color AddColor(RightMatchup.Children); RightMatchup.Visibility = Visibility.Visible; RightType.Visibility = Visibility.Visible; } else { RightMatchup.Visibility = Visibility.Collapsed; RightType.Visibility = Visibility.Collapsed; } if (!TemTypeDef && (EnemyTemLeft.Content.ToString() != "" || EnemyTemRight.Content.ToString() != "") && !AlwaysShowDefense) { TemTacOverlay.BeginStoryboard((Storyboard)this.Resources["TypeDefenseShow"]); TemTypeDef = true; } else if (TemTypeDef && (EnemyTemLeft.Content.ToString() == "" && EnemyTemRight.Content.ToString() == "") && !AlwaysShowDefense) { TemTacOverlay.BeginStoryboard((Storyboard)this.Resources["TypeDefenseHide"]); TemTypeDef = false; } }