Exemple #1
0
		public override bool ApplicationShouldHandleReopen(NSApplication sender, bool hasVisibleWindows)
		{
			// This could be invoked before DidFinishLaunching
			if (MainWindow != null) {
				MainWindow.IsVisible = true;
				MainWindow.MakeKeyAndOrderFront (this);
			}
			return false;
		}
 public override bool ApplicationShouldHandleReopen(NSApplication sender, bool hasVisibleWindows)
 {
     if (!hasVisibleWindows)
     {
         foreach (var window in sender.Windows)
             window.MakeKeyAndOrderFront(this);
     }
     return true;
 }
 public override NSApplicationTerminateReply ApplicationShouldTerminate(NSApplication sender)
 {
     if (_mainWindowController.ContinueIfChanged())
     {
         return NSApplicationTerminateReply.Now;
     }
     else
     {
         return NSApplicationTerminateReply.Cancel;
     }
 }
 public NSRunloopScheduler(NSApplication app)
 {
     theApp = app;
 }
Exemple #5
0
		/// <summary>
		/// This method is called when the user selects a file from the <c>Open Recent</c>
		/// menu item.
		/// </summary>
		/// <returns><c>true</c>, if file was opened, <c>false</c> otherwise.</returns>
		/// <param name="sender">A pointer to the app.</param>
		/// <param name="filename">The full path and filename of the file to open.</param>
		/// <remarks>For more details, see: https://developer.xamarin.com/guides/mac/user-interface/working-with-menus/#Working_with_the_Open_Recent_Menu</remarks>
		public override bool OpenFile (NSApplication sender, string filename)
		{
			// Trap all errors
			try {
				// Escape any spaces (" ") or they will cause an error
				// when converted to an NSUrl.
				filename = filename.Replace (" ", "%20");
				var url = new NSUrl ("file://"+filename);
				return OpenFile(url);
			} catch {
				return false;
			}
		}
Exemple #6
0
		/// <summary>
		/// Called before the app terminates to allow the app to cancel the termination
		/// based on state, such as a file not being saved.
		/// </summary>
		/// <returns>A flag stating if the app can terminate at this time.</returns>
		/// <param name="sender">A pointer to the app.</param>
		/// <remarks>For more details, see: https://developer.xamarin.com/guides/mac/user-interface/working-with-windows/#Modified_Windows_Content</remarks>
		public override NSApplicationTerminateReply ApplicationShouldTerminate (NSApplication sender)
		{
			// See if any window needs to be saved first
			foreach (NSWindow window in NSApplication.SharedApplication.Windows) {
				if (window.Delegate != null && !window.Delegate.WindowShouldClose (this)) {
					// Did the window terminate the close?
					return NSApplicationTerminateReply.Cancel;
				}
			}

			// Allow normal termination
			return NSApplicationTerminateReply.Now;
		}
		public override bool ApplicationShouldHandleReopen(NSApplication sender, bool hasVisibleWindows)
		{
			if (hasVisibleWindows == false)
				m_window.MakeKeyAndOrderFront (null);
			return true;
		}
Exemple #8
0
 public override bool ApplicationShouldOpenUntitledFile(NSApplication sender)
 {
     return(false);
 }
Exemple #9
0
 public override bool ApplicationShouldTerminateAfterLastWindowClosed(NSApplication sender)
 {
     return(true);
 }
 static void Main(string[] args)
 {
     NSApplication.Init();
     NSApplication.Main(args);
 }
Exemple #11
0
		public override bool ApplicationShouldOpenUntitledFile (NSApplication sender)
		{
			return false;
		}
Exemple #12
0
 static void Main(string[] args)
 {
     NSApplication.Init();
     NSApplication.SharedApplication.Delegate = new AppDelegate();
     NSApplication.Main(args);
 }
Exemple #13
0
 // untilDate isn't allowed null
 public static NSEvent NextEventEx(this NSApplication app, NSEventMask mask, NSDate untilDate, NSString mode, bool dequeue)
 {
     return((NSEvent)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend_nuint_IntPtr_IntPtr_bool(app.Handle, selNextEventMatchingMask, (nuint)(uint)mask, untilDate != null ? untilDate.Handle : IntPtr.Zero, mode.Handle, dequeue)));
 }
Exemple #14
0
 public static NSColor NSColorFromCGColor(CGColor cgColor)
 {
     NSApplication.EnsureUIThread();
     return(Messaging.GetNSObject <NSColor>(Messaging.IntPtr_objc_msgSend_IntPtr(NSColorClassPtr, selColorWithCGColor, cgColor.Handle)));
 }
Exemple #15
0
 public override bool ApplicationShouldOpenUntitledFile(NSApplication sender)
 {
     Console.WriteLine("ApplicationShouldOpenUntitledFile called");
     return PreferenceController.PreferenceEmptyDoc;
 }
Exemple #16
0
 public override bool ApplicationShouldTerminateAfterLastWindowClosed(NSApplication sender)
 {
     return true;
 }
Exemple #17
0
 public void Run()
 {
     NSApplication.Main(new string [0]);
 }