The print preview diagram command executes this code:
if (Commander == null)
return;
NDrawingDocument document = Commander.Document;
if (document == null)
return;
NPrintManager manager = new NPrintManager(document);
try
{
manager.ShowPrintPreview();
}
catch (Exception ex)
{
MessageBox.Show("Failed to show the print preview dialog. Exception was: " + ex.Message);
}
So as you can see you need to override the command in order to preselect any settings of the newly created print manager, that is created each time you click the PrintPreview command, like this:
public class MyPrintPreviewCommand : NPrintPreviewCommand
{
public override void Execute()
{
if (Commander == null)
return;
NDrawingDocument document = Commander.Document;
if (document == null)
return;
NPrintManager manager = new NPrintManager(document);
manager.Layout = Nevron.GraphicsCore.PagedLayout.FitToPages;
try
{
manager.ShowPrintPreview();
}
catch (Exception ex)
{
MessageBox.Show("Failed to show the print preview dialog. Exception was: " + ex.Message);
}
}
pubilc static void UpdateCmdBarManager(NDiagramCommandBarsManager cmdBarManager)
{
NDiagramCommand oldCommand = cmdBarManager.Commander.Commands.GetCommandFromId((int)DiagramCommand.PrintPreview);
cmdBarManager.Commander.Commands.Remove(oldCommand);
cmdBarManager.Commander.Commands.Add(new MyPrintPreviewCommand());
cmdBarManager.Recreate();
}
}
Last thing to do is to invoke the UpdateCmdBarManager by passing a reference to your command bars manager.
Best Regards,
Nevron Support Team