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);
                }
            }
예제 #2
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);
        }
예제 #3
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);
        }
            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);
                        }
                    }
                }
            }