2014-01-08 02:14:20 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
using APICodePack = Microsoft.WindowsAPICodePack.Dialogs;
|
|
|
|
|
|
|
|
|
|
namespace PdfScribeCore
|
|
|
|
|
{
|
2014-01-08 10:08:13 +08:00
|
|
|
|
public abstract class TaskDialogPresenter
|
2014-01-08 02:14:20 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
protected abstract APICodePack.TaskDialogStandardIcon DefaultTaskIcon { get; } // Override this to set the dialog icon you want
|
|
|
|
|
|
2014-01-08 10:08:13 +08:00
|
|
|
|
|
|
|
|
|
public TaskDialogPresenter()
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Ctor that shows the
|
|
|
|
|
/// task dialog immediately
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="captionText">Text that goes in the window caption</param>
|
|
|
|
|
/// <param name="instructionText">Instructional text (Appears next to the icon)</param>
|
|
|
|
|
/// <param name="messageText">Smaller message detail text at bottom</param>
|
|
|
|
|
public TaskDialogPresenter(String captionText,
|
|
|
|
|
String instructionText,
|
|
|
|
|
String messageText)
|
|
|
|
|
{
|
|
|
|
|
ShowSimple(captionText, instructionText, messageText);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-08 02:14:20 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Pops up a simple TaskDialog box
|
|
|
|
|
/// with just a Close button and
|
|
|
|
|
/// the default standard dialog icon
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="captionText">Text that goes in the window's caption</param>
|
|
|
|
|
/// <param name="instructionText">Instructional text (Appears next to the error icon)</param>
|
|
|
|
|
/// <param name="messageText">Smaller message detail text at bottom</param>
|
|
|
|
|
public virtual void ShowSimple(String captionText,
|
|
|
|
|
String instructionText,
|
|
|
|
|
String messageText)
|
|
|
|
|
{
|
|
|
|
|
using (APICodePack.TaskDialog simpleTaskDialog = new APICodePack.TaskDialog())
|
|
|
|
|
{
|
|
|
|
|
simpleTaskDialog.Caption = captionText;
|
|
|
|
|
simpleTaskDialog.InstructionText = instructionText;
|
|
|
|
|
simpleTaskDialog.Text = messageText;
|
|
|
|
|
simpleTaskDialog.Icon = this.DefaultTaskIcon;
|
|
|
|
|
simpleTaskDialog.StandardButtons = APICodePack.TaskDialogStandardButtons.Close;
|
|
|
|
|
simpleTaskDialog.Opened += new EventHandler(simpleTaskDialog_Opened);
|
2014-01-10 00:12:37 +08:00
|
|
|
|
simpleTaskDialog.StartupLocation = APICodePack.TaskDialogStartupLocation.CenterScreen;
|
2014-01-08 02:14:20 +08:00
|
|
|
|
simpleTaskDialog.Show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void simpleTaskDialog_Opened(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Really fucking annoying -
|
|
|
|
|
// There's a bug somewhere in the API Code Pack that
|
|
|
|
|
// causes the icon not to show
|
|
|
|
|
// unless you set it on the Opened event
|
|
|
|
|
// See: http://stackoverflow.com/questions/15645592/taskdialogstandardicon-not-working-on-task-dialog
|
|
|
|
|
// One of these days I'll try to find and fix it (honestly I hope
|
|
|
|
|
// someone else fixes first - also why isn't the API Code pack on codeplex
|
|
|
|
|
// or github so people can push patches), but until then...
|
|
|
|
|
((APICodePack.TaskDialog)sender).Icon = this.DefaultTaskIcon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|