public void Event(object sender, EventArgs e) { using (OpenFileDialog fdiag = new OpenFileDialog()) { fdiag.Filter = StringParser.Parse(filter); fdiag.Multiselect = false; try { string initialDir = System.IO.Path.GetDirectoryName(System.IO.Path.Combine(panel.baseDirectory, target.Text)); if (FileUtility.IsValidPath(initialDir) && System.IO.Directory.Exists(initialDir)) { fdiag.InitialDirectory = initialDir; } } catch {} if (fdiag.ShowDialog() == DialogResult.OK) { string file = fdiag.FileName; if (panel.baseDirectory != null) { file = FileUtility.GetRelativePath(panel.baseDirectory, file); } if (textBoxEditMode == TextBoxEditMode.EditEvaluatedProperty) { target.Text = file; } else { target.Text = MSBuildInternals.Escape(file); } } } }
private void CreateKeyFile() { if (File.Exists(StrongNameTool)) { string title = StringParser.Parse("${res:Dialog.ProjectOptions.Signing.CreateKey.Title}"); string str = StringParser.Parse("${res:Dialog.ProjectOptions.Signing.CreateKey.KeyName}"); var keyName = str.Remove(str.IndexOf("&"), 1); string key = MessageService.ShowInputBox(title, keyName, base.Project.Name); if (!String.IsNullOrEmpty(key)) { if (!key.EndsWith(".snk") && !key.EndsWith(".pfx")) { key += ".snk"; } if (CreateKey(Path.Combine(base.Project.Directory, key))) { AssemblyOriginatorKeyFile.Value = MSBuildInternals.Escape(key); keyFileComboBox.Text = AssemblyOriginatorKeyFile.Value; } } } else { MessageService.ShowMessage("${res:Dialog.ProjectOptions.Signing.SNnotFound}"); } }
public void Event(object sender, EventArgs e) { string startLocation = panel.baseDirectory; if (startLocation != null) { string text = panel.ControlDictionary[target].Text; if (textBoxEditMode == TextBoxEditMode.EditRawProperty) { text = MSBuildInternals.Unescape(text); } startLocation = FileUtility.GetAbsolutePath(startLocation, text); } string path = SD.FileService.BrowseForFolder(description, startLocation); if (panel.baseDirectory != null) { path = FileUtility.GetRelativePath(panel.baseDirectory, path); } if (!path.EndsWith("\\", StringComparison.Ordinal) && !path.EndsWith("/", StringComparison.Ordinal)) { path += "\\"; } if (textBoxEditMode == TextBoxEditMode.EditEvaluatedProperty) { panel.ControlDictionary[target].Text = path; } else { panel.ControlDictionary[target].Text = MSBuildInternals.Escape(path); } }
void FindKeys(string directory) { directory = FileUtility.NormalizePath(directory); while (true) { try { foreach (string fileName in Directory.GetFiles(directory, "*.snk")) { keyFile.Add(MSBuildInternals.Escape(FileUtility.GetRelativePath(base.BaseDirectory, fileName))); } foreach (string fileName in Directory.GetFiles(directory, "*.pfx")) { keyFile.Add(MSBuildInternals.Escape(FileUtility.GetRelativePath(base.BaseDirectory, fileName))); } foreach (string fileName in Directory.GetFiles(directory, "*.key")) { keyFile.Add(MSBuildInternals.Escape(FileUtility.GetRelativePath(base.BaseDirectory, fileName))); } } catch { // can happen for networked drives / network locations break; } int pos = directory.LastIndexOf(Path.DirectorySeparatorChar); if (pos < 0) { break; } directory = directory.Substring(0, pos); } }
/// <summary> /// Shows an 'Open File' dialog. /// </summary> /// <param name="filter">The filter string that determines which files are displayed.</param> /// <param name="startLocation">Start location, relative to the <see cref="BaseDirectory"/></param> /// <param name="textBoxEditMode">The TextBoxEditMode used for the text box containing the file name</param> /// <returns>Returns the location of the file; or null if the dialog was cancelled.</returns> protected string BrowseForFile(string filter, string startLocation, TextBoxEditMode textBoxEditMode) { var dialog = new OpenFileDialog(); dialog.InitialDirectory = GetInitialDirectory(startLocation, textBoxEditMode, true); if (!String.IsNullOrEmpty(filter)) { dialog.Filter = StringParser.Parse(filter); } if (dialog.ShowDialog() == true) { string fileName = dialog.FileName; if (!String.IsNullOrEmpty(this.BaseDirectory)) { fileName = FileUtility.GetRelativePath(this.BaseDirectory, fileName); } if (textBoxEditMode == TextBoxEditMode.EditEvaluatedProperty) { return(fileName); } else { return(MSBuildInternals.Escape(fileName)); } } return(null); }
/// <summary> /// Shows the 'Browse for folder' dialog. /// </summary> /// <param name="description">A description shown inside the dialog.</param> /// <param name="startLocation">Start location, relative to the <see cref="BaseDirectory"/></param> /// <param name="textBoxEditMode">The TextBoxEditMode used for the text box containing the file name</param> /// <returns>Returns the location of the folder; or null if the dialog was cancelled.</returns> protected string BrowseForFolder(string description, string startLocation, TextBoxEditMode textBoxEditMode) { string startAt = GetInitialDirectory(startLocation, textBoxEditMode, false); using (var fdiag = FileService.CreateFolderBrowserDialog(description, startAt)) { if (fdiag.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string path = fdiag.SelectedPath; if (!String.IsNullOrEmpty(startLocation)) { path = FileUtility.GetRelativePath(startLocation, path); } if (!path.EndsWith("\\", StringComparison.Ordinal) && !path.EndsWith("/", StringComparison.Ordinal)) { path += "\\"; } if (textBoxEditMode == TextBoxEditMode.EditEvaluatedProperty) { return(path); } else { return(MSBuildInternals.Escape(path)); } } } return(null); }
/// <summary> /// Shows the 'Browse for folder' dialog. /// </summary> /// <param name="description">A description shown inside the dialog.</param> /// <param name="startLocation">Start location, relative to the <see cref="BaseDirectory"/></param> /// <param name="textBoxEditMode">The TextBoxEditMode used for the text box containing the file name</param> /// <returns>Returns the location of the folder; or null if the dialog was cancelled.</returns> private string BrowseForFolder(string description, string startLocation, TextBoxEditMode textBoxEditMode) { string startAt = GetInitialDirectory(startLocation, textBoxEditMode, false); string path = SD.FileService.BrowseForFolder(description, startAt); if (String.IsNullOrEmpty(path)) { return(null); } else { if (!String.IsNullOrEmpty(startLocation)) { path = FileUtility.GetRelativePath(startLocation, path); } if (!path.EndsWith("\\", StringComparison.Ordinal) && !path.EndsWith("/", StringComparison.Ordinal)) { path += "\\"; } if (textBoxEditMode == TextBoxEditMode.EditEvaluatedProperty) { return(path); } else { return(MSBuildInternals.Escape(path)); } } }
private void XmlDocHelper() { if (DocumentFileIsChecked) { this.DocumentationFile.Value = MSBuildInternals.Escape( Path.ChangeExtension(ICSharpCode.Core.FileUtility.GetRelativePath(projectOptions.Project.Directory, projectOptions. Project.OutputAssemblyFullPath), ".xml")); } else { this.DocumentationFile.Value = string.Empty; } }
void UpdateXmlEnabled(object sender, EventArgs e) { Get <TextBox>("xmlDocumentation").Enabled = Get <CheckBox>("xmlDocumentation").Checked; if (Get <CheckBox>("xmlDocumentation").Checked) { if (Get <TextBox>("xmlDocumentation").Text.Length == 0) { Get <TextBox>("xmlDocumentation").Text = MSBuildInternals.Escape( Path.ChangeExtension(FileUtility.GetRelativePath(baseDirectory, project.OutputAssemblyFullPath), ".xml")); } } else { Get <TextBox>("xmlDocumentation").Text = ""; } }
void CreateKeyFile() { if (File.Exists(CreateKeyForm.StrongNameTool)) { using (CreateKeyForm createKey = new CreateKeyForm(baseDirectory)) { createKey.KeyFile = project.Name; if (createKey.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK) { keyFile.Text = MSBuildInternals.Escape(createKey.KeyFile); return; } } } else { MessageService.ShowMessage("${res:Dialog.ProjectOptions.Signing.SNnotFound}"); } keyFile.Text = ""; }
public void Event(object sender, EventArgs e) { string startLocation = panel.baseDirectory; if (startLocation != null) { string text = panel.ControlDictionary[target].Text; if (textBoxEditMode == TextBoxEditMode.EditRawProperty) { text = MSBuildInternals.Unescape(text); } startLocation = FileUtility.GetAbsolutePath(startLocation, text); } using (FolderBrowserDialog fdiag = FileService.CreateFolderBrowserDialog(description, startLocation)) { if (fdiag.ShowDialog() == DialogResult.OK) { string path = fdiag.SelectedPath; if (panel.baseDirectory != null) { path = FileUtility.GetRelativePath(panel.baseDirectory, path); } if (!path.EndsWith("\\") && !path.EndsWith("/")) { path += "\\"; } if (textBoxEditMode == TextBoxEditMode.EditEvaluatedProperty) { panel.ControlDictionary[target].Text = path; } else { panel.ControlDictionary[target].Text = MSBuildInternals.Escape(path); } } } }
bool EnsureCorrectName(ref string newName) { newName = newName.Trim(); if (editPlatforms && string.Equals(newName, "AnyCPU", StringComparison.OrdinalIgnoreCase)) { newName = "Any CPU"; } foreach (string item in listBox.Items) { if (string.Equals(item, newName, StringComparison.OrdinalIgnoreCase)) { MessageService.ShowMessage("${res:Dialog.EditAvailableConfigurationsDialog.DuplicateName}"); return(false); } } if (MSBuildInternals.Escape(newName) != newName || !FileUtility.IsValidDirectoryEntryName(newName) || newName.Contains("'")) { MessageService.ShowMessage("${res:Dialog.EditAvailableConfigurationsDialog.InvalidName}"); return(false); } return(true); }
bool EnsureCorrectName(ref string newName) { newName = newName.Trim(); if (editPlatforms && string.Equals(newName, "AnyCPU", StringComparison.InvariantCultureIgnoreCase)) { newName = "Any CPU"; } foreach (string item in listBox.Items) { if (string.Equals(item, newName, StringComparison.InvariantCultureIgnoreCase)) { MessageService.ShowMessage("Duplicate name."); return(false); } } if (MSBuildInternals.Escape(newName) != newName || !FileUtility.IsValidDirectoryName(newName) || newName.Contains("'")) { MessageService.ShowMessage("The name was invalid."); return(false); } return(true); }
public void SetEvaluatedMetadata(string name, string value) { item.SetMetadataValue(name, MSBuildInternals.Escape(value)); }