Browse Source

Fixed SD2-1235 - Browsing for a new folder in the New Project dialog should use the dialog's location as the starting folder. SharpDevelop now uses the FolderBrowserDialog that is a part of .NET 2.0 which allows the setting of the initial folder location.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2252 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 19 years ago
parent
commit
f8983fac80
  1. 10
      src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixPackageFilesControl.cs
  2. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  3. 18
      src/Main/Base/Project/Src/Gui/Components/StringListEditor.cs
  4. 22
      src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs
  5. 44
      src/Main/Base/Project/Src/Gui/Dialogs/FolderDialog.cs
  6. 9
      src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs
  7. 8
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/ProjectAndSolutionOptionsPanel.cs
  8. 27
      src/Main/Base/Project/Src/Services/File/FileService.cs
  9. 11
      src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Gui/SearchAndReplacePanel.cs

10
src/AddIns/BackendBindings/WixBinding/Project/Src/Gui/WixPackageFilesControl.cs

@ -12,6 +12,7 @@ using System.Windows.Forms; @@ -12,6 +12,7 @@ using System.Windows.Forms;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.WixBinding
@ -255,10 +256,11 @@ namespace ICSharpCode.WixBinding @@ -255,10 +256,11 @@ namespace ICSharpCode.WixBinding
TreeNode selectedNode = packageFilesTreeView.SelectedNode;
// Allow the user to select a directory.
FolderDialog dialog = new FolderDialog();
if (dialog.DisplayDialog("${res:ICSharpCode.WixBinding.PackageFilesView.AddDirectoryDialog.Title}") == DialogResult.OK) {
packageFilesTreeView.SelectedNode = selectedNode;
editor.AddDirectory(dialog.Path);
using (FolderBrowserDialog dialog = FileService.CreateFolderBrowserDialog("${res:ICSharpCode.WixBinding.PackageFilesView.AddDirectoryDialog.Title}")) {
if (dialog.ShowDialog() == DialogResult.OK) {
packageFilesTreeView.SelectedNode = selectedNode;
editor.AddDirectory(dialog.SelectedPath);
}
}
}

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -149,7 +149,6 @@ @@ -149,7 +149,6 @@
<SubType>Form</SubType>
</Compile>
<Compile Include="Src\Gui\Dialogs\DirtyFilesDialog.cs" />
<Compile Include="Src\Gui\Dialogs\FolderDialog.cs" />
<Compile Include="Src\Gui\Dialogs\NewFileDialog.cs">
<SubType>Form</SubType>
</Compile>

18
src/Main/Base/Project/Src/Gui/Components/StringListEditor.cs

