public ObservableCollection<TreeNode> GetCleaners() { if (base.IsInDesignMode) { #region designer data TreeNode root = new TreeNode("Chromium") { IsInitiallySelected = true, Children = { new TreeNode("Cache") {}, new TreeNode("Cookies") {} } }; root.Initialize(); this.CleanersCollection.Add(root); TreeNode root2 = new TreeNode("Windows Explorer") { Children = { new TreeNode("Most recently used") {}, new TreeNode("Recent documents list") {}, new TreeNode("Run") {}, new TreeNode("Search history") {}, new TreeNode("Thumbnails") {}, } }; root2.Initialize(); this.CleanersCollection.Add(root2); #endregion } else { XmlSerializer srlzr = new XmlSerializer(typeof(cleaner)); Model_CleanerML CleanerML = new Model_CleanerML(); string cleaners_folder = Path.Combine(this._exec_path, "cleaners"); foreach (string filename in Directory.GetFiles(cleaners_folder, "*.xml")) { TreeNode root = new TreeNode(); FileInfo fi = new FileInfo(filename); using (StreamReader reader = fi.OpenText()) { cleaner clnr = (cleaner)srlzr.Deserialize(reader); CleanerML.CleanerML = clnr; // cleaner files are initially verified after deserialization bool isSupported = CleanerML.isSupported; Debug.WriteLine(clnr.label + "> " + isSupported.ToString()); if (isSupported) { // further check if the current cleaner is executable. isSupported = CheckIfSupported(clnr); } if (isSupported) { root = new TreeNode(clnr.label, clnr.id); //root.IsInitiallySelected = true; //root.IsChecked = true; root.Tag = clnr; root.TreeNodeChecked += TeeNode_TreeNodeChecked; root.TreeNodeSelected += TreeNode_TreeNodeSelected; root.Children = new List<TreeNode>(); foreach (option o in clnr.option) { o.parent_cleaner = clnr; TreeNode child = new TreeNode(o.label, o.id); child.Tag = o; child.TreeNodeChecked += TeeNode_TreeNodeChecked; child.TreeNodeSelected += TreeNode_TreeNodeSelected; child.Initialize(); root.Children.Add(child); foreach (action a in o.action) { a.parent_option = o; } } root.Initialize(); this.CleanersCollection.Add(root); } } } } return this.CleanersCollection; }
void AddSystemCleaner(bool select = false) { cleaner c = new cleaner() { id = "system", label = "Microsoft Windows System", description = "General Windows system cleaners", option = new List<option>() }; TreeNode root = new TreeNode(); root = new TreeNode(c.label, c.id); root.IsAccordionHeader = true; root.IsExpanded = true; root.Tag = c; root.TreeNodeChecked += TeeNode_TreeNodeChecked; root.TreeNodeSelected += TreeNode_TreeNodeSelected; root.Children = new List<TreeNode>(); c.option.Add(MicrosoftWindows.AddClipboardCleaner()); //c.option.Add(AddClamAVCustomLocationsToTTD()); c.option.Add(MicrosoftWindows.AddCustomLocationsToTTD()); //c.option.Add(AddDuplicateCheckerCleaner()); // deep scan options c.option.Add(MicrosoftWindows.AddDeepScan_Backup_Cleaner()); c.option.Add(MicrosoftWindows.AddDeepScan_OfficeTemp_Cleaner()); c.option.Add(MicrosoftWindows.AddDeepScan_ThumbsDB_Cleaner()); c.option.Add(MicrosoftWindows.AddWindowsLogsCleaner()); c.option.Add(MicrosoftWindows.AddMemoryDumpCleaner()); c.option.Add(MicrosoftWindows.AddMUICacheCleaner()); c.option.Add(MicrosoftWindows.AddPrefetchCleaner()); c.option.Add(MicrosoftWindows.AddRecycleBinCleaner()); c.option.Add(MicrosoftWindows.AddTemporaryFilesCleaner()); c.option.Add(MicrosoftWindows.AddUpdateUninstallersCleaner()); foreach (option o in c.option) { o.parent_cleaner = c; TreeNode child = new TreeNode(o.label, o.id); child.Tag = o; child.TreeNodeChecked += TeeNode_TreeNodeChecked; child.TreeNodeSelected += TreeNode_TreeNodeSelected; child.Initialize(); root.Children.Add(child); foreach (action a in o.action) { a.parent_option = o; } } root.Initialize(); root.IsInitiallySelected = select; this._nodes.Add(root); }
public ObservableCollection<TreeNode> GetCleaners() { if (base.IsInDesignMode) { #region designer data TreeNode root = new TreeNode("Chromium", "chrome") { IsInitiallySelected = true, IsAccordionHeader = true, IsExpanded = true, Tag = 1, Children = { new TreeNode("Cache") {}, new TreeNode("Cookies") {} } }; root.Initialize(); this._nodes.Add(root); TreeNode root2 = new TreeNode("Windows Explorer", "win_exp") { IsAccordionHeader = true, IsExpanded = true, Tag = 1, Children = { new TreeNode("Most recently used") {}, new TreeNode("Recent documents list") {}, new TreeNode("Run") {}, new TreeNode("Search history") {}, new TreeNode("Thumbnails") {}, } }; root2.Initialize(); this._nodes.Add(root2); SortCleanerCollection(); #endregion } else { XmlSerializer srlzr = new XmlSerializer(typeof(cleaner)); Model_CleanerML CleanerML = new Model_CleanerML(); string cleaners_folder = Path.Combine(this._exec_path, "cleaners"); string[] files = Directory.GetFiles(cleaners_folder, "*.xml"); Array.Sort(files); this._nodes.Clear(); foreach (string filename in files) { TreeNode root = new TreeNode(); FileInfo fi = new FileInfo(filename); using (StreamReader reader = fi.OpenText()) { cleaner clnr = (cleaner)srlzr.Deserialize(reader); CleanerML.CleanerML = clnr; // cleaner files are initially verified after deserialization bool isSupported = CleanerML.isSupported; Debug.WriteLine(clnr.label + "> " + isSupported.ToString()); #if !DEBUG if (isSupported) { if (Settings.Default.HideIrrelevantCleaners) { // further check if the current cleaner is executable. // though check if it has a slow option so skip the precheck // and just include it automatically bool skipprecheck = false; foreach (option o in clnr.option) { if (o.warning != null && o.warning != string.Empty) { skipprecheck = true; break; } } if (skipprecheck) { isSupported = true; } else { isSupported = CheckIfSupported(clnr); } } } #endif if (isSupported) { root = new TreeNode(clnr.label, clnr.id); //root.IsInitiallySelected = true; //root.IsChecked = true; root.Tag = clnr; root.TreeNodeChecked += TeeNode_TreeNodeChecked; root.TreeNodeSelected += TreeNode_TreeNodeSelected; root.IsAccordionHeader = true; root.IsExpanded = true; root.Children = new List<TreeNode>(); foreach (option o in clnr.option) { o.parent_cleaner = clnr; TreeNode child = new TreeNode(o.label, o.id); child.Tag = o; child.TreeNodeChecked += TeeNode_TreeNodeChecked; child.TreeNodeSelected += TreeNode_TreeNodeSelected; child.Initialize(); root.Children.Add(child); foreach (action a in o.action) { a.parent_option = o; } } root.Initialize(); this._nodes.Add(root); } } } AddSystemCleaner(); //AddDuplicateCleaner(); } SortCleanerCollection(); return this.CleanersCollection; }
void AddDuplicateCleaner(bool select = false) { cleaner c = new cleaner() { id = "duplicate_checker", label = "Duplicate Checker", description = "Checks for duplicate in your file system", option = new List<option>() }; TreeNode root = new TreeNode(); root = new TreeNode(c.label, c.id); root.IsAccordionHeader = true; root.IsExpanded = true; root.Tag = c; root.TreeNodeChecked += TeeNode_TreeNodeChecked; root.TreeNodeSelected += TreeNode_TreeNodeSelected; root.Children = new List<TreeNode>(); // add subtree c.option.AddRange(AddDuplicateCheckerCleaner()); foreach (option o in c.option) { o.parent_cleaner = c; TreeNode child = new TreeNode(o.label, o.id); child.Tag = o; child.TreeNodeChecked += TeeNode_TreeNodeChecked; child.TreeNodeSelected += TreeNode_TreeNodeSelected; child.Initialize(); root.Children.Add(child); foreach (action a in o.action) { a.parent_option = o; } } root.Initialize(); root.IsInitiallySelected = select; this._nodes.Add(root); }