Ejemplo n.º 1
0
        // NOTE: I needed to add this method and export it as an action in order to hook up the
        // Print... menu to the FirstResponder printDocument: method which has to be called bu the OS
        // and will trigger the call to PrintOperation(NSDictionary printSettings, out NSError outError)
        // However, once I added this method and made the connection, I no longer need this here,
        // so it was just needed to be able to set the target/ action pair for the Print... menu.
//		[Action("printDocument:")]
//		public override void PrintDocument(NSObject sender)
//		{
//			//base.PrintDocument(sender);
//		}

        public override NSPrintOperation PrintOperation(NSDictionary printSettings, out NSError outError)
        {
            outError = new NSError();
            PeopleView       view      = new PeopleView(NSArray.FromObjects(Employees.ToArray()));
            NSPrintInfo      printInfo = this.PrintInfo;
            NSPrintOperation printOp   = NSPrintOperation.FromView(view, printInfo);

            return(printOp);
        }
Ejemplo n.º 2
0
        public void Print(NSObject sender)
        {
            try
            {
                var printInfo = new NSPrintInfo
                {
                    Orientation          = NSPrintingOrientation.Landscape,
                    LeftMargin           = 45,
                    RightMargin          = 30,
                    TopMargin            = 30,
                    BottomMargin         = 30,
                    HorizontalPagination = NSPrintingPaginationMode.Auto,
                    VerticallyCentered   = false,
                    HorizontallyCentered = false
                };
                var printView = new NSView
                {
                    AutoresizesSubviews = true
                };
                var indPrintVC = new TablePrintingViewController(_individualsViewController);
                var famPrintVC = new TablePrintingViewController(_familiesViewController);
                indPrintVC.View.SetFrameOrigin(new CoreGraphics.CGPoint(0, famPrintVC.TotalHeight));
                printView.AddSubview(indPrintVC.View);
                printView.AddSubview(famPrintVC.View);

                var width  = Math.Max(indPrintVC.TotalWidth, famPrintVC.TotalWidth);
                var height = indPrintVC.TotalHeight + famPrintVC.TotalHeight;
                printView.SetFrameSize(new CoreGraphics.CGSize(width, height));

                var printOperation = NSPrintOperation.FromView(printView, printInfo);
                printOperation.ShowsPrintPanel        = true;
                printOperation.ShowsProgressPanel     = true;
                printOperation.CanSpawnSeparateThread = true;
                printOperation.PrintPanel.Options     = NSPrintPanelOptions.ShowsCopies | NSPrintPanelOptions.ShowsPageRange | NSPrintPanelOptions.ShowsPreview |
                                                        NSPrintPanelOptions.ShowsPageSetupAccessory | NSPrintPanelOptions.ShowsScaling;
                printOperation.RunOperation();
                printOperation.CleanUpOperation();
            }
            catch (Exception e)
            {
                UIHelpers.ShowMessage($"Sorry there was a problem printing.\nError was: {e.Message}");
            }
        }
Ejemplo n.º 3
0
		public override bool ShouldChangePrintInfo (NSPrintInfo newPrintInfo)
		{
			return false;
		}
Ejemplo n.º 4
0
		public void BeginSheet (NSPrintInfo printInfo, NSWindow docWindow, NSAction onEnded)
		{
			var obj = OneShotTracker.Create (onEnded);
			BeginSheet (printInfo, docWindow, obj, NSActionDispatcher.Selector, IntPtr.Zero);
		}
Ejemplo n.º 5
0
		public void BeginSheet (NSPrintInfo printInfo, NSWindow docWindow)
		{
			BeginSheet (printInfo, docWindow, null, null, IntPtr.Zero);
		}
Ejemplo n.º 6
0
 /// <summary>
 /// <para>Displays a Print panel sheet and runs it modally for the specified window.</para>
 /// <para>Original signature is '- (void)beginSheetWithPrintInfo:(NSPrintInfo *)printInfo modalForWindow:(NSWindow *)docWindow delegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo'</para>
 /// <para>Available in Mac OS X v10.0 and later.</para>
 /// </summary>
 /// <param name="printInfo">The printing information for the current job.</param>
 /// <param name="docWindow">The window on which to display the sheet.</param>
 /// <param name="modalDelegate">A modal delegate object assigned to handle the closing of the Print panel sheet.</param>
 /// <param name="contextInfo">A pointer to context data the didEndSelector method needs to process the sheet. This data is user-defined and may be NULL.</param>
 public void BeginSheetWithPrintInfoModalForWindowDelegateDidEndSelectorContextInfo(NSPrintInfo printInfo, NSWindow docWindow, SheetDidEndReturnCodeContextInfoEventHandler<NSPrintPanel> modalDelegate, IntPtr contextInfo)
 {
     NSPrintPanelSheetDispatcher dispatcher = new NSPrintPanelSheetDispatcher(modalDelegate);
     ObjectiveCRuntime.SendMessage(this, "beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:", printInfo, docWindow, dispatcher, ObjectiveCRuntime.Selector("printPanelDidEnd:returnCode:contextInfo:"), contextInfo);
 }
Ejemplo n.º 7
0
 public void BeginSheet(NSPrintInfo printInfo, NSWindow docWindow, NSAction onEnded)
 {
     var obj = new NSAsyncActionDispatcher (onEnded);
     BeginSheet (printInfo, docWindow, obj, NSActionDispatcher.Selector, IntPtr.Zero);
 }
Ejemplo n.º 8
0
		/// <summary>
		/// Prints the document that is currently being edited.
		/// </summary>
		/// <param name="info">A <c>NSPrintInfo</c> object defining the page layout to use
		/// while printing.</param>
		public void PrintDocument(NSPrintInfo info) {

			// Configure print job
			TextEditor.Print (this);
		}
Ejemplo n.º 9
0
 /// <summary>
 /// Prints the document that is currently being edited.
 /// </summary>
 /// <param name="info">A <c>NSPrintInfo</c> object defining the page layout to use
 /// while printing.</param>
 public void PrintDocument(NSPrintInfo info)
 {
     // Configure print job
     TextEditor.Print(this);
 }