mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Work on project, document managers, controllers and UI
This commit is contained in:
@ -17,15 +17,14 @@
|
||||
<TextBlock Grid.Row="0" Text="{x:Static r:Strings.CloseUnsavedDialog_Message }"
|
||||
Margin="4"/>
|
||||
|
||||
<ScrollViewer Grid.Row="1"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||
|
||||
<TextBlock Name="textFiles"
|
||||
Margin="4" Padding="4"
|
||||
Background="White"/>
|
||||
|
||||
</ScrollViewer>
|
||||
<ListBox Name="listUnsavedDocuments" Grid.Row="1" Padding="3"
|
||||
IsEnabled="False" >
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Reference.Name}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<TextBlock Grid.Row="2" Text="{x:Static r:Strings.CloseUnsavedDialog_Question }"
|
||||
Margin="4"/>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
@ -11,9 +12,18 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using RainmeterStudio.Core.Model;
|
||||
using RainmeterStudio.Core.Utils;
|
||||
|
||||
namespace RainmeterStudio.UI.Dialogs
|
||||
{
|
||||
public enum CloseUnsavedDialogResult
|
||||
{
|
||||
Unset,
|
||||
Save,
|
||||
DoNotSave,
|
||||
Cancel
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for CloseUnsavedDialog.xaml
|
||||
/// </summary>
|
||||
@ -24,10 +34,11 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
/// </summary>
|
||||
/// <param name="unsavedDocuments">List of unsaved documents</param>
|
||||
/// <returns>Dialog result</returns>
|
||||
public static bool? ShowDialog(IEnumerable<IDocument> unsavedDocuments)
|
||||
public static CloseUnsavedDialogResult ShowDialog(IEnumerable<IDocument> unsavedDocuments)
|
||||
{
|
||||
var dialog = new CloseUnsavedDialog(unsavedDocuments);
|
||||
return dialog.ShowDialog();
|
||||
dialog.ShowDialog();
|
||||
return dialog.SaveDialogResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -36,11 +47,11 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
/// <param name="owner">Owner window</param>
|
||||
/// <param name="unsavedDocuments">List of unsaved documents</param>
|
||||
/// <returns>Dialog result</returns>
|
||||
public static bool? ShowDialog(Window owner, IEnumerable<IDocument> unsavedDocuments)
|
||||
public static CloseUnsavedDialogResult ShowDialog(Window owner, IEnumerable<IDocument> unsavedDocuments)
|
||||
{
|
||||
var dialog = new CloseUnsavedDialog(unsavedDocuments);
|
||||
dialog.Owner = owner;
|
||||
return dialog.ShowDialog();
|
||||
dialog.ShowDialog();
|
||||
return dialog.SaveDialogResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -49,13 +60,18 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
/// <param name="owner">Owner window</param>
|
||||
/// <param name="unsavedDocuments">List of unsaved documents</param>
|
||||
/// <returns>Dialog result</returns>
|
||||
public static bool? ShowDialog(Window owner, params IDocument[] unsavedDocuments)
|
||||
public static CloseUnsavedDialogResult ShowDialog(Window owner, params IDocument[] unsavedDocuments)
|
||||
{
|
||||
var dialog = new CloseUnsavedDialog(unsavedDocuments);
|
||||
dialog.Owner = owner;
|
||||
return dialog.ShowDialog();
|
||||
dialog.ShowDialog();
|
||||
return dialog.SaveDialogResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the 'close unsaved' dialog result
|
||||
/// </summary>
|
||||
public CloseUnsavedDialogResult SaveDialogResult { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the dialog
|
||||
/// </summary>
|
||||
@ -64,39 +80,25 @@ namespace RainmeterStudio.UI.Dialogs
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
textFiles.Inlines.AddRange(unsavedDocuments.SelectMany(GetInlines));
|
||||
}
|
||||
|
||||
private IEnumerable<Inline> GetInlines(IDocument doc)
|
||||
{
|
||||
var folder = System.IO.Path.GetDirectoryName(doc.Reference.StoragePath);
|
||||
|
||||
yield return new Run(folder)
|
||||
{
|
||||
Foreground = Brushes.DarkGray
|
||||
};
|
||||
|
||||
yield return new Run(doc.Reference.Name)
|
||||
{
|
||||
FontWeight = FontWeights.Bold
|
||||
};
|
||||
SaveDialogResult = CloseUnsavedDialogResult.Unset;
|
||||
unsavedDocuments.ForEach(d => listUnsavedDocuments.Items.Add(d));
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = true;
|
||||
SaveDialogResult = CloseUnsavedDialogResult.Save;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonDoNotSave_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = false;
|
||||
SaveDialogResult = CloseUnsavedDialogResult.DoNotSave;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = null;
|
||||
SaveDialogResult = CloseUnsavedDialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user