Exemplo n.º 1
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;
        }
Exemplo n.º 2
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;
        }
Exemplo 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();
         }
     }
 }
Exemplo n.º 4
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 ();
         }
     }
 }
Exemplo n.º 5
0
 public override void Alert(string message)
 {
     NSAlert alert = new NSAlert();
     alert.MessageText = message;
     alert.AddButton("Ok");
     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);
				}
			}
        	}
Exemplo n.º 7
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();
			});
		}
		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 ();
				}

			}
		}
Exemplo n.º 9
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;
        }
Exemplo n.º 10
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;
            }
        }
		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 ();
            		}
        }
Exemplo n.º 12
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;
                }
            }
        }
Exemplo n.º 13
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();
     }
 }
Exemplo n.º 14
0
		public bool Run (ExceptionDialogData data)
		{
			using (var alert = new NSAlert { AlertStyle = NSAlertStyle.Critical }) {
				alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;
				
				alert.MessageText = data.Title ?? GettextCatalog.GetString ("Error");
				
				if (!string.IsNullOrEmpty (data.Message)) {
					alert.InformativeText = data.Message;
				}

				List<AlertButton> buttons = null;
				if (data.Buttons != null && data.Buttons.Length > 0)
					buttons = data.Buttons.Reverse ().ToList ();

				if (buttons != null) {
					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);
					}
				}

				if (data.Exception != null) {
					var scrollSize = new SizeF (400, 130);
					float spacing = 4;
					
					string title = GettextCatalog.GetString ("View details");
					string altTitle = GettextCatalog.GetString ("Hide details");
					
					var buttonFrame = new RectangleF (0, 0, 0, 0);
					var button = new NSButton (buttonFrame) {
						BezelStyle = NSBezelStyle.Disclosure,
						Title = "",
						AlternateTitle = "",
					};
					button.SetButtonType (NSButtonType.OnOff);
					button.SizeToFit ();
					
					var label = new MDClickableLabel (title) {
						Alignment = NSTextAlignment.Left,
					};
					label.SizeToFit ();
					
					button.SetFrameSize (new SizeF (button.Frame.Width, Math.Max (button.Frame.Height, label.Frame.Height)));
					label.SetFrameOrigin (new PointF (button.Frame.Width + 5, button.Frame.Y));
					
					var text = new MyTextView (new RectangleF (0, 0, float.MaxValue, float.MaxValue)) {
						HorizontallyResizable = true,
					};
					text.TextContainer.ContainerSize = new SizeF (float.MaxValue, float.MaxValue);
					text.TextContainer.WidthTracksTextView = true;
					text.InsertText (new NSString (data.Exception.ToString ()));
					text.Editable = false;

					var scrollView = new NSScrollView (new RectangleF (PointF.Empty, SizeF.Empty)) {
						HasHorizontalScroller = true,
						HasVerticalScroller = true,
					};
					
					var accessory = new NSView (new RectangleF (0, 0, scrollSize.Width, button.Frame.Height));
					accessory.AddSubview (scrollView);
					accessory.AddSubview (button);
					accessory.AddSubview (label);
					
					alert.AccessoryView = accessory;
					
					button.Activated += delegate {
						float change;
						if (button.State == NSCellStateValue.On) {
							change = scrollSize.Height + spacing;
							label.StringValue = altTitle;
							scrollView.Hidden = false;
							scrollView.Frame = new RectangleF (PointF.Empty, scrollSize);
							scrollView.DocumentView = text;
						} else {
							change = -(scrollSize.Height + spacing);
							label.StringValue = title;
							scrollView.Hidden = true;
							scrollView.Frame = new RectangleF (PointF.Empty, SizeF.Empty);
						}
						var f = accessory.Frame;
						f.Height += change;
						accessory.Frame = f;
						var lf = label.Frame;
						lf.Y += change;
						label.Frame = lf;
						var bf = button.Frame;
						bf.Y += change;
						button.Frame = bf;
						label.SizeToFit ();
						var panel = (NSPanel) alert.Window;
						var pf = panel.Frame;
						pf.Height += change;
						pf.Y -= change;
						panel.SetFrame (pf, true, true);
						//unless we assign the icon again, it starts nesting old icon into the warning icon
						alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;
						alert.Layout ();
					};
					label.OnMouseUp += (sender, e) => button.PerformClick (e.Event);
				}

				int result = alert.RunModal () - (int)NSAlertButtonReturn.First;
				data.ResultButton = buttons != null ? buttons [result] : null;
				GtkQuartz.FocusWindow (data.TransientFor ?? MessageService.RootWindow);
			}
			
			return true;
		}
