internal void Wifi_CheckForImages(List <TheImage> AllImages, bool InvokeRequired, string WebSiteSearchDir, Form Parentform, Form waiter, Action <TheImage> ReportProgressForImageSearch, Action <bool> Done) { if (ConfigurationManager.AppSettings["Mode"] == "Diagnostic") { logger.Log(NLog.LogLevel.Info, "Inside Wifi_CheckForImages function"); } //AllImages = new List<ChitraKiAlbumAurVivaran>(); if (InvokeRequired) // this is invoked, coz file system watcher triggers an event which trigger this func. // Probably filesystemwatcher works on another thread. { Parentform.Invoke(new Action(() => waiter.Show())); } else { waiter.Show(); } var progressIndicator = new Progress <TheImage>(ReportProgressForImageSearch); lib.ImgSearch imgSearch = new ImgSearch(WebSiteSearchDir); Task waitToComplete = new Task(async() => { await imgSearch.Search(progressIndicator, Parentform, InvokeRequired, 0); if (AllImages.Count > 0) { await Wifi_PostProcessImages(AllImages[0]); } if (InvokeRequired) { Parentform.Invoke((Action <bool>)Done, true); return; } else { Done(true); } }); waitToComplete.Start(); }
private static void DissmissMissingSoldiers() { StopSoldierDismiss = false; if (StopSoldierDismiss == false && CheckforTruppkameradenliste() == 1) { if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.LeftAlt) && (Keyboard.IsKeyDown(Key.NumPad0) || Keyboard.IsKeyDown(Key.D0))) { log.Debug("Dismissing Soldiers interrupted by user at: CheckforTruppkameradenliste"); StopSoldierDismiss = true; return; } MouseActions.SingleClickAtPosition(-122, 925); //open Filtermenu if (StopSoldierDismiss == false && CheckforFilterScreen() == 1) { MouseActions.SingleClickAtPosition(-742, 218); //nicht verfügbar MainWindow.Sleep(250); MouseActions.SingleClickAtPosition(-551, 611); // activate 1* MainWindow.Sleep(250); MouseActions.SingleClickAtPosition(-446, 612); // activate 2* MainWindow.Sleep(250); MouseActions.SingleClickAtPosition(-1738, 209); // Close FilterScreen MainWindow.Sleep(350); int AmountOfLoops = 0; while (AmountOfLoops++ < 20) { if (AmountOfLoops > 1) { MainWindow.Sleep(300); //time required for SF to reorder soldiers after dissmissing one. Not needet in First round. } if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.LeftAlt) && (Keyboard.IsKeyDown(Key.NumPad0) || Keyboard.IsKeyDown(Key.D0))) { log.Debug("Dismissing Soldiers interrupted by user at: CheckforTruppkameradenliste"); StopSoldierDismiss = true; return; } string[] ImageLocation = ImgSearch.UseImageSearch(MainWindow.ResourcesPath + "berger.png", "140", -1920, 748, 1920, 890); if (StopSoldierDismiss == false && ImageLocation != null && ImageLocation.Length > 0) { int.TryParse(ImageLocation[1], out int x); int.TryParse(ImageLocation[2], out int y); MouseActions.SingleClickAtPosition(x - 100, y - 200); //upperleft corner of picture (which is in the "Bergung" Button) -> to middle of soldier screen if (CheckforSoldierDissmissScreen() == 1) { MainWindow.Sleep(100); MouseActions.SingleClickAtPosition(-1834, 997); // Dissmiss Soldier if (CheckforAcceptDissmissScreen() == 1) { MainWindow.Sleep(100); MouseActions.SingleClickAtPosition(-421, 811); //"Accept" Dismiss Button if (StopSoldierDismiss == false && CheckforTruppkameradenliste() == 1) { } else { StopSoldierDismiss = true; return; } } else { StopSoldierDismiss = true; return; } } else { StopSoldierDismiss = true; return; } } else if (StopSoldierDismiss == false && ImageLocation == null) { //scroll 3boosters int i = 0; while (StopSoldierDismiss == false && i < 3) { if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.LeftAlt) && (Keyboard.IsKeyDown(Key.NumPad0) || Keyboard.IsKeyDown(Key.D0))) { log.Debug("Dismissing Soldiers interrupted by user at: CheckforTruppkameradenliste"); StopSoldierDismiss = true; return; } int moveToX = 0; if (MainWindow.CurrentHostName == "VMgr4ndpa" || MainWindow.CurrentHostName == "VMgr4ndpaClone") { MouseActions.SetCursorPos(1868, 484); moveToX = 1715; MouseActions.LeftMouseDown(); while (moveToX > 48 && StopSoldierDismiss == false) { if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.LeftAlt) && (Keyboard.IsKeyDown(Key.NumPad0) || Keyboard.IsKeyDown(Key.D0))) { log.Debug("AutoMission interrupted by user at: selecting Booster"); StopSoldierDismiss = true; return; } moveToX -= 90; MouseActions.SetCursorPos(moveToX, 484); MainWindow.Sleep(34); } } else { MouseActions.SetCursorPos(-52, 557); moveToX = -215; MouseActions.LeftMouseDown(); while (moveToX > -1872 && StopSoldierDismiss == false) { if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.LeftAlt) && (Keyboard.IsKeyDown(Key.NumPad0) || Keyboard.IsKeyDown(Key.D0))) { log.Debug("AutoMission interrupted by user at: selecting Booster"); StopSoldierDismiss = true; return; } moveToX -= 90; MouseActions.SetCursorPos(moveToX, 484); MainWindow.Sleep(34); } } MainWindow.Sleep(150); MouseActions.LeftMouseUp(); i++; if (StopSoldierDismiss == false && ImgSearch.UseImageSearch(MainWindow.ResourcesPath + "berger.png", "140", -1920, 748, 1920, 890) != null) { break; } else if (StopSoldierDismiss == true) { return; } } } else if (StopSoldierDismiss == true) { return; } } log.Debug("Loops finished."); StopSoldierDismiss = true; return; } else { StopSoldierDismiss = true; return; } } else { StopSoldierDismiss = true; return; } }