mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Can now add new items to project.
This commit is contained in:
parent
fb2929e02a
commit
7f525d0d86
@ -8,7 +8,7 @@ namespace RainmeterStudio.Core.Model
|
||||
{
|
||||
public interface IDocument : INotifyPropertyChanged
|
||||
{
|
||||
Reference Reference { get; }
|
||||
Reference Reference { get; set; }
|
||||
bool IsDirty { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,11 @@ namespace RainmeterStudio.TextEditorPlugin
|
||||
InitializeComponent();
|
||||
|
||||
_document = document;
|
||||
text.Text = document.Lines.Aggregate((a, b) => a + "\n" + b);
|
||||
|
||||
StringBuilder txt = new StringBuilder();
|
||||
document.Lines.ForEach((line) => txt.AppendLine(line));
|
||||
|
||||
text.Text = txt.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@
|
||||
<Compile Include="UI\Dialogs\CreateProjectDialog.xaml.cs">
|
||||
<DependentUpon>CreateProjectDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\ProjectPanel.xaml.cs">
|
||||
<Compile Include="UI\Panels\ProjectPanel.xaml.cs">
|
||||
<DependentUpon>ProjectPanel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\UIManager.cs" />
|
||||
@ -124,7 +124,7 @@
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="UI\ProjectPanel.xaml">
|
||||
<Page Include="UI\Panels\ProjectPanel.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
|
@ -8,6 +8,7 @@ using RainmeterStudio.Core.Model.Events;
|
||||
using RainmeterStudio.UI.Dialogs;
|
||||
using RainmeterStudio.UI.ViewModel;
|
||||
using RainmeterStudio.Core.Model;
|
||||
using System.IO;
|
||||
|
||||
namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
@ -53,7 +54,7 @@ namespace RainmeterStudio.UI.Controller
|
||||
remove { DocumentManager.DocumentClosed -= value; }
|
||||
}
|
||||
|
||||
public Window OwnerWindow { get; set; }
|
||||
public MainWindow OwnerWindow { get; set; }
|
||||
|
||||
public DocumentController(DocumentManager documentManager, ProjectManager projectManager)
|
||||
{
|
||||
@ -75,10 +76,25 @@ namespace RainmeterStudio.UI.Controller
|
||||
return;
|
||||
|
||||
var format = dialog.SelectedTemplate;
|
||||
var path = dialog.SelectedName;
|
||||
|
||||
// Call manager
|
||||
DocumentManager.Create(format.Template);
|
||||
var editor = DocumentManager.Create(format.Template);
|
||||
|
||||
// Set the reference
|
||||
var name = dialog.SelectedName;
|
||||
|
||||
string folder = OwnerWindow.ProjectPanel.ActiveItem.Data.Path;
|
||||
if (!Directory.Exists(folder))
|
||||
folder = Path.GetDirectoryName(folder);
|
||||
|
||||
var reference = new Reference(name, Path.Combine(folder, name));
|
||||
editor.AttachedDocument.Reference = reference;
|
||||
|
||||
// Save document
|
||||
DocumentManager.Save(editor.AttachedDocument);
|
||||
|
||||
// Add to parent
|
||||
OwnerWindow.ProjectPanel.ActiveItem.Add(reference);
|
||||
}
|
||||
|
||||
public void Create(IDocumentTemplate format)
|
||||
|
@ -19,6 +19,7 @@ using RainmeterStudio.Core.Utils;
|
||||
using RainmeterStudio.Properties;
|
||||
using RainmeterStudio.Resources;
|
||||
using RainmeterStudio.UI.Controller;
|
||||
using RainmeterStudio.UI.ViewModel;
|
||||
|
||||
namespace RainmeterStudio.UI.Dialogs
|
||||
{
|
||||
@ -36,7 +37,12 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
{
|
||||
get
|
||||
{
|
||||
return listTemplates.SelectedItem as IProjectTemplate;
|
||||
var item = listTemplates.SelectedItem as ProjectTemplateViewModel;
|
||||
|
||||
if (item != null)
|
||||
return item.Template;
|
||||
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Window x:Class="RainmeterStudio.UI.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="clr-namespace:RainmeterStudio.UI"
|
||||
xmlns:uiPanels="clr-namespace:RainmeterStudio.UI.Panels"
|
||||
xmlns:ad="clr-namespace:Xceed.Wpf.AvalonDock;assembly=Xceed.Wpf.AvalonDock"
|
||||
xmlns:adlayout="clr-namespace:Xceed.Wpf.AvalonDock.Layout;assembly=Xceed.Wpf.AvalonDock"
|
||||
xmlns:r="clr-namespace:RainmeterStudio.Resources"
|
||||
@ -104,7 +104,7 @@
|
||||
<adlayout:LayoutAnchorablePaneGroup DockWidth="250" Orientation="Vertical">
|
||||
<adlayout:LayoutAnchorablePane>
|
||||
<adlayout:LayoutAnchorable Title="Project">
|
||||
<ui:ProjectPanel x:Name="projectPanel" />
|
||||
<uiPanels:ProjectPanel x:Name="projectPanel" />
|
||||
</adlayout:LayoutAnchorable>
|
||||
<adlayout:LayoutAnchorable Title="Outline" />
|
||||
</adlayout:LayoutAnchorablePane>
|
||||
|
@ -15,6 +15,7 @@ using RainmeterStudio.Business;
|
||||
using RainmeterStudio.Core.Model.Events;
|
||||
using RainmeterStudio.Storage;
|
||||
using RainmeterStudio.UI.Controller;
|
||||
using RainmeterStudio.UI.Panels;
|
||||
using Xceed.Wpf.AvalonDock.Layout;
|
||||
|
||||
namespace RainmeterStudio.UI
|
||||
@ -27,6 +28,8 @@ namespace RainmeterStudio.UI
|
||||
public DocumentController DocumentController { get; set; }
|
||||
public ProjectController ProjectController { get; set; }
|
||||
|
||||
public ProjectPanel ProjectPanel { get { return projectPanel; } }
|
||||
|
||||
public MainWindow(ProjectController projCtrl, DocumentController docCtrl)
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -52,7 +55,7 @@ namespace RainmeterStudio.UI
|
||||
// Spawn a new window
|
||||
LayoutDocument document = new LayoutDocument();
|
||||
document.Content = e.Editor.EditorUI;
|
||||
document.Title = e.Editor.AttachedDocument.Reference.Name;
|
||||
document.Title = (e.Editor.AttachedDocument.Reference == null) ? "New document" : e.Editor.AttachedDocument.Reference.Name;
|
||||
document.Closing += document_Closing;
|
||||
|
||||
documentPane.Children.Add(document);
|
||||
|
@ -1,4 +1,4 @@
|
||||
<UserControl x:Class="RainmeterStudio.UI.ProjectPanel"
|
||||
<UserControl x:Class="RainmeterStudio.UI.Panels.ProjectPanel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
@ -55,7 +55,7 @@
|
||||
<TreeView.ItemTemplate>
|
||||
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
||||
<DockPanel LastChildFill="True">
|
||||
<Image DockPanel.Dock="Left" Width="16" Height="16" Source="{Binding Data.Reference, Converter={StaticResource IconConverter}}" />
|
||||
<Image DockPanel.Dock="Left" Width="16" Height="16" Source="{Binding Data.Reference.Data, Converter={StaticResource IconConverter}}" />
|
||||
<TextBlock Text="{Binding Data.Name}" />
|
||||
</DockPanel>
|
||||
</HierarchicalDataTemplate>
|
@ -21,7 +21,7 @@ using RainmeterStudio.Storage;
|
||||
using RainmeterStudio.UI.Controller;
|
||||
using RainmeterStudio.UI.ViewModel;
|
||||
|
||||
namespace RainmeterStudio.UI
|
||||
namespace RainmeterStudio.UI.Panels
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SkinsPanel.xaml
|
||||
@ -37,7 +37,7 @@ namespace RainmeterStudio.UI
|
||||
}
|
||||
set
|
||||
{
|
||||
// Unsubscribe from old project
|
||||
// Unsubscribe from old controller
|
||||
if (_controller != null)
|
||||
{
|
||||
Controller.ActiveProjectChanged -= Controller_ActiveProjectChanged;
|
||||
@ -64,6 +64,26 @@ namespace RainmeterStudio.UI
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Gets the selected tree view item
|
||||
/// </summary>
|
||||
public Tree<Reference> ActiveItem
|
||||
{
|
||||
get
|
||||
{
|
||||
var selected = treeProjectItems.SelectedItem as Tree<ReferenceViewModel>;
|
||||
|
||||
if (selected == null)
|
||||
{
|
||||
return Controller.ActiveProject.Root;
|
||||
}
|
||||
else
|
||||
{
|
||||
return selected.Data.Reference;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _canExpand = false;
|
||||
private bool CanExpand
|
||||
{
|
||||
@ -75,10 +95,7 @@ namespace RainmeterStudio.UI
|
||||
{
|
||||
_canExpand = value;
|
||||
|
||||
if (ExpandAllCommand != null)
|
||||
ExpandAllCommand.NotifyCanExecuteChanged();
|
||||
|
||||
if (CollapseAllCommand != null)
|
||||
CollapseAllCommand.NotifyCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
@ -149,7 +166,7 @@ namespace RainmeterStudio.UI
|
||||
refTree.Remove(project);
|
||||
|
||||
// Transform to reference view model and return
|
||||
return refTree.TransformData<Reference, ReferenceViewModel>((data) => new ReferenceViewModel(data));
|
||||
return refTree.Transform<Reference, ReferenceViewModel>((node) => new Tree<ReferenceViewModel>(new ReferenceViewModel(node)));
|
||||
}
|
||||
|
||||
private Tree<ReferenceViewModel> GetProjectItems()
|
||||
@ -158,7 +175,7 @@ namespace RainmeterStudio.UI
|
||||
Tree<Reference> refTree = Controller.ActiveProject.Root;
|
||||
|
||||
// Transform to reference view model and return
|
||||
return refTree.TransformData<Reference, ReferenceViewModel>((data) => new ReferenceViewModel(data));
|
||||
return refTree.Transform<Reference, ReferenceViewModel>((node) => new Tree<ReferenceViewModel>(new ReferenceViewModel(node)));
|
||||
}
|
||||
|
||||
private void ExpandAll()
|
@ -17,7 +17,7 @@ namespace RainmeterStudio.UI.ViewModel
|
||||
/// <summary>
|
||||
/// Gets the linked reference
|
||||
/// </summary>
|
||||
public Reference Reference { get; private set; }
|
||||
public Tree<Reference> Reference { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name
|
||||
@ -26,11 +26,11 @@ namespace RainmeterStudio.UI.ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return Reference.Name;
|
||||
return Reference.Data.Name;
|
||||
}
|
||||
set
|
||||
{
|
||||
Reference.Name = value;
|
||||
Reference.Data.Name = value;
|
||||
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("Name"));
|
||||
@ -44,11 +44,11 @@ namespace RainmeterStudio.UI.ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return Reference.Path;
|
||||
return Reference.Data.Path;
|
||||
}
|
||||
set
|
||||
{
|
||||
Reference.Path = value;
|
||||
Reference.Data.Path = value;
|
||||
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("Path"));
|
||||
@ -115,7 +115,7 @@ namespace RainmeterStudio.UI.ViewModel
|
||||
/// Creates a new instance of reference view model
|
||||
/// </summary>
|
||||
/// <param name="reference">Reference</param>
|
||||
public ReferenceViewModel(Reference reference)
|
||||
public ReferenceViewModel(Tree<Reference> reference)
|
||||
{
|
||||
Reference = reference;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user