コード例 #1
0
        public static bool ShowInputAlert(NSWindow window, string question, string title, string defaultValue, out string result)
        {
            result = null;

            var msg = new NSAlert();

            msg.AddButton("OK");      // 1st button
            msg.AddButton("Cancel");  // 2nd button
            msg.MessageText     = title;
            msg.InformativeText = question;

            var txt = new NSTextField(new CGRect(x: 0, y: 0, width: 200, height: 24))
            {
                StringValue = defaultValue
            };

            msg.AccessoryView = txt;
            msg.Window.InitialFirstResponder = txt;
            var response = msg.RunSheetModal(window);

            if (response == 1)
            {
                result = txt.StringValue;
                return(true);
            }

            return(false);
        }
コード例 #2
0
        public override bool WindowShouldClose(Foundation.NSObject sender)
        {
            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);

                switch (result)
                {
                case 1000:
                    //Saving
                    return(Utilities.SaveDocument(Window));

                case 1001:
                    //Lose changes
                    return(true);

                case 1002:
                    //Cancel
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
        private static async void OnOpenSampleFile(string path)
        {
#if WINDOWS_UWP || __TVOS__ || __IOS__ || __ANDROID__ || __TIZEN__
            var title = "Open " + Path.GetExtension(path).ToUpperInvariant();
            await Launcher.OpenAsync(new OpenFileRequest(title, new ReadOnlyFile(path)));
#elif __MACOS__
            if (!NSWorkspace.SharedWorkspace.OpenFile(path))
            {
                var alert = new NSAlert();
                alert.AddButton("OK");
                alert.MessageText     = "SkiaSharp";
                alert.InformativeText = "Unable to open file.";
                alert.RunSheetModal(NSApplication.SharedApplication.MainWindow);
            }
#elif __DESKTOP__
            Process.Start(path);
#elif __WASM__
            var data       = File.ReadAllBytes(path);
            var gch        = GCHandle.Alloc(data, GCHandleType.Pinned);
            var pinnedData = gch.AddrOfPinnedObject();
            try
            {
                WebAssemblyRuntime.InvokeJS($"fileSaveAs('{Path.GetFileName(path)}', {pinnedData}, {data.Length})");
            }
            finally
            {
                gch.Free();
            }
#endif
        }
コード例 #4
0
        private void OmMessageReceived(SignalMessage signal)
        {
            var userItemIndex = _users.IndexOf(_users.First(i => i.Uid == signal.RtcPeerId));

            switch (signal.Action)
            {
            case SignalActionTypes.HandDown:
            case SignalActionTypes.HandUp:
                _users[userItemIndex].IsHandUp = signal.Action == SignalActionTypes.HandUp;
                RemoteUsersTableView.ReloadData();
                break;

            case SignalActionTypes.IncomingCall:
                var alert = new NSAlert();
                alert.AddButton("Join");
                alert.AddButton("Cancel");
                alert.MessageText     = "Invite";
                alert.InformativeText = $"You got invite to [{signal.Data}] room";

                var response = alert.RunSheetModal(this.View.Window);
                if (response == (long)NSAlertButtonReturn.First)
                {
                    LeaveChannel();
                    InitializeAgoraEngine();
                    SetupVideo();
                    ResetButtons();
                    SetupLocalVideo();
                    JoinChannel();
                    InitAndJoinRtm();
                }
                break;
            }
        }
コード例 #5
0
        private void didInviteButtonClicked(object sender, EventArgs e)
        {
            var alert = new NSAlert();

            alert.AddButton("Invite");
            alert.AddButton("Cancel");
            alert.MessageText     = "Invite people";
            alert.InformativeText = "Enter user name";

            var txt = new NSTextField(new CGRect(0, 0, 200, 24));

            alert.AccessoryView = txt;

            var response = alert.RunSheetModal(this.View.Window);

            if (response == (long)NSAlertButtonReturn.First)
            {
                var userName = txt.StringValue;

                var signal = new SignalMessage
                {
                    RtcPeerId   = _localId,
                    RtmUserName = RtmService.Instance.UserName,
                    Action      = SignalActionTypes.IncomingCall,
                    Data        = Channel
                };
                var sugnalText = JsonConvert.SerializeObject(signal);
                RtmService.Instance.SendPeerMessage(userName, sugnalText);
            }
        }
コード例 #6
0
		/// <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);
		}
