コード例 #1
0
        private void OpenMinecraftDirectory()
        {
            try {
                string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                path = Path.Combine(path, "Library", "Application Support");
                path = Path.Combine(path, "minecraft", "saves");

                if (!Directory.Exists(path))
                {
                    path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                }

                OpenPaths(new string[] { path });
            }
            catch (Exception e) {
                NSAlert.WithMessage("Operation Failed", "OK", null, null, "Could not open default Minecraft save directory").RunModal();
                Console.WriteLine(e.Message);

                try {
                    OpenPaths(new string[] { Directory.GetCurrentDirectory() });
                }
                catch (Exception) {
                    //MessageBox.Show("Could not open current directory, this tool is probably not compatible with your platform.");
                    Console.WriteLine(e.Message);
                    NSApplication.SharedApplication.Terminate(this);
                }
            }

            UpdateUI();
        }
コード例 #2
0
        private void SearchEndCallback(DataNode node)
        {
            _searchForm.Cancel();
            _searchForm = null;

            NSAlert.WithMessage("End of Results", "OK", null, null, "").RunModal();
        }
コード例 #3
0
ファイル: AlertSheet.cs プロジェクト: littlefeihu/checktask
        public static nint RunDeleteAlert(string title, string errorMsg)
        {
            NSAlert alert = NSAlert.WithMessage(title, "Delete", "Cancel", null, errorMsg);

            alert.Window.MakeFirstResponder(null);
            return(alert.RunModal());
        }
コード例 #4
0
 partial void btnCreate_Clicked(Foundation.NSObject sender)
 {
     if (txtData.Cell.Title.Length > 0 && txtIpBin.Cell.Title.Length > 0 && txtOutput.Cell.Title.Length > 0)
     {
         List <string> cdTracks = new List <string>();
         foreach (CddaItem lvi in _tracks.Rows)
         {
             cdTracks.Add(lvi.FilePath);
         }
         string checkMsg = _builder.CheckOutputExists(cdTracks, txtOutput.Cell.Title);
         if (checkMsg != null)
         {
             NSAlert dialog = NSAlert.WithMessage("Warning", "No", "Yes", null, checkMsg);
             if (dialog.RunModal() == 1)
             {
                 return;
             }
         }
         DisableButtons();
         _builder.RawMode        = (chkRawMode.State == NSCellStateValue.On);
         _builder.ReportProgress = UpdateProgress;
         string dataPath   = txtData.Cell.Title;
         string ipBinPath  = txtIpBin.Cell.Title;
         string outputPath = txtOutput.Cell.Title;
         _worker = new Thread(() => DoDiscBuild(dataPath, ipBinPath, cdTracks, outputPath));
         _worker.Start();
     }
     else
     {
         NSAlert.WithMessage("Error", "OK", null, null, "Not ready to build disc. Please provide more information above.").RunModal();
     }
 }
コード例 #5
0
ファイル: AlertSheet.cs プロジェクト: littlefeihu/checktask
        public static nint RunPromptModal(string title, string errorMsg)
        {
            NSAlert alert = NSAlert.WithMessage(title, "OK", null, null, errorMsg);

            alert.Window.MakeFirstResponder(null);
            return(alert.RunModal());
        }
コード例 #6
0
        public override string Ask(string title, string message, string defaultValue)
        {
            const int OK       = 1;
            string    response = null;

            using (var alert = NSAlert.WithMessage(title,
                                                   "OK",
                                                   "Cancel",
                                                   null,
                                                   message))
            {
                using (var input = new NSTextField(new CGRect(0, 0, 200, 24)))
                {
                    alert.AccessoryView = input;
                    nint result;

                    do
                    {
                        input.StringValue = defaultValue;

                        result = alert.RunSheetModal(_mainWindow);

                        input.ValidateEditing();
                    }while ((result == OK) && string.IsNullOrWhiteSpace(input.StringValue));

                    if (result == OK)
                    {
                        response = input.StringValue;
                    }
                }
            }

            return(response);
        }
