Ejemplo n.º 1
0
 public static void MessageBox(string message, string title)
 {
     NSAlert alert = new NSAlert();
     alert.MessageText = title;
     alert.InformativeText = message;
     alert.RunModal();
 }
		void ShowAlert (FinishState finishState)
		{
			InvokeOnMainThread (() => {
				var alert = new NSAlert ();
				switch (finishState) {
				case FinishState.NothingToDo:
					alert.MessageText = "Up to date";
					alert.InformativeText = "Your MonoTouch documentation is already based on the latest Apple documentation.";
					break;
				case FinishState.Processed:
					alert.MessageText = "Success";
					alert.InformativeText = "Your MonoTouch documentation was successfully merged with the latest Apple documentation.";
					break;
				case FinishState.Canceled:
					alert.MessageText = "Cancelled";
					alert.InformativeText = "The update operation was cancelled.";
					break;
				case FinishState.Error:
					alert.MessageText = "An error occurred";
					alert.InformativeText = "A fatal error occurred during one of the merge steps. Please report it.";
					break;
				case FinishState.NotAdmin:
					alert.MessageText = "Not enough rights";
					alert.InformativeText = "You need to be an administrator to use this tool.";
					break;
				}
				
				alert.RunModal ();
				NSApplication.SharedApplication.Terminate (this);
			});
		}
Ejemplo n.º 3
0
 protected void OnButtonClicked(object sender, EventArgs e)
 {
     if (sender == button1)
     {
         // native system calls messagebox demo
         // note: this is just a demo, you should always use GTK if you can!
         if (MainClass.platform == Platforms.Mac)
         {
             MonoMac.AppKit.NSAlert alert = new MonoMac.AppKit.NSAlert();
             alert.MessageText = "Hello";
             alert.AlertStyle  = MonoMac.AppKit.NSAlertStyle.Informational;
             alert.AddButton("Ok");
             alert.RunModal();
         }
         else if (MainClass.platform == Platforms.Windows)
         {
             CrossTemplate.Win32.user32.MessageBox(IntPtr.Zero, "Hello", "Caption", 0x40 /* MB_ICONINFORMATION */);
         }
         else
         {
             throw new NotImplementedException();
         }
     }
     else if (sender == button2)
     {
         // Gtk
         Gtk.MessageDialog alert = new Gtk.MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, "Hello");
         alert.Title = "Caption";
         ResponseType result = (ResponseType)alert.Run();
         if (result == ResponseType.Ok)
         {
             alert.Destroy();
         }
     }
 }
Ejemplo n.º 4
0
		void ShowAlert (FinishState finishState)
		{
			InvokeOnMainThread (() => {
				var alert = new NSAlert ();
				switch (finishState) {
				case FinishState.NothingToDo:
					alert.MessageText = "Up-to-date";
					alert.InformativeText = "Your MonoTouch documentation is already based on the latest version of the Apple documentation";
					break;
				case FinishState.Processed:
					alert.MessageText = "Success";
					alert.InformativeText = "Your MonoTouch documentation was successfully updated";
					break;
				case FinishState.Canceled:
					alert.MessageText = "Canceled";
					alert.InformativeText = "The update operation was canceled";
					break;
				case FinishState.Error:
					alert.MessageText = "An error occured";
					alert.InformativeText = "A fatal error occured during one of the documentation installer step";
					break;
				}
				
				alert.RunModal ();
				NSApplication.SharedApplication.Terminate (this);
			});
		}
Ejemplo n.º 5
0
 protected void OnButtonClicked(object sender, EventArgs e)
 {
     if (sender == button1)
     {
         // native system calls messagebox demo
         // note: this is just a demo, you should always use GTK if you can!
         if (MainClass.platform == Platforms.Mac)
         {
             MonoMac.AppKit.NSAlert alert = new MonoMac.AppKit.NSAlert ();
             alert.MessageText = "Hello";
             alert.AlertStyle = MonoMac.AppKit.NSAlertStyle.Informational;
             alert.AddButton ("Ok");
             alert.RunModal ();
         }
         else if (MainClass.platform == Platforms.Windows)
         {
             CrossTemplate.Win32.user32.MessageBox (IntPtr.Zero, "Hello", "Caption", 0x40 /* MB_ICONINFORMATION */);
         }
         else
         {
             throw new NotImplementedException ();
         }
     }
     else if (sender == button2)
     {
         // Gtk
         Gtk.MessageDialog alert = new Gtk.MessageDialog(this, DialogFlags.Modal, MessageType.Info, ButtonsType.Ok, "Hello");
         alert.Title = "Caption";
         ResponseType result = (ResponseType)alert.Run ();
         if (result == ResponseType.Ok)
         {
             alert.Destroy ();
         }
     }
 }
