2014-07-26 07:12:56 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
2014-08-16 11:35:54 +00:00
|
|
|
|
using RainmeterStudio.Core.Utils;
|
2014-08-14 07:06:20 +00:00
|
|
|
|
using RainmeterStudio.UI.Controller;
|
2014-08-15 12:31:33 +00:00
|
|
|
|
using RainmeterStudio.UI.ViewModel;
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
|
|
|
|
namespace RainmeterStudio.UI.Dialogs
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for CreateDocumentDialog.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class CreateDocumentDialog : Window
|
|
|
|
|
{
|
2014-08-14 07:06:20 +00:00
|
|
|
|
private DocumentController _documentController;
|
|
|
|
|
|
2014-07-26 07:12:56 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the currently selected file format
|
|
|
|
|
/// </summary>
|
2014-08-15 12:31:33 +00:00
|
|
|
|
public DocumentTemplateViewModel SelectedTemplate
|
2014-07-26 07:12:56 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2014-08-15 12:31:33 +00:00
|
|
|
|
return listTemplates.SelectedItem as DocumentTemplateViewModel;
|
2014-07-26 07:12:56 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2014-08-15 12:31:33 +00:00
|
|
|
|
listTemplates.SelectedItem = value;
|
2014-07-26 07:12:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the path
|
|
|
|
|
/// </summary>
|
2014-08-16 11:35:54 +00:00
|
|
|
|
public string SelectedName
|
2014-07-26 07:12:56 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2014-08-16 11:35:54 +00:00
|
|
|
|
return textName.Text;
|
2014-07-26 07:12:56 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2014-08-16 11:35:54 +00:00
|
|
|
|
textName.Text = value;
|
2014-07-26 07:12:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a new instance of CreateDocumentDialog
|
|
|
|
|
/// </summary>
|
2014-08-14 07:06:20 +00:00
|
|
|
|
public CreateDocumentDialog(DocumentController docCtrl)
|
2014-07-26 07:12:56 +00:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2014-08-14 07:06:20 +00:00
|
|
|
|
_documentController = docCtrl;
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
2014-08-16 11:35:54 +00:00
|
|
|
|
listTemplates.ItemsSource = _documentController.DocumentTemplates.OrderBy(x => x.DisplayText);
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
2014-08-16 11:35:54 +00:00
|
|
|
|
Validate();
|
2014-07-26 07:12:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonCreate_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DialogResult = true;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonCancel_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DialogResult = false;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Validate()
|
|
|
|
|
{
|
|
|
|
|
bool res = true;
|
2014-08-15 12:31:33 +00:00
|
|
|
|
|
|
|
|
|
res &= (listTemplates.SelectedItem != null);
|
2014-08-16 11:35:54 +00:00
|
|
|
|
res &= PathHelper.IsFileNameValid(SelectedName);
|
2014-07-26 07:12:56 +00:00
|
|
|
|
|
|
|
|
|
buttonCreate.IsEnabled = res;
|
|
|
|
|
}
|
2014-08-14 07:06:20 +00:00
|
|
|
|
|
2014-08-15 12:31:33 +00:00
|
|
|
|
private void listFormats_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
2014-08-14 07:06:20 +00:00
|
|
|
|
{
|
2014-08-15 12:31:33 +00:00
|
|
|
|
Validate();
|
2014-08-14 07:06:20 +00:00
|
|
|
|
}
|
2014-08-16 11:35:54 +00:00
|
|
|
|
|
|
|
|
|
private void textName_TextChanged(object sender, TextChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Validate();
|
|
|
|
|
}
|
2014-07-26 07:12:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|