コード例 #7
0
		/// <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;
		}
コード例 #8
0
ファイル: AlertSheet.cs プロジェクト: littlefeihu/checktask
        public static nint RunConfirmAlert(string title, string errorMsg)
        {
            NSAlert alert = NSAlert.WithMessage(title, "Confirm", "Cancel", null, errorMsg);

            InfoAlert = alert;

            alert.Window.MakeFirstResponder(null);
            var keyWindow = NSApplication.SharedApplication.KeyWindow;

            return(alert.RunSheetModal(keyWindow));
        }
コード例 #9
0
        /// <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);
        }
コード例 #10
0
        void ShowAlert()
        {
            // No, inform user
            var alert = new NSAlert {
                AlertStyle      = NSAlertStyle.Warning,
                InformativeText = "Before this example can be successfully run, you need to provide your developer information used to access Azure.",
                MessageText     = "Azure Not Configured"
            };

            alert.RunSheetModal(Window);
        }
コード例 #11
0
        private static async void OnOpenSampleFile(string path)
        {
#if WINDOWS_UWP
            var file = await StorageFile.GetFileFromPathAsync(path);

            await Launcher.LaunchFileAsync(file);
#elif __MACOS__
            if (!NSWorkspace.SharedWorkspace.OpenFile(path))
            {
                var alert = new NSAlert();
                alert.AddButton("OK");
                alert.MessageText     = "SkiaSharp";
                alert.InformativeText = "Unable to open file.";
                alert.RunSheetModal(NSApplication.SharedApplication.MainWindow);
            }
#elif __TVOS__
#elif __IOS__
            // the external / shared location
            var external = Path.Combine(Path.GetTempPath(), "SkiaSharpSample");
            if (!Directory.Exists(external))
            {
                Directory.CreateDirectory(external);
            }
            // copy file to external
            var newPath = Path.Combine(external, Path.GetFileName(path));
            File.Copy(path, newPath);
            // open the file
            var vc             = Xamarin.Forms.Platform.iOS.Platform.GetRenderer(Xamarin.Forms.Application.Current.MainPage) as UIViewController;
            var resourceToOpen = NSUrl.FromFilename(newPath);
            var controller     = UIDocumentInteractionController.FromUrl(resourceToOpen);
            if (!controller.PresentOpenInMenu(vc.View.Bounds, vc.View, true))
            {
                new UIAlertView("SkiaSharp", "Unable to open file.", (IUIAlertViewDelegate)null, "OK").Show();
            }
#elif __ANDROID__
            // the external / shared location
            var external = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "SkiaSharpSample");
            if (!Directory.Exists(external))
            {
                Directory.CreateDirectory(external);
            }
            // copy file to external
            var newPath = Path.Combine(external, Path.GetFileName(path));
            File.Copy(path, newPath);
            // open the file
            var uri    = Android.Net.Uri.FromFile(new Java.IO.File(newPath));
            var intent = new Intent(Intent.ActionView, uri);
            intent.AddFlags(ActivityFlags.NewTask);
            Application.Context.StartActivity(intent);
#elif __DESKTOP__
            Process.Start(path);
#endif
        }
コード例 #12
0
		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;
		}
コード例 #13
0
        partial void ShowGreeting(NSObject sender)
        {
            var msg   = $"Hello, {this.NameField.StringValue}!";
            var alert = new NSAlert
            {
                MessageText     = msg,
                InformativeText = "MonkeyFest 2017 demonstration",
                AlertStyle      = NSAlertStyle.Informational
            };

            alert.RunSheetModal(this.View.Window);
        }
コード例 #14
0
        private void CheckVersion(object sender, EventArgs e)
        {
            var major  = TextFieldMajor.IntValue;
            var minor  = TextFieldMinor.IntValue;
            var patch  = TextFieldPatchVersion.IntValue;
            var result = IsLaterVersion(major, minor, patch);

            var alert = new NSAlert();

            alert.MessageText = result.ToString();
            alert.RunSheetModal(this.View.Window);
        }
コード例 #15
0
 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;
 }
コード例 #16
0
ファイル: AlertSheet.cs プロジェクト: littlefeihu/checktask
        public static nint RunPromptAlert(string title, string errorMsg)
        {
            NSAlert alert = NSAlert.WithMessage(title, "OK", null, null, errorMsg);

            if (PromptAlert == null || !PromptAlert.Window.IsVisible)
            {
                PromptAlert = alert;
                PromptAlert.Window.MakeFirstResponder(null);
                return(alert.RunSheetModal(NSApplication.SharedApplication.MainWindow));
            }

            return(0);
        }
コード例 #17
0
ファイル: AlertSheet.cs プロジェクト: littlefeihu/checktask
        public static void RunResetPasswordAlert(NSWindow parentWindow, PasswordResetEnum resetResponse)
        {
            string errorMsg = "";
            string title;

            switch (resetResponse)
            {
            case PasswordResetEnum.NetDisconnected:
                title     = "Server Error";
                errorMsg += "Unable to communicate with LexisNexis Red services. Please ensure you have an internet connection, or try again later as the servers may be busy.";
                break;

            case PasswordResetEnum.EmailNotExist:
            case PasswordResetEnum.InvalidEmail:
                title     = "Error";
                errorMsg += "The email address you entered does not look correct. Please enter valid email address!";
                break;

            case PasswordResetEnum.ResetSuccess:
                title     = "";
                errorMsg += "Your password reset request has been sent.";
                break;

            case PasswordResetEnum.ResetFailure:
                title     = "Error";
                errorMsg += "Login failed, unknow error!";
                break;

            case PasswordResetEnum.SelectCountry:
                title     = "Error";
                errorMsg += "Please select a country from the drop down list.";
                break;

            case PasswordResetEnum.DeviceIdNotMatched:
                title     = "Error";
                errorMsg += "Device ID is not mapped to the email address provided.";                 //Device ID is not mapped to the email address provided.
                break;

            default:
                title     = "Error";
                errorMsg += "Login failed, unknow error!";
                break;
            }

            if (errorMsg != "")
            {
                NSAlert alert = NSAlert.WithMessage(title, "OK", null, null, errorMsg);
                alert.Window.MakeFirstResponder(null);
                alert.RunSheetModal(parentWindow);
            }
        }
コード例 #18
0
        public void ShowError(string linkId)
        {
            var alert = new NSAlert()
            {
                AlertStyle      = NSAlertStyle.Warning,
                MessageText     = string.Format("Could not open “{0}”", linkId),
                InformativeText = "Please check if the provided Figma Link and Personal Access Token are correct.",
            };

            alert.AddButton("Close");
            alert.RunSheetModal(Window);

            Window.PerformClose(this);
        }
コード例 #19
0
 NSAlertButtonReturn ShowAlert(string msg, string title, NSAlertStyle alertStyle, bool showYesNo)
 {
     using (var alert = new NSAlert())
     {
         alert.MessageText     = title;
         alert.InformativeText = msg;
         alert.AlertStyle      = alertStyle;
         if (showYesNo)
         {
             alert.AddButton("Yes");
             alert.AddButton("No");
         }
         return((NSAlertButtonReturn)((int)alert.RunSheetModal(NSApplication.SharedApplication.KeyWindow)));
     }
 }
コード例 #20
0
        partial void locationCenterClick(NSObject sender)
        {
            if (CLLocationManager.LocationServicesEnabled)
            {
                Console.WriteLine(CLLocationManager.Status);
                if (CLLocationManager.Status == CLAuthorizationStatus.AuthorizedAlways || CLLocationManager.Status == CLAuthorizationStatus.AuthorizedWhenInUse)
                {
                    if (mainMapView.UserLocationVisible)
                    {
                        var curUserLocation = mainMapView.UserLocation;


                        MKCoordinateRegion region = new MKCoordinateRegion();
                        region.Center.Latitude     = (curUserLocation.Location.Coordinate.Latitude);
                        region.Center.Longitude    = (curUserLocation.Location.Coordinate.Longitude);
                        region.Span.LatitudeDelta  = 1;
                        region.Span.LongitudeDelta = 1;
                        region = mainMapView.RegionThatFits(region);

                        mainMapView.SetRegion(region, animated: true); //zooms
                                                                       //mainMapView.SetCenterCoordinate(curUserLocation.Coordinate, animated: true); //doesn't zoom

                        LocationsDataSource.Locations.Add(new TravelMapLocation(DateTime.Now.ToString(),
                                                                                curUserLocation.Coordinate));
                        LocationTableView.ReloadData();
                    }
                    else
                    {
                        //TODO: Dialog
                        NSAlert alert = new NSAlert();
                        alert.MessageText     = "Please Allow this App to Access your Location.";
                        alert.InformativeText = "If you accidentally denied this app access to your location, it can be enabled in System Preferences -> Security & Privacy -> Privacy -> Location Services.";
                        alert.RunSheetModal(this.View.Window);
                    }
                }
                else
                {
                    //TODO: Dialog
                    NSAlert alert = new NSAlert();
                    alert.MessageText     = "Please Enable Location Services in macOS System Preferences";
                    alert.InformativeText = "Location Services can be enabled in System Preferences -> Security & Privacy->Privacy->Location Services.";
                    alert.RunSheetModal(this.View.Window);
                }
            }
        }
コード例 #21
0
        private static async void OnOpenSampleFile(string path)
        {
#if WINDOWS_UWP || __TVOS__ || __IOS__ || __ANDROID__ || __TIZEN__
            var title = "Open " + Path.GetExtension(path).ToUpperInvariant();
            await Launcher.OpenAsync(new OpenFileRequest(title, new ReadOnlyFile(path)));
#elif __MACOS__
            if (!NSWorkspace.SharedWorkspace.OpenFile(path))
            {
                var alert = new NSAlert();
                alert.AddButton("OK");
                alert.MessageText     = "SkiaSharp";
                alert.InformativeText = "Unable to open file.";
                alert.RunSheetModal(NSApplication.SharedApplication.MainWindow);
            }
#elif __DESKTOP__
            Process.Start(path);
#endif
        }
コード例 #22
0
        private void HandleGetURLEvent(NSAppleEventDescriptor descriptor, NSAppleEventDescriptor replyEvent)
        {
            // stackoverflow.com/questions/1945
            // https://forums.xamarin.com/discussion/9774/custom-url-schema-handling
            var keyDirectObject = "----";
            var keyword         =
                (((uint)keyDirectObject[0]) << 24 |
                    ((uint)keyDirectObject[1]) << 16 |
                    ((uint)keyDirectObject[2]) << 8 |
                    ((uint)keyDirectObject[3]));

            var urlString = descriptor.ParamDescriptorForKeyword(keyword).StringValue;

            using (var alert = new NSAlert()){
                alert.MessageText = urlString;
                alert.RunSheetModal(null);
            }
        }
コード例 #23
0
        public override IDisposable ActionSheet(ActionSheetConfig config)
        {
            var alert = new NSAlert
            {
                MessageText = config.Message
            };

            foreach (var opt in config.Options)
            {
                var btn = alert.AddButton(opt.Text);
                //if (opt.ItemIcon != null)
                //    btn.Image = opt.ItemIcon.ToNative();
            }
            var actionIndex = alert.RunSheetModal(null); // TODO: get top NSWindow

            config.Options[(int)actionIndex].Action?.Invoke();
            return(alert);
        }
コード例 #24
0
        void Run(NSAlert alert)
        {
            switch (AlertOptions.SelectedTag)
            {
            case 0:
                alert.BeginSheetForResponse(Window, response => ShowResponse(alert, response));
                break;

            case 1:
                ShowResponse(alert, alert.RunSheetModal(Window));
                break;

            case 2:
                ShowResponse(alert, alert.RunModal());
                break;

            default:
                ResultLabel.StringValue = "Unknown Alert Option";
                break;
            }
        }
コード例 #25
0
        void Initialize()
        {
            // First check if Growl is available globally
            string growlPath = "/Library/Frameworks/Growl.framework/Growl";

            // if not...
            if (!File.Exists(growlPath))
            {
                // then look if the application is bundling the framework
                growlPath = Path.Combine(NSBundle.MainBundle.ExecutablePath, "../../Frameworks/Growl.framework/Growl");
            }
            // Try loading the framework
            if (Dlfcn.dlopen(growlPath, 0) == IntPtr.Zero)
            {
                // if we can't then show some instructions
                NSAlert alert = NSAlert.WithMessage("Missing Growl.framework", "Quit", null, null,
                                                    "See README.md for the additional requirements");
                alert.RunSheetModal(this);
                NSApplication.SharedApplication.Terminate(this);
            }
        }
コード例 #26
0
        public ImportOptions AskImportOptions()
        {
            var import = new ImportViewController();
            var alert  = new NSAlert()
            {
                AlertStyle      = NSAlertStyle.Informational,
                InformativeText = "This will scan the auto-saved data files in your Synthesia data directory and import the selected data for any song entries matching those in the current metadata file.\n\nCAUTION: Matching song data will always overwrite the selected fields in this metadata file!  This cannot be reversed.  Save a backup copy first if you are unsure.",
                MessageText     = "Import from Synthesia",
                AccessoryView   = import.View
            };

            alert.AddButton("Import");
            alert.AddButton("Cancel");
            alert.Layout();

            if (alert.RunSheetModal(Window) == (int)NSAlertButtonReturn.Second)
            {
                return(ImportOptions.Cancel);
            }

            ImportOptions result = 0;

            if (import.StandardSource)
            {
                result |= ImportOptions.StandardPath;
            }
            if (import.FingerHints)
            {
                result |= ImportOptions.FingerHints;
            }
            if (import.HandParts)
            {
                result |= ImportOptions.HandParts;
            }
            if (import.Parts)
            {
                result |= ImportOptions.Parts;
            }
            return(result);
        }
コード例 #27
0
        partial void OnClickDelete(Foundation.NSObject sender)
        {
            Console.WriteLine("OnClickDelete");

            if (table.SelectedRowCount <= 0)
            {
                return;
            }

            using (var alert = new NSAlert())
            {
                alert.InformativeText = "削除する?";
                alert.AddButton("はい");
                alert.AddButton("いいえ");
                var ret = alert.RunSheetModal(NSApplication.SharedApplication.MainWindow);
                if (ret != (int)NSAlertButtonReturn.First)
                {
                    return;
                }
            }

            var datas = new List <ProvisioningProfileData>();

            foreach (var i in table.SelectedRows)
            {
                Console.WriteLine("Selected Row = " + i);
                datas.Add(source.datas[(int)i]);
            }

            foreach (var i in datas)
            {
                if (File.Exists(i.Path))
                {
                    File.Delete(i.Path);
                }
                source.datas.Remove(i);
            }

            table.ReloadData();
        }
コード例 #28
0
        public override void AwakeFromNib()
        {
            // hide progress indicators
            refreshSpinner.Hidden = true;
            joinSpinner.Hidden    = true;
            ibssSpinner.Hidden    = true;

            // quit if no wireless interfaces exist
            var interfaces = CWInterface.SupportedInterfaces;

            if (interfaces == null || interfaces.Length == 0)
            {
                BeginInvokeOnMainThread(() => {
                    var alert = new NSAlert {
                        AlertStyle      = NSAlertStyle.Critical,
                        MessageText     = "No Wireless Interfaces Available",
                        InformativeText = "This application requires at least one wireless interface.",
                    };
                    alert.AddButton("Quit");
                    alert.RunSheetModal(Window);
                    NSApplication.SharedApplication.Terminate(this);
                });
                return;
            }

            // populate interfaces popup with all supported interfaces
            supportedInterfacesPopup.RemoveAllItems();
            supportedInterfacesPopup.AddItems(interfaces);

            // setup scan results table
            scanResultsTable.DataSource = new ScanResultsTableDataSource(this);

            NSNotificationCenter.DefaultCenter.AddObserver(CWConstants.CWBSSIDDidChangeNotification, HandleNotification);
            NSNotificationCenter.DefaultCenter.AddObserver(CWConstants.CWCountryCodeDidChangeNotification, HandleNotification);
            NSNotificationCenter.DefaultCenter.AddObserver(CWConstants.CWLinkDidChangeNotification, HandleNotification);
            NSNotificationCenter.DefaultCenter.AddObserver(CWConstants.CWModeDidChangeNotification, HandleNotification);
            NSNotificationCenter.DefaultCenter.AddObserver(CWConstants.CWPowerDidChangeNotification, HandleNotification);
            NSNotificationCenter.DefaultCenter.AddObserver(CWConstants.CWSSIDDidChangeNotification, HandleNotification);
        }
コード例 #29
0
ファイル: AlertSheet.cs プロジェクト: littlefeihu/checktask
        public static nint RunChangePasswordAlert(NSWindow parentWindow, PasswordChangeEnum changeResponse)
        {
            string errorMsg = "";
            string title    = "";

            switch (changeResponse)
            {
            case PasswordChangeEnum.NetDisconnected:
                title     = "Server Error";
                errorMsg += "Unable to communicate with LexisNexis Red services. Please ensure you have an internet connection, or try again later as the servers may be busy.";
                break;

            case PasswordChangeEnum.LengthInvalid:
                title     = "Error";
                errorMsg += "Your new password is too short. Please select a password with at least 4 characters.";
                break;

            case PasswordChangeEnum.NotMatch:
                title     = "Error";
                errorMsg += "Passwords do not match. Please re-enter.";
                break;

            case PasswordChangeEnum.ChangeFailure:
                title     = "Error";
                errorMsg += "Password change failue. Please send request again.";
                break;

            case PasswordChangeEnum.ChangeSuccess:
                errorMsg += "Your password has been changed successfully.";
                title     = "";
                break;
            }

            NSAlert alert = NSAlert.WithMessage(title, "OK", null, null, errorMsg);

            alert.Window.MakeFirstResponder(null);
            return(alert.RunSheetModal(parentWindow));
        }
コード例 #30
0
        public void ChangeBackend(SampleBackends backend)
        {
            switch (backend)
            {
            case SampleBackends.Memory:
                glview.Hidden = true;
                canvas.Hidden = false;
                break;

            case SampleBackends.OpenGL:
                glview.Hidden = false;
                canvas.Hidden = true;
                break;

            default:
                var alert = new NSAlert();
                alert.MessageText = "Configure Backend";
                alert.AddButton("OK");
                alert.InformativeText = "This functionality is not yet implemented.";
                alert.RunSheetModal(View.Window);
                break;
            }
        }
