protected void BrowseForFile(Control target, string filter, TextBoxEditMode textBoxEditMode) { if (target == null) { throw new ArgumentNullException("target"); } new BrowseButtonEvent(this, target, filter, textBoxEditMode).Event(null, 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 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); }
public BrowseButtonEvent(XmlFormsOptionPanel panel, Control target, string filter, TextBoxEditMode textBoxEditMode) { this.panel = panel; this.filter = filter; this.target = target; this.textBoxEditMode = textBoxEditMode; }
internal BrowseFolderEvent(XmlFormsOptionPanel panel, string target, string description, TextBoxEditMode textBoxEditMode) { this.panel = panel; this.description = description; this.target = target; this.textBoxEditMode = textBoxEditMode; }
public ConfigurationGuiBinding BindString(Control control, string property, TextBoxEditMode textBoxEditMode, Func <string> defaultValueProvider) { if (control is TextBoxBase || control is ComboBox) { SimpleTextBinding binding = new SimpleTextBinding(control, defaultValueProvider); if (textBoxEditMode == TextBoxEditMode.EditEvaluatedProperty) { binding.TreatPropertyValueAsLiteral = true; } else { binding.TreatPropertyValueAsLiteral = false; } AddBinding(property, binding); control.TextChanged += ControlValueChanged; if (control is ComboBox) { control.KeyDown += ComboBoxKeyDown; } return(binding); } else { throw new ApplicationException("Cannot bind " + control.GetType().Name + " to string property."); } }
/// <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)); } } }
protected void ConnectBrowseFolder(string browseButton, string target, string description, TextBoxEditMode textBoxEditMode) { if (ControlDictionary[browseButton] == null) { MessageService.ShowError(browseButton + " not found!"); return; } if (ControlDictionary[target] == null) { MessageService.ShowError(target + " not found!"); return; } ControlDictionary[browseButton].Click += new EventHandler(new BrowseFolderEvent(this, target, description, textBoxEditMode).Event); }
public ProjectProperty <string> GetProperty(string propertyName, string defaultValue, TextBoxEditMode textBoxEditMode = TextBoxEditMode.EditEvaluatedProperty, PropertyStorageLocations defaultLocation = PropertyStorageLocations.Base) { IProjectProperty existingProperty; if (projectProperties.TryGetValue(propertyName, out existingProperty)) { return((ProjectProperty <string>)existingProperty); } bool treatAsLiteral = (textBoxEditMode == TextBoxEditMode.EditEvaluatedProperty); ProjectProperty <string> newProperty = new ProjectProperty <string>(this, propertyName, defaultValue, defaultLocation, treatAsLiteral); projectProperties.Add(propertyName, newProperty); return(newProperty); }
public ProjectProperty <string> GetProperty(string propertyName, string defaultValue, TextBoxEditMode textBoxEditMode = TextBoxEditMode.EditEvaluatedProperty, PropertyStorageLocations defaultLocation = PropertyStorageLocations.Base) { ILoadSaveCallback existingProperty; if (projectProperties.TryGetValue(propertyName, out existingProperty)) { return((ProjectProperty <string>)existingProperty); } bool treatAsLiteral = (textBoxEditMode == TextBoxEditMode.EditEvaluatedProperty); ProjectProperty <string> newProperty = new ProjectProperty <string>(this, propertyName, defaultValue, defaultLocation, treatAsLiteral); projectProperties.Add(propertyName, newProperty); if (isLoaded) { newProperty.Load(project, activeConfiguration, activePlatform); } return(newProperty); }
private string BrowseForFolder(string description, TextBoxEditMode textBoxEditMode) { string startLocation = base.BaseDirectory; if (startLocation != null) { string text = StartWorkingDirectory.Value; 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 (base.BaseDirectory != null) { path = FileUtility.GetRelativePath(base.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); //// } return(path); } } return(startLocation); }
string GetInitialDirectory(string relativeLocation, TextBoxEditMode textBoxEditMode, bool isFile) { if (textBoxEditMode == TextBoxEditMode.EditRawProperty) { relativeLocation = MSBuildInternals.Unescape(relativeLocation); } if (string.IsNullOrEmpty(relativeLocation)) { return(this.BaseDirectory); } try { string path = FileUtility.GetAbsolutePath(this.BaseDirectory, relativeLocation); if (FileUtility.IsValidPath(path)) { return(isFile ? System.IO.Path.GetDirectoryName(path) : path); } } catch (ArgumentException) { // can happen in GetAbsolutePath if the path contains invalid characters } return(this.BaseDirectory); }
private string BrowseForFolder(string description,TextBoxEditMode textBoxEditMode) { string startLocation = base.BaseDirectory; if (startLocation != null) { string text = StartWorkingDirectory.Value; 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 (base.BaseDirectory != null) { path = FileUtility.GetRelativePath(base.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); //// } return path; } } return startLocation; }
/// <summary> /// Connects the browse button control to the target control. /// </summary> protected virtual void ConnectBrowseButtonControl(string browseButton, string target, string fileFilter, TextBoxEditMode textBoxEditMode) { ConnectBrowseButton(browseButton, target, fileFilter, textBoxEditMode); }
public BrowseButtonInfo(string target, string fileFilter, TextBoxEditMode textBoxEditMode) { Target = target; FileFilter = fileFilter; TextBoxEditMode = textBoxEditMode; }
/// <summary> /// Connects the browse button control to the target control. /// </summary> protected override void ConnectBrowseButtonControl(string browseButton, string target, string fileFilter, TextBoxEditMode textBoxEditMode) { BrowseButtonInfo browseButtonInfo = new BrowseButtonInfo(target, fileFilter, textBoxEditMode); browseButtons.Add(browseButton, browseButtonInfo); base.ConnectBrowseButtonControl(browseButton, target, fileFilter, textBoxEditMode); }
/// <summary> /// Connects the browse folder button control to the target control. /// </summary> protected override void ConnectBrowseFolderButtonControl(string browseButton, string target, string description, TextBoxEditMode textBoxEditMode) { BrowseFolderButtonInfo browseButtonInfo = new BrowseFolderButtonInfo(target, description, textBoxEditMode); browseFolderButtons.Add(browseButton, browseButtonInfo); base.ConnectBrowseFolderButtonControl(browseButton, target, description, textBoxEditMode); }
protected void ConnectBrowseFolder(string browseButton, string target, TextBoxEditMode textBoxEditMode) { ConnectBrowseFolder(browseButton, target, "${res:Dialog.ProjectOptions.SelectFolderTitle}", textBoxEditMode); }
/// <summary> /// Binds the string property to a text box control. /// </summary> protected virtual ConfigurationGuiBinding BindString(string control, string property, TextBoxEditMode textBoxEditMode) { return helper.BindString(control, property, textBoxEditMode); }
/// <summary> /// Connects the browse folder button control to the target control. /// </summary> protected virtual void ConnectBrowseFolderButtonControl(string browseButton, string target, string description, TextBoxEditMode textBoxEditMode) { ConnectBrowseFolder(browseButton, target, description, textBoxEditMode); }
/// <summary> /// Called when binding a string property to a control. /// </summary> protected override ConfigurationGuiBinding BindString(string control, string property, TextBoxEditMode textBoxEditMode) { boundStringControls.Add(property, control); boundTextEditModes.Add(property, textBoxEditMode); return base.BindString(control, property, textBoxEditMode); }
public BrowseFolderButtonInfo(string target, string description, TextBoxEditMode textBoxEditMode) { Target = target; Description = description; TextBoxEditMode = textBoxEditMode; }
/// <summary> /// Called when binding a string property to a control. /// </summary> protected override ConfigurationGuiBinding BindString(string control, string property, TextBoxEditMode textBoxEditMode) { boundStringControls.Add(property, control); boundTextEditModes.Add(property, textBoxEditMode); return(base.BindString(control, property, textBoxEditMode)); }
/// <summary> /// Binds the string property to a text box control. /// </summary> protected virtual ConfigurationGuiBinding BindString(string control, string property, TextBoxEditMode textBoxEditMode) { return(helper.BindString(control, property, textBoxEditMode)); }
public ConfigurationGuiBinding BindString(Control control, string property, TextBoxEditMode textBoxEditMode) { return(BindString(control, property, textBoxEditMode, GetEmptyString)); }