public static BundleInfo FromXml(XmlNode configNode) { var bundleInfo = Empty(); if (configNode != null) { foreach (var node in configNode.SelectNodes("./BundleList/Bundle")?.OfType <XmlNode>().ToArray() ?? new XmlNode[] { }) { bundleInfo.Items.Add(BundleListItem.FromXml(node)); } } return(bundleInfo); }
public static BundleListItem FromXml(XmlNode node) { var listDataItem = new BundleListItem(); if (node != null) { listDataItem.IsDefault = Boolean.Parse(node.Attributes?.OfType <XmlAttribute>() .FirstOrDefault(a => String.Equals(a.Name, "IsDefault", StringComparison.OrdinalIgnoreCase))?.Value ?? "false"); listDataItem.Value1 = node.SelectSingleNode("./Item1")?.InnerText; listDataItem.Value2 = node.SelectSingleNode("./Item2")?.InnerText; listDataItem.Value3 = node.SelectSingleNode("./Item3")?.InnerText; } return(listDataItem); }
public void OpenNode(BundleTreeNode node, bool reset = false) { if (ActiveNode != node || reset) { ActiveNode = node; UpdatePathPanel(); fileListView.Items.Clear(); List <BundleListItem> res = new List <BundleListItem>(); if (node.Parent != null) { res.Add(new BundleListItem { Node = node.Parent, Text = "..", IsDirectory = true, ImageKey = "openFolder" }); } res.AddRange(node.Directories.OrderBy(x => x.Key).Select(item => new BundleListItem { Node = item.Value, Text = item.Key, IsDirectory = true, ImageKey = "openFolder" })); foreach (var item in node.Files.OrderBy(x => x.Key)) { var lastItem = item.Value[item.Value.Count - 1]; var listItem = new BundleListItem { Node = null, FullPath = lastItem.Name, Text = item.Key, IsDirectory = false, ImageKey = "genericFile" }; listItem.SubItems.Add(lastItem.Size.ToString()); listItem.SubItems.Add(string.Format("{0}%", (100 - (int)(lastItem.ZSize / (float)lastItem.Size * 100.0f)))); listItem.SubItems.Add(lastItem.CompressionType); listItem.SubItems.Add(lastItem.DateString); res.Add(listItem); } fileListView.Items.AddRange(res.ToArray()); } }
public void Search(string s, int i) { var extension = ""; if (filetypeCB.SelectedIndex != -1) { extension = filetypeCB.Items[i].ToString(); } var found = SearchFiles(FileList.ToArray(), s, extension); if (found.Length > 1000) { found = found.Take(1000).ToArray(); } fileListView.Items.Clear(); var results = new List <BundleListItem>(); foreach (var file in found) { var lastItem = file; var listItem = new BundleListItem { Node = null, FullPath = lastItem.Name, Text = file.Name, IsDirectory = false, ImageKey = "genericFile" }; listItem.SubItems.Add(lastItem.Size.ToString()); listItem.SubItems.Add($"{(100 - (int) (lastItem.ZSize/(float) lastItem.Size*100.0f))}%"); listItem.SubItems.Add(lastItem.CompressionType); listItem.SubItems.Add(lastItem.DateString); results.Add(listItem); } fileListView.Items.AddRange(results.ToArray()); }
public static bool Equals(BundleListItem item1, BundleListItem item2) { return(String.Equals(item1?.Value1, item2?.Value1, StringComparison.OrdinalIgnoreCase) && String.Equals(item1?.Value2, item2?.Value2, StringComparison.OrdinalIgnoreCase) && String.Equals(item1?.Value3, item2?.Value3, StringComparison.OrdinalIgnoreCase)); }