Work on resource and settings managers, added some documentation.

This commit is contained in:
2014-08-15 15:31:33 +03:00
parent 03d9848b50
commit ef8aec25b7
36 changed files with 1148 additions and 671 deletions

View File

@ -1,31 +1,21 @@
<Window x:Class="RainmeterStudio.UI.Dialogs.CreateDocumentDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Create..." Height="250" Width="400"
xmlns:r="clr-namespace:RainmeterStudio.Resources"
Title="{x:Static r:Strings.CreateDocumentDialog_Title}" Height="250" Width="400"
WindowStartupLocation="CenterOwner"
WindowStyle="ToolWindow" ShowInTaskbar="False"
Background="WhiteSmoke" >
<Grid Margin="2px">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2" />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<Grid Margin="2px">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView Name="listCategories" Grid.Row="0" Grid.Column="0"
SelectionChanged="listCategories_SelectionChanged"
Margin="1px"/>
<GridSplitter Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<ListView Name="listFormats" Grid.Row="0" Grid.Column="2" Margin="1px">
<ListView Name="listTemplates" Grid.Row="0" Margin="1px"
SelectionChanged="listFormats_SelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
<DockPanel>
@ -41,7 +31,7 @@
</ListView.ItemTemplate>
</ListView>
<Grid Grid.Row="1" Grid.ColumnSpan="3">
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
@ -52,13 +42,16 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0">Path:</TextBlock>
<TextBlock Grid.Row="0" Text="{x:Static r:Strings.CreateDocumentDialog_Name}" />
<TextBox Name="textPath" Grid.Row="0" Grid.Column="1" Margin="1px"></TextBox>
<Button Grid.Row="0" Grid.Column="2">...</Button>
<TextBlock Grid.Row="1">Path:</TextBlock>
<TextBox Name="textPath1" Grid.Row="1" Grid.Column="1" Margin="1px"></TextBox>
<Button Grid.Row="1" Grid.Column="2">...</Button>
</Grid>
<StackPanel Grid.Row="2" Grid.ColumnSpan="3" Orientation="Horizontal"
<StackPanel Grid.Row="2" Orientation="Horizontal"
HorizontalAlignment="Right">
<Button Name="buttonCreate" Click="buttonCreate_Click" IsDefault="True" Margin="1px">Create</Button>
<Button Name="buttonCancel" Click="buttonCancel_Click" IsCancel="True" Margin="1px">Cancel</Button>

View File

@ -1,19 +1,9 @@
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 RainmeterStudio.Business;
using RainmeterStudio.Core.Documents;
using RainmeterStudio.UI.Controller;
using RainmeterStudio.UI.ViewModel;
namespace RainmeterStudio.UI.Dialogs
{
@ -27,15 +17,15 @@ namespace RainmeterStudio.UI.Dialogs
/// <summary>
/// Gets or sets the currently selected file format
/// </summary>
public DocumentTemplate SelectedTemplate
public DocumentTemplateViewModel SelectedTemplate
{
get
{
return listFormats.SelectedItem as DocumentTemplate;
return listTemplates.SelectedItem as DocumentTemplateViewModel;
}
set
{
listFormats.SelectedItem = value;
listTemplates.SelectedItem = value;
}
}
@ -62,29 +52,13 @@ namespace RainmeterStudio.UI.Dialogs
InitializeComponent();
_documentController = docCtrl;
PopulateCategories();
RepopulateFormats();
PopulateFormats();
Validate();
}
private void PopulateCategories()
private void PopulateFormats()
{
listCategories.ItemsSource = _documentController.DocumentTemplates
.Select(template => template.Category)
.Where(cat => cat != null)
.Distinct()
.Concat(new[] { "All" });
listCategories.SelectedIndex = listCategories.Items.Count - 1;
}
private void RepopulateFormats()
{
if (Object.Equals(listCategories.SelectedItem, "All"))
listFormats.ItemsSource = _documentController.DocumentTemplates;
else
listFormats.ItemsSource = _documentController.DocumentTemplates.Where(x => Object.Equals(x.Category, listCategories.SelectedItem));
listTemplates.ItemsSource = _documentController.DocumentTemplates;
}
private void buttonCreate_Click(object sender, RoutedEventArgs e)
@ -102,15 +76,17 @@ namespace RainmeterStudio.UI.Dialogs
private void Validate()
{
bool res = true;
res &= !String.IsNullOrWhiteSpace(textPath.Text);
res &= (listFormats.SelectedItem != null);
res &= !textPath.Text.Intersect(System.IO.Path.GetInvalidFileNameChars()).Any();
res &= (listTemplates.SelectedItem != null);
buttonCreate.IsEnabled = res;
}
private void listCategories_SelectionChanged(object sender, SelectionChangedEventArgs e)
private void listFormats_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
RepopulateFormats();
Validate();
}
}
}

View File

@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:r="clr-namespace:RainmeterStudio.Resources"
Title="{x:Static r:Strings.ProjectCreateDialog_Title}" Height="320" Width="480"
Title="{x:Static r:Strings.CreateProjectDialog_Title}" Height="320" Width="480"
WindowStartupLocation="CenterOwner"
WindowStyle="ToolWindow" ShowInTaskbar="False">
@ -55,31 +55,31 @@
</Grid.ColumnDefinitions>
<!-- Name -->
<TextBlock Grid.Row="0" Text="{x:Static r:Strings.ProjectCreateDialog_Name}" />
<TextBlock Grid.Row="0" Text="{x:Static r:Strings.CreateProjectDialog_Name}" />
<TextBox Name="textName"
Grid.Row="0" Grid.Column="1"
TextChanged="textName_TextChanged"/>
<!-- Location -->
<TextBlock Grid.Row="1" Text="{x:Static r:Strings.ProjectCreateDialog_Location}" />
<TextBlock Grid.Row="1" Text="{x:Static r:Strings.CreateProjectDialog_Location}" />
<ComboBox Name="textLocation" IsEditable="True"
Grid.Row="1" Grid.Column="1" />
<Button Grid.Row="1" Grid.Column="2" Content="{x:Static r:Strings.Dialog_Browse}"/>
<CheckBox Name="checkLocationDefault"
Grid.Row="1" Grid.Column="3"
Content="{x:Static r:Strings.ProjectCreateDialog_LocationDefault}"
Content="{x:Static r:Strings.CreateProjectDialog_LocationDefault}"
VerticalAlignment="Center"/>
<!-- Path -->
<TextBlock Grid.Row="2" Text="{x:Static r:Strings.ProjectCreateDialog_Path}"/>
<TextBlock Grid.Row="2" Text="{x:Static r:Strings.CreateProjectDialog_Path}"/>
<ComboBox Name="textPath"
IsEditable="True"
Grid.Row="2" Grid.Column="1" />
<Button Grid.Row="2" Grid.Column="2" Content="{x:Static r:Strings.Dialog_Browse}" />
<CheckBox Name="checkCreateDirectory"
Grid.Row="2" Grid.Column="3"
Content="{x:Static r:Strings.ProjectCreateDialog_PathCreateFolder}"
Content="{x:Static r:Strings.CreateProjectDialog_PathCreateFolder}"
IsChecked="True"
Checked="checkCreateDirectory_CheckChanged"
Unchecked="checkCreateDirectory_CheckChanged"