コード例 #1
1
 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);
 }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
 public BrowseButtonEvent(XmlFormsOptionPanel panel, Control target, string filter, TextBoxEditMode textBoxEditMode)
 {
     this.panel           = panel;
     this.filter          = filter;
     this.target          = target;
     this.textBoxEditMode = textBoxEditMode;
 }
コード例 #5
0
 internal BrowseFolderEvent(XmlFormsOptionPanel panel, string target, string description, TextBoxEditMode textBoxEditMode)
 {
     this.panel           = panel;
     this.description     = description;
     this.target          = target;
     this.textBoxEditMode = textBoxEditMode;
 }
コード例 #6
0
 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.");
     }
 }
コード例 #7
0
        /// <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));
                }
            }
        }
コード例 #8
0
 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);
 }
コード例 #9
0
		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);
		}
コード例 #10
0
ファイル: ProjectOptionPanel.cs プロジェクト: soshan10/AI
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
ファイル: DebugOptions.xaml.cs プロジェクト: Altaxo/Altaxo
		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;
		}
コード例 #15
0
 /// <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);
 }
コード例 #16
0
 public BrowseButtonInfo(string target, string fileFilter, TextBoxEditMode textBoxEditMode)
 {
     Target          = target;
     FileFilter      = fileFilter;
     TextBoxEditMode = textBoxEditMode;
 }
コード例 #17
0
        /// <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);
        }
コード例 #18
0
 internal BrowseFolderEvent(XmlFormsOptionPanel panel, string target, string description, TextBoxEditMode textBoxEditMode)
 {
     this.panel  = panel;
     this.description = description;
     this.target = target;
     this.textBoxEditMode = textBoxEditMode;
 }
コード例 #19
0
		/// <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);
		}	
コード例 #20
0
        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);
        }
コード例 #21
0
 protected void ConnectBrowseFolder(string browseButton, string target, TextBoxEditMode textBoxEditMode)
 {
     ConnectBrowseFolder(browseButton, target, "${res:Dialog.ProjectOptions.SelectFolderTitle}", textBoxEditMode);
 }
コード例 #22
0
		/// <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);
		}
コード例 #23
0
		public BrowseButtonInfo(string target, string fileFilter, TextBoxEditMode textBoxEditMode)
		{
			Target = target;
			FileFilter = fileFilter;
			TextBoxEditMode = textBoxEditMode;
		}
コード例 #24
0
		/// <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);
		}
コード例 #25
0
		/// <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);
		}
コード例 #26
0
		public BrowseFolderButtonInfo(string target, string description, TextBoxEditMode textBoxEditMode)
		{
			Target = target;
			Description = description;
			TextBoxEditMode = textBoxEditMode;
		}
コード例 #27
0
 /// <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));
 }
コード例 #28
0
 /// <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));
 }
コード例 #29
0
        /// <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);
        }
コード例 #30
0
 /// <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);
 }
コード例 #31
0
 public BrowseButtonEvent(XmlFormsOptionPanel panel, Control target, string filter, TextBoxEditMode textBoxEditMode)
 {
     this.panel  = panel;
     this.filter = filter;
     this.target = target;
     this.textBoxEditMode = textBoxEditMode;
 }
コード例 #32
0
 public BrowseFolderButtonInfo(string target, string description, TextBoxEditMode textBoxEditMode)
 {
     Target          = target;
     Description     = description;
     TextBoxEditMode = textBoxEditMode;
 }
コード例 #33
0
 protected void ConnectBrowseFolder(string browseButton, string target, TextBoxEditMode textBoxEditMode)
 {
     ConnectBrowseFolder(browseButton, target, "${res:Dialog.ProjectOptions.SelectFolderTitle}", textBoxEditMode);
 }
コード例 #34
0
 public ConfigurationGuiBinding BindString(Control control, string property, TextBoxEditMode textBoxEditMode)
 {
     return(BindString(control, property, textBoxEditMode, GetEmptyString));
 }