@ -10,6 +10,7 @@ using System.Collections.Generic; @@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
namespace ICSharpCode.SharpDevelop.Gui
{
@ -281,14 +282,15 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -281,14 +282,15 @@ namespace ICSharpCode.SharpDevelop.Gui
void BrowseButtonClick(object sender, EventArgs e)
{
FolderDialog fdiag = new FolderDialog();
if (fdiag.DisplayDialog("${res:Dialog.ProjectOptions.SelectFolderTitle}") == DialogResult.OK) {
string path = fdiag.Path;
if (!path.EndsWith("\\") && !path.EndsWith("/"))
path += "\\";
editTextBox.Text = path;
if (autoAddAfterBrowse) {
AddButtonClick(null, null);
using (FolderBrowserDialog fdiag = FileService.CreateFolderBrowserDialog("${res:Dialog.ProjectOptions.SelectFolderTitle}")) {
if (fdiag.ShowDialog() == DialogResult.OK) {
string path = fdiag.SelectedPath;
if (!path.EndsWith("\\") && !path.EndsWith("/"))
path += "\\";
editTextBox.Text = path;
if (autoAddAfterBrowse) {
AddButtonClick(null, null);
}
}
}
}

22
src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs

@ -176,15 +176,21 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -176,15 +176,21 @@ namespace ICSharpCode.SharpDevelop.Gui
public void Event(object sender, EventArgs e)
{
FolderDialog fdiag = new FolderDialog();
if (fdiag.DisplayDialog(description) == DialogResult.OK) {
string path = fdiag.Path;
if (panel.baseDirectory != null) {
path = FileUtility.GetRelativePath(panel.baseDirectory, path);
string startLocation = panel.baseDirectory;
if (startLocation != null) {
startLocation = FileUtility.GetAbsolutePath(startLocation, panel.ControlDictionary[target].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 += "\\";
panel.ControlDictionary[target].Text = path;
}
if (!path.EndsWith("\\") && !path.EndsWith("/"))
path += "\\";
panel.ControlDictionary[target].Text = path;
}
}
}

44
src/Main/Base/Project/Src/Gui/Dialogs/FolderDialog.cs

@ -1,44 +0,0 @@ @@ -1,44 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version>$Revision$</version>
// </file>
using System.Windows.Forms;
using System.Windows.Forms.Design;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui
{
/// <summary>
/// This class helps to display the directory structure in the folder
/// As the FolderBrowser is inaccessible we have to inherit from the
/// FileNameBroswer and then call the method
/// </summary>
public class FolderDialog : FolderNameEditor
{
string path;
public string Path {
get {
return path;
}
}
// Alain VIZZINI reminded me to try out the .NET folder browser, because
// the my documents bug seemed to have gone away ...
public DialogResult DisplayDialog(string description)
{
using (FolderBrowser folderBrowser = new FolderBrowser()) {
folderBrowser.Description = StringParser.Parse(description);
DialogResult result = folderBrowser.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm);
path = folderBrowser.DirectoryPath;
LoggingService.Info("FolderDialog: user has choosen path " + path);
if (path == null || path.Length == 0)
return DialogResult.Cancel;
return result;
}
}
}
}

9
src/Main/Base/Project/Src/Gui/Dialogs/NewProjectDialog.cs

@ -320,11 +320,12 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs @@ -320,11 +320,12 @@ namespace ICSharpCode.SharpDevelop.Project.Dialogs
void BrowseDirectories(object sender, EventArgs e)
{
FolderDialog fd = new FolderDialog();
if (fd.DisplayDialog("${res:Dialog.NewProject.SelectDirectoryForProject}") == DialogResult.OK) {
((TextBox)ControlDictionary["locationTextBox"]).Text = fd.Path;
TextBox locationTextBox = ((TextBox)ControlDictionary["locationTextBox"]);
using (FolderBrowserDialog fd = FileService.CreateFolderBrowserDialog("${res:Dialog.NewProject.SelectDirectoryForProject}", locationTextBox.Text)) {
if (fd.ShowDialog() == DialogResult.OK) {
locationTextBox.Text = fd.SelectedPath;
}
}
// End
}
// list view event handlers

8
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/IDEOptions/ProjectAndSolutionOptionsPanel.cs

@ -51,9 +51,11 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -51,9 +51,11 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
void SelectProjectLocationButtonClicked(object sender, EventArgs e)
{
FolderDialog fdiag = new FolderDialog();
if (fdiag.DisplayDialog(StringParser.Parse("${res:Dialog.Options.IDEOptions.ProjectAndSolutionOptions.SelectDefaultProjectLocationDialog.Title}")) == DialogResult.OK) {
ControlDictionary["projectLocationTextBox"].Text = fdiag.Path;
TextBox projectLocationTextBox = (TextBox)ControlDictionary["projectLocationTextBox"];
using (FolderBrowserDialog fdiag = FileService.CreateFolderBrowserDialog("${res:Dialog.Options.IDEOptions.ProjectAndSolutionOptions.SelectDefaultProjectLocationDialog.Title}", projectLocationTextBox.Text)) {
if (fdiag.ShowDialog() == DialogResult.OK) {
projectLocationTextBox.Text = fdiag.SelectedPath;
}
}
}
}

27
src/Main/Base/Project/Src/Services/File/FileService.cs

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
@ -246,6 +247,32 @@ namespace ICSharpCode.SharpDevelop @@ -246,6 +247,32 @@ namespace ICSharpCode.SharpDevelop
return content;
}
/// <summary>
/// Creates a FolderBrowserDialog that will initially select the
/// specified folder. If the folder does not exist then the default
/// behaviour of the FolderBrowserDialog is used where it selects the
/// desktop folder.
/// </summary>
public static FolderBrowserDialog CreateFolderBrowserDialog(string description, string selectedPath)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.Description = StringParser.Parse(description);
if (selectedPath != null && selectedPath.Length > 0 && Directory.Exists(selectedPath)) {
dialog.RootFolder = Environment.SpecialFolder.MyComputer;
dialog.SelectedPath = selectedPath;
}
return dialog;
}
/// <summary>
/// Creates a FolderBrowserDialog that will initially select the
/// desktop folder.
/// </summary>
public static FolderBrowserDialog CreateFolderBrowserDialog(string description)
{
return CreateFolderBrowserDialog(description, null);
}
static void OnFileRemoved(FileEventArgs e)
{
if (FileRemoved != null) {

11
src/Main/Base/Project/Src/TextEditor/SearchAndReplace/Gui/SearchAndReplacePanel.cs

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
using System;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Gui.XmlForms;
using ICSharpCode.TextEditor;
@ -79,10 +80,12 @@ namespace SearchAndReplace @@ -79,10 +80,12 @@ namespace SearchAndReplace
void LookInBrowseButtonClicked(object sender, EventArgs e)
{
FolderDialog dlg = new FolderDialog();
if (dlg.DisplayDialog("${res:Dialog.NewProject.SearchReplace.LookIn.SelectDirectory}") == DialogResult.OK) {
Get<ComboBox>("lookIn").SelectedIndex = customDirectoryIndex;
Get<ComboBox>("lookIn").Text = dlg.Path;
ComboBox lookinComboBox = Get<ComboBox>("lookIn");
using (FolderBrowserDialog dlg = FileService.CreateFolderBrowserDialog("${res:Dialog.NewProject.SearchReplace.LookIn.SelectDirectory}", lookinComboBox.Text)) {
if (dlg.ShowDialog() == DialogResult.OK) {
lookinComboBox.SelectedIndex = customDirectoryIndex;
lookinComboBox.Text = dlg.SelectedPath;
}
}
}

Loading…
Cancel
Save