diff --git a/RainmeterStudio/Business/ProjectManager.cs b/RainmeterStudio/Business/ProjectManager.cs
index 614768a0..0c9e5690 100644
--- a/RainmeterStudio/Business/ProjectManager.cs
+++ b/RainmeterStudio/Business/ProjectManager.cs
@@ -51,14 +51,14 @@ namespace RainmeterStudio.Business
///
/// Name of project
/// Path of project file
- public void CreateProject(string name, string path)
+ public void CreateProject(string name, string path, IProjectTemplate template)
{
// If there is an opened project, close it
if (ActiveProject != null)
Close();
// Create project object
- ActiveProject = new Project();
+ ActiveProject = template.CreateProject();
ActiveProject.Name = name;
ActiveProject.Path = path;
diff --git a/RainmeterStudio/Properties/Settings.Designer.cs b/RainmeterStudio/Properties/Settings.Designer.cs
index 8586ff67..a8f0bc67 100644
--- a/RainmeterStudio/Properties/Settings.Designer.cs
+++ b/RainmeterStudio/Properties/Settings.Designer.cs
@@ -163,12 +163,12 @@ namespace RainmeterStudio.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
- public string CreateProjectDialog_SavedLocation {
+ public string Project_SavedLocation {
get {
- return ((string)(this["CreateProjectDialog_SavedLocation"]));
+ return ((string)(this["Project_SavedLocation"]));
}
set {
- this["CreateProjectDialog_SavedLocation"] = value;
+ this["Project_SavedLocation"] = value;
}
}
diff --git a/RainmeterStudio/Properties/Settings.settings b/RainmeterStudio/Properties/Settings.settings
index af3b6bf2..5b022c2c 100644
--- a/RainmeterStudio/Properties/Settings.settings
+++ b/RainmeterStudio/Properties/Settings.settings
@@ -35,7 +35,7 @@
-
+
diff --git a/RainmeterStudio/UI/Controller/DocumentController.cs b/RainmeterStudio/UI/Controller/DocumentController.cs
index e7db9970..f5fb811a 100644
--- a/RainmeterStudio/UI/Controller/DocumentController.cs
+++ b/RainmeterStudio/UI/Controller/DocumentController.cs
@@ -31,6 +31,8 @@ namespace RainmeterStudio.UI.Controller
public Command DocumentCreateCommand { get; private set; }
+ public Command DocumentOpenCommand { get; private set; }
+
#endregion
///
@@ -58,25 +60,22 @@ namespace RainmeterStudio.UI.Controller
DocumentManager = documentManager;
ProjectManager = projectManager;
- DocumentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow());
+ DocumentCreateCommand = new Command("DocumentCreateCommand", () => Create(), () => ProjectManager.ActiveProject != null);
+ ProjectManager.ActiveProjectChanged += new EventHandler((obj, e) => DocumentCreateCommand.NotifyCanExecuteChanged());
}
- public void CreateWindow(IDocumentTemplate defaultFormat = null, string defaultPath = "")
+ public void Create()
{
// Show dialog
- var dialog = new CreateDocumentDialog(this)
- {
- Owner = OwnerWindow,
- SelectedTemplate = new DocumentTemplateViewModel(defaultFormat),
- SelectedPath = defaultPath
- };
+ var dialog = new CreateDocumentDialog(this);
+ dialog.Owner = OwnerWindow;
bool? res = dialog.ShowDialog();
if (!res.HasValue || !res.Value)
return;
var format = dialog.SelectedTemplate;
- var path = dialog.SelectedPath;
+ var path = dialog.SelectedName;
// Call manager
DocumentManager.Create(format.Template);
diff --git a/RainmeterStudio/UI/Controller/ProjectController.cs b/RainmeterStudio/UI/Controller/ProjectController.cs
index 4cf66151..5be17e4f 100644
--- a/RainmeterStudio/UI/Controller/ProjectController.cs
+++ b/RainmeterStudio/UI/Controller/ProjectController.cs
@@ -8,6 +8,7 @@ using RainmeterStudio.Business;
using RainmeterStudio.Core.Model;
using RainmeterStudio.UI.Dialogs;
using RainmeterStudio.UI.ViewModel;
+using RainmeterStudio.Properties;
namespace RainmeterStudio.UI.Controller
{
@@ -115,9 +116,10 @@ namespace RainmeterStudio.UI.Controller
string selectedName = dialog.SelectedName;
string selectedPath = dialog.SelectedPath;
+ IProjectTemplate selectedTemplate = dialog.SelectedTemplate;
// Call manager
- Manager.CreateProject(selectedName, selectedPath);
+ Manager.CreateProject(selectedName, selectedPath, selectedTemplate);
}
///
@@ -132,6 +134,7 @@ namespace RainmeterStudio.UI.Controller
+ Resources.Strings.Dialog_FileType_AllFiles + "|*.*";
dialog.Title = Resources.Strings.Dialog_OpenProject_Title;
dialog.Multiselect = false;
+ dialog.InitialDirectory = Settings.Default.Project_SavedLocation;
// Show dialog
bool? res = dialog.ShowDialog(OwnerWindow);
diff --git a/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml b/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml
index f03b219b..d021580a 100644
--- a/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml
+++ b/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml
@@ -34,7 +34,6 @@
-
@@ -43,18 +42,14 @@
-
-
- Path:
-
-
+
-
-
+
+
diff --git a/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs b/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs
index d17819cb..8558f001 100644
--- a/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs
+++ b/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs
@@ -2,6 +2,7 @@
using System.Linq;
using System.Windows;
using System.Windows.Controls;
+using RainmeterStudio.Core.Utils;
using RainmeterStudio.UI.Controller;
using RainmeterStudio.UI.ViewModel;
@@ -32,15 +33,15 @@ namespace RainmeterStudio.UI.Dialogs
///
/// Gets or sets the path
///
- public string SelectedPath
+ public string SelectedName
{
get
{
- return textPath.Text;
+ return textName.Text;
}
set
{
- textPath.Text = value;
+ textName.Text = value;
}
}
@@ -52,13 +53,9 @@ namespace RainmeterStudio.UI.Dialogs
InitializeComponent();
_documentController = docCtrl;
- PopulateFormats();
- Validate();
- }
+ listTemplates.ItemsSource = _documentController.DocumentTemplates.OrderBy(x => x.DisplayText);
- private void PopulateFormats()
- {
- listTemplates.ItemsSource = _documentController.DocumentTemplates;
+ Validate();
}
private void buttonCreate_Click(object sender, RoutedEventArgs e)
@@ -77,9 +74,8 @@ namespace RainmeterStudio.UI.Dialogs
{
bool res = true;
- res &= !String.IsNullOrWhiteSpace(textPath.Text);
- res &= !textPath.Text.Intersect(System.IO.Path.GetInvalidFileNameChars()).Any();
res &= (listTemplates.SelectedItem != null);
+ res &= PathHelper.IsFileNameValid(SelectedName);
buttonCreate.IsEnabled = res;
}
@@ -88,5 +84,10 @@ namespace RainmeterStudio.UI.Dialogs
{
Validate();
}
+
+ private void textName_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ Validate();
+ }
}
}
diff --git a/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml.cs b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml.cs
index b2d50d9f..88cf948b 100644
--- a/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml.cs
+++ b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml.cs
@@ -32,11 +32,11 @@ namespace RainmeterStudio.UI.Dialogs
///
/// Gets or sets the currently selected file format
///
- public IDocumentTemplate SelectedTemplate
+ public IProjectTemplate SelectedTemplate
{
get
{
- return listTemplates.SelectedItem as IDocumentTemplate;
+ return listTemplates.SelectedItem as IProjectTemplate;
}
set
{
@@ -125,7 +125,7 @@ namespace RainmeterStudio.UI.Dialogs
private string GetLocation()
{
// Get setting
- string location = Settings.Default.CreateProjectDialog_SavedLocation;
+ string location = Settings.Default.Project_SavedLocation;
// No location provided, use default
if (String.IsNullOrEmpty(location))
@@ -197,7 +197,7 @@ namespace RainmeterStudio.UI.Dialogs
// Save location
if (checkLocationDefault.IsChecked.HasValue && checkLocationDefault.IsChecked.Value)
{
- Settings.Default.CreateProjectDialog_SavedLocation = SelectedLocation;
+ Settings.Default.Project_SavedLocation = SelectedLocation;
}
}
}
diff --git a/RainmeterStudio/app.config b/RainmeterStudio/app.config
index 7de0c84f..43db7399 100644
--- a/RainmeterStudio/app.config
+++ b/RainmeterStudio/app.config
@@ -41,7 +41,7 @@
-
+