public static string GetShortFileName(FileInfo fileInfo, WixFiles wixFiles, XmlNode componentElement) { string ShortName = "ShortName"; if (WixEditSettings.Instance.IsUsingWix2()) { ShortName = "Name"; } string nameStart = Path.GetFileNameWithoutExtension(fileInfo.Name).ToUpper().Replace(" ", ""); int tooShort = 0; if (nameStart.Length > 7) { nameStart = nameStart.Substring(0, 7); } else { tooShort = 7 - nameStart.Length; } string nameExtension = fileInfo.Extension.ToUpper(); if (nameExtension.Length > 4) { nameExtension = nameExtension.Substring(0, 4); } int i = 0; string shortFileName = String.Format("{0}{1}", nameStart, nameExtension); while (componentElement.SelectSingleNode(String.Format("wix:File[@{0}={1}]", ShortName, XPathHelper.EscapeXPathInputString(shortFileName)), wixFiles.WxsNsmgr) != null) { if (i % 10 == 0 && Math.Log10(i) % 1 == 0.00) { if (tooShort > 0) { tooShort--; } else { if (nameStart.Length <= 1) { throw new WixEditException("Cannot determine unique short name for " + fileInfo.Name); } nameStart = nameStart.Substring(0, nameStart.Length - 1); } } shortFileName = String.Format("{0}{1}{2}", nameStart, i, nameExtension); i++; } return(shortFileName); }
public static string GetShortDirectoryName(DirectoryInfo directoryInfo, WixFiles wixFiles, XmlNode componentElement) { string ShortName = "ShortName"; if (WixEditSettings.Instance.IsUsingWix2()) { ShortName = "Name"; } string nameStart = directoryInfo.Name; int tooShort = 0; if (nameStart.Length > 7) { nameStart = nameStart.Substring(0, 7); } else { tooShort = 7 - nameStart.Length; } int i = 0; string shortDirectoryName = String.Format("{0}", nameStart); while (componentElement.SelectSingleNode(String.Format("wix:Directory[@{0}={1}]", ShortName, XPathHelper.EscapeXPathInputString(shortDirectoryName)), wixFiles.WxsNsmgr) != null) { if (i % 10 == 0 && Math.Log10(i) % 1 == 0.00) { if (tooShort > 0) { tooShort--; } else { nameStart = nameStart.Substring(0, nameStart.Length - 1); } } shortDirectoryName = String.Format("{0}{1}", nameStart, ++i); } return(shortDirectoryName); }
private void InternalSearch() { Clear(); try { string searchAttrib = String.Format("//@*[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),{0})]", XPathHelper.EscapeXPathInputString(currentSearch.ToLower())); string searchElement = String.Format("//*[contains(translate(text(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),{0})]", XPathHelper.EscapeXPathInputString(currentSearch.ToLower())); lastNodes = currentWixFiles.WxsDocument.SelectNodes(searchAttrib + "|" + searchElement); foreach (XmlNode node in lastNodes) { if (isCancelled) { break; } OutputResult(currentSearch, node, GetFirstElement(node)); } if (isCancelled) { Output("Aborted...", true); } else { Output("--------------------------------", false); Output(String.Format("Found \"{0}\" {1} {2}", currentSearch, lastNodes.Count, (lastNodes.Count == 1) ? "time" : "times"), true); } } catch (Exception ex) { Output(ex.ToString(), true); } editMenu.MenuItems.Remove(cancelMenuItem); outputTextBox.Cursor = Cursors.IBeam; }