Ejemplo n.º 6
0
 public override void Alert(string message)
 {
     NSAlert alert = new NSAlert();
     alert.MessageText = message;
     alert.AddButton("Ok");
     alert.RunModal ();
 }
Ejemplo n.º 7
0
 public void ShowMessage(NSString message)
 {
     MonoMac.AppKit.NSAlert alert = new MonoMac.AppKit.NSAlert();
     alert.MessageText     = "Message from JavaScript";
     alert.InformativeText = (String)message;
     alert.RunModal();
 }
		// The user just clicked the Show Message NSButton, so we show him/her
		// a greeting. This code shows you how to execute C# code when a click is done in
		// and HTML button.
		public override void HandleEvent (DomEvent evt)
		{
			var alert = new NSAlert () {
				MessageText = "Hello there",
				InformativeText = "Saying hello from C# code. Event type: " + evt.Type
			};
			alert.RunModal();
		}
Ejemplo n.º 9
0
 /// <summary>
 /// Show message box with title and message.
 /// </summary>
 /// <param name="title">Title.</param>
 /// <param name="message">Message.</param>
 public void Show(string title, string message)
 {
     using (var alert = new NSAlert()) {
         alert.MessageText = title;
         alert.InformativeText = message;
         alert.AlertStyle = NSAlertStyle.Informational;
         alert.RunModal ();
     }
 }
		partial void SetSyncPath(NSObject sender) {
			bool webSync = false;

			if (!String.IsNullOrEmpty (AppDelegate.settings.webSyncURL) || !String.IsNullOrWhiteSpace (AppDelegate.settings.webSyncURL)) {
				webSync = true;
				NSAlert syncWarning = new NSAlert() {
					MessageText = "Web Sync Found",
					InformativeText = "Setting the File System Sync Path will override the Web Sync Authorization",
					AlertStyle = NSAlertStyle.Informational
				};
				syncWarning.AddButton ("OK");
				syncWarning.BeginSheet (this.Window,this,null,IntPtr.Zero);
			}

            		var openPanel = new NSOpenPanel();
            		openPanel.ReleasedWhenClosed = true;
            		openPanel.CanChooseDirectories = true;
            		openPanel.CanChooseFiles = false;
            		openPanel.CanCreateDirectories = true;
            		openPanel.Prompt = "Select Directory";

            		var result = openPanel.RunModal();
            		if (result == 1) {
                		SyncPathTextField.Cell.Title = openPanel.DirectoryUrl.Path;
				//AppDelegate.FilesystemSyncPath = openPanel.DirectoryUrl.Path;

				AppDelegate.settings.syncURL = openPanel.DirectoryUrl.Path;


                		NSAlert alert = new NSAlert () {
                    			MessageText = "File System Sync",
                    			InformativeText = "File System Sync path has been set at:\n"+AppDelegate.settings.syncURL,
                    			AlertStyle = NSAlertStyle.Warning
                		};
                		alert.AddButton ("OK");
                		alert.BeginSheet (this.Window,
                    			this,
                    			null,
					IntPtr.Zero);

				if (webSync) {
					AppDelegate.settings.webSyncURL = String.Empty;
					AppDelegate.settings.token = String.Empty;
					AppDelegate.settings.secret = String.Empty;
				}

				try {
					if (AppDelegate.settings != null){
						SettingsSync.Write(AppDelegate.settings);
						Console.WriteLine ("WRITTEN PROPERLY");
					}
				} catch (NullReferenceException ex) {
					Console.WriteLine ("ERROR - "+ex.Message);
				}
			}
        	}
Ejemplo n.º 11
0
		public void OnAlertDidEnd (NSAlert alert, int returnCode, IntPtr context)
		{
			try {
				if (action != null)
					action (returnCode);
			} finally {
				action = null;
				pendingInvokes.Remove (this);
			}
		}
Ejemplo n.º 12
0
 public static void ShowAlert(string title, string text, NSAlertStyle alertStyle)
 {
     using(NSAlert alert = new NSAlert())
     {
         alert.MessageText = title;
         alert.InformativeText = text;
         alert.AlertStyle = alertStyle;
         alert.RunModal();
     }
 }
