diff --git a/RainmeterStudio/Resources/Strings.Designer.cs b/RainmeterStudio/Resources/Strings.Designer.cs
index 47a4bb9e..a799170d 100644
--- a/RainmeterStudio/Resources/Strings.Designer.cs
+++ b/RainmeterStudio/Resources/Strings.Designer.cs
@@ -249,6 +249,15 @@ namespace RainmeterStudio.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Select project path.
+ ///
+ public static string CreateProjectDialog_Browse_Title {
+ get {
+ return ResourceManager.GetString("CreateProjectDialog_Browse_Title", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Location:.
///
@@ -277,7 +286,7 @@ namespace RainmeterStudio.Resources {
}
///
- /// Looks up a localized string similar to Path:.
+ /// Looks up a localized string similar to Full path:.
///
public static string CreateProjectDialog_Path {
get {
diff --git a/RainmeterStudio/Resources/Strings.resx b/RainmeterStudio/Resources/Strings.resx
index 6bb32b2a..0963ae54 100644
--- a/RainmeterStudio/Resources/Strings.resx
+++ b/RainmeterStudio/Resources/Strings.resx
@@ -184,7 +184,7 @@
Name:
- Path:
+ Full path:
Create directory for project
@@ -237,4 +237,7 @@
Empty project
+
+ Select project path
+
\ No newline at end of file
diff --git a/RainmeterStudio/UI/Controller/ProjectController.cs b/RainmeterStudio/UI/Controller/ProjectController.cs
index d1577fde..4cf66151 100644
--- a/RainmeterStudio/UI/Controller/ProjectController.cs
+++ b/RainmeterStudio/UI/Controller/ProjectController.cs
@@ -102,18 +102,12 @@ namespace RainmeterStudio.UI.Controller
///
/// Displays the 'create project' dialog and creates a new project
///
- public void CreateProject(string name = null, string path = null)
+ public void CreateProject()
{
// Create dialog
var dialog = new CreateProjectDialog(this);
dialog.Owner = OwnerWindow;
- if (name != null)
- dialog.Name = name;
-
- if (path != null)
- dialog.SelectedPath = path;
-
// Display
bool? res = dialog.ShowDialog();
if (!res.HasValue || !res.Value)
diff --git a/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml
index 27efe9ff..d716f816 100644
--- a/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml
+++ b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml
@@ -59,23 +59,21 @@
-
+
+
-
-
-
-
diff --git a/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml.cs b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml.cs
index e358c4bf..edde29b8 100644
--- a/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml.cs
+++ b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml.cs
@@ -11,11 +11,13 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
+using Microsoft.Win32;
using RainmeterStudio.Business;
using RainmeterStudio.Core.Documents;
using RainmeterStudio.Core.Model;
using RainmeterStudio.Core.Utils;
using RainmeterStudio.Properties;
+using RainmeterStudio.Resources;
using RainmeterStudio.UI.Controller;
namespace RainmeterStudio.UI.Dialogs
@@ -73,18 +75,18 @@ namespace RainmeterStudio.UI.Dialogs
}
///
- /// Gets or sets the path
+ /// Gets the selected path
///
public string SelectedPath
{
get
{
- return textPath.Text;
- }
- set
- {
- textPath.Text = value;
- _pathUserSet = true;
+ string path = SelectedLocation;
+
+ if (checkCreateDirectory.IsChecked.HasValue && checkCreateDirectory.IsChecked.Value)
+ path = System.IO.Path.Combine(path, SelectedName);
+
+ return System.IO.Path.Combine(path, SelectedName + ".rsproj");
}
}
@@ -92,8 +94,6 @@ namespace RainmeterStudio.UI.Dialogs
#region Private fields
- private bool _pathUserSet = false;
- private bool _ignoreNextChange = false;
private ProjectController _projectController;
#endregion
@@ -146,73 +146,20 @@ namespace RainmeterStudio.UI.Dialogs
{
bool res = true;
res &= (listTemplates.SelectedItem != null);
- res &= !String.IsNullOrWhiteSpace(textPath.Text);
- res &= PathHelper.IsPathValid(textPath.Text);
-
+
buttonCreate.IsEnabled = res;
}
- private void UpdatePath()
- {
- if (!_pathUserSet)
- {
- // Start with location
- string path = textLocation.Text;
-
- try
- {
- // Combine with project directory
- if (checkCreateDirectory.IsChecked.HasValue && checkCreateDirectory.IsChecked.Value)
- path = System.IO.Path.Combine(path, textName.Text);
-
- // Combine with project file name
- path = System.IO.Path.Combine(path, textName.Text + ".rsproj");
-
- // Set new value
- _ignoreNextChange = true;
- textPath.Text = path;
- }
- catch (ArgumentException)
- {
- }
- }
- }
-
private void textName_TextChanged(object sender, TextChangedEventArgs e)
{
- UpdatePath();
+ Validate();
}
private void textLocation_TextChanged(object sender, TextChangedEventArgs e)
{
- UpdatePath();
- }
-
- private void textPath_TextChanged(object sender, TextChangedEventArgs e)
- {
- if (_ignoreNextChange)
- {
- _ignoreNextChange = false;
- }
- else
- {
- _pathUserSet = true;
-
- try
- {
- textLocation.Text = System.IO.Path.GetDirectoryName(textPath.Text);
- }
- catch { }
- }
-
Validate();
}
- private void checkCreateDirectory_CheckChanged(object sender, RoutedEventArgs e)
- {
- UpdatePath();
- }
-
private void listTemplates_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Validate();
@@ -254,5 +201,23 @@ namespace RainmeterStudio.UI.Dialogs
}
}
}
+
+ private void buttonBrowse_Click(object sender, RoutedEventArgs e)
+ {
+ // Show dialog
+ SaveFileDialog dialog = new SaveFileDialog();
+ dialog.Title = Strings.CreateProjectDialog_Browse_Title;
+ dialog.AddExtension = true;
+ dialog.Filter = Strings.Dialog_FileType_Project + "|*.rsproj|" + Strings.Dialog_FileType_AllFiles + "|*.*";
+ dialog.InitialDirectory = SelectedLocation;
+ dialog.FileName = SelectedName;
+ bool? res = dialog.ShowDialog();
+
+ if (res.HasValue && res.Value)
+ {
+ SelectedName = System.IO.Path.GetFileNameWithoutExtension(dialog.FileName);
+ SelectedLocation = System.IO.Path.GetDirectoryName(dialog.FileName);
+ }
+ }
}
}