Exemplo n.º 15
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;
        }
Exemplo n.º 16
0
		public bool Run (AlertDialogData data)
		{
			using (var alert = new NSAlert ()) {
				
				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));
						}
					}
				}
				
				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");
				}
				
				alert.Layout ();
				
				int result = alert.RunModal () - (int)NSAlertButtonReturn.First;
				
				data.ResultButton = buttons [result];
				
				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;
		}
Exemplo n.º 17
0
		void LaunchDocumentationUpdate ()
		{
			var infoDialog = new NSAlert {
				AlertStyle = NSAlertStyle.Informational,
				MessageText = "Documentation update available",
				InformativeText = "We have detected your MonoTouch documentation can be upgraded with Apple documentation, would you like to launch the merge now (root password required)?"
			};
			
			infoDialog.AddButton ("Yes");
			infoDialog.AddButton ("Cancel");
			var dialogResult = infoDialog.RunModal ();
			// If Cancel was clicked, just return
			if (dialogResult == (int)NSAlertButtonReturn.Second)
				return;
			
			// Launching AppleDocWizard as root
			// First get the directory
			var updaterPath = Path.Combine (Path.GetDirectoryName (NSBundle.MainBundle.BuiltinPluginsPath), "MacOS");
			// Next get the executable
			updaterPath = Path.Combine (updaterPath, "AppleDocWizard.app", "Contents", "MacOS", "AppleDocWizard");
			try {
				RootLauncher.LaunchExternalTool (updaterPath);
			} catch (RootLauncherException ex) {
				var alertDialog = new NSAlert {
					AlertStyle = NSAlertStyle.Critical,
					MessageText = "Documentation updater error",
					InformativeText = string.Format ("There was an error launching the documentation updater: {0}{1}{2}", ex.ResultCode.ToString (), Environment.NewLine, ex.Message)
				};
				alertDialog.RunModal ();
			}
		}
Exemplo n.º 18
0
		void LaunchDocumentationUpdate (Dictionary<Product, Tuple<bool, bool>> toUpdate)
		{
			var informative = "We have detected your " + string.Join (" and ", toUpdate.Keys.Select (ProductUtils.GetFriendlyName)) +
				" documentation can be upgraded with Apple documentation.";
			// Check if we are going to be downloading stuff
			if (toUpdate.Any (kvp => kvp.Value.Item1))
				informative += Environment.NewLine + Environment.NewLine + "Warning: we are going to download documentation from Apple servers which can take a long time depending on your Internet connection.";
			informative += Environment.NewLine + Environment.NewLine + "Would you like to update the documentation now?";

			var infoDialog = new NSAlert {
				AlertStyle = NSAlertStyle.Informational,
				MessageText = "Documentation update available",
				InformativeText = informative
			};
			
			infoDialog.AddButton ("Update now");
			infoDialog.AddButton ("Remind me later");
			var dialogResult = infoDialog.RunModal ();
			// If Cancel was clicked, just return
			if (dialogResult == (int)NSAlertButtonReturn.Second)
				return;
			
			// Launching AppleDocWizard as root
			var mergerTasks = toUpdate
				.Where (kvp => kvp.Value.Item1 || kvp.Value.Item2)
				.Select (kvp => Task.Factory.StartNew (() => {
						var mergeToolPath = ProductUtils.GetMergeToolForProduct (kvp.Key);
						var docOutdated = kvp.Value.Item1;

						// If the script has its setuid bit on and user as root, then we launch it directly otherwise we first restore it
						if (!RootLauncher.IsRootEnabled (mergeToolPath)) {
							RootLauncher.LaunchExternalTool (mergeToolPath, new string[] { "--self-repair" });
							// No good way to know when the process will finish, so wait a bit. Not ideal but since this is an unlikely codepath, shouldn't matter.
							System.Threading.Thread.Sleep (1000);
						}
						var psi = new System.Diagnostics.ProcessStartInfo (mergeToolPath, docOutdated ? "--force-download" : null);
						return ProcessUtils.StartProcess (psi, null, null, CancellationToken.None);
					}).Unwrap ());
			// No Task.WhenAll yet
			var tcs = new TaskCompletionSource<int> ();
			Task.Factory.ContinueWhenAll (mergerTasks.ToArray (), ts => {
				var faulteds = ts.Where (t => t.IsFaulted);
				if (faulteds.Any ())
					tcs.SetException (faulteds.Select (t => t.Exception));
				else
					tcs.SetResult (ts.Select (t => t.Result).FirstOrDefault (r => r != 0));
			});

			var mergeController = new AppleDocMergeWindowController ();
			mergeController.TrackProcessTask (tcs.Task);
			mergeController.ShowWindow (this);
			mergeController.Window.Center ();
		}
Exemplo n.º 19
0
		void LaunchDocumentationUpdate (bool docOutdated, bool mergeOutdated)
		{
			var infoDialog = new NSAlert {
				AlertStyle = NSAlertStyle.Informational,
				MessageText = "Documentation update available",
				InformativeText = "We have detected your MonoTouch documentation can be upgraded with Apple documentation."
					+ Environment.NewLine
					+ Environment.NewLine
					+ "Would you like to update the documentation now? You can continue to browse the documentation while the update is performed."
			};
			
			infoDialog.AddButton ("Update now");
			infoDialog.AddButton ("Remind me later");
			var dialogResult = infoDialog.RunModal ();
			// If Cancel was clicked, just return
			if (dialogResult == (int)NSAlertButtonReturn.Second)
				return;
			
			// Launching AppleDocWizard as root
			// First get the directory
			try {
				RootLauncher.LaunchExternalTool (mergeToolPath, docOutdated ? new string[] { "--force-download" } : (string[])null);
			} catch (RootLauncherException ex) {
				var alertDialog = new NSAlert {
					AlertStyle = NSAlertStyle.Critical,
					MessageText = "Documentation updater error",
					InformativeText = string.Format ("There was an error launching the documentation updater: {0}{1}{2}", ex.ResultCode.ToString (), Environment.NewLine, ex.Message)
				};
				alertDialog.RunModal ();
			}
		}
Exemplo n.º 20
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;
		}
Exemplo n.º 21
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();
            }
        }
Exemplo n.º 22
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();
            }
        }
		partial void ExportNotesAction(NSObject sender) {
            		if (ExportPathTextField.StringValue != null){
                		string rootDirectory = ExportPathTextField.StringValue;
				ExportNotes.Export(rootDirectory, AppDelegate.NoteEngine);

                	NSAlert alert = new NSAlert () {
                    		MessageText = "Note Imported",
                    		InformativeText = "All the notes have been imported to local storage. Please restart the Tomboy to see your old notes",
                    		AlertStyle = NSAlertStyle.Warning
                	};
                	alert.AddButton ("OK");
                	alert.BeginSheet (this.Window,
                    		this,
                    		null,
                    		IntPtr.Zero);
            		}

        	}
		partial void Authenticate (NSObject sender) {

			if (!String.IsNullOrEmpty (AppDelegate.settings.syncURL) || !String.IsNullOrWhiteSpace (AppDelegate.settings.syncURL)) {
				NSAlert alert = new NSAlert () {
					MessageText = "File System Sync Found",
					InformativeText = "The File System Sync option would be overriden with Rainy Web Sync.",
					AlertStyle = NSAlertStyle.Warning
				};
				alert.AddButton ("Override File System Sync");
				alert.AddButton ("Cancel");
				alert.BeginSheet (this.Window,
					this,
					new MonoMac.ObjCRuntime.Selector ("alertDidEnd:returnCode:contextInfo:"),
					IntPtr.Zero);

				AppDelegate.settings.syncURL = "";
				SettingsSync.Write (AppDelegate.settings);
			} else {
				SyncPrefDialogController.AuthorizeAction (this.Window, SyncURL.StringValue);
			}
		}
		public static void AuthorizeAction (NSWindow window, String serverURL) {

			if (String.IsNullOrEmpty (serverURL) || String.IsNullOrWhiteSpace (serverURL)) {
				NSAlert alert = new NSAlert () {
					MessageText = "Incorrect URL",
					InformativeText = "The Sync URL cannot be empty",
					AlertStyle = NSAlertStyle.Warning
				};
				alert.AddButton ("OK");
				alert.BeginSheet (window,
					null,
					null,
					IntPtr.Zero);

				//SyncURL.StringValue = "";
				return;

			} else {
				if (!serverURL.EndsWith ("/"))
					serverURL += "/";
			}

			HttpListener listener = new HttpListener ();
			string callbackURL = "http://localhost:9001/";
			listener.Prefixes.Add (callbackURL);
			listener.Start ();

			var callback_delegate = new OAuthAuthorizationCallback ( url => {
				Process.Start (url);

				// wait (block) until the HttpListener has received a request 
				var context = listener.GetContext ();

				// if we reach here the authentication has most likely been successfull and we have the
				// oauth_identifier in the request url query as a query parameter
				var request_url = context.Request.Url;
				string oauth_verifier = System.Web.HttpUtility.ParseQueryString (request_url.Query).Get("oauth_verifier");

				if (string.IsNullOrEmpty (oauth_verifier)) {
					// authentication failed or error
					context.Response.StatusCode = 500;
					context.Response.StatusDescription = "Error";
					context.Response.Close();
					throw new ArgumentException ("oauth_verifier");
				} else {
					// authentication successfull
					context.Response.StatusCode = 200;
					using (var writer = new StreamWriter (context.Response.OutputStream)) {
						writer.WriteLine("<h1>Authorization successfull!</h1>Go back to the Tomboy application window.");
					}
					context.Response.Close();
					return oauth_verifier;
				}
			});

			try{
				//FIXME: see http://mono-project.com/UsingTrustedRootsRespectfully for SSL warning
				ServicePointManager.CertificatePolicy = new DummyCertificateManager ();

				IOAuthToken access_token = WebSyncServer.PerformTokenExchange (serverURL, callbackURL, callback_delegate);

				AppDelegate.settings.webSyncURL = serverURL;
				AppDelegate.settings.token = access_token.Token;
				AppDelegate.settings.secret = access_token.Secret;

				SettingsSync.Write (AppDelegate.settings);

				Console.WriteLine ("Received token {0} with secret key {1}",access_token.Token, access_token.Secret);

				listener.Stop ();

				NSAlert success = new NSAlert () {
					MessageText = "Authentication Successful",
					InformativeText = "The authentication with the server has been successful. You can sync with the web server now.",
					AlertStyle = NSAlertStyle.Informational
				};
				success.AddButton ("OK");
				success.BeginSheet (window,
					window,
					null,
					IntPtr.Zero);
				return;
			} catch (Exception ex) {

				if (ex is WebException || ex is System.Runtime.Serialization.SerializationException) {

					NSAlert alert = new NSAlert () {
						MessageText = "Incorrect URL",
						InformativeText = "The URL entered " + serverURL + " is not valid for syncing",
						AlertStyle = NSAlertStyle.Warning
					};
					alert.AddButton ("OK");
					alert.BeginSheet (window,
						null,
						null,
						IntPtr.Zero);

					listener.Abort ();

					return;
				} else {
					NSAlert alert = new NSAlert () {
						MessageText = "Some Issue has occured",
						InformativeText = "Something does not seem right!",
						AlertStyle = NSAlertStyle.Warning
					};
					alert.AddButton ("OK");
					alert.BeginSheet (window,
						null,
						null,
						IntPtr.Zero);

					listener.Abort ();
				}
			}
		}
Exemplo n.º 26
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();
     }
 }
        public void event_btnUpload_Activated(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty (txtUserName.StringValue) || string.IsNullOrEmpty (txtPassWord.StringValue)) {
                var alert = new NSAlert {
                    MessageText = "Username or password empty.",
                    AlertStyle = NSAlertStyle.Informational
                };

                alert.AddButton ("Ok");

                alert.RunModal();
                return;
            }

            FileInfo fInfo = new FileInfo(txtFullSceneName.StringValue);
            long numBytes = fInfo.Length;

            FileStream fStream = new FileStream(txtFullSceneName.StringValue, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fStream);

            FormUpload.FileParameter fp = new FormUpload.FileParameter (br.ReadBytes((int)numBytes),
                Path.GetFileName (txtFullSceneName.StringValue),
                "application/octet-stream");

            br.Close();
            fStream.Close();

            string releaseType = string.Empty;
            if (cmbType.StringValue == "App")
                releaseType = "1";
            if (cmbType.StringValue == "Game")
                releaseType = "2";

            var client = new WebClientEx ();
            var values = new NameValueCollection
            {
                { "username", txtUserName.StringValue },
                { "password", txtPassWord.StringValue },
            };

            // Authenticate
            client.UploadValues("https://mac-torrents.me/login.php", values);
            string tempResponse = client.DownloadString ("https://mac-torrents.me/upload.php");

            string searchFor = "<input type=\"hidden\" name=\"auth\" value=\"";
            int indexSearchFor = tempResponse.IndexOf (searchFor) + searchFor.Length;
            string authString = tempResponse.Substring (indexSearchFor, 32);

            // Upload torrent
            Dictionary<string, object> paramsDic = new Dictionary<string, object> ();
            paramsDic.Add ("submit", "true");
            paramsDic.Add ("auth", authString);
            paramsDic.Add ("type", releaseType);
            paramsDic.Add ("title", txtTitleCode.StringValue);
            paramsDic.Add ("tags", txtTagsCode.StringValue);
            paramsDic.Add ("image", txtImageCode.StringValue);
            paramsDic.Add ("desc", txtDescriptionCode.Value);
            paramsDic.Add ("file_input", fp);

            if (cmbComp.StringValue == "10.6") {
                paramsDic.Add ("macos[]", new string[] {"1", "2", "3", "4"});
            }
            if (cmbComp.StringValue == "10.7")
            {
                paramsDic.Add ("macos[]", new string[] {"2", "3", "4"});
            }
            if (cmbComp.StringValue == "10.8")
            {
                paramsDic.Add ("macos[]", new string[] {"3", "4"});
            }
            if (cmbComp.StringValue == "10.9")
            {
                paramsDic.Add ("macos[]", "4");
            }
            //Upload torrent
            FormUpload.MultipartFormDataPost (
                "https://mac-torrents.me/upload.php",
                "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) " +
                    "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36",
                paramsDic,
                client.CookieContainer);

            try
            {
                tempResponse = client.DownloadString ("https://mac-torrents.me/logout.php?auth=" + authString);
            } catch {
            }

            txtNfoFilename.StringValue = "";
            txtDescription.Value = "";
            txtDescriptionCode.Value = "";
            txtTagsCode.StringValue = "";
            txtImageCode.StringValue = "";

            var alertEnd = new NSAlert {
                MessageText = "Done!",
                AlertStyle = NSAlertStyle.Informational
            };

            alertEnd.AddButton ("Ok");

            alertEnd.RunModal();
        }