Ejemplo n.º 13
0
		private void MessageBox(string message, string title)
		{
			var alert = new NSAlert();
			alert.AddButton ("OK");
			alert.MessageText = title;
			alert.InformativeText = message;
			
			alert.BeginSheet(this, delegate
			{
			    alert.Dispose();
			});
		}
Ejemplo n.º 14
0
 public void OnAlertDidEnd(NSAlert alert, int returnCode, IntPtr context)
 {
     try {
         if (action != null)
         {
             action(returnCode);
         }
     } finally {
         action = null;
         pendingInvokes.Remove(this);
     }
 }
Ejemplo n.º 15
0
        public override bool Confirm(string message)
        {
            NSAlert alert = new NSAlert();
            alert.MessageText = message;
            alert.AddButton("No");
            alert.AddButton("Yes");
            int ret = alert.RunModal ();
            if (ret == 1001) {
                return true;
            }

            return false;
        }
		partial void UpdateNotebook ( NSObject sender) {
			string updatedName = NotebookNameTextField.StringValue;

			if (string.IsNullOrEmpty (updatedName) || string.IsNullOrWhiteSpace (updatedName)) {
				NSAlert alert = new NSAlert () {
					MessageText = "Notebook Empty",
					InformativeText = "The Notebook name cannot be empty.",
					AlertStyle = NSAlertStyle.Warning
				};
				alert.AddButton ("OK");
				alert.BeginSheet (this.Window,
					this,
					null,
					IntPtr.Zero);

				NotebookNameTextField.SelectText(this);
			} else {
				if (AppDelegate.Notebooks.Contains(updatedName)) {
					NSAlert alert = new NSAlert () {
						MessageText = "Notebook Already Exists",
						InformativeText = "The Notebook " + updatedName+ " already exists.",
						AlertStyle = NSAlertStyle.Warning
					};
					alert.AddButton ("OK");
					alert.BeginSheet (this.Window,
						this,
						null,
						IntPtr.Zero);

					NotebookNameTextField.SelectText(this);
				}
				else {
					string oldName = AppDelegate.currentNotebook;
					AppDelegate.Notebooks.Remove (oldName);
					Dictionary<string, Note> allNotes = AppDelegate.NoteEngine.GetNotesForNotebook (oldName);

					foreach(KeyValuePair<string, Note> note in allNotes) {
						note.Value.Notebook = updatedName;
						AppDelegate.NoteEngine.SaveNote (note.Value);
					}


					AppDelegate.currentNotebook = updatedName;
					AppDelegate.Notebooks.Add (updatedName);
					AppDelegate.RefreshNotesWindowController ();

					this.Window.Close ();
				}

			}
		}
Ejemplo n.º 17
0
        public static bool MessageYesNo(string message, string title)
        {
            NSAlert alert = new NSAlert();
            alert.MessageText = title;
            alert.InformativeText = message;
            alert.AddButton ("Yes");
            alert.AddButton ("No");
            int r = alert.RunModal();

            if (r == 1000)
                return true;

            return false;
        }
Ejemplo n.º 18
0
        public override WindowResponse Show(object parent, string message, string title, MessageWindowType type, MessageWindowButtons bType)
        {
            NSAlert al = new NSAlert();
            al.AlertStyle = CocoaHelper.GetWinType(type);
            al.MessageText = title;
            al.InformativeText = message;

            switch (bType)
            {
                case MessageWindowButtons.AbortRetryIgnore:
                    al.AddButton(Message.GetString("Abort"));
                    al.AddButton(Message.GetString("Retry"));
                    al.AddButton(Message.GetString("Ignore"));
                    break;
                case MessageWindowButtons.Cancel:
                    al.AddButton(Message.GetString("Cancel"));
                    break;
                case MessageWindowButtons.Close:
                    al.AddButton(Message.GetString("Close"));
                    break;
                case  MessageWindowButtons.Ok:
                    al.AddButton(Message.GetString("Ok"));
                    break;
                case MessageWindowButtons.OkCancel:
                    al.AddButton(Message.GetString("Ok"));
                    al.AddButton(Message.GetString("Cancel"));
                    break;
                case MessageWindowButtons.RetryCancel:
                    al.AddButton(Message.GetString("Retry"));
                    al.AddButton(Message.GetString("Cancel"));
                    break;
                case MessageWindowButtons.YesNo:
                    al.AddButton(Message.GetString("Yes"));
                    al.AddButton(Message.GetString("No"));
                    break;
                case MessageWindowButtons.YesNoCancel:
                    al.AddButton(Message.GetString("Yes"));
                    al.AddButton(Message.GetString("No"));
                    al.AddButton(Message.GetString("Cancel"));
                    break;
            }

            WindowResponse resp = CocoaHelper.GetResponse(al.RunModal(), bType);
            al.Dispose();
            return resp;
        }
