public static void DisplayTreeListViewFile(Form1.IncrementStatusDel incrementStatus, TreeListView TV, String path) { TV.Items.Clear(); try { serialisation.DeserializeTreeListView(incrementStatus, TV, path); } catch (Exception ex) { MessageBox.Show("There was an error opening the file:" + ex); } }
public static List <TreeListViewItem> GetDups(Form1.IncrementStatusDel incrementStatus, TreeListViewItem TLVI, bool fuzzy) { //get a list of all the files at this level var ret = new List <TreeListViewItem>(); var retout = new List <TreeListViewItem>(); foreach (TreeListViewItem TLVI2 in TLVI.Items) { if (TLVI2.isfolder == false) { ret.Add(TLVI2); } if (TLVI2.Items.Count > 0) { retout.AddRange(GetDups(incrementStatus, TLVI2, fuzzy)); } } //go through and get the dups foreach (TreeListViewItem R1 in ret) { incrementStatus(true); foreach (TreeListViewItem R2 in ret) { if (R1 == R2) { continue; } String r11 = R1.Text; GetString(ref r11); String r22 = R2.Text; GetString(ref r22); if ((r11.Equals(r22) && fuzzy) || R1.Text.Equals(R2.Text) && fuzzy == false) { if (retout.Contains(R1) == false) { retout.Add(R1); incrementStatus(); } if (retout.Contains(R2) == false) { retout.Add(R2); } } } } return(retout); }
public static void resetRelativePath(Form1.IncrementStatusDel incrementStatus, ref TreeListView change, TreeListViewItem fromthis) { for (int a = 0; a < fromthis.Items.Count; a++) { String s = getRelativePath(fromthis.Items[a].fullPath); TreeListViewItem TLVI = getItemByName(change, fromthis.Items[a].fullPath); if (TLVI != null) { TLVI.Text = s; } fromthis.Items[a].Text = s; incrementStatus(); resetRelativePath(incrementStatus, ref change, fromthis.Items[a]); } }
public static void lowercase(Form1.IncrementStatusDel incrementStatus, ref TreeListView change, TreeListViewItem fromthis) { for (int a = 0; a < fromthis.Items.Count; a++) { String s = fromthis.Items[a].Text.ToLower(); TreeListViewItem TLVI = getItemByName(change, fromthis.Items[a].fullPath); if (TLVI != null) { TLVI.Text = s; } fromthis.Items[a].Text = s; incrementStatus(); camelcase(incrementStatus, ref change, fromthis.Items[a]); } }
public static void camelcase(Form1.IncrementStatusDel incrementStatus, ref TreeListView change, ref TreeListView fromthis) { for (int a = 0; a < fromthis.Items.Count; a++) { String s = StringExtras.ToCamelCase(fromthis.Items[a].Text, true, null); TreeListViewItem TLVI = getItemByName(change, fromthis.Items[a].fullPath); if (TLVI != null) { TLVI.Text = s; } fromthis.Items[a].Text = s; incrementStatus(); camelcase(incrementStatus, ref change, fromthis.Items[a]); } }
public static void spaceToDot(Form1.IncrementStatusDel incrementStatus, ref TreeListView change, TreeListViewItem fromthis, char replacethis, char withthis) { for (int a = 0; a < fromthis.Items.Count; a++) { String s = fromthis.Items[a].Text.Replace(replacethis, withthis); TreeListViewItem TLVI = getItemByName(change, fromthis.Items[a].fullPath); if (TLVI != null) { TLVI.Text = s; } fromthis.Items[a].Text = s; incrementStatus(); spaceToDot(incrementStatus, ref change, fromthis.Items[a], replacethis, withthis); } }
//from file to tree public static void DeserializeTreeListView(Form1.IncrementStatusDel incrementStatus, TreeListView TreeListView, string fileName) { XmlTextReader reader = null; try { // disabling re-drawing of TreeListView till all nodes are added TreeListView.BeginUpdate(); reader = new XmlTextReader(fileName); TreeListViewItem parentNode = null; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (reader.Name == XmlNodeTag) { TreeListViewItem newNode = new TreeListViewItem(); bool isEmptyElement = reader.IsEmptyElement; // loading node attributes int attributeCount = reader.AttributeCount; if (attributeCount > 0) { for (int i = 0; i < attributeCount; i++) { reader.MoveToAttribute(i); SetAttributeValue(newNode, reader.Name, reader.Value); } } newNode.SubItems.Add(newNode.nodeSize.getSizeString()); newNode.SubItems.Add(newNode.fullPath); newNode.Name = newNode.fullPath; incrementStatus(true); // add new node to Parent Node or TreeListView if (parentNode != null) { parentNode.Items.Add(newNode); } else { TreeListView.Items.Add(newNode); } // making current node 'ParentNode' if its not empty if (!isEmptyElement) { parentNode = newNode; } } } // moving up to in TreeListView if end tag is encountered else if (reader.NodeType == XmlNodeType.EndElement) { if (reader.Name == XmlNodeTag) { parentNode = parentNode.Parent; } } } } finally { // enabling redrawing of TreeListView after all nodes are added TreeListView.EndUpdate(); reader.Close(); } }