Ejemplo n.º 1
0
        public bool Print(bool showPanel, Window parent, NSPrintPanel panel)
        {
            var op = NSPrintOperation.FromView(Control);

            if (printSettings != null)
            {
                op.PrintInfo = printSettings.ToNS();
            }
            if (panel != null)
            {
                op.PrintPanel = panel;
            }
            op.ShowsPrintPanel = showPanel;
            if (parent != null)
            {
                var parentHandler = (IMacWindow)parent.Handler;
                var closeSheet    = new SheetHelper();
                op.RunOperationModal(parentHandler.Control, closeSheet, new Selector("printOperationDidRun:success:contextInfo:"), IntPtr.Zero);
                NSApplication.SharedApplication.RunModalForWindow(parentHandler.Control);
                return(closeSheet.Success);
            }
            return(op.RunOperation());
        }
Ejemplo n.º 2
0
        protected override bool RunDialog(IntPtr hwndOwner)
        {
            var currentDirectory = Environment.CurrentDirectory;

            try
            {
                using (var context = new ModalDialogContext())
                {
                    using (var panel = new NSPrintPanel())
                    {
                        var info = NSPrintInfo.SharedPrintInfo ?? new NSPrintInfo();
                        if (NSPanelButtonType.Ok != (NSPanelButtonType)(int)panel.RunModalWithPrintInfo(info))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            finally
            {
            }
        }
Ejemplo n.º 3
0
        void ShowDocument(NSObject sender)
        {
            var dlg = new NSPrintPanel();

            // Display the print dialog as dialog box
            if (ShowPrintAsSheet)
            {
                dlg.BeginSheet(new NSPrintInfo(), this, this, null, new IntPtr());
            }
            else
            {
                if (dlg.RunModalWithPrintInfo(new NSPrintInfo()) == 1)
                {
                    var alert = new NSAlert()
                    {
                        AlertStyle      = NSAlertStyle.Warning,
                        InformativeText = "We need to print the document here...",
                        MessageText     = "Print Document",
                    };
                    alert.RunModal();
                }
            }
        }
Ejemplo n.º 4
0
 public void PrintPanelDidEnd(NSPrintPanel printPanel, int returnCode, IntPtr contextInfo)
 {
     NSApplication.SharedApplication.StopModalWithCode(returnCode);
 }
Ejemplo n.º 5
0
		void ShowDocument (NSObject sender) {
			var dlg = new NSPrintPanel();

			// Display the print dialog as dialog box
			if (ShowPrintAsSheet) {
				dlg.BeginSheet(new NSPrintInfo(),this,this,null,new IntPtr());
			} else {
				if (dlg.RunModalWithPrintInfo(new NSPrintInfo()) == 1) {
					var alert = new NSAlert () {
						AlertStyle = NSAlertStyle.Warning,
						InformativeText = "We need to print the document here...",
						MessageText = "Print Document",
					};
					alert.RunModal ();
				}
			}
		}