public static void Print(IWin32Window owner, string fileName) { var vector = new WIA.VectorClass(); object objFilename = fileName; vector.Add(ref objFilename, 0); var dialogClass = new WIA.CommonDialogClass(); var form = new Form { ShowInTaskbar = false, FormBorderStyle = FormBorderStyle.None }; form.TransparencyKey = form.BackColor; form.Shown += (sender, args) => { object vectorObject = vector; dialogClass.ShowPhotoPrintingWizard(ref vectorObject); form.Close(); }; form.ShowDialog(owner); form = null; Marshal.ReleaseComObject(dialogClass); dialogClass = null; }
private static void Print(string fileName) { WIA.VectorClass vector = new WIA.VectorClass(); object tempName_o = (object)fileName; vector.Add(ref tempName_o, 0); object vector_o = (object)vector; WIA.CommonDialogClass cdc = new WIA.CommonDialogClass(); cdc.ShowPhotoPrintingWizard(ref vector_o); }
private void _PrintFileCallback(object sender, SaveImageCompletedEventArgs e) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke((SaveImageAsyncCallback)_PrintFileCallback, new [] { sender, e }); return; } if (e.Cancelled || e.Error != null) { MessageBox.Show("Unable to print the image"); return; } object path = e.ImagePath; WIA.CommonDialog dialog = new WIA.CommonDialogClass(); dialog.ShowPhotoPrintingWizard(ref path); }
// Prints the document file specified // by lpFile. If lpFile is not a // document file, the function will // fail. public static void PrintFiles(params string[] files) { try { WIA.CommonDialog dialog = new WIA.CommonDialogClass(); WIA.VectorClass vector = new WIA.VectorClass(); for (int i = 0; i < files.Length; i++) { object obj = files[i]; vector.Add(ref obj, i); } object vecObj = vector; dialog.ShowPhotoPrintingWizard(ref vecObj); } catch { } }
public void Print(Control owner, string fileName) { Tracing.Enter(); WIA.VectorClass vector = new WIA.VectorClass(); object tempName_o = (object)fileName; vector.Add(ref tempName_o, 0); object vector_o = (object)vector; WIA.CommonDialogClass cdc = new WIA.CommonDialogClass(); // Ok, this looks weird, but here's the story. // When we show the WIA printing dialog, it is a modal dialog but the way // it handles itself is that the main window can still be interacted with. // I don't know why, and it doesn't matter to me except that it causes all // sorts of other problems (esp. related to the scratch surface.) // So we show a modal dialog that is effectively invisible so that the user // cannot interact with the main window while the print dialog is still open. Form modal = new Form(); modal.ShowInTaskbar = false; modal.TransparencyKey = modal.BackColor; modal.FormBorderStyle = FormBorderStyle.None; modal.Shown += delegate(object sender, EventArgs e) { cdc.ShowPhotoPrintingWizard(ref vector_o); modal.Close(); }; modal.ShowDialog(owner); modal = null; Marshal.ReleaseComObject(cdc); cdc = null; Tracing.Leave(); }