public Image GetImage(string p_strImagePath) { if (ModFiles == null) { return(null); } VirtualFileSystemItem vfiItem = ModFiles.Find((f) => { return(f.Path.Equals(p_strImagePath, StringComparison.OrdinalIgnoreCase)); }); byte[] bteImage = null; if (vfiItem != null) { if (Archive.IsArchivePath(vfiItem.Source)) { KeyValuePair <string, string> kvpArchive = Archive.ParseArchivePath(vfiItem.Source); using (Archive arcMod = new Archive(kvpArchive.Key)) { bteImage = arcMod.GetFileContents(kvpArchive.Value); } } else if (File.Exists(vfiItem.Source)) { bteImage = File.ReadAllBytes(vfiItem.Source); } } if (bteImage == null) { return(null); } using (MemoryStream msmImage = new MemoryStream(bteImage)) { try { Image imgTmp = Image.FromStream(msmImage); return(new Bitmap(imgTmp)); } catch (ArgumentException) { } } return(null); }
/// <summary> /// Addes the specified virtual path to the source tree. /// </summary> /// <param name="p_tndRoot">The node to which to add the path.</param> /// <param name="p_vfiPath">The path to add to the source tree.</param> public void AddVirtualPath(FileSystemTreeNode p_tndRoot, VirtualFileSystemItem p_vfiPath) { Cursor crsOldCursor = Cursor; Cursor = Cursors.WaitCursor; Queue<string> queRemainingPath = null; FileSystemTreeNode tndNode = FindNearestAncestor(p_tndRoot, p_vfiPath.Path, out queRemainingPath); string strCurrentPath = null; while (queRemainingPath.Count > 0) { strCurrentPath = queRemainingPath.Dequeue(); if ((queRemainingPath.Count > 0) || p_vfiPath.IsDirectory) { FileSystemTreeNode tndChild = new FileSystemTreeNode(strCurrentPath, null); ((tndNode == null) ? Nodes : tndNode.Nodes).Add(tndChild); OnNodeAdded(new NodesChangedEventArgs(tndChild)); tndNode = tndChild; } else { tndNode = AddPath(tndNode, p_vfiPath.Source); } } tndNode.AddSource(p_vfiPath.Source, true); Cursor = crsOldCursor; }
/// <summary> /// Addes the specified virtual paths to the source tree. /// </summary> /// <param name="p_tndRoot">The node to which to add the paths.</param> /// <param name="p_vfiPaths">The paths to add to the source tree.</param> public void AddVirtualPaths(FileSystemTreeNode p_tndRoot, VirtualFileSystemItem[] p_vfiPaths) { Cursor crsOldCursor = Cursor; Cursor = Cursors.WaitCursor; foreach (VirtualFileSystemItem vfiPath in p_vfiPaths) AddVirtualPath(p_tndRoot, vfiPath); Cursor = crsOldCursor; }