Ejemplo n.º 19
0
		public static int Run (NSAlert view, Control parent)
		{
			int ret;
			if (parent != null) {
				var window = parent.ControlObject as NSWindow;
				if (window == null && parent.ControlObject is NSView)
					window = ((NSView)parent.ControlObject).Window;
				if (window == null || !view.RespondsToSelector (new Selector ("beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:")))
					ret = view.RunModal ();
				else {
					ret = 0;
					NSApplication.SharedApplication.InvokeOnMainThread (delegate {
						view.BeginSheet (window, new MacModal (), new Selector ("alertDidEnd:returnCode:contextInfo:"), IntPtr.Zero);
						ret = NSApplication.SharedApplication.RunModalForWindow (window);
					});
				}
			} else
				ret = view.RunModal ();
			return ret;
		}
Ejemplo n.º 20
0
        public DialogResult ShowDialog(Control parent, MessageBoxButtons buttons)
        {
            var alert = new NSAlert ();

            var OkButton = "OK";
            var CancelButton = "Cancel";
            var YesButton = "Yes";
            var NoButton = "No";

            switch (buttons) {
            case MessageBoxButtons.OK:
                alert.AddButton (OkButton);
                break;
            case MessageBoxButtons.OKCancel:
                alert.AddButton (OkButton);
                alert.AddButton (CancelButton);
                break;
            case MessageBoxButtons.YesNo:
                alert.AddButton (YesButton);
                alert.AddButton (NoButton);
                break;
            case MessageBoxButtons.YesNoCancel:
                alert.AddButton (YesButton);
                alert.AddButton (CancelButton);
                alert.AddButton (NoButton);
                break;
            }
            alert.AlertStyle = Convert (this.Type);
            int ret = RunDialog (parent, alert);
            switch (buttons) {
            default:
            case MessageBoxButtons.OK:
                return DialogResult.Ok;
            case MessageBoxButtons.OKCancel:
                return (ret == 1000) ? DialogResult.Ok : DialogResult.Cancel;
            case MessageBoxButtons.YesNo:
                return (ret == 1000) ? DialogResult.Yes : DialogResult.No;
            case MessageBoxButtons.YesNoCancel:
                return (ret == 1000) ? DialogResult.Yes : (ret == 1001) ? DialogResult.Cancel : DialogResult.No;
            }
        }
		public bool Run (ExceptionDialogData data)
		{
			using (var alert = new NSAlert ()) {
				alert.AlertStyle = NSAlertStyle.Critical;
				
				var pix = ImageService.GetPixbuf (Gtk.Stock.DialogError, Gtk.IconSize.Dialog);
				byte[] buf = pix.SaveToBuffer ("tiff");
				alert.Icon = new NSImage (NSData.FromArray (buf));
				
				alert.MessageText = data.Title ?? "Some Message";
				alert.InformativeText = data.Message ?? "Some Info";

				if (data.Exception != null) {

					var text = new NSTextView (new RectangleF (0, 0, float.MaxValue, float.MaxValue));
					text.HorizontallyResizable = true;
					text.TextContainer.ContainerSize = new SizeF (float.MaxValue, float.MaxValue);
					text.TextContainer.WidthTracksTextView = false;
					text.InsertText (new NSString (data.Exception.ToString ()));
					text.Editable = false;
					
					var scrollView = new NSScrollView (new RectangleF (0, 0, 450, 150)) {
						HasHorizontalScroller = true,
						DocumentView = text,
					};
;
					alert.AccessoryView = scrollView;
				}
				
				// Hack up a slightly wider than normal alert dialog. I don't know how to do this in a nicer way
				// as the min size constraints are apparently ignored.
				var frame = ((NSPanel) alert.Window).Frame;
				((NSPanel) alert.Window).SetFrame (new RectangleF (frame.X, frame.Y, Math.Max (frame.Width, 600), frame.Height), true);
				
				int result = alert.RunModal () - (int)NSAlertButtonReturn.First;
				
				GtkQuartz.FocusWindow (data.TransientFor ?? MessageService.RootWindow);
			}
			
			return true;
		}
Ejemplo n.º 22
0
        void HandleWindowWillClose(object sender, EventArgs e)
        {
            if (!Platform.MacPreferences.ShouldAskToStartAtLogin) return;

            var alert = new NSAlert {
                AlertStyle = NSAlertStyle.Informational,
                MessageText = "Would you like Awareness to start at login?",
                InformativeText = "Unless Awareness starts automatically, you will likely forget to use it. What good would that do you?"
            };
            alert.AddButton ("Start Awareness at Login");
            alert.AddButton ("No Thanks");

            // TODO: Figure out why this freezes Awareness!
            // alert.BeginSheet (Window, this, new Selector ("alertDidEnd:returnCode:contextInfo:"), IntPtr.Zero);

            var pressed = (NSAlertButtonReturn) alert.RunModal ();
            if (pressed == NSAlertButtonReturn.First) {
                Log.Info ("User consented to starting Awareness automatically at login.");
                Platform.Preferences.StartAtLogin = true;
            }

            Platform.MacPreferences.HasAskedToStartAtLogin = true;
        }
Ejemplo n.º 23
0
		void ShowResponse (NSAlert alert, int response)
		{
			string message;

			if (response <= 1) {
				switch (response) {
				case -1:
					message = String.Format ("Non-custom response: -1 (other)");
					break;
				case 0:
					message = String.Format ("Non-custom response: 0 (alternate)");
					break;
				case 1:
					message = String.Format ("Non-custom response: 1 (default)");
					break;
				default:
					message = String.Format ("Unknown Response: {0}", response);
					break;
				}
			} else {
				var buttonIndex = response - (int)NSAlertButtonReturn.First;
				if (buttonIndex >= alert.Buttons.Length)
					message = String.Format ("Unknown Response: {0}", response);
				else
					message = String.Format (
						"\"{0}\"\n\nButton Index: {1}\nResult (NSAlertButtonReturn): {2}\nResult (int): {3}",
						alert.Buttons [buttonIndex].Title,
						buttonIndex,
						(NSAlertButtonReturn)response,
						response);
			}

			if (alert.ShowsSuppressionButton)
				message += String.Format ("\nSuppression: {0}", alert.SuppressionButton.State);

			ResultLabel.StringValue = message;
		}
		partial void AddNotebook (NSObject sender) {
            		string notebook = NotebookName.StringValue;

			if (AppDelegate.Notebooks.Contains(notebook, StringComparer.OrdinalIgnoreCase)) {
                		//The notebook already exists, hence should not be added again
                		NSAlert alert = new NSAlert () {
                    			MessageText = "Notebook Already Exists",
                    			InformativeText = "The Notebook " + notebook + " already exists.",
                    			AlertStyle = NSAlertStyle.Warning
                		};
                		alert.AddButton ("OK");
                		alert.BeginSheet (this.Window,
                    			this,
                    			null,
                    			IntPtr.Zero);

                		NotebookName.SelectText(this);
			} else if (string.IsNullOrEmpty (notebook) || string.IsNullOrWhiteSpace (notebook)) {
				NSAlert alert = new NSAlert () {
					MessageText = "Notebook Empty",
					InformativeText = "The Notebook name cannot be empty.",
					AlertStyle = NSAlertStyle.Warning
				};
				alert.AddButton ("OK");
				alert.BeginSheet (this.Window,
					this,
					null,
					IntPtr.Zero);

				NotebookName.SelectText(this);
			} else {
                		AppDelegate.Notebooks.Add (notebook);
				AppDelegate.currentNotebook = notebook;
                		Window.PerformClose (this);
                		AppDelegate.RefreshNotesWindowController ();
            		}
        }
Ejemplo n.º 25
0
		public bool Run (AlertDialogData data)
		{
			using (var alert = new NSAlert ()) {
				alert.Window.Title = data.Title ?? BrandingService.ApplicationName;

				if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Information) {
					alert.AlertStyle = NSAlertStyle.Critical;
				} else if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Warning) {
					alert.AlertStyle = NSAlertStyle.Warning;
				} else { //if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Information) {
					alert.AlertStyle = NSAlertStyle.Informational;
				}
				
				//FIXME: use correct size so we don't get horrible scaling?
				if (!string.IsNullOrEmpty (data.Message.Icon)) {
					var pix = ImageService.GetPixbuf (data.Message.Icon, Gtk.IconSize.Dialog);
					byte[] buf = pix.SaveToBuffer ("tiff");
					unsafe {
						fixed (byte* b = buf) {
							alert.Icon = new NSImage (NSData.FromBytes ((IntPtr)b, (uint)buf.Length));
						}
					}
				} else {
					//for some reason the NSAlert doesn't pick up the app icon by default
					alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;
				}
				
				alert.MessageText = data.Message.Text;
				alert.InformativeText = data.Message.SecondaryText ?? "";
				
				var buttons = data.Buttons.Reverse ().ToList ();
				
				for (int i = 0; i < buttons.Count - 1; i++) {
					if (i == data.Message.DefaultButton) {
						var next = buttons[i];
						for (int j = buttons.Count - 1; j >= i; j--) {
							var tmp = buttons[j];
							buttons[j] = next;
							next = tmp;
						}
						break;
					}
				}
				
				foreach (var button in buttons) {
					var label = button.Label;
					if (button.IsStockButton)
						label = Gtk.Stock.Lookup (label).Label;
					label = label.Replace ("_", "");

					//this message seems to be a standard Mac message since alert handles it specially
					if (button == AlertButton.CloseWithoutSave)
						label = GettextCatalog.GetString ("Don't Save");

					alert.AddButton (label);
				}
				
				
				NSButton[] optionButtons = null;
				if (data.Options.Count > 0) {
					var box = new MDBox (LayoutDirection.Vertical, 2, 2);
					optionButtons = new NSButton[data.Options.Count];
					
					for (int i = data.Options.Count - 1; i >= 0; i--) {
						var option = data.Options[i];
						var button = new NSButton () {
							Title = option.Text,
							Tag = i,
							State = option.Value? NSCellStateValue.On : NSCellStateValue.Off,
						};
						button.SetButtonType (NSButtonType.Switch);
						optionButtons[i] = button;
						box.Add (new MDAlignment (button, true) { XAlign = LayoutAlign.Begin });
					}
					
					box.Layout ();
					alert.AccessoryView = box.View;
				}
				
				NSButton applyToAllCheck = null;
				if (data.Message.AllowApplyToAll) {
					alert.ShowsSuppressionButton = true;
					applyToAllCheck = alert.SuppressionButton;
					applyToAllCheck.Title = GettextCatalog.GetString ("Apply to all");
				}
				
				// Hack up a slightly wider than normal alert dialog. I don't know how to do this in a nicer way
				// as the min size constraints are apparently ignored.
				var frame = ((NSPanel) alert.Window).Frame;
				((NSPanel) alert.Window).SetFrame (new RectangleF (frame.X, frame.Y, Math.Max (frame.Width, 600), frame.Height), true);
				alert.Layout ();
				
				bool completed = false;
				if (data.Message.CancellationToken.CanBeCanceled) {
					data.Message.CancellationToken.Register (delegate {
						alert.InvokeOnMainThread (() => {
							if (!completed) {
								NSApplication.SharedApplication.AbortModal ();
							}
						});
					});
				}
				
				if (!data.Message.CancellationToken.IsCancellationRequested) {
					int result = alert.RunModal () - (int)NSAlertButtonReturn.First;
					completed = true;
					if (result >= 0 && result < buttons.Count) {
						data.ResultButton = buttons [result];
					} else {
						data.ResultButton = null;
					}
				}
				
				if (data.ResultButton == null || data.Message.CancellationToken.IsCancellationRequested) {
					data.SetResultToCancelled ();
				}
				
				if (optionButtons != null) {
					foreach (var button in optionButtons) {
						var option = data.Options[button.Tag];
						data.Message.SetOptionValue (option.Id, button.State != 0);
					}
				}
				
				if (applyToAllCheck != null && applyToAllCheck.State != 0)
					data.ApplyToAll = true;
				
				GtkQuartz.FocusWindow (data.TransientFor ?? MessageService.RootWindow);
			}
			
			return true;
		}
        public void ExportEveryGlyphsAsPNGTo(string path)
        {
            float scale = Window.BackingScaleFactor;
            var glyphInfos = _tableViewSource.GlyphInfos;
            //actvw.StartAnimating ();
            Task.Factory.StartNew (() => {
                Func<string, string> makeName = (rawName) => {
                    return String.Format ("{0}_{1}{2}.png", rawName, (int)this.unitFontSize
                                          , ((scale > 2f) ? "@4x" : (scale > 1f) ? "@2x" : ""));
                };
                //string documentDirPath = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
                string documentDirPath = path;

                NSDictionary prop = new NSDictionary (); //
                int nSucceeded = 0;
                int nFailed = 0;
                glyphInfos.ForEach ((gi) => {
                    var url = new NSUrl (System.IO.Path.Combine (documentDirPath, makeName (gi.RawName)), false);
                    try {
                        CGImageDestination dest = CGImageDestination.FromUrl (url, "public.png", 1);
                        dest.AddImage (gi.GlyphImage, prop);
                        dest.Close ();
                    }
                    catch (Exception ex) {
                        Console.WriteLine (ex.ToString ());
                    }
                    if (System.IO.File.Exists (url.Path)) {
                        //Console.WriteLine ("Succeeded to write {0}", url);
                        ++ nSucceeded;
                    }
                    else {
                        Console.WriteLine ("Failed to write {0}", url);
                        ++ nFailed;
                    }
                    BeginInvokeOnMainThread (() => {
                        //ShowProgressionLabel (String.Format ("{0} of {1} processed", (nSucceeded + nFailed), glyphInfos.Count));
                    });
                });

                InvokeOnMainThread (() => {
                    //actvw.StopAnimating ();
                    //DismissProgressionLabel ();
                    var alert = new NSAlert ();
                    alert.MessageText = String.Format ("{0} succeeded, {1} failed", nSucceeded, nFailed);
                    alert.RunModal ();
                });
            });
        }
Ejemplo n.º 27
0
 private void HandleOnResetAudioSettingsButtonSelected(SessionsButton button)
 {
     if (OnCheckIfPlayerIsPlaying())
     {
         using(var alert = new NSAlert())
         {
             alert.MessageText = "Confirmation";
             alert.InformativeText = "Resetting the audio settings will stop the playback.\n\nIf you click OK, the playback will stop and changes will be applied immediately.\n\nIf you click Cancel, the changes will be applied the next time the player is reinitialized.";
             alert.AlertStyle = NSAlertStyle.Warning;
             var btnOK = alert.AddButton("OK");
             btnOK.Activated += (sender2, e2) => {
                 NSApplication.SharedApplication.StopModal();
                 OnResetAudioSettings();
             };
             var btnCancel = alert.AddButton("Cancel");
             btnCancel.Activated += (sender3, e3) => NSApplication.SharedApplication.StopModal();
             alert.RunModal();
         }
     }
 }
Ejemplo n.º 28
0
        private void SetOutputDeviceAndSampleRate()
        {
            if (popupOutputDevice.IndexOfSelectedItem == -1 || popupSampleRate.IndexOfSelectedItem == -1 || _isRefreshingComboBoxes)
                return;

            if (OnCheckIfPlayerIsPlaying())
            {
                using (var alert = new NSAlert())
                {
                    alert.MessageText = "Confirmation";
                    alert.InformativeText = "Resetting the audio settings will stop the playback.\n\nIf you click OK, the playback will stop and changes will be applied immediately.\n\nIf you click Cancel, the changes will be applied the next time the player is reinitialized.";
                    alert.AlertStyle = NSAlertStyle.Warning;
                    var btnOK = alert.AddButton("OK");
                    btnOK.Activated += (sender2, e2) =>
                    {
                        NSApplication.SharedApplication.StopModal();
                        SetOutputDeviceAndSampleRateInternal();
                    };
                    var btnCancel = alert.AddButton("Cancel");
                    btnCancel.Activated += (sender3, e3) => NSApplication.SharedApplication.StopModal();
                    alert.RunModal();
                }
            }
            else
            {
                SetOutputDeviceAndSampleRateInternal();
            }
        }
Ejemplo n.º 29
0
 private void HandleOnResetLibraryButtonSelected(SessionsButton button)
 {
     using(var alert = new NSAlert())
     {
         alert.MessageText = "Library will be reset";
         alert.InformativeText = "Are you sure you wish to reset your library? This won't delete any audio files from your hard disk.";
         alert.AlertStyle = NSAlertStyle.Warning;
         var btnOK = alert.AddButton("OK");
         btnOK.Activated += (sender2, e2) => {
             NSApplication.SharedApplication.StopModal();
             OnResetLibrary();
         };
         var btnCancel = alert.AddButton("Cancel");
         btnCancel.Activated += (sender3, e3) => NSApplication.SharedApplication.StopModal();
         alert.RunModal();
     }
 }
Ejemplo n.º 30
0
        private void HandleOnRemoveFolderButtonSelected(SessionsButton button)
        {
            using(var alert = new NSAlert())
            {
                alert.MessageText = "Folder will be removed from library";
                alert.InformativeText = "Are you sure you wish to remove this folder from your library? This won't delete any audio files from your hard disk.";
                alert.AlertStyle = NSAlertStyle.Warning;
                var btnOK = alert.AddButton("OK");
                btnOK.Activated += (sender2, e2) => {
                    NSApplication.SharedApplication.StopModal();

                    // Remove files from database
                    //OnRemoveFolder(_libraryAppConfig.Folders[tableFolders.SelectedRow]);

                    // Remove folder from list of configured folders
                    _libraryAppConfig.Folders.RemoveAt(tableFolders.SelectedRow);
                    OnSetLibraryPreferences(_libraryAppConfig);
                    tableFolders.ReloadData();
                };
                var btnCancel = alert.AddButton("Cancel");
                btnCancel.Activated += (sender3, e3) => NSApplication.SharedApplication.StopModal();
                alert.RunModal();
            }
        }
Ejemplo n.º 31
0
        private void ControlTextDidEndEditing(NSNotification notification)
        {
            Console.WriteLine("ControlTextDidEndEditing");
            var textField = notification.Object as NSTextField;
            if (textField == null)
                return;

            if (textField == txtCustomDirectory)
            {
                // Should this be done in the presenter instead? 
                if (!Directory.Exists(textField.StringValue))
                {
                    using (var alert = new NSAlert())
                    {
                        alert.MessageText = "Path is invalid";
                        alert.InformativeText = "The path you have entered is invalid or the folder does not exist.";
                        alert.AlertStyle = NSAlertStyle.Critical;
                        var btnOK = alert.AddButton("OK");
                        btnOK.Activated += (sender2, e2) => textField.StringValue = string.Empty;
                    }
                    return;
                }

                _generalAppConfig.CustomPeakFileFolder = textField.StringValue;
                OnSetGeneralPreferences(_generalAppConfig);
            } 
            else if (textField == txtHttpPort)
            {
                int port = 0;
                int.TryParse(textField.StringValue, out port);
                if (port >= 21 && port <= 65535)
                {
                    _libraryAppConfig.SyncServicePort = port;
                    OnSetLibraryPreferences(_libraryAppConfig);
                } 
                else
                {
                    using (var alert = new NSAlert())
                    {
                        alert.MessageText = "Library service HTTP port is invalid";
                        alert.InformativeText = "The HTTP port you have entered is invalid. It must be between 21 and 65535.";
                        alert.AlertStyle = NSAlertStyle.Critical;
                        var btnOK = alert.AddButton("OK");
                        btnOK.Activated += (sender2, e2) => textField.StringValue = string.Empty;
                    }
                    return;
                }
            }
        }
Ejemplo n.º 32
0
 private void HandleOnDeletePeakFilesButtonSelected(SessionsButton button)
 {
     using(var alert = new NSAlert())
     {
         alert.MessageText = "Peak files will be deleted";
         alert.InformativeText = "Are you sure you wish to delete the peak files folder? Peak files can always be generated later.";
         alert.AlertStyle = NSAlertStyle.Warning;
         var btnOK = alert.AddButton("OK");
         btnOK.Activated += (sender2, e2) => {
             NSApplication.SharedApplication.StopModal();
             OnDeletePeakFiles();
         };
         var btnCancel = alert.AddButton("Cancel");
         btnCancel.Activated += (sender3, e3) => NSApplication.SharedApplication.StopModal();
         alert.RunModal();
     }
 }
		partial void SetSyncPath(NSObject sender) {
            		var openPanel = new NSOpenPanel();
            		openPanel.ReleasedWhenClosed = true;
            		openPanel.CanChooseDirectories = true;
            		openPanel.CanChooseFiles = false;
            		openPanel.CanCreateDirectories = true;
            		openPanel.Prompt = "Select Directory";

            		var result = openPanel.RunModal();
            		if (result == 1) {
                		SyncPathTextField.Cell.Title = openPanel.DirectoryUrl.Path;
				//AppDelegate.FilesystemSyncPath = openPanel.DirectoryUrl.Path;

				AppDelegate.settings.syncURL = openPanel.DirectoryUrl.Path;
				SettingsSync.Write(AppDelegate.settings);

                		NSAlert alert = new NSAlert () {
                    			MessageText = "File System Sync",
                    			InformativeText = "File System Sync path has been set at:\n"+AppDelegate.settings.syncURL,
                    			AlertStyle = NSAlertStyle.Warning
                		};
                		alert.AddButton ("OK");
                			alert.BeginSheet (this.Window,
                    			this,
                    			null,
                    			IntPtr.Zero);
			}

        	}