diff --git a/RainmeterEditor/App.xaml b/RainmeterEditor/App.xaml index aad2ee1f..3054e9e2 100644 --- a/RainmeterEditor/App.xaml +++ b/RainmeterEditor/App.xaml @@ -1,7 +1,8 @@  + StartupUri="UI/MainWindow.xaml" + Startup="Application_Startup"> diff --git a/RainmeterEditor/App.xaml.cs b/RainmeterEditor/App.xaml.cs index dff941ce..3a28b755 100644 --- a/RainmeterEditor/App.xaml.cs +++ b/RainmeterEditor/App.xaml.cs @@ -4,6 +4,8 @@ using System.Configuration; using System.Data; using System.Linq; using System.Windows; +using RainmeterEditor.Business; +using RainmeterEditor.Documents.Text; namespace RainmeterEditor { @@ -12,5 +14,9 @@ namespace RainmeterEditor /// public partial class App : Application { + private void Application_Startup(object sender, StartupEventArgs e) + { + DocumentManager.Instance.RegisterEditorFactory(new TextEditorFactory()); + } } } diff --git a/RainmeterEditor/Business/DocumentManager.cs b/RainmeterEditor/Business/DocumentManager.cs new file mode 100644 index 00000000..113a82bc --- /dev/null +++ b/RainmeterEditor/Business/DocumentManager.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RainmeterEditor.Model; +using RainmeterEditor.Model.Events; + +namespace RainmeterEditor.Business +{ + public class DocumentManager + { + #region Singleton instance + private static DocumentManager _instance = null; + + /// + /// Gets the instance of DocumentManager + /// + public static DocumentManager Instance + { + get + { + if (_instance == null) + _instance = new DocumentManager(); + + return _instance; + } + } + + #endregion + + private DocumentManager() + { + } + + List _factories = new List(); + List _editors = new List(); + + public event EventHandler DocumentOpened; + + /// + /// Registers a document editor factory + /// + /// Document editor factory + public void RegisterEditorFactory(IDocumentEditorFactory factory) + { + _factories.Add(factory); + } + + /// + /// Creates a new document in the specified path, with the specified format, and opens it + /// + /// + /// + public void Create(DocumentFormat format, string path) + { + // Create document + var document = format.Factory.CreateDocument(format, path); + + // Create editor + var editor = format.Factory.CreateEditor(document); + _editors.Add(editor); + + // Trigger event + if (DocumentOpened != null) + DocumentOpened(this, new DocumentOpenedEventArgs(editor)); + } + + public IEnumerable DocumentFormats + { + get + { + foreach (var f in _factories) + foreach (var df in f.CreateDocumentFormats) + yield return df; + } + } + } +} diff --git a/RainmeterEditor/Documents/Ini/IniDocument.cs b/RainmeterEditor/Documents/Ini/IniDocument.cs new file mode 100644 index 00000000..1cad4829 --- /dev/null +++ b/RainmeterEditor/Documents/Ini/IniDocument.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RainmeterEditor.Model; + +namespace RainmeterEditor.Documents.Ini +{ + /*public class IniDocument : IDocument + { + }*/ +} diff --git a/RainmeterEditor/Documents/Ini/IniSkinDesigner.cs b/RainmeterEditor/Documents/Ini/IniSkinDesigner.cs new file mode 100644 index 00000000..b68504cf --- /dev/null +++ b/RainmeterEditor/Documents/Ini/IniSkinDesigner.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RainmeterEditor.Model; + +namespace RainmeterEditor.Documents.Ini +{ + /*public class IniSkinDesigner : IDocumentEditor + { + public override IDocument Document + { + get { throw new NotImplementedException(); } + } + + public override string Title + { + get { throw new NotImplementedException(); } + } + + public override System.Windows.UIElement EditorUI + { + get { throw new NotImplementedException(); } + } + + public override EventHandler SelectionChanged + { + get { throw new NotImplementedException(); } + } + }*/ +} diff --git a/RainmeterEditor/Documents/Ini/IniSkinDesignerControl.xaml b/RainmeterEditor/Documents/Ini/IniSkinDesignerControl.xaml new file mode 100644 index 00000000..69b23166 --- /dev/null +++ b/RainmeterEditor/Documents/Ini/IniSkinDesignerControl.xaml @@ -0,0 +1,11 @@ + + + + + diff --git a/RainmeterEditor/Documents/Ini/IniSkinDesignerControl.xaml.cs b/RainmeterEditor/Documents/Ini/IniSkinDesignerControl.xaml.cs new file mode 100644 index 00000000..c9998a72 --- /dev/null +++ b/RainmeterEditor/Documents/Ini/IniSkinDesignerControl.xaml.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace RainmeterEditor.Documents.Ini +{ + /// + /// Interaction logic for IniSkinDesignerControl.xaml + /// + public partial class IniSkinDesignerControl : UserControl + { + public IniSkinDesignerControl() + { + InitializeComponent(); + } + } +} diff --git a/RainmeterEditor/Documents/Ini/IniSkinDesignerFactory.cs b/RainmeterEditor/Documents/Ini/IniSkinDesignerFactory.cs new file mode 100644 index 00000000..7a644116 --- /dev/null +++ b/RainmeterEditor/Documents/Ini/IniSkinDesignerFactory.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using RainmeterEditor.Model; + +namespace RainmeterEditor.Documents.Ini +{ + /*public class IniSkinDesignerFactory : IDocumentEditorFactory + { + + }*/ +} diff --git a/RainmeterEditor/Documents/Text/TextDocument.cs b/RainmeterEditor/Documents/Text/TextDocument.cs new file mode 100644 index 00000000..f2ab6ba2 --- /dev/null +++ b/RainmeterEditor/Documents/Text/TextDocument.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using RainmeterEditor.Model; + +namespace RainmeterEditor.Documents.Text +{ + public class TextDocument : IDocument + { + public string Name + { + get + { + return Path.GetFileName(FilePath); + } + } + + public string FilePath + { + get; set; + } + + public string Text + { + get; set; + } + + public TextDocument() + { + Text = String.Empty; + } + } +} diff --git a/RainmeterEditor/Documents/Text/TextEditor.cs b/RainmeterEditor/Documents/Text/TextEditor.cs new file mode 100644 index 00000000..673f514d --- /dev/null +++ b/RainmeterEditor/Documents/Text/TextEditor.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using RainmeterEditor.Model; + +namespace RainmeterEditor.Documents.Text +{ + public class TextEditor : IDocumentEditor + { + private TextDocument _document; + private TextEditorControl _control; + + public TextEditor(TextDocument document) + { + _document = document; + _control = new TextEditorControl(document); + } + + public override IDocument Document { get { return _document; } } + + public override string Title { get { return _document.Name; } } + + public override System.Windows.UIElement EditorUI { get { return _control; } } + } +} diff --git a/RainmeterEditor/Documents/Text/TextEditorControl.xaml b/RainmeterEditor/Documents/Text/TextEditorControl.xaml new file mode 100644 index 00000000..53b9aa76 --- /dev/null +++ b/RainmeterEditor/Documents/Text/TextEditorControl.xaml @@ -0,0 +1,11 @@ + + + + + diff --git a/RainmeterEditor/Documents/Text/TextEditorControl.xaml.cs b/RainmeterEditor/Documents/Text/TextEditorControl.xaml.cs new file mode 100644 index 00000000..0c625f0b --- /dev/null +++ b/RainmeterEditor/Documents/Text/TextEditorControl.xaml.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace RainmeterEditor.Documents.Text +{ + /// + /// Interaction logic for TextEditorControl.xaml + /// + public partial class TextEditorControl : UserControl + { + private TextDocument _document; + + public TextEditorControl(TextDocument document) + { + InitializeComponent(); + + _document = document; + text.Text = document.Text; + } + } +} diff --git a/RainmeterEditor/Documents/Text/TextEditorFactory.cs b/RainmeterEditor/Documents/Text/TextEditorFactory.cs new file mode 100644 index 00000000..8136c656 --- /dev/null +++ b/RainmeterEditor/Documents/Text/TextEditorFactory.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using RainmeterEditor.Business; +using RainmeterEditor.Model; + +namespace RainmeterEditor.Documents.Text +{ + public class TextEditorFactory : IDocumentEditorFactory + { + private TextStorage _storage = new TextStorage(); + + /// + public string EditorName + { + get { return Resources.Strings.DocumentEditor_Text_Name; } + } + + /// + public IEnumerable CreateDocumentFormats + { + get + { + yield return new DocumentFormat() + { + Name = Resources.Strings.DocumentFormat_TextFile_Name, + Category = Resources.Strings.Category_Utility, + DefaultExtension = ".txt", + Description = Resources.Strings.DocumentFormat_TextFile_Description, + Icon = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Resources/Icons/text-x-generic-32.png", UriKind.RelativeOrAbsolute)), + Factory = this + }; + } + } + + + public IDocumentEditor CreateEditor(IDocument document) + { + TextDocument textDocument = document as TextDocument; + + if (textDocument == null) + throw new ArgumentException("Cannot edit provided document."); + + return new TextEditor(textDocument); + } + + public IDocumentStorage Storage { get { return _storage; } } + + public IDocument CreateDocument(DocumentFormat format, string path) + { + var document = new TextDocument(); + document.FilePath = path; + + return document; + } + } +} diff --git a/RainmeterEditor/Documents/Text/TextStorage.cs b/RainmeterEditor/Documents/Text/TextStorage.cs new file mode 100644 index 00000000..0ac65ca8 --- /dev/null +++ b/RainmeterEditor/Documents/Text/TextStorage.cs @@ -0,0 +1,64 @@ +using System; +using System.IO; +using RainmeterEditor.Model; + +namespace RainmeterEditor.Documents.Text +{ + /// + /// Storage for text files + /// + public class TextStorage : IDocumentStorage + { + /// + IDocument IDocumentStorage.Read(string path) + { + TextDocument document = new TextDocument(); + document.FilePath = path; + document.Text = File.ReadAllText(path); + + return document; + } + + /// + public void Write(string path, IDocument document) + { + TextDocument textDocument = document as TextDocument; + + if (textDocument == null) + throw new ArgumentException("Provided document is not supported by this storage."); + + File.WriteAllText(path, textDocument.Text); + } + + /// + public bool CanRead(string path) + { + // Open the file + FileStream file = File.OpenRead(path); + + // Read a small chunk (1kb should be enough) + byte[] buffer = new byte[1024]; + int read = file.Read(buffer, 0, buffer.Length); + + // Close file + file.Close(); + + // Find 4 consecutive zero bytes + int cnt = 0; + for (int i = 0; i < read; i++) + { + // Count zero bytes + if (buffer[i] == 0) + ++cnt; + else cnt = 0; + + // Found > 4? Most likely binary file + if (cnt >= 4) + return false; + } + + // Not found, probably text file + return true; + } + } +} diff --git a/RainmeterEditor/Model/DocumentFormat.cs b/RainmeterEditor/Model/DocumentFormat.cs new file mode 100644 index 00000000..33c53728 --- /dev/null +++ b/RainmeterEditor/Model/DocumentFormat.cs @@ -0,0 +1,14 @@ +using System.Windows.Media; + +namespace RainmeterEditor.Model +{ + public class DocumentFormat + { + public string Name { get; set; } + public ImageSource Icon { get; set; } + public string Description { get; set; } + public string DefaultExtension { get; set; } + public IDocumentEditorFactory Factory { get; set; } + public string Category { get; set; } + } +} diff --git a/RainmeterEditor/Model/Events/DocumentOpenedEventArgs.cs b/RainmeterEditor/Model/Events/DocumentOpenedEventArgs.cs new file mode 100644 index 00000000..f195ffc4 --- /dev/null +++ b/RainmeterEditor/Model/Events/DocumentOpenedEventArgs.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace RainmeterEditor.Model.Events +{ + public class DocumentOpenedEventArgs : EventArgs + { + public IDocumentEditor Editor { get; private set; } + + public DocumentOpenedEventArgs(IDocumentEditor editor) + { + Editor = editor; + } + } +} diff --git a/RainmeterEditor/Model/IDocument.cs b/RainmeterEditor/Model/IDocument.cs new file mode 100644 index 00000000..d2fccb6d --- /dev/null +++ b/RainmeterEditor/Model/IDocument.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace RainmeterEditor.Model +{ + public interface IDocument + { + string Name { get; } + string FilePath { get; } + } +} diff --git a/RainmeterEditor/Model/IDocumentEditor.cs b/RainmeterEditor/Model/IDocumentEditor.cs new file mode 100644 index 00000000..3844e2dc --- /dev/null +++ b/RainmeterEditor/Model/IDocumentEditor.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; + +namespace RainmeterEditor.Model +{ + public abstract class IDocumentEditor : IDisposable + { + #region Dirty flag + + private bool _dirty = false; + + /// + /// Gets a flag indicating if the active document is dirty (modified and not saved) + /// + public virtual bool Dirty + { + get + { + return _dirty; + } + protected set + { + _dirty = value; + if (DirtyChanged != null) + DirtyChanged(this, new EventArgs()); + } + } + + /// + /// Triggered when the dirty flag changes + /// + public event EventHandler DirtyChanged; + + #endregion + + #region Document + + /// + /// Gets the opened document + /// + public abstract IDocument Document { get; } + + /// + /// Gets the title to be displayed in the title bar + /// + public abstract string Title { get; } + + /// + /// Triggered when the title changes + /// + public event EventHandler TitleChanged; + + #endregion + + #region EditorUI + + /// + /// Gets the editor UI + /// + public abstract UIElement EditorUI { get; } + + #endregion + + #region Selection properties + + /// + /// Gets a value indicating if this editor uses the selection properties window + /// + public virtual bool UsesSelectionProperties + { + get + { + return false; + } + } + + /// + /// Gets the name of the selected object + /// + public virtual string SelectionName + { + get + { + return String.Empty; + } + } + + /// + /// Gets a list of properties for the currently selected object + /// + public virtual IEnumerable SelectionProperties + { + get + { + yield break; + } + } + + /// + /// Triggered when the selected object changes (used to update properties) + /// + public event EventHandler SelectionChanged; + + #endregion + + #region Toolbox + + /// + /// Gets a list of items to populate the toolbox + /// + public virtual IEnumerable ToolboxItems + { + get + { + yield break; + } + } + + public event EventHandler ToolboxChanged; + + #endregion + + #region Dispose + /// + /// Dispose + /// + public virtual void Dispose() + { + } + + #endregion + } +} diff --git a/RainmeterEditor/Model/IDocumentEditorFactory.cs b/RainmeterEditor/Model/IDocumentEditorFactory.cs new file mode 100644 index 00000000..aa10e374 --- /dev/null +++ b/RainmeterEditor/Model/IDocumentEditorFactory.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RainmeterEditor.Storage; + +namespace RainmeterEditor.Model +{ + public interface IDocumentEditorFactory + { + /// + /// Name of the editor + /// + string EditorName { get; } + + /// + /// Formats that will be used to populate the 'create document' dialog + /// + IEnumerable CreateDocumentFormats { get; } + + /// + /// Creates a new editor object + /// + /// Document to be edited by the editor + /// A new document editor + IDocumentEditor CreateEditor(IDocument document); + + /// + /// Creates a new document + /// + /// A new document + IDocument CreateDocument(DocumentFormat format, string path); + + /// + /// Gets the storage of this factory + /// + IDocumentStorage Storage { get; } + } +} diff --git a/RainmeterEditor/Model/IDocumentStorage.cs b/RainmeterEditor/Model/IDocumentStorage.cs new file mode 100644 index 00000000..9ee7edac --- /dev/null +++ b/RainmeterEditor/Model/IDocumentStorage.cs @@ -0,0 +1,26 @@ +namespace RainmeterEditor.Model +{ + public interface IDocumentStorage + { + /// + /// Reads a document from file + /// + /// Path to file + /// Read document + IDocument Read(string path); + + /// + /// Writes a document to a file + /// + /// Path to file + /// Document to write + void Write(string path, IDocument document); + + /// + /// Tests if the file can be read by this storage + /// + /// Path to file + /// True if file can be read + bool CanRead(string path); + } +} diff --git a/RainmeterEditor/Model/Property.cs b/RainmeterEditor/Model/Property.cs new file mode 100644 index 00000000..2f06d25d --- /dev/null +++ b/RainmeterEditor/Model/Property.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace RainmeterEditor.Model +{ + public class Property + { + public string Name { get; set; } + + private object _value; + public object Value + { + get + { + return _value; + } + set + { + _value = value; + + if (ValueChanged != null) + ValueChanged(this, new EventArgs()); + } + } + + public event EventHandler ValueChanged; + } +} diff --git a/RainmeterEditor/RainmeterEditor.csproj b/RainmeterEditor/RainmeterStudio.csproj similarity index 69% rename from RainmeterEditor/RainmeterEditor.csproj rename to RainmeterEditor/RainmeterStudio.csproj index 3fb8e5eb..87079580 100644 --- a/RainmeterEditor/RainmeterEditor.csproj +++ b/RainmeterEditor/RainmeterStudio.csproj @@ -69,13 +69,55 @@ MSBuild:Compile Designer + + + + TextEditorControl.xaml + + + + + + + + + + IniSkinDesignerControl.xaml + + + + + + + True + True + Strings.resx + + + + CreateDocumentDialog.xaml + + + SkinsPanel.xaml + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -111,6 +153,10 @@ ResXFileCodeGenerator Resources.Designer.cs + + ResXFileCodeGenerator + Strings.Designer.cs + @@ -120,6 +166,12 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + Utility + + + Text Editor + + + Blank text file + + + Text file + + \ No newline at end of file diff --git a/RainmeterEditor/UI/Controller/DocumentController.cs b/RainmeterEditor/UI/Controller/DocumentController.cs new file mode 100644 index 00000000..ab96d8e0 --- /dev/null +++ b/RainmeterEditor/UI/Controller/DocumentController.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RainmeterEditor.Business; +using RainmeterEditor.UI.Dialogs; +using RainmeterEditor.Model.Events; +using RainmeterEditor.Model; + +namespace RainmeterEditor.UI.Controller +{ + public class DocumentController + { + public event EventHandler DocumentOpened + { + add + { + DocumentManager.Instance.DocumentOpened += value; + } + remove + { + DocumentManager.Instance.DocumentOpened -= value; + } + } + + public event EventHandler DocumentClosed; + + public DocumentController() + { + } + + public void Create() + { + // Show dialog + var dialog = new CreateDocumentDialog(); + bool? res = dialog.ShowDialog(); + + if (!res.HasValue || !res.Value) + return; + + var format = dialog.SelectedFormat; + var path = dialog.SelectedPath; + + // Call manager + DocumentManager.Instance.Create(format, path); + } + } +} diff --git a/RainmeterEditor/UI/Dialogs/CreateDocumentDialog.xaml b/RainmeterEditor/UI/Dialogs/CreateDocumentDialog.xaml new file mode 100644 index 00000000..1749a7ea --- /dev/null +++ b/RainmeterEditor/UI/Dialogs/CreateDocumentDialog.xaml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Path: + + + + + + + + + + + + diff --git a/RainmeterEditor/UI/Dialogs/CreateDocumentDialog.xaml.cs b/RainmeterEditor/UI/Dialogs/CreateDocumentDialog.xaml.cs new file mode 100644 index 00000000..cc033bfc --- /dev/null +++ b/RainmeterEditor/UI/Dialogs/CreateDocumentDialog.xaml.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +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 RainmeterEditor.Business; +using RainmeterEditor.Model; + +namespace RainmeterEditor.UI.Dialogs +{ + /// + /// Interaction logic for CreateDocumentDialog.xaml + /// + public partial class CreateDocumentDialog : Window + { + /// + /// Gets or sets the currently selected file format + /// + public DocumentFormat SelectedFormat + { + get + { + return listFormats.SelectedItem as DocumentFormat; + } + set + { + listFormats.SelectedItem = value; + } + } + + /// + /// Gets or sets the path + /// + public string SelectedPath + { + get + { + return textPath.Text; + } + set + { + textPath.Text = value; + } + } + + /// + /// Creates a new instance of CreateDocumentDialog + /// + public CreateDocumentDialog() + { + InitializeComponent(); + + PopulateFormats(); + } + + private void PopulateFormats() + { + listFormats.ItemsSource = DocumentManager.Instance.DocumentFormats; + CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(listFormats.ItemsSource); + view.GroupDescriptions.Add(new PropertyGroupDescription("Category")); + } + + private void buttonCreate_Click(object sender, RoutedEventArgs e) + { + DialogResult = true; + Close(); + } + + private void buttonCancel_Click(object sender, RoutedEventArgs e) + { + DialogResult = false; + Close(); + } + } +} diff --git a/RainmeterEditor/UI/MainWindow.xaml b/RainmeterEditor/UI/MainWindow.xaml index ec88b06e..cc1c7924 100644 --- a/RainmeterEditor/UI/MainWindow.xaml +++ b/RainmeterEditor/UI/MainWindow.xaml @@ -4,7 +4,7 @@ xmlns:ui="clr-namespace:RainmeterEditor.UI" xmlns:ad="clr-namespace:Xceed.Wpf.AvalonDock;assembly=Xceed.Wpf.AvalonDock" xmlns:adlayout="clr-namespace:Xceed.Wpf.AvalonDock.Layout;assembly=Xceed.Wpf.AvalonDock" - Title="MainWindow" Height="350" Width="525"> + Title="Rainmeter Studio" Height="350" Width="525"> @@ -20,7 +20,7 @@ - + diff --git a/RainmeterEditor/UI/MainWindow.xaml.cs b/RainmeterEditor/UI/MainWindow.xaml.cs index 64e22c5e..fca3c97a 100644 --- a/RainmeterEditor/UI/MainWindow.xaml.cs +++ b/RainmeterEditor/UI/MainWindow.xaml.cs @@ -11,6 +11,9 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using RainmeterEditor.Model.Events; +using RainmeterEditor.UI.Controller; +using Xceed.Wpf.AvalonDock.Layout; namespace RainmeterEditor { @@ -19,9 +22,46 @@ namespace RainmeterEditor /// public partial class MainWindow : Window { + DocumentController documentController = new DocumentController(); + public MainWindow() { InitializeComponent(); + + documentController.DocumentOpened += documentController_DocumentOpened; + } + + void documentController_DocumentOpened(object sender, DocumentOpenedEventArgs e) + { + // Spawn a new window + LayoutDocument document = new LayoutDocument(); + document.Content = e.Editor.EditorUI; + document.Title = e.Editor.Title; + document.Closing += document_Closing; + + documentPane.Children.Add(document); + documentPane.SelectedContentIndex = documentPane.IndexOf(document); + } + + void document_Closing(object sender, System.ComponentModel.CancelEventArgs e) + { + switch (MessageBox.Show("Are you sure?", "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question)) + { + case MessageBoxResult.Yes: + break; + + case MessageBoxResult.No: + break; + + default: + e.Cancel = true; + return; + } + } + + private void File_New_Click(object sender, RoutedEventArgs e) + { + documentController.Create(); } } -} +} \ No newline at end of file diff --git a/RainmeterEditor/UI/SkinsPanel.xaml.cs b/RainmeterEditor/UI/SkinsPanel.xaml.cs index 0b9c96bb..6cc848bd 100644 --- a/RainmeterEditor/UI/SkinsPanel.xaml.cs +++ b/RainmeterEditor/UI/SkinsPanel.xaml.cs @@ -25,7 +25,7 @@ namespace RainmeterEditor.UI { InitializeComponent(); - var x = Rainmeter.Instance.Handle; + //var x = Rainmeter.Instance.Handle; } } } diff --git a/RainmeterEditor.sln b/RainmeterStudio.sln similarity index 98% rename from RainmeterEditor.sln rename to RainmeterStudio.sln index 930fe685..cfc05631 100644 --- a/RainmeterEditor.sln +++ b/RainmeterStudio.sln @@ -72,7 +72,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginWin7Audio", "Plugins\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginWindowMessage", "Plugins\PluginWindowMessage\PluginWindowMessage.vcxproj", "{B9184DBA-C6B7-44FE-8BBD-0852DB22D2E4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RainmeterEditor", "RainmeterEditor\RainmeterEditor.csproj", "{438D0136-4A27-4E4D-A617-FFACE4554236}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RainmeterStudio", "RainmeterEditor\RainmeterStudio.csproj", "{438D0136-4A27-4E4D-A617-FFACE4554236}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution