public void DeletePerson(NSWindow window) { if (Table.SelectedRow == -1) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = "Please select the person to remove from the list of people.", MessageText = "Delete Person", }; alert.BeginSheet (window); } else { // Grab person SelectedPerson = _people.GetItem<PersonModel> ((nuint)Table.SelectedRow); // Confirm delete var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = string.Format("Are you sure you want to delete person `{0}` from the table?",SelectedPerson.Name), MessageText = "Delete Person", }; alert.AddButton ("Ok"); alert.AddButton ("Cancel"); alert.BeginSheetForResponse (window, (result) => { // Delete? if (result == 1000) { RemovePerson(Table.SelectedRow); } }); } }
public override void SelectionDidChange (NSNotification notification) { Console.WriteLine (notification); var table = notification.Object as NSTableView; var row = table.SelectedRow; // Anything to process if (row < 0) return; // Get current values from the data source var name = table.DataSource.GetObjectValue (table, new NSTableColumn("name"), row) + ""; var id = table.DataSource.GetObjectValue (table, new NSTableColumn("id"), row) + ""; // Confirm deletion of a todo item var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = "Do you want to delete row " + name + "?", MessageText = "Delete Todo", }; alert.AddButton ("Cancel"); alert.AddButton ("Delete"); alert.BeginSheetForResponse (windowController.Window, async (result) => { Console.WriteLine ("Alert Result: {0}", result); if (result == 1001) { await windowController.Delete(id); } table.DeselectAll(this); }); }
public override void AwakeFromNib () { base.AwakeFromNib (); // Show when the document is edited documentEditor.TextDidChange += (sender, e) => { // Mark the document as dirty DocumentEdited = true; }; // Overriding this delegate is required to monitor the TextDidChange event documentEditor.ShouldChangeTextInRanges += (NSTextView view, NSValue[] values, string[] replacements) => { return true; }; WillClose += (sender, e) => { // is the window dirty? if (DocumentEdited) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = "We need to give the user the ability to save the document here...", MessageText = "Save Document", }; alert.RunModal (); } }; }
public void DeletePerson(NSWindow window) { // Anything to process? if (SelectedPerson == null) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = "Please select the person to remove from the collection of people.", MessageText = "Delete Person", }; alert.BeginSheet (window); } else { // Confirm delete var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = string.Format ("Are you sure you want to delete person `{0}` from the collection?", SelectedPerson.Name), MessageText = "Delete Person", }; alert.AddButton ("Ok"); alert.AddButton ("Cancel"); alert.BeginSheetForResponse (window, (result) => { // Delete? if (result == 1000) { RemovePerson (View.SelectionIndex); } }); } }
public static nint ShowAlert (String text, String caption) { var alert = new NSAlert (); alert.MessageText = caption; alert.InformativeText = text; return alert.RunModal (); }
public AlertButtonWrapper(NSButton nsbutton, MessageDescription message, AlertButton alertButton, NSAlert alert) { this.nsbutton = nsbutton; this.message = message; this.alertButton = alertButton; this.alert = alert; oldAction = nsbutton.Action; }
public override bool ShowHelp(NSAlert alert) { if (!string.IsNullOrEmpty(HelpUrl)) { IdeServices.DesktopService.ShowUrl(HelpUrl); } return(true); }
public static void MessageBox(string message, string title) { NSAlert alert = new NSAlert(); alert.MessageText = title; alert.InformativeText = 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(); }
public static nint ShowAlert(String text, String caption) { var alert = new NSAlert(); alert.MessageText = caption; alert.InformativeText = text == null ? "Error" : text; return(alert.RunModal()); }
public override void ViewDidLoad() { base.ViewDidLoad(); lbl_info.StringValue = @"Mac have 3 styles of notifications: 1) None 2) Banners(default) 3) Alert Alerts aren’t dismissed automatically, Banners dismiss automatically. If you want to use Alert style you need to go in Info.plist and add Property: NSUserNotificationAlertStyle Type: String Value: alert"; btn_simple.Activated += (sender, e) => _creator.CreateSimpleNotification( "Simple notification", "Subtitle", "Click here and message will gone", true, "Top", "Bottom"); btn_withButtons.Activated += (sender, e) => { var list = new List <(string, string, Action)>(); for (int i = 0; i < 5; i++) { var alert = new NSAlert() { MessageText = "Identifier: A" + i, InformativeText = "You chosen - Action " + i, AlertStyle = NSAlertStyle.Informational, }; list.Add(("A" + i, "Action " + i, () => alert.RunModal())); } _creator.CreateButtonsNotification( "Notification with buttons", "Subtitle", "Choose action", "Hold", list.ToArray()); }; btn_reply.Activated += (sender, e) => { _creator.CreateReplyNotification( "Reply notification", "Subtitle", "This message have reply button", "Write here"); }; btn_timer.Activated += (sender, e) => { _creator.CreateTimerNotification( "Timer notification", "Subtitle", "Notification will stay for 5 sec", 5000); }; btn_banner.Activated += (sender, e) => { _creator.CreateBannerNotification( "Banner", "Subtitle", "Just simple message."); }; }
partial void ChangeWorkSpace(NSObject sender) { var dlg = NSOpenPanel.OpenPanel; dlg.CanChooseFiles = false; dlg.CanChooseDirectories = true; dlg.AllowsMultipleSelection = false; dlg.CanCreateDirectories = true; if (dlg.RunModal() == 1) { string msg = "Are you sure you want to change your CloudCoin Directory? This will not move your coins to new folders!"; var alert = new NSAlert() { AlertStyle = NSAlertStyle.Warning, InformativeText = msg, MessageText = "Change Workspace", }; alert.AddButton("OK"); alert.AddButton("Cancel"); nint num = alert.RunModal(); if (num == 1000) { string msgRestart = "Changing the workspace will require you to manually restart the Application. Contniue?"; var alertRestart = new NSAlert() { AlertStyle = NSAlertStyle.Warning, InformativeText = msgRestart, MessageText = "Restart CloudCoin CE", }; alertRestart.AddButton("Yes"); alertRestart.AddButton("No"); nint numRestart = alertRestart.RunModal(); if (numRestart == 1000) { Console.WriteLine(dlg.Urls[0].Path); var defaults = NSUserDefaults.StandardUserDefaults; defaults.SetString(dlg.Urls[0].Path + System.IO.Path.DirectorySeparatorChar, "workspace"); string RootPath = defaults.StringForKey("workspace"); FileSystem fileUtils = new FileSystem(RootPath); fileUtils.CreateFolderStructure(); updateLog("Workspace changed to " + RootPath + " ."); System.Diagnostics.Process.GetCurrentProcess().Kill(); AppDelegate.FS = new FileSystem(RootPath); } else { } } } }
internal Platform() { PlatformRenderer = new PlatformRenderer(this); MessagingCenter.Subscribe(this, Page.AlertSignalName, (Page sender, AlertArguments arguments) => { var alert = NSAlert.WithMessage(arguments.Title, arguments.Cancel, arguments.Accept, null, arguments.Message); var result = alert.RunSheetModal(PlatformRenderer.View.Window); if (arguments.Accept == null) { arguments.SetResult(result == 1); } else { arguments.SetResult(result == 0); } }); MessagingCenter.Subscribe(this, Page.ActionSheetSignalName, (Page sender, ActionSheetArguments arguments) => { var alert = NSAlert.WithMessage(arguments.Title, arguments.Cancel, arguments.Destruction, null, ""); if (arguments.Buttons != null) { int maxScrollHeight = (int)(0.6 * NSScreen.MainScreen.Frame.Height); NSView extraButtons = GetExtraButton(arguments); if (extraButtons.Frame.Height > maxScrollHeight) { NSScrollView scrollView = new NSScrollView(); scrollView.Frame = new RectangleF(0, 0, extraButtons.Frame.Width, maxScrollHeight); scrollView.DocumentView = extraButtons; scrollView.HasVerticalScroller = true; alert.AccessoryView = scrollView; } else { alert.AccessoryView = extraButtons; } alert.Layout(); } var result = (int)alert.RunSheetModal(PlatformRenderer.View.Window); var titleResult = string.Empty; if (result == 1) { titleResult = arguments.Cancel; } else if (result == 0) { titleResult = arguments.Destruction; } else if (result > 1 && arguments.Buttons != null && result - 2 <= arguments.Buttons.Count()) { titleResult = arguments.Buttons.ElementAt(result - 2); } arguments.SetResult(titleResult); }); }
public override void WindowControllerDidLoadNib(NSWindowController windowController) { NSError err; // Create a movie, and store the information in memory on an NSMutableData movie = new QTMovie(new NSMutableData(1), out err); if (movie == null) { NSAlert.WithError(err).RunModal(); return; } movieView.Movie = movie; // Find video device captureSession = new QTCaptureSession(); var device = QTCaptureDevice.GetDefaultInputDevice(QTMediaType.Video); if (device == null) { new NSAlert { MessageText = "You do not have a camera connected." }.BeginSheet(windowController.Window); return; } else if (!device.Open(out err)) { NSAlert.WithError(err).BeginSheet(windowController.Window); return; } // Add device input captureInput = new QTCaptureDeviceInput(device); if (!captureSession.AddInput(captureInput, out err)) { NSAlert.WithError(err).BeginSheet(windowController.Window); return; } // Create decompressor for video output, to get raw frames decompressedVideo = new QTCaptureDecompressedVideoOutput(); decompressedVideo.DidOutputVideoFrame += delegate(object sender, QTCaptureVideoFrameEventArgs e) { lock (this) { currentImage = e.VideoFrame; } }; if (!captureSession.AddOutput(decompressedVideo, out err)) { NSAlert.WithError(err).BeginSheet(windowController.Window); return; } // Activate preview captureView.CaptureSession = captureSession; // Start running. captureSession.StartRunning(); }
public static nint ShowError(String text) { var alert = new NSAlert(); alert.MessageText = "Error"; alert.AlertStyle = NSAlertStyle.Critical; alert.InformativeText = text; return(alert.RunModal()); }
public static nint ShowInformation(String text) { var alert = new NSAlert(); alert.MessageText = "Information"; alert.AlertStyle = NSAlertStyle.Warning; alert.InformativeText = text; return(alert.RunModal()); }
void ShowAlert(string title, string msg) { NSAlert alert = new NSAlert(); alert.MessageText = title; alert.InformativeText = msg; alert.AlertStyle = NSAlertStyle.Warning; alert.RunModal(); }
void IProgressControls.ShowError(string message) { var alert = new NSAlert(); alert.MessageText = "ImageDiffDemo"; alert.InformativeText = message; alert.AlertStyle = NSAlertStyle.Critical; alert.BeginSheet(this); }
void ShowAlert(string message) { using (NSAlert alert = new NSAlert()) { alert.MessageText = message; alert.AlertStyle = NSAlertStyle.Critical; alert.RunModal(); } }
public static void Show (string messageText) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Informational, InformativeText = string.Empty, MessageText = messageText, }; alert.RunModal (); }
public CancelButton(IntPtr handle) : base(handle) { var alert = new NSAlert(); alert.AddButton("OK"); alert.AddButton("Cancel"); KeyEquivalent = alert.Buttons[1].KeyEquivalent; }
private static void PlatformPanic(string message, string title) { var messageBox = new NSAlert(); messageBox.MessageText = title; messageBox.InformativeText = message; messageBox.AlertStyle = NSAlertStyle.Critical; messageBox.RunModal(); }
public static NSAlert CreateAlert(string title, string message, NSAlertStyle style) { var alert = new NSAlert(); alert.AlertStyle = style; alert.InformativeText = message; alert.MessageText = title; return(alert); }
public static void MessageBoxError(string message) { NSAlert alert = new NSAlert(); alert.AlertStyle = NSAlertStyle.Critical; alert.MessageText = Constants.Name; alert.InformativeText = message; alert.RunModal(); }
partial void joinOKButtonPressed(NSObject sender) { CW8021XProfile profile = null; joinSpinner.Hidden = false; joinSpinner.StartAnimation(Window); if (joinUser8021XProfilePopupButton.Enabled) { if (String.Equals(joinUser8021XProfilePopupButton, "Default")) { profile = CW8021XProfile.Profile; profile.Ssid = joinNetworkNameField.StringValue; profile.UserDefinedName = joinNetworkNameField.StringValue; profile.Username = !String.IsNullOrEmpty(joinUsernameField.StringValue) ? joinUsernameField.StringValue : null; profile.Password = !String.IsNullOrEmpty(joinPassphraseField.StringValue) ? joinPassphraseField.StringValue : null; } else { var index = joinUser8021XProfilePopupButton.IndexOfSelectedItem; if (index >= 0) { profile = CW8021XProfile.AllUser8021XProfiles[index]; } } } if (JoinDialogContext) { NSMutableDictionary param = new NSMutableDictionary(); if (profile != null) { param.SetValueForKey(profile, CWConstants.CWAssocKey8021XProfile); } else { param.SetValueForKey(!String.IsNullOrEmpty(joinPassphraseField.StringValue) ? joinPassphraseField.ObjectValue: null, CWConstants.CWAssocKeyPassPhrase); } NSError error = null; bool result = CurrentInterface.AssociateToNetwork(SelectedNetwork, NSDictionary.FromDictionary(param), out error); joinSpinner.StopAnimation(Window); joinSpinner.Hidden = true; if (!result) { NSAlert.WithError(error).RunModal(); } else { joinCancelButtonPressed(this); } } }
public override void WindowDidLoad() { base.WindowDidLoad(); tableViewDataSource = new TableViewDataSource(); tableViewDelegate = new TableViewDelegate(tableViewDataSource); tableView.DataSource = tableViewDataSource; tableView.Delegate = tableViewDelegate; PortableSettingsProvider.SettingsFileName = Common.USER_SETTINGS; PortableSettingsProviderBase.SettingsDirectory = Process.path_prefix; PortableSettingsProvider.ApplyProvider(Common.Settings.Default, Common.History.Default); Common.Settings.Default.Upgrade(); Common.History.Default.Upgrade(); NSMenuItem debugLog = Window.Menu?.ItemWithTitle("File")?.Submenu.ItemWithTitle("Debug Log"); if (debugLog != null) { debugLog.State = Common.Settings.Default.DebugLog ? NSCellStateValue.On : NSCellStateValue.Off; } bool init = Process.initialize(out List <string> messages); foreach (var message in messages) { var alert = new NSAlert() { InformativeText = message, MessageText = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleExecutable").ToString(), }; alert.RunModal(); } if (!init) { Environment.Exit(-1); } backgroundWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; backgroundWorker.DoWork += BackgroundWorker_DoWork; backgroundWorker.ProgressChanged += BackgroundWorker_ProgressChanged; backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted; titles = Process.processHistory(); tableViewDataSource.Titles.AddRange(titles); tableView.ReloadData(); }
private const int FirstButtonResultIndex = 1000; // Result is a number starting at 1000 private IAsyncOperation <IUICommand> ShowNativeAsync(CancellationToken ct) { var alert = new NSAlert() { MessageText = Title ?? "", InformativeText = Content ?? "", AlertStyle = NSAlertStyle.Informational }; var actualCommandOrder = new List <UICommand>(); UICommand defaultCommand = null; if (DefaultCommandIndex >= 0 && DefaultCommandIndex < Commands.Count) { defaultCommand = Commands[(int)DefaultCommandIndex] as UICommand; } // Default command must be added first (to be default on macOS). if (defaultCommand != null) { alert.AddButton(defaultCommand.Label); actualCommandOrder.Add(defaultCommand); } // Add remaining alert buttons in reverse because NSAlert.AddButtons adds them // from the right to the left. foreach (var command in Commands.OfType <UICommand>()) { if (command == defaultCommand) { // Skip, already added. continue; } alert.AddButton(command.Label); actualCommandOrder.Add(command); } return(AsyncOperation.FromTask <IUICommand>(async ct => { var response = await alert.BeginSheetAsync(NSApplication.SharedApplication.KeyWindow); if (actualCommandOrder.Count == 0) { // There is no button specified, return dummy OK result. return new UICommand("OK"); } var commandIndex = (int)response - FirstButtonResultIndex; var commandResponse = actualCommandOrder[commandIndex]; commandResponse?.Invoked?.Invoke(commandResponse); return commandResponse; })); }
public static void ShowAlert(string message, NSAlertStyle style = NSAlertStyle.Informational) { var alert = new NSAlert { AlertStyle = style, MessageText = message, }; alert.RunModal(); }
public static void DestroyConfirmAlert() { NSApplication NSApp = NSApplication.SharedApplication; if (InfoAlert != null) { NSApp.EndSheet(InfoAlert.Window); InfoAlert = null; } }
public override void ViewDidLoad() { base.ViewDidLoad(); SimpleClass c = new SimpleClass(); var alert = NSAlert.WithMessage("Native Library Value = " + c.DoIt().ToString(), "OK", null, null, String.Empty); alert.BeginSheetForResponse(View.Window, x => NSApplication.SharedApplication.Terminate(this)); }
public static void Show(string message, string title) { var alert = new NSAlert(); alert.AlertStyle = NSAlertStyle.Informational; alert.MessageText = title; alert.InformativeText = message; alert.AddButton("Tamam"); alert.RunModal(); }
private NSAlert CreateAlert(string text, NSAlertStyle alertStyle) { NSAlert alert = new NSAlert { MessageText = text, AlertStyle = alertStyle }; return(alert); }
/// <summary> /// Shows the alert on this window. /// </summary> /// <param name="msg">Message.</param> /// <param name="title">Title.</param> /// <param name="style">Style.</param> private void ShowAlertOnWindow(string msg, string title, NSAlertStyle style = NSAlertStyle.Informational) { var alert = new NSAlert { InformativeText = msg, MessageText = title, AlertStyle = style }; alert.RunSheetModal(Window); }
public static void Show(IntPtr owner, string text, string caption) { #if WINDOWS PInvokeWindows.MessageBox(owner, text, caption, PInvokeWindows.MessageBoxOptions.OkOnly | PInvokeWindows.MessageBoxOptions.IconExclamation); #elif OSX NSAlert alert = new NSAlert(); alert.MessageText = text; alert.RunModal(); #endif }
// 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(); }
public override void AwakeFromNib() { msgPort = CFMessagePortCreateRemote(IntPtr.Zero, PortName.Handle); if (msgPort == IntPtr.Zero) { NSAlert.WithMessage("Unable to connect to port? Did you launch server first?", "OK", "", "", "").RunModal(); NSApplication.SharedApplication.Terminate(this); } TheButton.Activated += SendMessage; }
public static NSAlert GetError(string toError) { NSAlert NotValid = new NSAlert(); NotValid.AlertStyle = NSAlertStyle.Warning; NotValid.MessageText = "Ошибка"; NotValid.InformativeText = toError; NotValid.Icon = NSImage.ImageNamed(NSImageName.Caution); return(NotValid); }
void __ViewModel_OnError(string errorText, string errorDescription = "") { var alert = new NSAlert(); alert.MessageText = errorText; alert.InformativeText = errorDescription; alert.AddButton(LocalizedStrings.Instance.LocalizedString("Button_Close")); alert.BeginSheetForResponse(View.Window, (result) => { }); }
/// <summary> /// Called before an <c>NSWindow</c> is closed. If the contents of the window has changed and /// not been saved, display a dialog allowing the user to: a) Cancel the closing, b) Close /// without saving, c) Save the changes to the document. /// </summary> /// <returns><c>true</c>, if the window can be closed, else <c>false</c> if it cannot.</returns> /// <param name="sender">The <c>NSWindowController</c> calling this method.</param> public override bool WindowShouldClose (Foundation.NSObject sender) { // is the window dirty? if (Window.DocumentEdited) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = "Save changes to document before closing window?", MessageText = "Save Document", }; alert.AddButton ("Save"); alert.AddButton ("Lose Changes"); alert.AddButton ("Cancel"); var result = alert.RunSheetModal (Window); // Take action based on resu;t switch (result) { case 1000: // Grab controller var viewController = Window.ContentViewController as ViewController; // Already saved? if (Window.RepresentedUrl != null) { var path = Window.RepresentedUrl.Path; // Save changes to file File.WriteAllText (path, viewController.Text); return true; } else { var dlg = new NSSavePanel (); dlg.Title = "Save Document"; dlg.BeginSheet (Window, (rslt) => { // File selected? if (rslt == 1) { var path = dlg.Url.Path; File.WriteAllText (path, viewController.Text); Window.DocumentEdited = false; viewController.View.Window.SetTitleWithRepresentedFilename (Path.GetFileName(path)); viewController.View.Window.RepresentedUrl = dlg.Url; Window.Close(); } }); return true; } return false; case 1001: // Lose Changes return true; case 1002: // Cancel return false; } } return true; }
public override void AwakeFromNib () { msgPort = CFMessagePort.CreateRemotePort (CFAllocator.Default, "com.example.app.port.server"); if (msgPort == null) { var alert = new NSAlert { MessageText = "Unable to connect to port? Did you launch server first?", }; alert.AddButton ("OK"); alert.RunSheetModal (Window); } TheButton.Activated += SendMessage; }
void OpenDialog (NSObject sender) { var dlg = NSOpenPanel.OpenPanel; dlg.CanChooseFiles = false; dlg.CanChooseDirectories = true; if (dlg.RunModal () == 1) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Informational, InformativeText = "At this point we should do something with the folder that the user just selected in the Open File Dialog box...", MessageText = "Folder Selected" }; alert.RunModal (); } }
public static bool ShowConfirm (String text, String caption) { var oAlert = new NSAlert(); // Set the buttons oAlert.AddButton("Yes"); oAlert.AddButton("No"); // Show the message box and capture oAlert.MessageText = caption; oAlert.InformativeText = text; oAlert.AlertStyle = NSAlertStyle.Warning; oAlert.Icon = NSImage.ImageNamed (NSImageName.Caution); var responseAlert = oAlert.RunModal(); return (responseAlert == 1000); }
public override void ViewWillAppear () { base.ViewWillAppear (); // Set Window Title this.View.Window.Title = "untitled"; View.Window.WillClose += (sender, e) => { // is the window dirty? if (DocumentEdited) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = "We need to give the user the ability to save the document here...", MessageText = "Save Document", }; alert.RunModal (); } }; }
public static bool ConfirmDeleteOperation (string confirmMessage) { try { var oAlert = new NSAlert(); // Set the buttons oAlert.AddButton("Yes"); oAlert.AddButton("No"); // Show the message box and capture oAlert.MessageText = confirmMessage; oAlert.InformativeText = "Confirmation"; oAlert.AlertStyle = NSAlertStyle.Warning; oAlert.Icon = NSImage.ImageNamed (NSImageName.Caution); var responseAlert = oAlert.RunModal(); return (responseAlert == 1000); //returns 1001 for No and 1000 for Yes in this case } catch (Exception e) { throw e; } }
void ShowResponse (NSAlert alert, nint 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)(int)response, response); } if (alert.ShowsSuppressionButton) message += String.Format ("\nSuppression: {0}", alert.SuppressionButton.State); ResultLabel.StringValue = message; }
public TodoItemManager() { // Has the application been configured with the developer's // Azure information? if (Constants.ApplicationURL == "") { // No, inform user var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = "Before this example can be successfully run, you need to provide your developer information used to access Azure.", MessageText = "Azure Not Configured", }; alert.RunModal (); } else { // Establish a link to Azure client = new MobileServiceClient ( Constants.ApplicationURL, Constants.ApplicationKey); // Read any existing todo items from the Azure client this.todoTable = client.GetTable<TodoItem> (); } }
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 CGSize (400, 130); const float spacing = 4; string title = GettextCatalog.GetString ("View details"); string altTitle = GettextCatalog.GetString ("Hide details"); var buttonFrame = new CGRect (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 CGSize (button.Frame.Width, NMath.Max (button.Frame.Height, label.Frame.Height))); label.SetFrameOrigin (new CGPoint (button.Frame.Width + 5, button.Frame.Y)); var text = new MyTextView (new CGRect (0, 0, float.MaxValue, float.MaxValue)) { HorizontallyResizable = true, }; text.TextContainer.ContainerSize = new CGSize (float.MaxValue, float.MaxValue); text.TextContainer.WidthTracksTextView = true; text.InsertText (new NSString (data.Exception.ToString ())); text.Editable = false; var scrollView = new NSScrollView (new CGRect (CGPoint.Empty, CGSize.Empty)) { HasHorizontalScroller = true, HasVerticalScroller = true, }; var accessory = new NSView (new CGRect (0, 0, scrollSize.Width, button.Frame.Height)); accessory.AddSubview (scrollView); accessory.AddSubview (button); accessory.AddSubview (label); alert.AccessoryView = accessory; button.Activated += delegate { nfloat change; if (button.State == NSCellStateValue.On) { change = scrollSize.Height + spacing; label.StringValue = altTitle; scrollView.Hidden = false; scrollView.Frame = new CGRect (CGPoint.Empty, scrollSize); scrollView.DocumentView = text; } else { change = -(scrollSize.Height + spacing); label.StringValue = title; scrollView.Hidden = true; scrollView.Frame = new CGRect (CGPoint.Empty, CGSize.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 = 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); } var result = (int)(nint)alert.RunModal () - (int)(long)NSAlertButtonReturn.First; data.ResultButton = buttons != null ? buttons [result] : null; GtkQuartz.FocusWindow (data.TransientFor ?? MessageService.RootWindow); } return true; }
public bool Run (AlertDialogData data) { using (var alert = new NSAlert ()) { alert.Window.Title = data.Title ?? BrandingService.ApplicationName; IdeTheme.ApplyTheme (alert.Window); bool stockIcon; if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Error || data.Message.Icon == Gtk.Stock.DialogError) { alert.AlertStyle = NSAlertStyle.Critical; stockIcon = true; } else if (data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Warning || data.Message.Icon == Gtk.Stock.DialogWarning) { alert.AlertStyle = NSAlertStyle.Critical; stockIcon = true; } else { alert.AlertStyle = NSAlertStyle.Informational; stockIcon = data.Message.Icon == MonoDevelop.Ide.Gui.Stock.Information; } if (!stockIcon && !string.IsNullOrEmpty (data.Message.Icon)) { var img = ImageService.GetIcon (data.Message.Icon, Gtk.IconSize.Dialog); // HACK: VK The icon is not rendered in dark style correctly // Use light variant and reder it here // as long as NSAppearance.NameVibrantDark is broken if (IdeTheme.UserInterfaceTheme == Theme.Dark) alert.Icon = img.WithStyles ("-dark").ToBitmap (GtkWorkarounds.GetScaleFactor ()).ToNSImage (); else alert.Icon = img.ToNSImage (); } 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; } } var wrappers = new List<AlertButtonWrapper> (buttons.Count); 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"); var nsbutton = alert.AddButton (label); var wrapperButton = new AlertButtonWrapper (nsbutton, data.Message, button, alert); wrappers.Add (wrapperButton); nsbutton.Target = wrapperButton; nsbutton.Action = new ObjCRuntime.Selector ("buttonActivatedAction"); } 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 = alert.Window.Frame; alert.Window.SetFrame (new CGRect (frame.X, frame.Y, NMath.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) { var result = (int)alert.RunModal () - (long)(int)NSAlertButtonReturn.First; completed = true; if (result >= 0 && result < buttons.Count) { data.ResultButton = buttons [(int)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[(int)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 override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint row) { // This pattern allows you reuse existing views when they are no-longer in use. // If the returned view is null, you instance up a new view // If a non-null view is returned, you modify it enough to reflect the new data NSTableCellView view = (NSTableCellView)tableView.MakeView (tableColumn.Title, this); if (view == null) { view = new NSTableCellView (); // Configure the view view.Identifier = tableColumn.Title; // Take action based on title switch (tableColumn.Title) { case "Product": view.ImageView = new NSImageView (new CGRect (0, 0, 16, 16)); view.AddSubview (view.ImageView); view.TextField = new NSTextField (new CGRect (20, 0, 400, 16)); ConfigureTextField (view, row); break; case "Details": view.TextField = new NSTextField (new CGRect (0, 0, 400, 16)); ConfigureTextField (view, row); break; case "Action": // Create new button var button = new NSButton (new CGRect (0, 0, 81, 16)); button.SetButtonType (NSButtonType.MomentaryPushIn); button.Title = "Delete"; button.Tag = row; // Wireup events button.Activated += (sender, e) => { // Get button and product var btn = sender as NSButton; var product = DataSource.Products [(int)btn.Tag]; // Configure alert var alert = new NSAlert () { AlertStyle = NSAlertStyle.Informational, InformativeText = $"Are you sure you want to delete {product.Title}? This operation cannot be undone.", MessageText = $"Delete {product.Title}?", }; alert.AddButton ("Cancel"); alert.AddButton ("Delete"); alert.BeginSheetForResponse (Controller.View.Window, (result) => { // Should we delete the requested row? if (result == 1001) { // Remove the given row from the dataset DataSource.Products.RemoveAt((int)btn.Tag); Controller.ReloadTable (); } }); }; // Add to view view.AddSubview (button); break; } } // Setup view based on the column selected switch (tableColumn.Title) { case "Product": view.ImageView.Image = NSImage.ImageNamed ("tag.png"); view.TextField.StringValue = DataSource.Products [(int)row].Title; view.TextField.Tag = row; break; case "Details": view.TextField.StringValue = DataSource.Products [(int)row].Description; view.TextField.Tag = row; break; case "Action": foreach (NSView subview in view.Subviews) { var btn = subview as NSButton; if (btn != null) { btn.Tag = row; } } break; } return view; }
public string OpenRAR(string path, MainWindow window, NSTableView TableView) { if (path.Length > 0) { clsIOPrefs ioPrefs = new clsIOPrefs (); string txtRAR = ioPrefs.GetStringValue ("CaminhoRAR"); if (txtRAR.Length > 0) { string[] launchArgs = {"vt", path}; NSPipe pipeOut = new NSPipe(); NSTask t = new NSTask(); t.LaunchPath = txtRAR; t.Arguments = launchArgs; t.StandardOutput = pipeOut; t.Launch (); ViewArquivosDataSource datasource = new ViewArquivosDataSource (); ProgressWindowController sheet = null; TableView.InvokeOnMainThread (delegate { sheet = new ProgressWindowController (); sheet.ShowSheet (window); }); bool Cancela = false; do { string txtRET = pipeOut.ReadHandle.ReadDataToEndOfFile ().ToString (); int pos = txtRET.IndexOf ("Name:"); if (pos > 0) { TableView.InvokeOnMainThread(delegate{ if(!TableView.Enabled) { TableView.Enabled = true; TableView.Hidden = false; window.tb_outAdicionarActive = true; window.tb_outAtualizarActive = true; window.tb_outExtrairActive = true; window.tb_outRemoverActive = true; window.tb_outDesfazerActive = true; } }); txtRET = txtRET.Substring (pos); List<string> nomes = new List<string>(); do { pos = txtRET.IndexOf ("Name:",pos + 1); if (pos < 0) { nomes.Add (txtRET.Trim()); break; } nomes.Add(txtRET.Substring(0, pos - 2).Trim()); txtRET = txtRET.Substring(pos); pos = 0; } while (true); if (nomes.Count > 0) { sheet.InvokeOnMainThread(delegate{ sheet.ProgressBarMinValue = 0; sheet.ProgressBarMaxValue = nomes.Count; }); double conta = 0; foreach (string nome in nomes) { clsViewArquivos viewArquivos = new clsViewArquivos (); string[] colunas = nome.Split ('\n'); string tipo = colunas [1].Substring (colunas [1].IndexOf (":") + 1).Trim(); viewArquivos.Nome = colunas [0].Substring (colunas [0].IndexOf (":") + 1).Trim(); viewArquivos.Tipo = colunas [1].Substring (colunas [1].IndexOf (":") + 1).Trim(); ++conta; sheet.InvokeOnMainThread(delegate{ sheet.LabelArqValue = "Processando arquivo: " + viewArquivos.Nome; sheet.ProgressBarValue = conta; }); // NSApplication.SharedApplication.InvokeOnMainThread (() => { // sheet.LabelArqValue = "Processando arquivo: " + viewArquivos.Nome; // sheet.ProgressBarValue = conta; // }); if (tipo == "File") { viewArquivos.Tamanho = colunas [2].Substring (colunas [2].IndexOf (":") + 1).Trim(); viewArquivos.Compactado = colunas [3].Substring (colunas [3].IndexOf (":") + 1).Trim(); viewArquivos.Compressao = colunas [4].Substring (colunas [4].IndexOf (":") + 1).Trim(); viewArquivos.DataHora = colunas [5].Substring (colunas [5].IndexOf (":") + 1).Trim(); viewArquivos.Atributos = colunas [6].Substring (colunas [6].IndexOf (":") + 1).Trim(); viewArquivos.CRC32 = colunas [7].Substring (colunas [7].IndexOf (":") + 1).Trim(); viewArquivos.OS = colunas [8].Substring (colunas [8].IndexOf (":") + 1).Trim(); viewArquivos.Compressor = colunas [9].Substring (colunas [9].IndexOf (":") + 1).Trim(); } else { viewArquivos.Tamanho = ""; viewArquivos.Compactado = ""; viewArquivos.Compressao = ""; viewArquivos.DataHora = colunas [2].Substring (colunas [2].IndexOf (":") + 1).Trim(); viewArquivos.Atributos = colunas [3].Substring (colunas [3].IndexOf (":") + 1).Trim(); viewArquivos.CRC32 = colunas [4].Substring (colunas [4].IndexOf (":") + 1).Trim(); viewArquivos.OS = colunas [5].Substring (colunas [5].IndexOf (":") + 1).Trim(); viewArquivos.Compressor = colunas [6].Substring (colunas [6].IndexOf (":") + 1).Trim(); } viewArquivos.Tags = "0"; datasource.ViewArquivos.Add (viewArquivos); viewArquivos = null; sheet.InvokeOnMainThread(delegate{ Cancela = sheet.Canceled; }); if(Cancela) { break; } } } } else { TableView.InvokeOnMainThread (delegate { TableView.Enabled = false; TableView.Hidden = true; sheet.CloseSheet(); NSAlert alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = "Não foi possível processar o arquivo:\r\n" + path, MessageText = "Abrir Arquivo", }; alert.RunSheetModal(window); }); } if(Cancela) { break; } } while(t.IsRunning); sheet.InvokeOnMainThread (delegate { sheet.CloseSheet (); sheet = null; }); pipeOut.Dispose (); pipeOut = null; TableView.InvokeOnMainThread (delegate { TableView.DataSource = datasource; TableView.Delegate = new ViewArquivosDelegate (datasource); }); t.Terminate (); t.Dispose (); t = null; } ioPrefs = null; } return path; }
public void EditPerson(NSWindow window) { if (Table.SelectedRow == -1) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Informational, InformativeText = "Please select the person to edit from the list of people.", MessageText = "Edit Person", }; alert.BeginSheet (window); } else { // Grab person SelectedPerson = _people.GetItem<PersonModel> ((nuint)Table.SelectedRow); // Display editor PerformSegue("EditorSegue", this); } }
void ShowAlert (NSObject sender) { if (ShowAlertAsSheet) { var input = new NSTextField (new CGRect (0, 0, 300, 20)); var alert = new NSAlert () { AlertStyle = NSAlertStyle.Informational, InformativeText = "This is the body of the alert where you describe the situation and any actions to correct it.", MessageText = "Alert Title", }; alert.AddButton ("Ok"); alert.AddButton ("Cancel"); alert.AddButton ("Maybe"); alert.ShowsSuppressionButton = true; alert.AccessoryView = input; alert.Layout (); alert.BeginSheetForResponse (this, (result) => { Console.WriteLine ("Alert Result: {0}, Suppress: {1}", result, alert.SuppressionButton.State == NSCellStateValue.On); }); } else { var input = new NSTextField (new CGRect (0, 0, 300, 20)); var alert = new NSAlert () { AlertStyle = NSAlertStyle.Informational, InformativeText = "This is the body of the alert where you describe the situation and any actions to correct it.", MessageText = "Alert Title", }; alert.AddButton ("Ok"); alert.AddButton ("Cancel"); alert.AddButton ("Maybe"); alert.ShowsSuppressionButton = true; alert.AccessoryView = input; alert.Layout (); var result = alert.RunModal (); Console.WriteLine ("Alert Result: {0}, Suppress: {1}", result, alert.SuppressionButton.State == NSCellStateValue.On); } }
void ShowDocument (NSObject sender) { var dlg = new NSPrintPanel(); // Display the print dialog as dialog box if (ShowPrintAsSheet) { dlg.BeginSheet(new NSPrintInfo(),this,this,null,new IntPtr()); } else { if (dlg.RunModalWithPrintInfo(new NSPrintInfo()) == 1) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Warning, InformativeText = "We need to print the document here...", MessageText = "Print Document", }; alert.RunModal (); } } }
/// <summary> /// Begins an asynchronous operation showing a dialog. /// </summary> /// <returns>An object that represents the asynchronous operation. /// For more on the async pattern, see Asynchronous programming in the Windows Runtime.</returns> /// <remarks>In some cases, such as when the dialog is closed by the system out of your control, your result can be an empty command. /// Returns either the command selected which destroyed the dialog, or an empty command. /// For example, a dialog hosted in a charms window will return an empty command if the charms window has been dismissed.</remarks> public Task<IUICommand> ShowAsync() { if (Commands.Count > MaxCommands) { throw new InvalidOperationException(); } #if __ANDROID__ Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity); Android.App.AlertDialog dialog = builder.Create(); dialog.SetTitle(Title); dialog.SetMessage(Content); if (Commands.Count == 0) { dialog.SetButton(-1, Resources.System.GetString(Android.Resource.String.Cancel), new EventHandler<Android.Content.DialogClickEventArgs>(Clicked)); } else { for (int i = 0; i < Commands.Count; i++) { dialog.SetButton(-1 - i, Commands[i].Label, new EventHandler<Android.Content.DialogClickEventArgs>(Clicked)); } } dialog.Show(); return Task.Run<IUICommand>(() => { _handle.WaitOne(); return _selectedCommand; }); #elif __IOS__ || __TVOS__ uac = UIAlertController.Create(Title, Content, UIAlertControllerStyle.Alert); if (Commands.Count == 0) { uac.AddAction(UIAlertAction.Create("Close", UIAlertActionStyle.Cancel | UIAlertActionStyle.Default, ActionClicked)); } else { for (int i = 0; i < Commands.Count; i++) { UIAlertAction action = UIAlertAction.Create(Commands[i].Label, CancelCommandIndex == i ? UIAlertActionStyle.Cancel : UIAlertActionStyle.Default, ActionClicked); uac.AddAction(action); } } UIViewController currentController = UIApplication.SharedApplication.KeyWindow.RootViewController; while (currentController.PresentedViewController != null) currentController = currentController.PresentedViewController; currentController.PresentViewController(uac, true, null); return Task.Run<IUICommand>(() => { _handle.WaitOne(); return _selectedCommand; }); #elif __MAC__ NSAlert alert = new NSAlert(); alert.AlertStyle = NSAlertStyle.Informational; alert.InformativeText = Content; alert.MessageText = Title; foreach(IUICommand command in Commands) { var button = alert.AddButton(command.Label); } alert.BeginSheetForResponse(NSApplication.SharedApplication.MainWindow, NSAlert_onEnded); return Task.Run<IUICommand>(() => { _handle.WaitOne(); return _selectedCommand; }); #elif WINDOWS_PHONE List<string> buttons = new List<string>(); foreach(IUICommand uic in this.Commands) { buttons.Add(uic.Label); } if (buttons.Count == 0) { buttons.Add("Close"); } MessageDialogAsyncOperation asyncOperation = new MessageDialogAsyncOperation(this); string contentText = Content; // trim message body to 255 chars if (contentText.Length > 255) { contentText = contentText.Substring(0, 255); } while(Microsoft.Xna.Framework.GamerServices.Guide.IsVisible) { Thread.Sleep(250); } Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox( string.IsNullOrEmpty(Title) ? " " : Title, contentText, buttons, (int)DefaultCommandIndex, // can choose which button has the focus Microsoft.Xna.Framework.GamerServices.MessageBoxIcon.None, // can play sounds result => { int? returned = Microsoft.Xna.Framework.GamerServices.Guide.EndShowMessageBox(result); // process and fire the required handler if (returned.HasValue) { if (Commands.Count > returned.Value) { IUICommand theCommand = Commands[returned.Value]; asyncOperation.SetResults(theCommand); if (theCommand.Invoked != null) { theCommand.Invoked(theCommand); } } else { asyncOperation.SetResults(null); } } else { asyncOperation.SetResults(null); } }, null); return asyncOperation.AsTask<IUICommand>(); #elif WINDOWS_UWP if (Commands.Count < 3 && Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.UI.ApplicationSettings.ApplicationsSettingsContract", 1)) { Windows.UI.Xaml.Controls.ContentDialog cd = new Windows.UI.Xaml.Controls.ContentDialog(); cd.Title = Title; cd.Content = Content; if(Commands.Count == 0) { cd.PrimaryButtonText = "Close"; } else { cd.PrimaryButtonText = Commands[0].Label; cd.PrimaryButtonClick += Cd_PrimaryButtonClick; if(Commands.Count > 1) { cd.SecondaryButtonText = Commands[1].Label; cd.SecondaryButtonClick += Cd_SecondaryButtonClick; } } return Task.Run<IUICommand>(async () => { ManualResetEvent mre = new ManualResetEvent(false); IUICommand command = null; await cd.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => { ContentDialogResult dr = await cd.ShowAsync(); if (Commands.Count > 0) { switch (dr) { case ContentDialogResult.Primary: command = Commands[0]; if(Commands[0].Invoked != null) { Commands[0].Invoked.Invoke(Commands[0]); } break; case ContentDialogResult.Secondary: command = Commands[1]; if (Commands[1].Invoked != null) { Commands[1].Invoked.Invoke(Commands[1]); } break; } } }); mre.WaitOne(); return command; }); } else { Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(Content, Title); foreach (IUICommand command in Commands) { dialog.Commands.Add(new Windows.UI.Popups.UICommand(command.Label, (c)=> { command.Invoked(command); }, command.Id)); } return Task.Run<IUICommand>(async () => { Windows.UI.Popups.IUICommand command = await dialog.ShowAsync(); if (command != null) { int i = 0; foreach(Windows.UI.Popups.IUICommand c in dialog.Commands) { if(command == c) { break; } i++; } return Commands[i]; } return null; }); } #elif WIN32 return Task.Run<IUICommand>(() => { IUICommand cmd = ShowTaskDialog(); if (cmd != null) { cmd.Invoked?.Invoke(cmd); } return cmd; }); #else throw new PlatformNotSupportedException(); #endif }
public AlertButtonWrapper (NSButton nsbutton, MessageDescription message, AlertButton alertButton, NSAlert alert) { this.nsbutton = nsbutton; this.message = message; this.alertButton = alertButton; this.alert = alert; oldAction = nsbutton.Action; }
public void EditPerson(NSWindow window) { if (View.SelectedRow == -1) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Informational, InformativeText = "Please select the person to edit from the list of people.", MessageText = "Edit Person", }; alert.BeginSheet (window); } else { // Grab person SelectedPerson = _people.GetItem<PersonModel> ((nuint)View.SelectedRow); var sheet = new PersonEditorSheetController(SelectedPerson, false); // Display sheet sheet.ShowSheet(window); } }
void GetResponse(NSAlert alert, nint response) { if (response <= 1) { switch (response) { case -1: NSIndexSet rows = tableView.SelectedRows; for (int i = 0; i < rows.Count; i++) { Person p = Employees[(int)rows.ElementAt(i)]; p.SetValueForKey(new NSNumber(0.0f), new NSString("expectedRaise")); } break; case 0: // OK deleteSelectedEmployees(this); break; default: // Cancel break; } } }
void ShowLayout (NSObject sender) { var dlg = new NSPageLayout(); // Display the print dialog as dialog box if (ShowPrintAsSheet) { dlg.BeginSheet (new NSPrintInfo (), this); } else { if (dlg.RunModal () == 1) { var alert = new NSAlert () { AlertStyle = NSAlertStyle.Critical, InformativeText = "We need to print the document here...", MessageText = "Print Document", }; alert.RunModal (); } } }
public void ExtractRAR(MainWindow window, NSTableView TableView, NSIndexSet nSelRows, string rarFile, string extractPath) { clsIOPrefs ioPrefs = new clsIOPrefs (); string txtRAR = ioPrefs.GetStringValue ("CaminhoRAR"); if (txtRAR.Length > 0) { if (nSelRows.Count > 0) { ProgressWindowController sheet = null; TableView.InvokeOnMainThread (delegate { sheet = new ProgressWindowController (); sheet.ShowSheet (window); }); sheet.InvokeOnMainThread(delegate{ sheet.ProgressBarMinValue = 0; sheet.ProgressBarMaxValue = nSelRows.Count; }); double conta = 0; bool Cancela = false; nuint[] nRows = nSelRows.ToArray (); ViewArquivosDataSource datasource = null; TableView.InvokeOnMainThread(delegate { datasource = (ViewArquivosDataSource)TableView.DataSource; }); foreach (int lRow in nRows) { string NomeArq = datasource.ViewArquivos [lRow].Nome; ++conta; sheet.InvokeOnMainThread(delegate{ sheet.LabelArqValue = "Extraindo arquivo: " + NomeArq; sheet.ProgressBarValue = conta; }); string[] launchArgs = { "x", rarFile, NomeArq, extractPath }; NSPipe pipeOut = new NSPipe (); NSTask t = new NSTask (); t.LaunchPath = txtRAR; t.Arguments = launchArgs; t.StandardOutput = pipeOut; t.Launch (); t.WaitUntilExit(); //string txtRET = pipeOut.ReadHandle.ReadDataToEndOfFile ().ToString (); sheet.InvokeOnMainThread(delegate{ Cancela = sheet.Canceled; }); if(Cancela) { break; } } sheet.InvokeOnMainThread (delegate { sheet.CloseSheet (); sheet = null; }); if (!Cancela) { TableView.InvokeOnMainThread (delegate { NSAlert alert = new NSAlert () { AlertStyle = NSAlertStyle.Informational, InformativeText = "Arquivo(s) extraido(s) com sucesso !", MessageText = "Extrair arquivos", }; alert.RunSheetModal(window); }); } } } }