private void Stage_4() { Data.Session.Stage = 4; Thread.Sleep(250); ColorLabels(FormDesign.Design); PGB_SecondPass.Percentage = 100; Invoke(new Action(() => { if (Data.Session.SecondPassFolders.Count > 0) { L_SecondPass_Info.Text = $"Done, {Data.Session.SecondPassFolders.Where(x => x.Match != null).Count()} / {Data.Session.SecondPassFolders.Count} matches found."; } else { L_SecondPass_Info.Text = $"Done, no need for Second Pass."; } L_ApplyChanges_Info.ForeColor = FormDesign.Design.InfoColor; if (Data.Session.StageErrors[3] > 0) { L_SecondPass_Info.ForeColor = FormDesign.Design.RedColor; } L_SecondPass_Info.Text += Data.Session.StageErrors[3] == 0 ? "." : $", {Data.Session.StageErrors[3]} errors occurred."; PB_SecondPass.Hide(); PB_Final.Show(); })); try { BackEndWorker.CloseExplorerWindows(); } catch (Exception) { } for (int i = 0; i < (Data.Session.Files.Count / 500).Between(1, MAX_RUNS); i++) { WorkingThreads.Add(new Action(S4_Work).RunInBackground(THREAD_PRIORITY)); } }
private void S4_Work() { while (Data.Session.Stage == 4 && Data.Session.Files.Count >= Data.Session.LastProccessedFile + 1) { if (Data.Session.LastProccessedFile >= Data.Session.Files.Count) { break; } var item = Data.Session.Files[Data.Session.LastProccessedFile++]; Invoke(new Action(() => { L_ApplyChanges_Info.Text = item.Name; TaskbarProgress.SetValue(Handle, 7500 + 2500d * Data.Session.LastProccessedFile / Data.Session.Files.Count, 10000); })); var error = BackEndWorker.SetIcon(item); PGB_ApplyChanges.Percentage = 100d * Data.Session.LastProccessedFile / Data.Session.Files.Count; if (error != null) { Data.Session.StageErrors[4]++; #if DEBUG Data.Session.Exceptions.Add(error); #endif } } if (Data.Session.Stage == 4) { End(); } }
public ItemFile(string path, out bool error) { try { FilePath = path; Formats = new List <Format>() { new Format(path) }; Type = BackEndWorker.GetType(path); foreach (var synonym in IconSynonym.Synonyms) { if (Regex.IsMatch(Formats[0].LowerCase, synonym.Pattern)) { Formats.Add(Format.FromBase(Formats[0].LowerCase.RegexReplace(synonym.Pattern, synonym.Value))); } } Parents = path.Parents(true).ToArray(); Categories = BackEndWorker.GetCategories(this); error = false; } catch (Exception) { error = true; } }
private void End() { Data.Session.Stage = 5; try { BackEndWorker.RefreshIcons(); } catch (Exception) { } Thread.Sleep(250); Invoke(new Action(() => { PGB_ApplyChanges.Percentage = 100; if (Data.Session.Errors == 0) { L_ApplyChanges_Info.Text = "Done"; } else { L_ApplyChanges_Info.Text = $"Done, {Data.Session.Errors}{(Data.Session.Errors == Data.Session.StageErrors[4] ? "" : " total")} errors occurred."; } if (Data.Session.Errors > 0) { L_ApplyChanges_Info.ForeColor = FormDesign.Design.RedColor; } B_Abort.HueShade = null; B_Abort.Text = "Done"; B_Abort.Image = Properties.Resources.Icon_Checkmark; PB_Final.Hide(); TaskbarProgress.SetState(Handle, TaskbarProgress.TaskbarStates.NoProgress); if (!FormIsActive) { FlashWindow.Flash(this, 5); } })); #if DEBUG try { File.WriteAllText(@"C:\Users\DotCa\Desktop\AIC_LastMatches.txt", Data.Session.Files.Where(x => x.Match != null).Convert(x => "{\r\n" + $" {x.ToString()}\r\n {(x.Match == null ? "NULL" : x.Match.ToString())}" + "\r\n}\r\n").ListStrings()); File.WriteAllText(@"C:\Users\DotCa\Desktop\AIC_Errors.txt", Data.Session.Exceptions.Where(x => x != null).Convert(x => $"--------------------------------------\r\n{x.ToString()}\r\n--------------------------------------\r\n\r\n").ListStrings()); } catch (Exception) { } #endif }