Exemplo n.º 28
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();
         }
     }
 }
Exemplo n.º 29
0
		/// <summary>
		/// Syncs the notes.
		/// </summary>
		/// <param name="sender">Sender.</param>
		partial void SyncNotes(NSObject sender) {

			bool success = false;

			if (!String.IsNullOrEmpty (settings.syncURL) || !String.IsNullOrWhiteSpace (settings.syncURL)) {

				var dest_manifest_path = Path.Combine (settings.syncURL, "manifest.xml");
				SyncManifest dest_manifest;
				if (!File.Exists (dest_manifest_path)) {
					using (var output = new FileStream (dest_manifest_path, FileMode.Create)) {
						SyncManifest.Write (new SyncManifest (), output);
					}
				}
				using (var input = new FileStream (dest_manifest_path, FileMode.Open)) {
					dest_manifest = SyncManifest.Read (input);
				}
				var dest_storage = new DiskStorage (settings.syncURL);
				var dest_engine = new Engine (dest_storage);

				var client = new FilesystemSyncClient (NoteEngine, manifestTracker.Manifest);
				var server = new FilesystemSyncServer (dest_engine, dest_manifest);
				new SyncManager(client, server).DoSync ();

				// write back the dest manifest
		        	using (var output = new FileStream (dest_manifest_path, FileMode.Create)) {
					SyncManifest.Write (dest_manifest, output);
				}

				PopulateNotebookList (false);
				RefreshNotesWindowController ();

				success = true;
			}

			else if (!String.IsNullOrEmpty (settings.webSyncURL) ||!String.IsNullOrWhiteSpace (settings.webSyncURL)) {

				ServicePointManager.CertificatePolicy = new DummyCertificateManager();

				OAuthToken reused_token = new OAuthToken { Token = settings.token, Secret = settings.secret };


				ISyncClient client = new FilesystemSyncClient (NoteEngine, manifestTracker.Manifest);
				ISyncServer server = new WebSyncServer (settings.webSyncURL, reused_token);

				new SyncManager (client, server).DoSync ();

				PopulateNotebookList (false);
				RefreshNotesWindowController ();

				success = true;
			}

			if (success) {
				NSAlert alert = new NSAlert () {
					MessageText = "Sync Successful",
					InformativeText = "The sync was successful",
					AlertStyle = NSAlertStyle.Warning
				};
				alert.AddButton ("OK");
				alert.BeginSheet (null);
				alert.Window.Title = "Sync Successful";
			} else {
				NSAlert alert = new NSAlert () {
					MessageText = "Sync Failed",
					InformativeText = "The sync was not successful. Please check the Sync Settings.",
					AlertStyle = NSAlertStyle.Warning
				};
				alert.AddButton ("OK");
				alert.BeginSheet (null);
				alert.Window.Title = "Sync Failed";
			}
        	}
Exemplo n.º 30
0
partial         void DeleteNote(NSObject sender)
        {
            NSAlert alert = new NSAlert () {
                MessageText = "Really delete this note?",
                InformativeText = "You are about to delete this note, this operation cannot be undone",
                AlertStyle = NSAlertStyle.Warning
            };
            alert.AddButton ("OK");
            alert.AddButton ("Cancel");
            alert.BeginSheet (WindowForSheet,
                              this,
                              new MonoMac.ObjCRuntime.Selector ("alertDidEnd:returnCode:contextInfo:"),
                              IntPtr.Zero);
        }
		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);
			}

        	}