コード例 #31
0
ファイル: MainWindow.cs プロジェクト: luicil/MacRAR
        public override bool WindowShouldClose(NSObject sender)
        {
            NSAlert alert = new NSAlert()
            {
                AlertStyle      = NSAlertStyle.Warning,
                InformativeText = "Deseja realmente encerrar o MacRAR ?",
                MessageText     = "Encerrar MacRAR",
            };

            alert.AddButton("Não");
            alert.AddButton("Sim");
            nint result = alert.RunSheetModal((NSWindow)sender);

            //nint result = alert.RunModal ();
            if (result == 1001)
            {
                NSApplication.SharedApplication.Terminate(this);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #32
0
        public override bool WindowShouldClose(Foundation.NSObject sender)
        {
            var controller = Window.ContentViewController as EditorViewController;

            if (!controller.DView.ChangesApplied)
            {
                //controller.PerformSegue("ConfirmCloseSegue", controller);
                var alert = new NSAlert()
                {
                    AlertStyle      = NSAlertStyle.Informational,
                    InformativeText = "Changes were made in the editor that hve not been applied to the beat. Do you want to apply the changes or discard them before closing the editor?",
                    MessageText     = "Apply Changes?"
                };
                alert.AddButton("Apply Changes");
                alert.AddButton("Discard Changes");
                alert.AddButton("Cancel");
                var result = alert.RunSheetModal(Window);
                // take action based on result
                switch (result)
                {
                case 1000:
                    controller.ApplyChangesAction();
                    return(true);

                case 1001:
                    // discard
                    return(true);

                default:
                    // cancel
                    return(false);
                }
            }

            return(true);
        }
コード例 #33
0
        public override void PrepareForSegue(NSStoryboardSegue segue, NSObject sender)
        {
            base.PrepareForSegue(segue, sender);

            switch (segue.Identifier)
            {
            case "SheetSegue":
                var sheet = segue.DestinationController as AuthSheetViewController;
                sheet.Presentor      = this;
                sheet.SheetCanceled += (o, args) =>
                {
                    var ac           = o as AuthSheetViewController;
                    var userDefaults = NSUserDefaults.StandardUserDefaults;
                    // if token not have
                    if (userDefaults.StringForKey(Config.CONFIG_TOKEN) == null)
                    {
                        var alert = new NSAlert {
                            MessageText = "アカウントの設定が出来ていません。", InformativeText = "終了しますか?"
                        };
                        alert.AddButton("Yes").Tag = 1;
                        alert.AddButton("No").Tag  = 0;

                        var quit = alert.RunSheetModal(ac.View.Window);
                        if (quit != 0)
                        {
                            ac.WillClose = ac.WillQuit = true;
                        }
                        else
                        {
                            ac.WillClose = false;
                        }
                    }
                };
                break;
            }
        }
コード例 #34
0
		void ShowAlert ()
		{
			// No, inform user
			var alert = new NSAlert {
				AlertStyle = NSAlertStyle.Warning,
				InformativeText = "Before this example can be successfully run, you need to provide your developer information used to access Azure.",
				MessageText = "Azure Not Configured"
			};
			alert.RunSheetModal (Window);
		}
コード例 #35
0
		void Run (NSAlert alert)
		{
			switch (AlertOptions.SelectedTag) {
			case 0:
				alert.BeginSheetForResponse (Window, response => ShowResponse (alert, response));
				break;
			case 1:
				ShowResponse (alert, (int)alert.RunSheetModal (Window));
				break;
			case 2:
				ShowResponse (alert, (int)alert.RunModal ());
				break;
			default:
				ResultLabel.StringValue = "Unknown Alert Option";
				break;
			}
		}
コード例 #36
0
ファイル: clsRAR.cs プロジェクト: luicil/MacRAR
        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;
        }
コード例 #37
0
ファイル: clsRAR.cs プロジェクト: luicil/MacRAR
        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);
                        });

                    }

                }
            }
        }