partial void OnContinue(MonoMac.Foundation.NSObject sender) { ServerCredentials credentials = new ServerCredentials() { UserName = UserText.StringValue, Password = PasswordText.StringValue, Address = new Uri(AddressText.StringValue) }; AddressText.Enabled = false; UserText.Enabled = false; PasswordText.Enabled = false; ContinueButton.Enabled = false; CancelButton.Enabled = false; Thread check = new Thread(() => { Tuple <CmisServer, Exception> fuzzyResult = CmisUtils.GetRepositoriesFuzzy(credentials); CmisServer cmisServer = fuzzyResult.Item1; if (cmisServer != null) { Controller.repositories = cmisServer.Repositories; } else { Controller.repositories = null; } InvokeOnMainThread(delegate { if (Controller.repositories == null) { WarnText.StringValue = Controller.getConnectionsProblemWarning(fuzzyResult.Item1, fuzzyResult.Item2); AddressText.Enabled = true; UserText.Enabled = true; PasswordText.Enabled = true; ContinueButton.Enabled = true; CancelButton.Enabled = true; } else { RemoveEvent(); Controller.Add1PageCompleted(cmisServer.Url, credentials.UserName, credentials.Password.ToString()); } }); }); check.Start(); }
void ShowLoginPage() { Header = CmisSync.Properties_Resources.Where; Description = ""; AddressLabel = new NSTextField() { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(190, 320, 196 + 196 + 16, 17), StringValue = Properties_Resources.EnterWebAddress, Font = UI.BoldFont }; AddressTextField = new NSTextField() { Frame = new RectangleF(190, 290, 196 + 196 + 16, 22), Font = UI.Font, Delegate = new TextFieldDelegate(), StringValue = (Controller.PreviousAddress == null || String.IsNullOrEmpty(Controller.PreviousAddress.ToString())) ? "https://" : Controller.PreviousAddress.ToString() }; AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingHead; AddressHelpLabel = new NSTextField() { BackgroundColor = NSColor.WindowBackground, Bordered = false, TextColor = NSColor.DisabledControlText, Editable = false, Frame = new RectangleF(190, 265, 196 + 196 + 16, 17), Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11), }; NSTextField UserLabel = new NSTextField() { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Font = UI.BoldFont, Bordered = false, Editable = false, Frame = new RectangleF(190, 230, 196, 17), StringValue = Properties_Resources.User }; NSTextField UserTextField = new NSTextField() { Font = UI.Font, StringValue = String.IsNullOrEmpty(Controller.saved_user) ? Environment.UserName : Controller.saved_user, Frame = new RectangleF(190, 200, 196, 22) }; UserTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingHead; PasswordLabel = new NSTextField() { Alignment = NSTextAlignment.Left, BackgroundColor = NSColor.WindowBackground, Bordered = false, Editable = false, Frame = new RectangleF(190 + 196 + 16, 230, 196, 17), StringValue = Properties_Resources.Password, Font = UI.BoldFont }; PasswordTextField = new NSSecureTextField() { Frame = new RectangleF(190 + 196 + 16, 200, 196, 22), Delegate = new TextFieldDelegate() }; WarningTextField = new NSTextField() { BackgroundColor = NSColor.WindowBackground, Bordered = false, TextColor = NSColor.Red, Editable = false, Frame = new RectangleF(190, 30, 196 + 196 + 16, 160), Font = NSFontManager.SharedFontManager.FontWithFamily("Lucida Grande", NSFontTraitMask.Condensed, 0, 11), }; WarningTextField.Cell.LineBreakMode = NSLineBreakMode.ByWordWrapping; ContinueButton = new NSButton() { Title = Properties_Resources.Continue, Enabled = false }; CancelButton = new NSButton() { Title = Properties_Resources.Cancel }; (AddressTextField.Delegate as TextFieldDelegate).StringValueChanged += CheckAddressTextField; ContinueButton.Activated += delegate { ServerCredentials credentials = null; InvokeOnMainThread(delegate { credentials = new ServerCredentials() { UserName = UserTextField.StringValue, Password = PasswordTextField.StringValue, Address = new Uri(AddressTextField.StringValue) }; ContinueButton.Enabled = false; CancelButton.Enabled = false; }); Thread check = new Thread(() => { Tuple <CmisServer, Exception> fuzzyResult = CmisUtils.GetRepositoriesFuzzy(credentials); CmisServer cmisServer = fuzzyResult.Item1; if (cmisServer != null) { Controller.repositories = cmisServer.Repositories; } else { Controller.repositories = null; } InvokeOnMainThread(delegate { if (Controller.repositories == null) { WarningTextField.StringValue = Controller.getConnectionsProblemWarning(fuzzyResult.Item1, fuzzyResult.Item2); ContinueButton.Enabled = true; CancelButton.Enabled = true; } else { Controller.Add1PageCompleted(cmisServer.Url, credentials.UserName, credentials.Password.ToString()); } }); }); check.Start(); }; CancelButton.Activated += delegate { Controller.PageCancelled(); }; ContentView.AddSubview(AddressLabel); ContentView.AddSubview(AddressTextField); ContentView.AddSubview(AddressHelpLabel); ContentView.AddSubview(UserLabel); ContentView.AddSubview(UserTextField); ContentView.AddSubview(PasswordLabel); ContentView.AddSubview(PasswordTextField); ContentView.AddSubview(WarningTextField); Buttons.Add(ContinueButton); Buttons.Add(CancelButton); Controller.CheckAddPage(AddressTextField.StringValue); }