diff --git a/RainmeterStudio/Business/DocumentManager.cs b/RainmeterStudio/Business/DocumentManager.cs
index 62a38377..7e5eb36d 100644
--- a/RainmeterStudio/Business/DocumentManager.cs
+++ b/RainmeterStudio/Business/DocumentManager.cs
@@ -51,7 +51,7 @@ namespace RainmeterStudio.Business
///
///
///
- public void Create(DocumentFormat format, string path)
+ public void Create(DocumentTemplate format, string path)
{
// Create document
var document = format.Factory.CreateDocument(format, path);
@@ -65,7 +65,7 @@ namespace RainmeterStudio.Business
DocumentOpened(this, new DocumentOpenedEventArgs(editor));
}
- public IEnumerable DocumentFormats
+ public IEnumerable DocumentFormats
{
get
{
diff --git a/RainmeterStudio/Business/ProjectManager.cs b/RainmeterStudio/Business/ProjectManager.cs
index a29b6852..3a8bf75f 100644
--- a/RainmeterStudio/Business/ProjectManager.cs
+++ b/RainmeterStudio/Business/ProjectManager.cs
@@ -3,14 +3,117 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using RainmeterStudio.Model;
+using RainmeterStudio.Storage;
namespace RainmeterStudio.Business
{
public class ProjectManager
{
+ #region Properties
+
+ ///
+ /// Gets the currently opened project
+ ///
public Project ActiveProject { get; protected set; }
- public void Open() { }
- public void Close() { }
+ ///
+ /// Gets the currently opened project's path
+ ///
+ public string ActiveProjectPath { get; protected set; }
+
+ ///
+ /// Gets or sets the project storage
+ ///
+ protected ProjectStorage Storage { get; set; }
+
+ #endregion
+
+ #region Callbacks
+
+ ///
+ /// Called when a project is opened or the active project closes.
+ ///
+ public event EventHandler ActiveProjectChanged;
+
+ #endregion
+
+ ///
+ /// Initializes the project manager
+ ///
+ /// Project storage
+ public ProjectManager(ProjectStorage storage)
+ {
+ Storage = storage;
+ ActiveProject = null;
+ }
+
+ ///
+ /// Creates a new project
+ ///
+ /// Name of project
+ /// Path of project file
+ public void CreateProject(string name, string path)
+ {
+ // If there is an opened project, close it
+ if (ActiveProject != null)
+ Close();
+
+ // Create project object
+ ActiveProject = new Project();
+ ActiveProject.Name = name;
+
+ // Save to file
+ ActiveProjectPath = path;
+ SaveActiveProject();
+
+ // Raise event
+ if (ActiveProjectChanged != null)
+ ActiveProjectChanged(this, new EventArgs());
+ }
+
+ ///
+ /// Opens a project from disk
+ ///
+ ///
+ public void OpenProject(string path)
+ {
+ // If there is an opened project, close it
+ if (ActiveProject != null)
+ Close();
+
+ // Open using storage
+ ActiveProject = Storage.Load(path);
+ ActiveProjectPath = path;
+
+ // Raise event
+ if (ActiveProjectChanged != null)
+ ActiveProjectChanged(this, new EventArgs());
+ }
+
+ ///
+ /// Saves the changes to the current project to disk
+ ///
+ public void SaveActiveProject()
+ {
+ // Safety check
+ if (ActiveProject == null)
+ throw new InvalidOperationException("Cannot save a project that is not opened.");
+
+ // Save
+ Storage.Save(ActiveProjectPath, ActiveProject);
+ }
+
+ ///
+ /// Closes an opened project
+ ///
+ public void Close()
+ {
+ ActiveProject = null;
+ ActiveProjectPath = null;
+
+ // Raise event
+ if (ActiveProjectChanged != null)
+ ActiveProjectChanged(this, new EventArgs());
+ }
}
}
diff --git a/RainmeterStudio/Documents/Text/TextEditorFactory.cs b/RainmeterStudio/Documents/Text/TextEditorFactory.cs
index b75dbead..bdef5786 100644
--- a/RainmeterStudio/Documents/Text/TextEditorFactory.cs
+++ b/RainmeterStudio/Documents/Text/TextEditorFactory.cs
@@ -19,11 +19,11 @@ namespace RainmeterStudio.Documents.Text
}
///
- public IEnumerable CreateDocumentFormats
+ public IEnumerable CreateDocumentFormats
{
get
{
- yield return new DocumentFormat()
+ yield return new DocumentTemplate()
{
Name = Resources.Strings.DocumentFormat_TextFile_Name,
Category = Resources.Strings.Category_Utility,
@@ -48,7 +48,7 @@ namespace RainmeterStudio.Documents.Text
public IDocumentStorage Storage { get { return _storage; } }
- public IDocument CreateDocument(DocumentFormat format, string path)
+ public IDocument CreateDocument(DocumentTemplate format, string path)
{
var document = new TextDocument();
document.FilePath = path;
diff --git a/RainmeterStudio/Model/DocumentFormat.cs b/RainmeterStudio/Model/DocumentFormat.cs
index b9522f80..f525ca6a 100644
--- a/RainmeterStudio/Model/DocumentFormat.cs
+++ b/RainmeterStudio/Model/DocumentFormat.cs
@@ -2,7 +2,7 @@
namespace RainmeterStudio.Model
{
- public class DocumentFormat
+ public class DocumentTemplate
{
public string Name { get; set; }
public ImageSource Icon { get; set; }
diff --git a/RainmeterStudio/Model/IDocumentEditorFactory.cs b/RainmeterStudio/Model/IDocumentEditorFactory.cs
index a6205e9f..a1553509 100644
--- a/RainmeterStudio/Model/IDocumentEditorFactory.cs
+++ b/RainmeterStudio/Model/IDocumentEditorFactory.cs
@@ -16,7 +16,7 @@ namespace RainmeterStudio.Model
///
/// Formats that will be used to populate the 'create document' dialog
///
- IEnumerable CreateDocumentFormats { get; }
+ IEnumerable CreateDocumentFormats { get; }
///
/// Creates a new editor object
@@ -29,7 +29,7 @@ namespace RainmeterStudio.Model
/// Creates a new document
///
/// A new document
- IDocument CreateDocument(DocumentFormat format, string path);
+ IDocument CreateDocument(DocumentTemplate format, string path);
///
/// Gets the storage of this factory
diff --git a/RainmeterStudio/Properties/Settings.Designer.cs b/RainmeterStudio/Properties/Settings.Designer.cs
index c6767e20..43b346eb 100644
--- a/RainmeterStudio/Properties/Settings.Designer.cs
+++ b/RainmeterStudio/Properties/Settings.Designer.cs
@@ -22,5 +22,16 @@ namespace RainmeterStudio.Properties {
return defaultInstance;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ public global::System.Windows.Input.KeyGestureConverter asdf {
+ get {
+ return ((global::System.Windows.Input.KeyGestureConverter)(this["asdf"]));
+ }
+ set {
+ this["asdf"] = value;
+ }
+ }
}
}
diff --git a/RainmeterStudio/RainmeterStudio.csproj b/RainmeterStudio/RainmeterStudio.csproj
index 21268294..4a6c233f 100644
--- a/RainmeterStudio/RainmeterStudio.csproj
+++ b/RainmeterStudio/RainmeterStudio.csproj
@@ -40,6 +40,7 @@
+
@@ -95,6 +96,11 @@
+
+ True
+ True
+ Icons.resx
+
True
True
@@ -104,11 +110,15 @@
+
CreateDocumentDialog.xaml
+
+ CreateProjectDialog.xaml
+
SkinsPanel.xaml
@@ -124,6 +134,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
@@ -167,8 +181,12 @@
ResXFileCodeGenerator
Resources.Designer.cs
-
+
ResXFileCodeGenerator
+ Icons.Designer.cs
+
+
+ PublicResXFileCodeGenerator
Strings.Designer.cs
diff --git a/RainmeterStudio/Resources/Icons.Designer.cs b/RainmeterStudio/Resources/Icons.Designer.cs
new file mode 100644
index 00000000..81c269ec
--- /dev/null
+++ b/RainmeterStudio/Resources/Icons.Designer.cs
@@ -0,0 +1,81 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.34014
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace RainmeterStudio.Resources {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Icons {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Icons() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RainmeterStudio.Resources.Icons", typeof(Icons).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to /Resources/Icons/page_white_star_16.png.
+ ///
+ internal static string DocumentCreateCommand_Icon {
+ get {
+ return ResourceManager.GetString("DocumentCreateCommand_Icon", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to /Resources/Icons/project_star_16.png.
+ ///
+ internal static string ProjectCreateCommand_Icon {
+ get {
+ return ResourceManager.GetString("ProjectCreateCommand_Icon", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/RainmeterStudio/Resources/Icons.resx b/RainmeterStudio/Resources/Icons.resx
new file mode 100644
index 00000000..776fcd5c
--- /dev/null
+++ b/RainmeterStudio/Resources/Icons.resx
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ /Resources/Icons/page_white_star_16.png
+
+
+ /Resources/Icons/project_star_16.png
+
+
\ No newline at end of file
diff --git a/RainmeterStudio/Resources/Strings.Designer.cs b/RainmeterStudio/Resources/Strings.Designer.cs
index c82b8218..10a61dac 100644
--- a/RainmeterStudio/Resources/Strings.Designer.cs
+++ b/RainmeterStudio/Resources/Strings.Designer.cs
@@ -22,7 +22,7 @@ namespace RainmeterStudio.Resources {
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Strings {
+ public class Strings {
private static global::System.Resources.ResourceManager resourceMan;
@@ -36,7 +36,7 @@ namespace RainmeterStudio.Resources {
/// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
+ public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RainmeterStudio.Resources.Strings", typeof(Strings).Assembly);
@@ -51,7 +51,7 @@ namespace RainmeterStudio.Resources {
/// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
+ public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
@@ -63,16 +63,52 @@ namespace RainmeterStudio.Resources {
///
/// Looks up a localized string similar to Utility.
///
- internal static string Category_Utility {
+ public static string Category_Utility {
get {
return ResourceManager.GetString("Category_Utility", resourceCulture);
}
}
+ ///
+ /// Looks up a localized string similar to Browse.
+ ///
+ public static string Dialog_Browse {
+ get {
+ return ResourceManager.GetString("Dialog_Browse", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Cancel.
+ ///
+ public static string Dialog_Cancel {
+ get {
+ return ResourceManager.GetString("Dialog_Cancel", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Create.
+ ///
+ public static string Dialog_Create {
+ get {
+ return ResourceManager.GetString("Dialog_Create", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to OK.
+ ///
+ public static string Dialog_OK {
+ get {
+ return ResourceManager.GetString("Dialog_OK", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to _File....
///
- internal static string DocumentCreateCommand_DisplayText {
+ public static string DocumentCreateCommand_DisplayText {
get {
return ResourceManager.GetString("DocumentCreateCommand_DisplayText", resourceCulture);
}
@@ -81,7 +117,7 @@ namespace RainmeterStudio.Resources {
///
/// Looks up a localized string similar to Creates a new file.
///
- internal static string DocumentCreateCommand_ToolTip {
+ public static string DocumentCreateCommand_ToolTip {
get {
return ResourceManager.GetString("DocumentCreateCommand_ToolTip", resourceCulture);
}
@@ -90,7 +126,7 @@ namespace RainmeterStudio.Resources {
///
/// Looks up a localized string similar to Text Editor.
///
- internal static string DocumentEditor_Text_Name {
+ public static string DocumentEditor_Text_Name {
get {
return ResourceManager.GetString("DocumentEditor_Text_Name", resourceCulture);
}
@@ -99,7 +135,7 @@ namespace RainmeterStudio.Resources {
///
/// Looks up a localized string similar to Blank text file.
///
- internal static string DocumentFormat_TextFile_Description {
+ public static string DocumentFormat_TextFile_Description {
get {
return ResourceManager.GetString("DocumentFormat_TextFile_Description", resourceCulture);
}
@@ -108,10 +144,82 @@ namespace RainmeterStudio.Resources {
///
/// Looks up a localized string similar to Text file.
///
- internal static string DocumentFormat_TextFile_Name {
+ public static string DocumentFormat_TextFile_Name {
get {
return ResourceManager.GetString("DocumentFormat_TextFile_Name", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to _Project....
+ ///
+ public static string ProjectCreateCommand_DisplayText {
+ get {
+ return ResourceManager.GetString("ProjectCreateCommand_DisplayText", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Creates a new project.
+ ///
+ public static string ProjectCreateCommand_ToolTip {
+ get {
+ return ResourceManager.GetString("ProjectCreateCommand_ToolTip", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Location:.
+ ///
+ public static string ProjectCreateDialog_Location {
+ get {
+ return ResourceManager.GetString("ProjectCreateDialog_Location", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Set location as default.
+ ///
+ public static string ProjectCreateDialog_LocationDefault {
+ get {
+ return ResourceManager.GetString("ProjectCreateDialog_LocationDefault", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Name:.
+ ///
+ public static string ProjectCreateDialog_Name {
+ get {
+ return ResourceManager.GetString("ProjectCreateDialog_Name", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Path:.
+ ///
+ public static string ProjectCreateDialog_Path {
+ get {
+ return ResourceManager.GetString("ProjectCreateDialog_Path", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Create directory for project.
+ ///
+ public static string ProjectCreateDialog_PathCreateFolder {
+ get {
+ return ResourceManager.GetString("ProjectCreateDialog_PathCreateFolder", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Create project.
+ ///
+ public static string ProjectCreateDialog_Title {
+ get {
+ return ResourceManager.GetString("ProjectCreateDialog_Title", resourceCulture);
+ }
+ }
}
}
diff --git a/RainmeterStudio/Resources/Strings.resx b/RainmeterStudio/Resources/Strings.resx
index e2d125c1..5c45a36e 100644
--- a/RainmeterStudio/Resources/Strings.resx
+++ b/RainmeterStudio/Resources/Strings.resx
@@ -120,6 +120,18 @@
Utility
+
+ Browse
+
+
+ Cancel
+
+
+ Create
+
+
+ OK
+
_File...
@@ -135,4 +147,28 @@
Text file
+
+ _Project...
+
+
+ Creates a new project
+
+
+ Location:
+
+
+ Set location as default
+
+
+ Name:
+
+
+ Path:
+
+
+ Create directory for project
+
+
+ Create project
+
\ No newline at end of file
diff --git a/RainmeterStudio/UI/Controller/DocumentController.cs b/RainmeterStudio/UI/Controller/DocumentController.cs
index 6acaded3..083507a1 100644
--- a/RainmeterStudio/UI/Controller/DocumentController.cs
+++ b/RainmeterStudio/UI/Controller/DocumentController.cs
@@ -16,7 +16,25 @@ namespace RainmeterStudio.UI.Controller
{
#region Commands
- public Command DocumentCreateCommand { get; private set; }
+ public Command _documentCreateCommand;
+ public Command DocumentCreateCommand
+ {
+ get
+ {
+ if (_documentCreateCommand == null)
+ {
+ _documentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow())
+ {
+ DisplayText = Resources.Strings.DocumentCreateCommand_DisplayText,
+ Tooltip = Resources.Strings.DocumentCreateCommand_ToolTip,
+ Icon = new BitmapImage(new Uri(Resources.Icons.DocumentCreateCommand_Icon, UriKind.RelativeOrAbsolute)),
+ Shortcut = new KeyGesture(Key.N, ModifierKeys.Control)
+ };
+ }
+
+ return _documentCreateCommand;
+ }
+ }
#endregion
@@ -37,16 +55,9 @@ namespace RainmeterStudio.UI.Controller
public DocumentController()
{
- DocumentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow())
- {
- DisplayText = Resources.Strings.DocumentCreateCommand_DisplayText,
- Tooltip = Resources.Strings.DocumentCreateCommand_ToolTip,
- Icon = new BitmapImage(new Uri("/Resources/Icons/page_white_star_16.png", UriKind.RelativeOrAbsolute)),
- Shortcut = new KeyGesture(Key.N, ModifierKeys.Control)
- };
}
- public void CreateWindow(DocumentFormat defaultFormat = null, string defaultPath = "")
+ public void CreateWindow(DocumentTemplate defaultFormat = null, string defaultPath = "")
{
// Show dialog
var dialog = new CreateDocumentDialog()
@@ -67,7 +78,7 @@ namespace RainmeterStudio.UI.Controller
DocumentManager.Instance.Create(format, path);
}
- public void Create(DocumentFormat format, string path)
+ public void Create(DocumentTemplate format, string path)
{
// Call manager
DocumentManager.Instance.Create(format, path);
diff --git a/RainmeterStudio/UI/Controller/ProjectController.cs b/RainmeterStudio/UI/Controller/ProjectController.cs
new file mode 100644
index 00000000..ab0646f3
--- /dev/null
+++ b/RainmeterStudio/UI/Controller/ProjectController.cs
@@ -0,0 +1,148 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Input;
+using System.Windows.Media.Imaging;
+using RainmeterStudio.Business;
+using RainmeterStudio.Model;
+using RainmeterStudio.UI.Dialogs;
+
+namespace RainmeterStudio.UI.Controller
+{
+ public class ProjectController
+ {
+ #region Properties
+
+ ///
+ /// Gets the project manager
+ ///
+ protected ProjectManager Manager { get; private set; }
+
+ ///
+ /// Gets or sets the owner window. Used for creating dialogs.
+ ///
+ public Window OwnerWindow { get; set; }
+
+ ///
+ /// Gets the active project
+ ///
+ public Project ActiveProject
+ {
+ get
+ {
+ return Manager.ActiveProject;
+ }
+ }
+
+ ///
+ /// Gets the active project path
+ ///
+ public string ActiveProjectPath
+ {
+ get
+ {
+ return Manager.ActiveProjectPath;
+ }
+ }
+
+ #endregion
+
+ #region Callbacks
+
+ ///
+ /// Called when a project is opened or the active project closes.
+ ///
+ public event EventHandler ActiveProjectChanged
+ {
+ add
+ {
+ Manager.ActiveProjectChanged += value;
+ }
+ remove
+ {
+ Manager.ActiveProjectChanged -= value;
+ }
+ }
+
+ #endregion
+
+ #region Commands
+
+ private Command _projectCreateCommand;
+ public Command ProjectCreateCommand
+ {
+ get
+ {
+ if (_projectCreateCommand == null)
+ {
+ _projectCreateCommand = new Command("ProjectCreateComand", () => CreateProject())
+ {
+ DisplayText = Resources.Strings.ProjectCreateCommand_DisplayText,
+ Tooltip = Resources.Strings.ProjectCreateCommand_ToolTip,
+ Icon = new BitmapImage(new Uri(Resources.Icons.ProjectCreateCommand_Icon, UriKind.RelativeOrAbsolute)),
+ Shortcut = new KeyGesture(Key.N, ModifierKeys.Control | ModifierKeys.Shift)
+ };
+ }
+
+ return _projectCreateCommand;
+ }
+ }
+
+ #endregion
+
+ ///
+ /// Initializes the project controller
+ ///
+ /// Project manager
+ public ProjectController(ProjectManager manager)
+ {
+ Manager = manager;
+ }
+
+ ///
+ /// Displays the 'create project' dialog and creates a new project
+ ///
+ public void CreateProject(string name = null, string path = null)
+ {
+ // Create dialog
+ var dialog = new CreateProjectDialog();
+ dialog.Owner = OwnerWindow;
+ dialog.SelectedLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Rainmeter Studio Projects");
+
+ if (name != null)
+ dialog.Name = name;
+
+ if (path != null)
+ dialog.SelectedPath = path;
+
+ // Display
+ bool? res = dialog.ShowDialog();
+ if (!res.HasValue || !res.Value)
+ return;
+
+ string selectedPath = dialog.SelectedPath;
+
+ // Call manager
+ Manager.CreateProject(name, selectedPath); // TODO
+ }
+
+ ///
+ /// Displays an 'open file' dialog and opens an existing project
+ ///
+ ///
+ public void OpenProject(string path = null)
+ {
+
+ }
+
+ ///
+ /// Closes the active project
+ ///
+ public void CloseProject()
+ {
+ }
+ }
+}
diff --git a/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs b/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs
index 8c2767bf..be5e69c2 100644
--- a/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs
+++ b/RainmeterStudio/UI/Dialogs/CreateDocumentDialog.xaml.cs
@@ -24,11 +24,11 @@ namespace RainmeterStudio.UI.Dialogs
///
/// Gets or sets the currently selected file format
///
- public DocumentFormat SelectedFormat
+ public DocumentTemplate SelectedFormat
{
get
{
- return listFormats.SelectedItem as DocumentFormat;
+ return listFormats.SelectedItem as DocumentTemplate;
}
set
{
diff --git a/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml
new file mode 100644
index 00000000..2c38e379
--- /dev/null
+++ b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml.cs b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml.cs
new file mode 100644
index 00000000..c73cf525
--- /dev/null
+++ b/RainmeterStudio/UI/Dialogs/CreateProjectDialog.xaml.cs
@@ -0,0 +1,207 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using RainmeterStudio.Business;
+using RainmeterStudio.Model;
+
+namespace RainmeterStudio.UI.Dialogs
+{
+ ///
+ /// Interaction logic for CreateProjectDialog.xaml
+ ///
+ public partial class CreateProjectDialog : Window
+ {
+ #region Commands
+
+ private Command _createCommand;
+ public Command CreateCommand
+ {
+ get
+ {
+ if (_createCommand == null)
+ _createCommand = new Command("CreateCommand", Create, Validate);
+
+ return _createCommand;
+ }
+ }
+
+ private Command _cancelCommand;
+ public Command CancelCommand
+ {
+ get
+ {
+ if (_cancelCommand == null)
+ _cancelCommand = new Command("CancelCommand", Cancel);
+
+ return _cancelCommand;
+ }
+ }
+
+ #endregion
+
+ #region Properties
+
+ ///
+ /// Gets or sets the currently selected file format
+ ///
+ public DocumentTemplate SelectedTemplate
+ {
+ get
+ {
+ return listTemplates.SelectedItem as DocumentTemplate;
+ }
+ set
+ {
+ listTemplates.SelectedItem = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the path
+ ///
+ public string SelectedName
+ {
+ get
+ {
+ return textName.Text;
+ }
+ set
+ {
+ textName.Text = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the path
+ ///
+ public string SelectedLocation
+ {
+ get
+ {
+ return textLocation.Text;
+ }
+ set
+ {
+ textLocation.Text = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the path
+ ///
+ public string SelectedPath
+ {
+ get
+ {
+ return textPath.Text;
+ }
+ set
+ {
+ textPath.Text = value;
+ _pathUserSet = true;
+ }
+ }
+
+ #endregion
+
+ #region Private fields
+
+ private bool _pathUserSet = false;
+ private bool _ignoreNextChange = false;
+
+ #endregion
+
+ public CreateProjectDialog()
+ {
+ InitializeComponent();
+
+ textLocation.AddHandler(TextBoxBase.TextChangedEvent, new TextChangedEventHandler(textLocation_TextChanged));
+ textPath.AddHandler(TextBoxBase.TextChangedEvent, new TextChangedEventHandler(textPath_TextChanged));
+
+ DataContext = this;
+ }
+
+ private void Create()
+ {
+ DialogResult = true;
+ Close();
+ }
+
+ private void Cancel()
+ {
+ DialogResult = false;
+ Close();
+ }
+
+ private bool Validate()
+ {
+ bool res = true;
+ res &= !String.IsNullOrWhiteSpace(textPath.Text);
+ res &= (listTemplates.SelectedItem != null);
+ return 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();
+ }
+
+ private void textLocation_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ UpdatePath();
+ }
+
+ private void textPath_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ if (_ignoreNextChange)
+ {
+ _ignoreNextChange = false;
+ }
+ else
+ {
+ _pathUserSet = true;
+ }
+ }
+
+ private void checkCreateDirectory_CheckChanged(object sender, RoutedEventArgs e)
+ {
+ UpdatePath();
+ }
+ }
+}
diff --git a/RainmeterStudio/UI/MainWindow.xaml b/RainmeterStudio/UI/MainWindow.xaml
index 65071269..9973331b 100644
--- a/RainmeterStudio/UI/MainWindow.xaml
+++ b/RainmeterStudio/UI/MainWindow.xaml
@@ -6,11 +6,27 @@
xmlns:adlayout="clr-namespace:Xceed.Wpf.AvalonDock.Layout;assembly=Xceed.Wpf.AvalonDock"
Title="Rainmeter Studio" Height="350" Width="525"
ResizeMode="CanResizeWithGrip" >
-
+
-
+
+
-
+
@@ -27,19 +43,20 @@
diff --git a/RainmeterStudio/UI/MainWindow.xaml.cs b/RainmeterStudio/UI/MainWindow.xaml.cs
index 29cacacb..9d712e9c 100644
--- a/RainmeterStudio/UI/MainWindow.xaml.cs
+++ b/RainmeterStudio/UI/MainWindow.xaml.cs
@@ -11,7 +11,9 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using RainmeterStudio.Business;
using RainmeterStudio.Model.Events;
+using RainmeterStudio.Storage;
using RainmeterStudio.UI.Controller;
using Xceed.Wpf.AvalonDock.Layout;
@@ -22,9 +24,8 @@ namespace RainmeterStudio.UI
///
public partial class MainWindow : Window
{
- private DocumentController documentController;
-
- public Command DocumentCreateCommand { get { return documentController.DocumentCreateCommand; } }
+ public DocumentController DocumentController { get; set; }
+ public ProjectController ProjectController { get; set; }
public MainWindow()
{
@@ -32,10 +33,19 @@ namespace RainmeterStudio.UI
this.DataContext = this;
- documentController = new DocumentController();
- documentController.OwnerWindow = this;
- documentController.DocumentOpened += documentController_DocumentOpened;
- AddKeyBinding(documentController.DocumentCreateCommand);
+ // Initialize project controller
+ // TODO: put this in main
+ ProjectStorage projectStorage = new ProjectStorage();
+ ProjectManager projectManager = new ProjectManager(projectStorage);
+ ProjectController = new Controller.ProjectController(projectManager);
+ ProjectController.OwnerWindow = this;
+ AddKeyBinding(ProjectController.ProjectCreateCommand);
+
+ // Initialize document controller
+ DocumentController = new DocumentController();
+ DocumentController.OwnerWindow = this;
+ DocumentController.DocumentOpened += documentController_DocumentOpened;
+ AddKeyBinding(DocumentController.DocumentCreateCommand);
}
private void AddKeyBinding(Command c)