#region License
#endregion
using System.Windows.Forms;
namespace MiniSqlQuery.Core.Commands
{
public class PrintCommand
: CommandBase
{
public PrintCommand()
: base("Print...")
{
SmallImage = ImageResource.printer;
}
public override bool Enabled
{
get
{
var printable = HostWindow.ActiveChildForm as IPrintableContent;
if (printable != null)
{
var doc = printable.PrintDocument;
if (doc != null)
{
return true;
}
}
return false;
}
}
public override void Execute()
{
var printable = HostWindow.ActiveChildForm as IPrintableContent;
if (printable != null)
{
var doc = printable.PrintDocument;
if (doc != null)
{
using (var ppd = new PrintDialog())
{
ppd.Document = doc;
ppd.AllowSomePages = true;
ppd.UseEXDialog = true;
if (ppd.ShowDialog(HostWindow.Instance) == DialogResult.OK)
{
doc.Print();
}
}
}
}
}
}
}
|