2014-08-30 07:24:01 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2014-09-08 18:31:47 +00:00
|
|
|
|
using System.Collections.ObjectModel;
|
2014-08-30 07:24:01 +00:00
|
|
|
|
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.Core.Model;
|
2014-09-08 18:31:47 +00:00
|
|
|
|
using RainmeterStudio.Core.Utils;
|
2014-08-30 07:24:01 +00:00
|
|
|
|
|
|
|
|
|
namespace RainmeterStudio.UI.Dialogs
|
|
|
|
|
{
|
2014-09-08 18:31:47 +00:00
|
|
|
|
public enum CloseUnsavedDialogResult
|
|
|
|
|
{
|
|
|
|
|
Unset,
|
|
|
|
|
Save,
|
|
|
|
|
DoNotSave,
|
|
|
|
|
Cancel
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-30 07:24:01 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for CloseUnsavedDialog.xaml
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class CloseUnsavedDialog : Window
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Displays the dialog and returns the result
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unsavedDocuments">List of unsaved documents</param>
|
|
|
|
|
/// <returns>Dialog result</returns>
|
2014-09-08 18:31:47 +00:00
|
|
|
|
public static CloseUnsavedDialogResult ShowDialog(IEnumerable<IDocument> unsavedDocuments)
|
2014-08-30 07:24:01 +00:00
|
|
|
|
{
|
|
|
|
|
var dialog = new CloseUnsavedDialog(unsavedDocuments);
|
2014-09-08 18:31:47 +00:00
|
|
|
|
dialog.ShowDialog();
|
|
|
|
|
return dialog.SaveDialogResult;
|
2014-08-30 07:24:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Displays the dialog and returns the result
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="owner">Owner window</param>
|
|
|
|
|
/// <param name="unsavedDocuments">List of unsaved documents</param>
|
|
|
|
|
/// <returns>Dialog result</returns>
|
2014-09-08 18:31:47 +00:00
|
|
|
|
public static CloseUnsavedDialogResult ShowDialog(Window owner, IEnumerable<IDocument> unsavedDocuments)
|
2014-08-30 07:24:01 +00:00
|
|
|
|
{
|
|
|
|
|
var dialog = new CloseUnsavedDialog(unsavedDocuments);
|
2014-09-08 18:31:47 +00:00
|
|
|
|
dialog.ShowDialog();
|
|
|
|
|
return dialog.SaveDialogResult;
|
2014-08-30 07:24:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Displays the dialog and returns the result
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="owner">Owner window</param>
|
|
|
|
|
/// <param name="unsavedDocuments">List of unsaved documents</param>
|
|
|
|
|
/// <returns>Dialog result</returns>
|
2014-09-08 18:31:47 +00:00
|
|
|
|
public static CloseUnsavedDialogResult ShowDialog(Window owner, params IDocument[] unsavedDocuments)
|
2014-08-30 07:24:01 +00:00
|
|
|
|
{
|
|
|
|
|
var dialog = new CloseUnsavedDialog(unsavedDocuments);
|
2014-09-08 18:31:47 +00:00
|
|
|
|
dialog.ShowDialog();
|
|
|
|
|
return dialog.SaveDialogResult;
|
2014-08-30 07:24:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-09-08 18:31:47 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the 'close unsaved' dialog result
|
|
|
|
|
/// </summary>
|
|
|
|
|
public CloseUnsavedDialogResult SaveDialogResult { get; private set; }
|
|
|
|
|
|
2014-08-30 07:24:01 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes the dialog
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unsavedDocuments">List of unsaved documents</param>
|
|
|
|
|
public CloseUnsavedDialog(IEnumerable<IDocument> unsavedDocuments)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2014-09-08 18:31:47 +00:00
|
|
|
|
SaveDialogResult = CloseUnsavedDialogResult.Unset;
|
|
|
|
|
unsavedDocuments.ForEach(d => listUnsavedDocuments.Items.Add(d));
|
2014-08-30 07:24:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonSave_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2014-09-08 18:31:47 +00:00
|
|
|
|
SaveDialogResult = CloseUnsavedDialogResult.Save;
|
2014-08-30 07:24:01 +00:00
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonDoNotSave_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2014-09-08 18:31:47 +00:00
|
|
|
|
SaveDialogResult = CloseUnsavedDialogResult.DoNotSave;
|
2014-08-30 07:24:01 +00:00
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonCancel_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2014-09-08 18:31:47 +00:00
|
|
|
|
SaveDialogResult = CloseUnsavedDialogResult.Cancel;
|
2014-08-30 07:24:01 +00:00
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|