I dunno - a quick glance at decomp shows it eventually calling this on preview:
// Ice.Lib.Framework.EpiReportTransaction
private bool RunDirectForPreview(string rptTypeID, long schedID, int taskID)
How you would use it - beats the hell out of me.
I suppose you could add a button that opens an instance of the form that pops up when you click print. Have the code click the PrintPreview button, then close the form in a worse case hacky way. I am sure there is a better way.
Does that occur when pressing the Print button (print screen pops up), or does that occur when the user clicks the Print Preview button? Looks like Print Preview since it’s “RunDirectForPreview” - but I wanted a clarification
I was going to say couldn’t you just add a button that calls this specific method? I’m not sure if this would work as simply as you would think it would though
This code is from the SECOND window that pops up so I agree, it wouldn’t be as easy as simply calling it.
The idea of stealing the code from their print button that inits the second form should work. You create it and operate upon the reference to click it’s button (or call the method directly with reflection)
I have done this on a few forms. I chose to use the buttons to set a checkbox which then does the print processing via Data Directive BPM as this seemed much easier. There are two buttons added to my form, print preview and send document. I removed the existing print button because I wanted to have better control over exactly how and where the printing took place. The result looks like
In addition to the below and the BPMs, you will need to add and remove the events below in the relevant InitializeCustomCode and DestroyCustomCode:
Script.baseToolbarsManager.ToolClick += new Infragistics.Win.UltraWinToolbars.ToolClickEventHandler(Script.baseToolbarsManager_ToolClick);
Script.SalesOrderForm.Shown += new System.EventHandler(Script.SalesOrderForm_Shown);
private static void baseToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs args)
{
try
{
if(args.Tool.Key=="PrintPreview")
{
EpiDataView edvOrderHead = (EpiDataView)oTrans.EpiDataViews["OrderHed"];
edvOrderHead.dataView[0].BeginEdit();
edvOrderHead.CurrentDataRow["Checkbox04"] = true;
edvOrderHead.dataView[0].EndEdit();
oTrans.Update();
}
if(args.Tool.Key=="SendDocument")
{
EpiDataView edvOrderHead = (EpiDataView)oTrans.EpiDataViews["OrderHed"];
edvOrderHead.dataView[0].BeginEdit();
edvOrderHead.CurrentDataRow["Checkbox05"] = true;
edvOrderHead.dataView[0].EndEdit();
oTrans.Update();
}
}
catch
{
}
}
private static void SalesOrderForm_Shown(object sender, EventArgs args)
{
//create new buttons for print preview and send document
Infragistics.Win.UltraWinToolbars.ButtonTool PPTool = new Infragistics.Win.UltraWinToolbars.ButtonTool("PrintPreview");
Infragistics.Win.UltraWinToolbars.ButtonTool SDTool = new Infragistics.Win.UltraWinToolbars.ButtonTool("SendDocument");
// set the Properties of the new buttons
PPTool.SharedProps.Caption = "Print Preview";
PPTool.SharedProps.Enabled = true;
PPTool.SharedProps.Visible = true;
SDTool.SharedProps.Caption = "Send Document";
SDTool.SharedProps.Enabled = true;
SDTool.SharedProps.Visible = true;
PPTool.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("PrintPreview")];
SDTool.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("SendRecByEmail")];
//Add the buttons to the tool bar at the index position
baseToolbarsManager.Tools.Add(PPTool);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.InsertTool(14, "PrintPreview");
baseToolbarsManager.Tools.Add(SDTool);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.InsertTool(15, "SendDocument");
baseToolbarsManager.Toolbars["Standard Tools"].Tools["PrintPreview"].InstanceProps.IsFirstInGroup=true;
baseToolbarsManager.Toolbars["Standard Tools"].Tools["PrintTool"].SharedProps.Visible = false;
foreach (Infragistics.Win.UltraWinToolbars.ToolBase Tool in Script.baseToolbarsManager.Toolbars["Standard Tools"].Tools)
{
if(Tool.Key=="PrintTool")
{
//Tool.SharedProps.Visible = false;
}
}
}
public static void AddButtons()
{
//create a new button tool for UltraWinToolbars
Infragistics.Win.UltraWinToolbars.ButtonTool PPTool = new Infragistics.Win.UltraWinToolbars.ButtonTool("PrintPreview");
Infragistics.Win.UltraWinToolbars.ButtonTool SDTool = new Infragistics.Win.UltraWinToolbars.ButtonTool("SendDocument");
// set the Properties of the new menu
PPTool.SharedProps.Caption = "Print Preview";
PPTool.SharedProps.Enabled = true;
PPTool.SharedProps.Visible = true;
SDTool.SharedProps.Caption = "Send Document";
SDTool.SharedProps.Enabled = true;
SDTool.SharedProps.Visible = true;
PPTool.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("PrintPreview")];
baseToolbarsManager.Tools.Add(PPTool);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.InsertTool(14, "PrintPreview");
SDTool.SharedProps.AppearancesSmall.Appearance.Image = EpiUIImages.SmallEnabledImages.Images[EpiUIImages.IndexOf("SendRecByEmail")];
baseToolbarsManager.Tools.Add(SDTool);
baseToolbarsManager.Toolbars["Standard Tools"].Tools.InsertTool(15, "SendDocument");
}