Esempio n. 1
0
        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();
        }
Esempio n. 2
0
 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);
 }