mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Added project templates, work on document template
This commit is contained in:
@ -7,6 +7,7 @@ using RainmeterStudio.Core.Documents;
|
||||
using RainmeterStudio.Core.Model.Events;
|
||||
using RainmeterStudio.UI.Dialogs;
|
||||
using RainmeterStudio.UI.ViewModel;
|
||||
using RainmeterStudio.Core.Model;
|
||||
|
||||
namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
@ -60,7 +61,7 @@ namespace RainmeterStudio.UI.Controller
|
||||
DocumentCreateCommand = new Command("DocumentCreateCommand", () => CreateWindow());
|
||||
}
|
||||
|
||||
public void CreateWindow(DocumentTemplate defaultFormat = null, string defaultPath = "")
|
||||
public void CreateWindow(IDocumentTemplate defaultFormat = null, string defaultPath = "")
|
||||
{
|
||||
// Show dialog
|
||||
var dialog = new CreateDocumentDialog(this)
|
||||
@ -81,7 +82,7 @@ namespace RainmeterStudio.UI.Controller
|
||||
DocumentManager.Create(format.Template);
|
||||
}
|
||||
|
||||
public void Create(DocumentTemplate format)
|
||||
public void Create(IDocumentTemplate format)
|
||||
{
|
||||
// Call manager
|
||||
DocumentManager.Create(format);
|
||||
|
@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Linq;
|
||||
using Microsoft.Win32;
|
||||
using RainmeterStudio.Business;
|
||||
using RainmeterStudio.Core.Model;
|
||||
using RainmeterStudio.UI.Dialogs;
|
||||
using RainmeterStudio.UI.ViewModel;
|
||||
|
||||
namespace RainmeterStudio.UI.Controller
|
||||
{
|
||||
@ -44,6 +47,17 @@ namespace RainmeterStudio.UI.Controller
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the project templates
|
||||
/// </summary>
|
||||
public IEnumerable<ProjectTemplateViewModel> ProjectTemplates
|
||||
{
|
||||
get
|
||||
{
|
||||
return Manager.ProjectTemplates.Select(pt => new ProjectTemplateViewModel(pt));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Callbacks
|
||||
@ -91,7 +105,7 @@ namespace RainmeterStudio.UI.Controller
|
||||
public void CreateProject(string name = null, string path = null)
|
||||
{
|
||||
// Create dialog
|
||||
var dialog = new CreateProjectDialog();
|
||||
var dialog = new CreateProjectDialog(this);
|
||||
dialog.Owner = OwnerWindow;
|
||||
dialog.SelectedLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Rainmeter Studio Projects");
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
Width="32" Height="32" Margin="2"
|
||||
Stretch="Uniform" VerticalAlignment="Top" />
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding Name}" FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding DisplayText}" FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding Description}" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
|
@ -13,9 +13,8 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ListView Name="listTemplates" Grid.Row="0" SelectedIndex="0"
|
||||
IsEnabled="False">
|
||||
|
||||
<ListView Name="listTemplates" Grid.Row="0" Margin="1px"
|
||||
SelectionChanged="listTemplates_SelectionChanged">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DockPanel>
|
||||
@ -23,21 +22,12 @@
|
||||
Width="32" Height="32" Margin="2"
|
||||
Stretch="Uniform" VerticalAlignment="Top" />
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Center">
|
||||
<TextBlock Text="{Binding Name}" FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding DisplayText}" FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding Description}" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
<ListView.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock FontWeight="Bold" FontSize="13pt" Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
</GroupStyle>
|
||||
</ListView.GroupStyle>
|
||||
</ListView>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
|
@ -13,6 +13,8 @@ using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using RainmeterStudio.Business;
|
||||
using RainmeterStudio.Core.Documents;
|
||||
using RainmeterStudio.Core.Model;
|
||||
using RainmeterStudio.UI.Controller;
|
||||
|
||||
namespace RainmeterStudio.UI.Dialogs
|
||||
{
|
||||
@ -54,11 +56,11 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
/// <summary>
|
||||
/// Gets or sets the currently selected file format
|
||||
/// </summary>
|
||||
public DocumentTemplate SelectedTemplate
|
||||
public IDocumentTemplate SelectedTemplate
|
||||
{
|
||||
get
|
||||
{
|
||||
return listTemplates.SelectedItem as DocumentTemplate;
|
||||
return listTemplates.SelectedItem as IDocumentTemplate;
|
||||
}
|
||||
set
|
||||
{
|
||||
@ -121,7 +123,7 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
|
||||
#endregion
|
||||
|
||||
public CreateProjectDialog()
|
||||
public CreateProjectDialog(ProjectController projectController)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@ -132,6 +134,9 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
// Set data context
|
||||
DataContext = this;
|
||||
|
||||
// Populate templates
|
||||
listTemplates.ItemsSource = projectController.ProjectTemplates.OrderBy(x => x.DisplayText);
|
||||
|
||||
// Focus on name textbox
|
||||
textName.Focus();
|
||||
}
|
||||
@ -208,5 +213,9 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
{
|
||||
UpdatePath();
|
||||
}
|
||||
|
||||
private void listTemplates_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,18 @@
|
||||
using System.Windows.Media;
|
||||
using RainmeterStudio.Business;
|
||||
using RainmeterStudio.Core.Documents;
|
||||
using RainmeterStudio.Core.Model;
|
||||
|
||||
namespace RainmeterStudio.UI.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// View model for document templates
|
||||
/// </summary>
|
||||
public class DocumentTemplateViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the document template
|
||||
/// </summary>
|
||||
public DocumentTemplate Template { get; private set; }
|
||||
public IDocumentTemplate Template { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the document template name
|
||||
@ -23,7 +26,7 @@ namespace RainmeterStudio.UI.ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceProvider.GetImage("Template_" + Name + "_Icon");
|
||||
return ResourceProvider.GetImage("DocumentTemplate_" + Name + "_Icon");
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +37,7 @@ namespace RainmeterStudio.UI.ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceProvider.GetString("Template_" + Name + "_DisplayText");
|
||||
return ResourceProvider.GetString("DocumentTemplate_" + Name + "_DisplayText");
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +48,7 @@ namespace RainmeterStudio.UI.ViewModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceProvider.GetString("Template_" + Name + "_Description");
|
||||
return ResourceProvider.GetString("DocumentTemplate_" + Name + "_Description");
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +56,7 @@ namespace RainmeterStudio.UI.ViewModel
|
||||
/// Initializes the document template view model
|
||||
/// </summary>
|
||||
/// <param name="template">The document template</param>
|
||||
public DocumentTemplateViewModel(DocumentTemplate template)
|
||||
public DocumentTemplateViewModel(IDocumentTemplate template)
|
||||
{
|
||||
this.Template = template;
|
||||
}
|
||||
|
74
RainmeterStudio/UI/ViewModel/ProjectTemplateViewModel.cs
Normal file
74
RainmeterStudio/UI/ViewModel/ProjectTemplateViewModel.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Media;
|
||||
using RainmeterStudio.Business;
|
||||
using RainmeterStudio.Core.Model;
|
||||
|
||||
namespace RainmeterStudio.UI.ViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// View model for project templates
|
||||
/// </summary>
|
||||
public class ProjectTemplateViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the project template
|
||||
/// </summary>
|
||||
public IProjectTemplate Template { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the template
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return Template.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the display text
|
||||
/// </summary>
|
||||
public string DisplayText
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceProvider.GetString("ProjectTemplate_" + Name + "_DisplayText");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description
|
||||
/// </summary>
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceProvider.GetString("ProjectTemplate_" + Name + "_Description");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the icon
|
||||
/// </summary>
|
||||
public ImageSource Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
return ResourceProvider.GetImage("ProjectTemplate_" + Name + "_Icon");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the project template view model
|
||||
/// </summary>
|
||||
/// <param name="template">A project template</param>
|
||||
public ProjectTemplateViewModel(IProjectTemplate template)
|
||||
{
|
||||
Template = template;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user