コード例 #7
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            LocalExtensionManager = new ExtensionManager("com.userfilesystem.vfs.app", "ITHitFS");

            NSMenu menu = new NSMenu();

            NSMenuItem installMenuItem   = new NSMenuItem("Install FS Extension", (a, b) => { LocalExtensionManager.InstallExtension(); });
            NSMenuItem uninstallMenuItem = new NSMenuItem("Uninstall FS Extension", (a, b) => { LocalExtensionManager.UninstallExtension(); });
            NSMenuItem exitMenuItem      = new NSMenuItem("Quit", (a, b) => { NSApplication.SharedApplication.Terminate(this); });

            menu.AddItem(installMenuItem);
            menu.AddItem(uninstallMenuItem);
            menu.AddItem(exitMenuItem);

            StatusItem               = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
            StatusItem.Menu          = menu;
            StatusItem.Image         = NSImage.ImageNamed("TrayIcon.png");
            StatusItem.HighlightMode = true;

            NSDictionary userData = AppGroupSettings.SaveSharedSettings("appsettings.json");

            if (!Directory.Exists(userData[AppGroupSettings.LocalPathId] as NSString))
            {
                NSAlert alert = NSAlert.WithMessage("Path is not found", null, null, null, "");
                alert.RunModal();

                NSApplication.SharedApplication.Terminate(this);
            }
        }
コード例 #8
0
        public AppDelegate()
        {
            OS.Current = new AxCrypt.Core.MacOsx.RuntimeEnvironment();

            UpdateCheck updatecheck    = new UpdateCheck(UpdateCheck.VersionUnknown);
            Uri         restApiUri     = new Uri("https://www.axantum.com/Xecrets/RestApi.ashx/axcrypt2version/mac");
            Uri         versionUri     = new Uri("http://www.axantum.com/");
            string      currentVersion = UpdateCheck.VersionUnknown.ToString();

            updatecheck.VersionUpdate += (sender, versionArguments) => {
                if (versionArguments.VersionUpdateStatus == VersionUpdateStatus.NewerVersionIsAvailable)
                {
                    int response = NSAlert.WithMessage("New version available!", "Update now", "Update later", null,
                                                       "A new version of Axantum AxCrypt for Mac is available! " +
                                                       "Would you like to download and install it now?")
                                   .RunModal();

                    if (response == 1)
                    {
                        Process.Start(versionArguments.UpdateWebpageUrl.AbsoluteUri);
                        NSApplication.SharedApplication.Terminate(this);
                    }
                }
            };

            updatecheck.CheckInBackground(DateTime.UtcNow, currentVersion, restApiUri, versionUri);
        }
コード例 #9
0
        public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, ICredentials existingCredentials, bool retrying)
        {
            bool result = false;

            DispatchService.GuiSyncDispatch(() => {
                using (var ns = new NSAutoreleasePool()) {
                    var message = string.Format("{0} needs {1} credentials to access {2}.", BrandingService.ApplicationName,
                                                credentialType == CredentialType.ProxyCredentials ? "proxy" : "request", uri.Host);

                    NSAlert alert = NSAlert.WithMessage("Credentials Required", "OK", "Cancel", null, message);
                    alert.Icon    = NSApplication.SharedApplication.ApplicationIconImage;

                    NSView view = new NSView(new RectangleF(0, 0, 313, 91));

                    var creds = Utility.GetCredentialsForUriFromICredentials(uri, existingCredentials);

                    var usernameLabel = new NSTextField(new RectangleF(17, 55, 71, 17))
                    {
                        Identifier      = "usernameLabel",
                        StringValue     = "Username:"******"Password:",
                        Alignment       = NSTextAlignment.Right,
                        Editable        = false,
                        Bordered        = false,
                        DrawsBackground = false,
                        Bezeled         = false,
                        Selectable      = false,
                    };
                    view.AddSubview(passwordLabel);

                    var passwordInput         = new NSSecureTextField(new RectangleF(93, 20, 200, 22));
                    passwordInput.StringValue = creds != null ? creds.Password : string.Empty;
                    view.AddSubview(passwordInput);

                    alert.AccessoryView = view;
                    result = alert.RunModal() == 1;

                    username = usernameInput.StringValue;
                    password = passwordInput.StringValue;
                }
            });

            return(result ? new NetworkCredential(username, password) : null);
        }
コード例 #10
0
ファイル: Controller.cs プロジェクト: weberale/CmisSync
        public Controller() : base()
        {
            using (var a = new NSAutoreleasePool())
            {
                NSApplication.Init();
            }

            // We get the Default notification Center
            notificationCenter = NSUserNotificationCenter.DefaultUserNotificationCenter;

            // Clear old notifications
            foreach (var n in notificationCenter.DeliveredNotifications)
            {
                notificationCenter.RemoveDeliveredNotification(n);
            }

            notificationCenter.DidDeliverNotification += (s, e) =>
            {
                Console.WriteLine("Notification Delivered");
            };

            // If the notification is clicked, displays the entire message.
            notificationCenter.DidActivateNotification += (object sender, UNCDidActivateNotificationEventArgs e) =>
            {
                var notification = (UserNotification)e.Notification;

                if (notification.Kind == UserNotification.NotificationKind.Normal)
                {
                    notificationCenter.RemoveDeliveredNotification(e.Notification);
                    string  msg   = notificationMessages[notification.Id];
                    NSAlert alert = NSAlert.WithMessage(notification.Title, "OK", null, null, msg);
                    notificationMessages.Remove(notification.Id);
                    alert.Icon = new NSImage(System.IO.Path.Combine(NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-error.icns"));
                    alert.Window.OrderFrontRegardless();
                    alert.RunModal();
                }
                else
                {
                    LocalFolderClicked(Path.GetDirectoryName(e.Notification.InformativeText));
                }
            };

            // If we return true here, Notification will show up even if your app is TopMost.
            notificationCenter.ShouldPresentNotification = (c, n) => { return(true); };

            AlertNotificationRaised += delegate(string title, string message) {
                var alert = new NSAlert {
                    MessageText = message,
                    AlertStyle  = NSAlertStyle.Informational
                };

                alert.AddButton("OK");

                alert.RunModal();
            };

            Utils.SetUserNotificationListener(this);
            PathRepresentationConverter.SetConverter(new OSXPathRepresentationConverter());
        }
コード例 #11
0
        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);
            });
        }
コード例 #12
0
 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;
 }
コード例 #13
0
        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));
        }
コード例 #14
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));
        }
コード例 #15
0
 public override void Alert(string title, string message, Severity severity)
 {
     using (var alert = NSAlert.WithMessage(title,
                                            "OK",
                                            null,
                                            null,
                                            message))
     {
         alert.RunSheetModal(_mainWindow);
     }
 }
コード例 #16
0
        public void Exit()
        {
            using (NSAlert alert = NSAlert.WithMessage("Game Exit", "Ok", "Cancel", null, "Are you sure you wish to exit?"))
            {
                var button = alert.RunModal();

                if (button == 1)
                {
                    NSApplication.SharedApplication.Terminate(new NSObject());
                }
            }
        }
コード例 #17
0
 private void UsageFetchError(string errorMessage)
 {
     using (var pool = new NSAutoreleasePool())
     {
         pool.BeginInvokeOnMainThread(() =>
         {
             var alert        = NSAlert.WithMessage("Error", "OK", null, null, "Could not get usage information: " + errorMessage);
             alert.AlertStyle = NSAlertStyle.Warning;
             alert.RunModal();
         });
     }
 }
コード例 #18
0
 public async void StopServer()
 {
     try {
         await ui.ServerManager.Stop.Execute();
     } catch (TaskCanceledException) {
         ;
     } catch (Exception ex) {
         var alert = NSAlert.WithMessage("Failed to stop server", "Ok", string.Empty, string.Empty, ex.Message);
         alert.RunModal();
         return;
     }
 }
コード例 #19
0
        private bool ConfirmExit()
        {
            if (CheckModifications())
            {
                int id = NSAlert.WithMessage("Unsaved Changes", "OK", "Cancel", "", "You currently have unsaved changes.  Close anyway?").RunModal();
                if (id != 1)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #20
0
        public static bool EditByteArrayHandler(ByteArrayFormData data)
        {
            NSAlert.WithMessage("Not supported.", "OK", null, null, "Array editing is currently not supported in the Mac version of NBTExplorer.").RunModal();
            return(false);

            /*HexEditor form = new HexEditor(data.NodeName, data.Data, data.BytesPerElement);
             * if (form.ShowDialog() == DialogResult.OK && form.Modified) {
             *      Array.Copy(form.Data, data.Data, data.Data.Length);
             *      return true;
             * }
             * else
             *      return false;*/
        }
コード例 #21
0
        private bool ValidateNameInput()
        {
            string text = _textField.StringValue.Trim();

            if (text != _originalName && _invalidNames.Contains(text))
            {
                NSAlert.WithMessage("Duplicate name provided.", "OK", null, null, "Duplicate name provided.").RunModal();
                return(false);
            }

            _name = _textField.StringValue.Trim();
            return(true);
        }
コード例 #22
0
 private EventHandler RemoveFolderFromSyncDelegate()
 {
     return(delegate {
         NSAlert alert = NSAlert.WithMessage(Properties_Resources.RemoveSyncQuestion, "No, please continue syncing", "Yes, stop syncing", null, "");
         alert.Icon = this.removeImage;
         alert.Window.OrderFrontRegardless();
         int i = alert.RunModal();
         if (i == 0)
         {
             this.controller.RemoveFolderFromSyncClicked(this.repository.Name);
         }
     });
 }
コード例 #23
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);
        }
コード例 #24
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);
            }
        }
コード例 #25
0
        private static bool LocalPathExistsHandler(string path)
        {
            NSAlert alert = NSAlert.WithMessage(
                String.Format(Properties_Resources.ConfirmExistingLocalFolderText, path),
                "No, I want to choose another target",
                "Yes, I understand the risk",
                null,
                "");

            alert.Icon = new NSImage(Path.Combine(NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-error.icns"));
            int i = alert.RunModal();

            return(i == 0);
        }
コード例 #26
0
 private EventHandler RemoveFolderDelegate(string name)
 {
     return(delegate
     {
         NSAlert alert = NSAlert.WithMessage(
             Properties_Resources.RemoveSyncQuestion, "No", "Yes", null, "");
         alert.Icon = this.caution_image;
         int i = alert.RunModal();
         if (i == 0)
         {
             Controller.RemoveFolderFromSyncClicked(name);
         }
     });
 }
コード例 #27
0
        bool LocalPathExistsHandler(string path)
        {
            NSAlert alert = NSAlert.WithMessage(
                String.Format(Properties_Resources.ConfirmExistingLocalFolderText, path),
                "No, I want to choose another target",
                "Yes, I understand the risk",
                null,
                "");

            alert.Icon = new NSImage(UIHelpers.GetImagePathname("process-syncing-error", "icns"));
            int i = alert.RunModal();

            return(i == 0);
        }
コード例 #28
0
        public void GetURL(NSObject sender)
        {
            // FIFinderSyncController.DefaultController is only valid on the thread that invokes this method
            var url = FIFinderSyncController.DefaultController.TargetedURL;

            // See NSLogHelper for details on this vs Console.WriteLine
            ExtensionSamples.NSLogHelper.NSLog($"FinderSync - GetURL - {url}");

            // But we must get to the UI thread to use NSAlert
            BeginInvokeOnMainThread(() =>
            {
                NSAlert.WithMessage(url.ToString(), "OK", null, null, url.ToString()).RunModal();
            });
        }
コード例 #29
0
        public override bool Confirm(string title, string message)
        {
            const int OK = 0;

            using (var alert = NSAlert.WithMessage(title,
                                                   "Cancel",
                                                   "OK",
                                                   null,
                                                   message))
            {
                alert.AlertStyle = NSAlertStyle.Critical;

                return(alert.RunSheetModal(_mainWindow) == OK);
            }
        }
コード例 #30
0
        public override NSApplicationTerminateReply ApplicationShouldTerminate(NSApplication sender)
        {
            NSAlert alert = NSAlert.WithMessage("Warning", "Yes", "No", null, "Do you really want to close?");

            var button = alert.RunModal();

            if (button == 0)
            {
                return(NSApplicationTerminateReply.Cancel);
            }                    //if
            else
            {
                return(NSApplicationTerminateReply.Now);
            }                    //else
        }