public MainWindow() { InitializeComponent(); try { //Fill lists with data from CSVs TemTems = PopulateList(); TemTraits = PopulateTraits(); TemResolutions = PopulateResolutions(); SupportedResolutions = PopulateSupportedResolutions(); } catch (Exception ex) { log.Error(ex.Message); log.Error(ex.StackTrace); Close(); } //Resolution settings if (HandleResolution()) { //Start the screen checking function if the resolution is supported. StartScreenChecker(); } //Init Type Defense if (AlwaysShowDefense) { TemTacOverlay.BeginStoryboard((Storyboard)this.Resources["TypeDefenseShow"]); TemTypeDef = true; } }
private void CheckboxDefense_Checked(object sender, RoutedEventArgs e) { Properties.Settings.Default.AlwaysShowDefense = true; Properties.Settings.Default.Save(); AlwaysShowDefense = true; TemTacOverlay.BeginStoryboard((Storyboard)this.Resources["TypeDefenseShow"]); TemTypeDef = 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; } }