/// <summary> /// Gets the connections problem warning message internationalized. /// </summary> /// <returns>The connections problem warning.</returns> /// <param name="server">Tried server.</param> /// <param name="e">Returned Exception</param> public string GetConnectionsProblemWarning(CmisServer server, Exception e) { string warning = ""; string message = e.Message; if (e is CmisPermissionDeniedException) { warning = Properties_Resources.LoginFailedForbidden; } else if (e is CmisServerNotFoundException) { warning = Properties_Resources.ConnectFailure; } else if (e.Message == "SendFailure" && server.Url.Scheme.StartsWith("https")) { warning = Properties_Resources.SendFailureHttps; } else if (e.Message == "TrustFailure") { warning = Properties_Resources.TrustFailure; } /* else if (e.Message == "NameResolutionFailure") * warning = Properties_Resources.NameResolutionFailure;*/ else { warning = String.Format("{0}{1}{2}", message, Environment.NewLine, String.Format(Properties_Resources.Sorry, Properties_Resources.ApplicationName)); } return(warning); }
partial void OnContinue(MonoMac.Foundation.NSObject sender) { ServerCredentials credentials = new ServerCredentials() { UserName = UserText.StringValue, Password = PasswordText.StringValue, Address = new Uri(AddressText.StringValue) }; WarnText.StringValue = String.Empty; AddressText.Enabled = false; UserText.Enabled = false; PasswordText.Enabled = false; ContinueButton.Enabled = false; CancelButton.Enabled = false; // monomac bug: animation GUI effect will cause GUI to hang, when backend thread is busy // LoginProgress.StartAnimation(this); 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()); } LoginProgress.StopAnimation(this); }); }); check.Start(); }
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 = GUI.BoldFont }; AddressTextField = new NSTextField() { Frame = new RectangleF(190, 290, 196 + 196 + 16, 22), Font = GUI.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 = GUI.BoldFont, Bordered = false, Editable = false, Frame = new RectangleF(190, 230, 196, 17), StringValue = Properties_Resources.User }; NSTextField UserTextField = new NSTextField() { Font = GUI.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 = GUI.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) { // TODO fix // WarningTextField.StringValue = Controller.getConnectionsProblemWarning(fuzzyResult.Item1, fuzzyResult.Item2); 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); }
public void GetRepositoriesFuzzy(string url, string user, string password) { CmisServer server = CmisUtils.GetRepositoriesFuzzy(new Uri(url), user, password); Assert.NotNull(server); }
private void ShowAdd1Page() { this.Present(); Header = CmisSync.Properties_Resources.Where; VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_address = new VBox(true, 0); HBox layout_address_help = new HBox(false, 3); VBox layout_user = new VBox(true, 0); VBox layout_password = new VBox(true, 0); // Address Label address_label = new Label() { UseMarkup = true, Xalign = 0, Markup = "<b>" + CmisSync.Properties_Resources.EnterWebAddress + "</b>" }; Entry address_entry = new Entry() { Text = (Controller.PreviousAddress == null || String.IsNullOrEmpty(Controller.PreviousAddress.ToString()))?"https://":Controller.PreviousAddress.ToString(), ActivatesDefault = false }; Label address_help_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span foreground=\"#808080\" size=\"small\">" + CmisSync.Properties_Resources.Help + ": " + "</span>" }; EventBox address_help_urlbox = new EventBox(); Label address_help_urllabel = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span foreground=\"blue\" underline=\"single\" size=\"small\">" + CmisSync.Properties_Resources.WhereToFind + "</span>" }; address_help_urlbox.Add(address_help_urllabel); address_help_urlbox.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { Process process = new Process(); process.StartInfo.FileName = "xdg-open"; process.StartInfo.Arguments = "https://github.com/nicolas-raoul/CmisSync/wiki/What-address"; process.Start(); }; address_help_urlbox.EnterNotifyEvent += delegate(object o, EnterNotifyEventArgs args) { address_help_urlbox.GdkWindow.Cursor = hand_cursor; }; Label address_error_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "" }; address_error_label.Hide(); // User Entry user_entry = new Entry() { Text = Controller.PreviousPath, ActivatesDefault = false }; if (String.IsNullOrEmpty(Controller.saved_user)) { user_entry.Text = Environment.UserName; } else { user_entry.Text = Controller.saved_user; } // Password Entry password_entry = new Entry() { Visibility = false, ActivatesDefault = true }; Controller.ChangeAddressFieldEvent += delegate(string text, string example_text) { Application.Invoke(delegate { address_entry.Text = text; }); }; Controller.ChangeUserFieldEvent += delegate(string text, string example_text) { Application.Invoke(delegate { user_entry.Text = text; }); }; Controller.ChangePasswordFieldEvent += delegate(string text, string example_text) { Application.Invoke(delegate { password_entry.Text = text; }); }; address_entry.Changed += delegate { string error = Controller.CheckAddPage(address_entry.Text); if (!String.IsNullOrEmpty(error)) { address_error_label.Markup = "<span foreground=\"red\">" + CmisSync.Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture) + "</span>"; address_error_label.Show(); } else { address_error_label.Hide(); } }; // Address layout_address_help.PackStart(address_help_label, false, false, 0); layout_address_help.PackStart(address_help_urlbox, false, false, 0); layout_address.PackStart(address_label, true, true, 0); layout_address.PackStart(address_entry, true, true, 0); layout_address.PackStart(layout_address_help, true, true, 0); // layout_address.PackStart (address_error_label, true, true, 0); // User layout_user.PackStart(new Label() { Markup = "<b>" + CmisSync.Properties_Resources.User + ":</b>", Xalign = 0 }, true, true, 0); layout_user.PackStart(user_entry, false, false, 0); // Password layout_password.PackStart(new Label() { Markup = "<b>" + CmisSync.Properties_Resources.Password + ":</b>", Xalign = 0 }, true, true, 0); layout_password.PackStart(password_entry, false, false, 0); layout_fields.PackStart(layout_user); layout_fields.PackStart(layout_password); // layout_vertical.PackStart (new Label (""), false, false, 0); layout_vertical.PackStart(layout_address, false, false, 0); layout_vertical.PackStart(layout_fields, false, false, 0); layout_vertical.PackStart(address_error_label, true, true, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button(cancelText); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; // Continue button Button continue_button = new Button(continueText) { Sensitive = String.IsNullOrEmpty(Controller.CheckAddPage(address_entry.Text)) }; continue_button.Clicked += delegate { // Show wait cursor this.GdkWindow.Cursor = wait_cursor; // Try to find the CMIS server (asynchronous using a delegate) GetRepositoriesFuzzyDelegate dlgt = new GetRepositoriesFuzzyDelegate(CmisUtils.GetRepositoriesFuzzy); ServerCredentials credentials = new ServerCredentials() { UserName = user_entry.Text, Password = password_entry.Text, Address = new Uri(address_entry.Text) }; IAsyncResult ar = dlgt.BeginInvoke(credentials, null, null); while (!ar.AsyncWaitHandle.WaitOne(100)) { while (Application.EventsPending()) { Application.RunIteration(); } } Tuple <CmisServer, Exception> result = dlgt.EndInvoke(ar); CmisServer cmisServer = result.Item1; if (cmisServer != null) { Controller.repositories = cmisServer.Repositories; address_entry.Text = cmisServer.Url.ToString(); } else { Controller.repositories = null; } // Hide wait cursor this.GdkWindow.Cursor = default_cursor; if (Controller.repositories == null) { // Show warning string warning = ""; string message = result.Item2.Message; Exception e = result.Item2; if (e is CmisPermissionDeniedException) { warning = Properties_Resources.LoginFailedForbidden; } else if (e is CmisServerNotFoundException) { warning = Properties_Resources.ConnectFailure; } else if (e.Message == "SendFailure" && cmisServer.Url.Scheme.StartsWith("https")) { warning = Properties_Resources.SendFailureHttps; } else if (e.Message == "TrustFailure") { warning = Properties_Resources.TrustFailure; } else { warning = message + Environment.NewLine + Properties_Resources.Sorry; } address_error_label.Markup = "<span foreground=\"red\">" + warning + "</span>"; address_error_label.Show(); } else { // Continue to folder selection Controller.Add1PageCompleted( new Uri(address_entry.Text), user_entry.Text, password_entry.Text); } }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; if (button_enabled) { continue_button.SetFlag(Gtk.WidgetFlags.CanFocus); continue_button.SetFlag(Gtk.WidgetFlags.CanDefault); continue_button.GrabDefault(); } }); }; AddButton(cancel_button); AddButton(continue_button); Controller.CheckAddPage(address_entry.Text); address_entry.GrabFocus(); }
public void ShowSettingsPage() { SetSizeRequest(680, 470); Header = CmisSync.Properties_Resources.Settings; string localfoldername = Controller.saved_address.ToString(); string username = Controller.saved_user; Label url_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<b>" + CmisSync.Properties_Resources.WebAddress + "</b>" }; Entry url_entry = new Entry() { Text = localfoldername, IsEditable = false, Sensitive = false }; Label user_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<b>" + CmisSync.Properties_Resources.User + "</b>" }; Entry user_entry = new Entry() { Text = username, IsEditable = false, Sensitive = false }; Label password_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<b>" + CmisSync.Properties_Resources.Password + "</b>", }; Label authentification_error_label = new Label() { Xalign = 0, UseMarkup = true, Visible = false }; Entry password_entry = new Entry() { Text = "", ActivatesDefault = false }; String password = ""; password_entry.TextInserted += delegate { password += password_entry.Text[password_entry.Text.Length - 1]; password_entry.Text = password_entry.Text.Replace(password_entry.Text[password_entry.Text.Length - 1], '*'); }; CheckButton launcAtStartup = new CheckButton(CmisSync.Properties_Resources.SyncAtStartup); if (Controller.saved_syncatstartup) { launcAtStartup.Active = true; } Label syncInterval_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<b>" + CmisSync.Properties_Resources.SyncInterval + "(Secondes)" + "</b>" }; //sync interval is between 5s and 1day HScale syncInterval_hscale = new HScale(new Adjustment(0, 5, 86401, 5, 5, 1)); syncInterval_hscale.DrawValue = true; // syncinterval is converted in secondes syncInterval_hscale.Value = Controller.saved_sync_interval / 1000; syncInterval_hscale.Digits = 0; syncInterval_hscale.ValueChanged += delegate { Application.Invoke(delegate { syncInterval_hscale.TooltipText = syncInterval_hscale.Value + " s"; }); }; Button cancel_button = new Button(cancelText); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button save_button = new Button( CmisSync.Properties_Resources.Save ); VBox layout_vertical = new VBox(false, 10); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(url_label, false, false, 0); layout_vertical.PackStart(url_entry, false, false, 0); layout_vertical.PackStart(user_label, false, false, 0); layout_vertical.PackStart(user_entry, false, false, 0); layout_vertical.PackStart(password_label, false, false, 0); layout_vertical.PackStart(password_entry, false, false, 0); layout_vertical.PackStart(authentification_error_label, false, false, 0); layout_vertical.PackStart(launcAtStartup, false, false, 0); layout_vertical.PackStart(syncInterval_label, false, false, 0); layout_vertical.PackStart(syncInterval_hscale, false, false, 0); //layout_vertical.PackStart (scale2, false, false, 0); ScrolledWindow scrolledWindow = new ScrolledWindow(); scrolledWindow.SetPolicy(PolicyType.Never, PolicyType.Automatic); scrolledWindow.AddWithViewport(layout_vertical); scrolledWindow.ShadowType = ShadowType.None; Add(scrolledWindow); AddButton(save_button); AddButton(cancel_button); save_button.Clicked += delegate { //save password not masked String verypassword = ""; for (int i = 0; i < password.Length; i++) { if (!password[i].Equals('*')) { verypassword += password[i]; } } //reset password = ""; if (!String.IsNullOrEmpty(verypassword)) { // Show wait cursor this.GdkWindow.Cursor = wait_cursor; // Try to find the CMIS server (asynchronous using a delegate) GetRepositoriesFuzzyDelegate dlgt = new GetRepositoriesFuzzyDelegate(CmisUtils.GetRepositoriesFuzzy); ServerCredentials credentials = new ServerCredentials() { UserName = user_entry.Text, Password = verypassword, Address = new Uri(url_entry.Text) }; IAsyncResult ar = dlgt.BeginInvoke(credentials, null, null); while (!ar.AsyncWaitHandle.WaitOne(100)) { while (Application.EventsPending()) { Application.RunIteration(); } } Tuple <CmisServer, Exception> result = dlgt.EndInvoke(ar); CmisServer cmisServer = result.Item1; if (cmisServer != null) { Controller.repositories = cmisServer.Repositories; url_entry.Text = cmisServer.Url.ToString(); } else { Controller.repositories = null; } // Hide wait cursor this.GdkWindow.Cursor = default_cursor; if (Controller.repositories == null) { // Show warning string warning = ""; string message = result.Item2.Message; Exception e = result.Item2; if (e is CmisPermissionDeniedException) { warning = Properties_Resources.LoginFailedForbidden; } else if (e.Message == "SendFailure" && cmisServer.Url.Scheme.StartsWith("https")) { warning = Properties_Resources.SendFailureHttps; } else if (e.Message == "TrustFailure") { warning = Properties_Resources.TrustFailure; } else { warning = message + Environment.NewLine + Properties_Resources.Sorry; } authentification_error_label.Markup = "<span foreground=\"red\">" + warning + "</span>"; authentification_error_label.Show(); } else { // update settings // syncinterval is converted in millisecondes Controller.SettingsPageCompleted(verypassword, (int)(syncInterval_hscale.Value * 1000), launcAtStartup.Active); } } else { Controller.SettingsPageCompleted(null, (int)syncInterval_hscale.Value * 1000, launcAtStartup.Active); } }; }
public SparkleSetup() : base() { Controller.HideWindowEvent += delegate { Application.Invoke(delegate { HideAll(); }); }; Controller.ShowWindowEvent += delegate { Application.Invoke(delegate { ShowAll(); Present(); }); }; Controller.ChangePageEvent += delegate(PageType type, string [] warnings) { Application.Invoke(delegate { Reset(); switch (type) { case PageType.Setup: { Header = "Welcome to CmisSync!"; Description = "First off, what's your name and email?\nThis information is only visible to team members."; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label name_label = new Label("<b>" + "Full Name:" + "</b>") { UseMarkup = true, Xalign = 1 }; Entry name_entry = new Entry(UnixUserInfo.GetRealUser().RealName) { Xalign = 0, ActivatesDefault = true }; Entry email_entry = new Entry() { Xalign = 0, ActivatesDefault = true }; name_entry.Changed += delegate { Controller.CheckSetupPage(); }; email_entry.Changed += delegate { Controller.CheckSetupPage(); }; Label email_label = new Label("<b>" + "Email:" + "</b>") { UseMarkup = true, Xalign = 1 }; table.Attach(name_label, 0, 1, 0, 1); table.Attach(name_entry, 1, 2, 0, 1); table.Attach(email_label, 0, 1, 1, 2); table.Attach(email_entry, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.SetupPageCancelled(); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate(object o, EventArgs args) { string full_name = name_entry.Text; string email = email_entry.Text; Controller.SetupPageCompleted(); }; AddButton(cancel_button); AddButton(continue_button); Add(wrapper); Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Controller.CheckSetupPage(); break; } case PageType.Add1: { Header = "Where is your organization's server?"; VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_address = new VBox(true, 0); VBox layout_user = new VBox(true, 0); VBox layout_password = new VBox(true, 0); // Address Entry address_entry = new Entry() { Text = Controller.PreviousAddress, Sensitive = (Controller.SelectedPlugin.Address == null), ActivatesDefault = true }; Label address_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.AddressExample + "</span>" }; Label address_help_label = new Label() { Text = "Help: ", // TODO FontSize = 11, // TODO Foreground = new SolidColorBrush(Color.FromRgb(128, 128, 128)) }; /* TODO Run run = new Run("Where to find this address"); * Hyperlink link = new Hyperlink(run); * link.NavigateUri = new Uri("https://github.com/nicolas-raoul/CmisSync/wiki/What-address"); * address_help_label.Inlines.Add(link); * link.RequestNavigate += (sender, e) => * { * System.Diagnostics.Process.Start(e.Uri.ToString()); * };*/ Label address_error_label = new Label() { // TODO FontSize = 11, // TODO Foreground = new SolidColorBrush(Color.FromRgb(255, 128, 128)), // TODO Visibility = Visibility.Hidden }; // User Entry user_entry = new Entry() { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.User == null), ActivatesDefault = true }; Label user_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.UserExample + "</span>" }; // Password Entry password_entry = new Entry() { Text = Controller.PreviousPath, Sensitive = (Controller.SelectedPlugin.Password == null), ActivatesDefault = true }; Label password_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.PasswordExample + "</span>" }; Controller.ChangeAddressFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { address_entry.Text = text; address_entry.Sensitive = (state == FieldState.Enabled); address_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangeUserFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { user_entry.Text = text; user_entry.Sensitive = (state == FieldState.Enabled); user_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePasswordFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { password_entry.Text = text; password_entry.Sensitive = (state == FieldState.Enabled); password_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.CheckAddPage(address_entry.Text); address_entry.Changed += delegate { Controller.CheckAddPage(address_entry.Text); }; // Address layout_address.PackStart(new Label() { Markup = "<b>" + "Address:" + "</b>", Xalign = 0 }, true, true, 0); layout_address.PackStart(address_entry, false, false, 0); layout_address.PackStart(address_example, false, false, 0); // User layout_user.PackStart(new Label() { Markup = "<b>" + "User:"******"</b>", Xalign = 0 }, true, true, 0); layout_user.PackStart(user_entry, false, false, 0); layout_user.PackStart(user_example, false, false, 0); // Password layout_password.PackStart(new Label() { Markup = "<b>" + "password:"******"</b>", Xalign = 0 }, true, true, 0); layout_password.PackStart(password_entry, false, false, 0); layout_password.PackStart(password_example, false, false, 0); layout_fields.PackStart(layout_address); layout_fields.PackStart(layout_user); layout_fields.PackStart(layout_password); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; // Continue button Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { // Show wait cursor // TODO System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; SparkleLogger.LogInfo("SparkleSetup", "address:" + address_entry.Text + " user:"******" password:"******"Sorry, CmisSync can not find a CMIS server at this address.\nPlease check again.\nIf you are sure about the address, open it in a browser and post\nthe resulting XML to the CmisSync forum."; // TODO address_error_label.Visibility = Visibility.Visible; } else { SparkleLogger.LogInfo("SparkleSetup", "repositories[0]:" + Controller.repositories[0]); // Continue to folder selection Controller.Add1PageCompleted( address_entry.Text, user_entry.Text, password_entry.Text); } }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; AddButton(cancel_button); AddButton(continue_button); Controller.CheckAddPage(address_entry.Text); break; } case PageType.Add2: { Header = "Which remote folder do you want to sync?"; VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_repository = new VBox(true, 0); VBox layout_path = new VBox(true, 0); // Repository Entry repository_entry = new Entry() { Text = Controller.repositories[0], // TODO put all elements in a tree Sensitive = (Controller.SelectedPlugin.Repository == null), ActivatesDefault = true }; Label repository_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.RepositoryExample + "</span>" }; // Path Entry path_entry = new Entry() { Text = "/", Sensitive = (Controller.SelectedPlugin.Path == null), ActivatesDefault = true }; Label path_example = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + Controller.SelectedPlugin.PathExample + "</span>" }; Controller.ChangeRepositoryFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { repository_entry.Text = text; repository_entry.Sensitive = (state == FieldState.Enabled); repository_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; Controller.ChangePathFieldEvent += delegate(string text, string example_text, FieldState state) { Application.Invoke(delegate { path_entry.Text = text; path_entry.Sensitive = (state == FieldState.Enabled); path_example.Markup = "<span size=\"small\" fgcolor=\"" + SecondaryTextColor + "\">" + example_text + "</span>"; }); }; //Controller.CheckAddPage (address_entry.Text); // Repository layout_repository.PackStart(new Label() { Markup = "<b>" + "Repository:" + "</b>", Xalign = 0 }, true, true, 0); layout_repository.PackStart(repository_entry, false, false, 0); layout_repository.PackStart(repository_example, false, false, 0); // Path layout_path.PackStart(new Label() { Markup = "<b>" + "Remote Path:" + "</b>", Xalign = 0 }, true, true, 0); layout_path.PackStart(path_entry, false, false, 0); layout_path.PackStart(path_example, false, false, 0); layout_fields.PackStart(layout_repository); layout_fields.PackStart(layout_path); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button("Add") { //Sensitive = false }; add_button.Clicked += delegate { Controller.Add2PageCompleted(repository_entry.Text, path_entry.Text); }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { add_button.Sensitive = button_enabled; }); }; AddButton(cancel_button); AddButton(add_button); //Controller.CheckAddPage (address_entry.Text); break; } case PageType.Invite: { Header = "You've received an invite!"; Description = "Do you want to add this project to SparkleShare?"; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; Label address_label = new Label("Address:") { Xalign = 1 }; Label path_label = new Label("Remote Path:") { Xalign = 1 }; Label address_value = new Label("<b>" + Controller.PendingInvite.Address + "</b>") { UseMarkup = true, Xalign = 0 }; Label path_value = new Label("<b>" + Controller.PendingInvite.RemotePath + "</b>") { UseMarkup = true, Xalign = 0 }; table.Attach(address_label, 0, 1, 0, 1); table.Attach(address_value, 1, 2, 0, 1); table.Attach(path_label, 0, 1, 1, 2); table.Attach(path_value, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button add_button = new Button("Add"); add_button.Clicked += delegate { Controller.InvitePageCompleted(); }; AddButton(cancel_button); AddButton(add_button); Add(wrapper); break; } case PageType.Syncing: { Header = String.Format("Adding project ‘{0}’…", Controller.SyncingFolder); Description = "This may either take a short or a long time depending on the project's size."; this.progress_bar.Fraction = Controller.ProgressBarPercentage / 100; Button finish_button = new Button() { Sensitive = false, Label = "Finish" }; Button cancel_button = new Button() { Label = "Cancel" }; cancel_button.Clicked += delegate { Controller.SyncingCancelled(); }; AddButton(cancel_button); AddButton(finish_button); Controller.UpdateProgressBarEvent += delegate(double percentage) { Application.Invoke(delegate { this.progress_bar.Fraction = percentage / 100; }); }; if (this.progress_bar.Parent != null) { (this.progress_bar.Parent as Container).Remove(this.progress_bar); } VBox bar_wrapper = new VBox(false, 0); bar_wrapper.PackStart(this.progress_bar, false, false, 15); Add(bar_wrapper); break; } case PageType.Error: { Header = "Oops! Something went wrong" + "…"; VBox points = new VBox(false, 0); Image list_point_one = new Image(SparkleUIHelpers.GetIcon("go-next", 16)); Image list_point_two = new Image(SparkleUIHelpers.GetIcon("go-next", 16)); Image list_point_three = new Image(SparkleUIHelpers.GetIcon("go-next", 16)); Label label_one = new Label() { Markup = "<b>" + Controller.PreviousUrl + "</b> is the address we've compiled. " + "Does this look alright?", Wrap = true, Xalign = 0 }; Label label_two = new Label() { Text = "Do you have access rights to this remote project?", Wrap = true, Xalign = 0 }; points.PackStart(new Label("Please check the following:") { Xalign = 0 }, false, false, 6); HBox point_one = new HBox(false, 0); point_one.PackStart(list_point_one, false, false, 0); point_one.PackStart(label_one, true, true, 12); points.PackStart(point_one, false, false, 12); HBox point_two = new HBox(false, 0); point_two.PackStart(list_point_two, false, false, 0); point_two.PackStart(label_two, true, true, 12); points.PackStart(point_two, false, false, 12); if (warnings.Length > 0) { string warnings_markup = ""; foreach (string warning in warnings) { warnings_markup += "\n<b>" + warning + "</b>"; } Label label_three = new Label() { Markup = "Here's the raw error message:" + warnings_markup, Wrap = true, Xalign = 0 }; HBox point_three = new HBox(false, 0); point_three.PackStart(list_point_three, false, false, 0); point_three.PackStart(label_three, true, true, 12); points.PackStart(point_three, false, false, 12); } points.PackStart(new Label(""), true, true, 0); Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; Button try_again_button = new Button("Try Again…") { Sensitive = true }; try_again_button.Clicked += delegate { Controller.ErrorPageCompleted(); }; AddButton(cancel_button); AddButton(try_again_button); Add(points); break; } case PageType.CryptoSetup: { Header = "Set up file encryption"; Description = "This project is supposed to be encrypted, but it doesn't yet have a password set. Please provide one below."; Label password_label = new Label("<b>" + "Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0, }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoSetupPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoSetupPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoSetupContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label() { Xalign = 0, Wrap = true, Text = "This password can't be changed later, and your files can't be recovered if it's forgotten." }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 15); wrapper.PackStart(warning_wrapper, false, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.CryptoPassword: { Header = "This project contains encrypted files"; Description = "Please enter the password to see their contents."; Label password_label = new Label("<b>" + "Password:"******"</b>") { UseMarkup = true, Xalign = 1 }; Entry password_entry = new Entry() { Xalign = 0, Visibility = false, ActivatesDefault = true }; CheckButton show_password_check_button = new CheckButton("Show password") { Active = false, Xalign = 0 }; show_password_check_button.Toggled += delegate { password_entry.Visibility = !password_entry.Visibility; }; password_entry.Changed += delegate { Controller.CheckCryptoPasswordPage(password_entry.Text); }; Button continue_button = new Button("Continue") { Sensitive = false }; continue_button.Clicked += delegate { Controller.CryptoPasswordPageCompleted(password_entry.Text); }; Button cancel_button = new Button("Cancel"); cancel_button.Clicked += delegate { Controller.CryptoPageCancelled(); }; Controller.UpdateCryptoPasswordContinueButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; Table table = new Table(2, 3, true) { RowSpacing = 6, ColumnSpacing = 6 }; table.Attach(password_label, 0, 1, 0, 1); table.Attach(password_entry, 1, 2, 0, 1); table.Attach(show_password_check_button, 1, 2, 1, 2); VBox wrapper = new VBox(false, 9); wrapper.PackStart(table, true, false, 0); Add(wrapper); AddButton(cancel_button); AddButton(continue_button); break; } case PageType.Finished: { UrgencyHint = true; if (!HasToplevelFocus) { string title = "Your documents are ready!"; string subtext = "You can find them in your CmisSync folder."; Program.UI.Bubbles.Controller.ShowBubble(title, subtext, null); } Header = "Your documents are ready!"; Description = "You can find them in your CmisSync folder."; // A button that opens the synced folder Button open_folder_button = new Button(string.Format("Open {0}", System.IO.Path.GetFileName(Controller.PreviousPath))); open_folder_button.Clicked += delegate { Controller.OpenFolderClicked(); }; Button finish_button = new Button("Finish"); finish_button.Clicked += delegate { Controller.FinishPageCompleted(); }; if (warnings.Length > 0) { Image warning_image = new Image( SparkleUIHelpers.GetIcon("dialog-information", 24) ); Label warning_label = new Label(warnings [0]) { Xalign = 0, Wrap = true }; HBox warning_layout = new HBox(false, 0); warning_layout.PackStart(warning_image, false, false, 15); warning_layout.PackStart(warning_label, true, true, 0); VBox warning_wrapper = new VBox(false, 0); warning_wrapper.PackStart(warning_layout, false, false, 0); Add(warning_wrapper); } else { Add(null); } AddButton(open_folder_button); AddButton(finish_button); break; } case PageType.Tutorial: { switch (Controller.TutorialPageNumber) { case 1: { Header = "What's happening next?"; Description = "CmisSync creates a special folder on your computer " + "that will keep track of your folders."; Button skip_tutorial_button = new Button("Skip Tutorial"); skip_tutorial_button.Clicked += delegate { Controller.TutorialSkipped(); }; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-1.png"); Add(slide); AddButton(skip_tutorial_button); AddButton(continue_button); break; } case 2: { Header = "Sharing files with others"; Description = "All files added to the server are automatically synced to your " + "local folder."; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-2.png"); Add(slide); AddButton(continue_button); break; } case 3: { Header = "The status icon is here to help"; Description = "It shows the syncing progress, provides easy access to " + "your folders and let's you view recent changes."; Button continue_button = new Button("Continue"); continue_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-3.png"); Add(slide); AddButton(continue_button); break; } case 4: { Header = "Adding repository folders to CmisSync"; Description = " " + " "; Image slide = SparkleUIHelpers.GetImage("tutorial-slide-4.png"); Button finish_button = new Button("Finish"); finish_button.Clicked += delegate { Controller.TutorialPageCompleted(); }; CheckButton check_button = new CheckButton("Add CmisSync to startup items") { Active = true }; check_button.Toggled += delegate { Controller.StartupItemChanged(check_button.Active); }; Add(slide); AddOption(check_button); AddButton(finish_button); break; } } break; } } ShowAll(); }); }; }
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; // Could not retrieve repositories list from server string warning = ""; } InvokeOnMainThread(delegate { if (Controller.repositories == null) { // WarnText.StringValue = Controller.getConnectionsProblemWarning(fuzzyResult.Item1, fuzzyResult.Item2); string message = fuzzyResult.Item2.Message; string warning = ""; Exception e = fuzzyResult.Item2; if (e is PermissionDeniedException) { warning = Properties_Resources.LoginFailedForbidden; } else if (e is ServerNotFoundException) { warning = Properties_Resources.ConnectFailure; } else if (e.Message == "SendFailure" && cmisServer.Url.Scheme.StartsWith("https")) { warning = Properties_Resources.SendFailureHttps; } else if (e.Message == "TrustFailure") { warning = Properties_Resources.TrustFailure; } else if (e.Message == "Unauthorized") { warning = Properties_Resources.LoginFailedForbidden; } else { warning = message + Environment.NewLine + Properties_Resources.Sorry; } WarnText.StringValue = warning; AddressText.Enabled = true; UserText.Enabled = true; PasswordText.Enabled = true; ContinueButton.Enabled = true; CancelButton.Enabled = true; // TODO remove this line for debug } else { RemoveEvent(); Controller.Add1PageCompleted(cmisServer.Url, credentials.UserName, credentials.Password.ToString()); } }); }); check.Start(); }
private void LoadAddLoginWPF() { // define UI elements. Header = Properties_Resources.Where; System.Uri resourceLocater = new System.Uri("/DataSpaceSync;component/SetupAddLoginWPF.xaml", System.UriKind.Relative); UserControl LoadAddLoginWPF = Application.LoadComponent(resourceLocater) as UserControl; address_label = LoadAddLoginWPF.FindName("address_label") as TextBlock; address_box = LoadAddLoginWPF.FindName("address_box") as TextBox; address_help_label = LoadAddLoginWPF.FindName("address_help_label") as TextBlock; user_label = LoadAddLoginWPF.FindName("user_label") as TextBlock; user_box = LoadAddLoginWPF.FindName("user_box") as TextBox; user_help_label = LoadAddLoginWPF.FindName("user_help_label") as TextBlock; password_label = LoadAddLoginWPF.FindName("password_label") as TextBlock; password_box = LoadAddLoginWPF.FindName("password_box") as PasswordBox; password_progress = LoadAddLoginWPF.FindName("password_progress") as CircularProgressBar; password_help_label = LoadAddLoginWPF.FindName("password_help_label") as TextBlock; address_error_label = LoadAddLoginWPF.FindName("address_error_label") as TextBox; continue_button = LoadAddLoginWPF.FindName("continue_button") as Button; cancel_button = LoadAddLoginWPF.FindName("cancel_button") as Button; ContentCanvas.Children.Add(LoadAddLoginWPF); address_box.Text = (Controller.PreviousAddress != null) ? Controller.PreviousAddress.ToString() : String.Empty; if (Controller.saved_user == String.Empty || Controller.saved_user == null) { user_box.Text = Environment.UserName; } else { user_box.Text = Controller.saved_user; } TaskbarItemInfo.ProgressValue = 0.0; TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None; if (Controller.PreviousAddress == null || Controller.PreviousAddress.ToString() == String.Empty) { address_box.Text = "https://"; } else { address_box.Text = Controller.PreviousAddress.ToString(); } address_box.Focus(); address_box.Select(address_box.Text.Length, 0); // Actions. ControllerLoginInsertAction(); Controller.CheckAddPage(address_box.Text); address_box.TextChanged += delegate { string error = Controller.CheckAddPage(address_box.Text); if (!String.IsNullOrEmpty(error)) { address_error_label.Text = Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture); address_error_label.Visibility = Visibility.Visible; } else { address_error_label.Visibility = Visibility.Hidden; } }; cancel_button.Click += delegate { ControllerLoginRemoveAction(); Controller.PageCancelled(); }; continue_button.Click += delegate { // Show wait cursor password_progress.Visibility = Visibility.Visible; System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; // Try to find the CMIS server (asynchronously) GetRepositoriesFuzzyDelegate dlgt = new GetRepositoriesFuzzyDelegate(CmisUtils.GetRepositoriesFuzzy); ServerCredentials credentials = new ServerCredentials() { UserName = user_box.Text, Password = password_box.Password, Address = new Uri(address_box.Text) }; IAsyncResult ar = dlgt.BeginInvoke(credentials, null, null); while (!ar.AsyncWaitHandle.WaitOne(100)) { System.Windows.Forms.Application.DoEvents(); } Tuple <CmisServer, Exception> result = dlgt.EndInvoke(ar); CmisServer cmisServer = result.Item1; Controller.repositories = cmisServer != null ? cmisServer.Repositories : null; address_box.Text = cmisServer.Url.ToString(); // Hide wait cursor System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; password_progress.Visibility = Visibility.Hidden; if (Controller.repositories == null) { // Could not retrieve repositories list from server, show warning. string warning = Controller.GetConnectionsProblemWarning(cmisServer, result.Item2); address_error_label.Text = warning; address_error_label.Visibility = Visibility.Visible; } else { ControllerLoginRemoveAction(); // Continue to next step, which is choosing a particular folder. Controller.Add1PageCompleted( new Uri(address_box.Text), user_box.Text, password_box.Password); } }; }
private void ShowAdd1Page() { Header = CmisSync.Properties_Resources.ResourceManager.GetString("Where", CultureInfo.CurrentCulture); VBox layout_vertical = new VBox(false, 12); HBox layout_fields = new HBox(true, 12); VBox layout_address = new VBox(true, 0); HBox layout_address_help = new HBox(false, 3); VBox layout_user = new VBox(true, 0); VBox layout_password = new VBox(true, 0); // Address Label address_label = new Label() { UseMarkup = true, Xalign = 0, Markup = "<b>" + CmisSync.Properties_Resources.ResourceManager.GetString("EnterWebAddress", CultureInfo.CurrentCulture) + "</b>" }; Entry address_entry = new Entry() { Text = Controller.PreviousAddress, ActivatesDefault = false }; Label address_help_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span foreground=\"#808080\" size=\"small\">" + CmisSync.Properties_Resources.ResourceManager.GetString("Help", CultureInfo.CurrentCulture) + ": " + "</span>" }; EventBox address_help_urlbox = new EventBox(); Label address_help_urllabel = new Label() { Xalign = 0, UseMarkup = true, Markup = "<span foreground=\"blue\" underline=\"single\" size=\"small\">" + CmisSync.Properties_Resources.ResourceManager.GetString("WhereToFind", CultureInfo.CurrentCulture) + "</span>" }; address_help_urlbox.Add(address_help_urllabel); address_help_urlbox.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { Process process = new Process(); process.StartInfo.FileName = "xdg-open"; process.StartInfo.Arguments = "https://github.com/nicolas-raoul/CmisSync/wiki/What-address"; process.Start(); }; address_help_urlbox.EnterNotifyEvent += delegate(object o, EnterNotifyEventArgs args) { address_help_urlbox.GdkWindow.Cursor = hand_cursor; }; Label address_error_label = new Label() { Xalign = 0, UseMarkup = true, Markup = "" }; address_error_label.Hide(); // User Entry user_entry = new Entry() { Text = Controller.PreviousPath, ActivatesDefault = false }; // Password Entry password_entry = new Entry() { Text = Controller.PreviousPath, Visibility = false, ActivatesDefault = true }; Controller.ChangeAddressFieldEvent += delegate(string text, string example_text) { Application.Invoke(delegate { address_entry.Text = text; }); }; Controller.ChangeUserFieldEvent += delegate(string text, string example_text) { Application.Invoke(delegate { user_entry.Text = text; }); }; Controller.ChangePasswordFieldEvent += delegate(string text, string example_text) { Application.Invoke(delegate { password_entry.Text = text; }); }; address_entry.Changed += delegate { string error = Controller.CheckAddPage(address_entry.Text); if (!String.IsNullOrEmpty(error)) { address_error_label.Markup = "<span foreground=\"red\">" + CmisSync.Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture) + "</span>"; address_error_label.Show(); } else { address_error_label.Hide(); } }; // Address layout_address_help.PackStart(address_help_label, false, false, 0); layout_address_help.PackStart(address_help_urlbox, false, false, 0); layout_address.PackStart(address_label, true, true, 0); layout_address.PackStart(address_entry, true, true, 0); layout_address.PackStart(layout_address_help, true, true, 0); layout_address.PackStart(address_error_label, true, true, 0); // User layout_user.PackStart(new Label() { Markup = "<b>" + CmisSync.Properties_Resources.ResourceManager.GetString("User", CultureInfo.CurrentCulture) + ":</b>", Xalign = 0 }, true, true, 0); layout_user.PackStart(user_entry, false, false, 0); // Password layout_password.PackStart(new Label() { Markup = "<b>" + CmisSync.Properties_Resources.ResourceManager.GetString("Password", CultureInfo.CurrentCulture) + ":</b>", Xalign = 0 }, true, true, 0); layout_password.PackStart(password_entry, false, false, 0); layout_fields.PackStart(layout_user); layout_fields.PackStart(layout_password); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(layout_address, false, false, 0); layout_vertical.PackStart(layout_fields, false, false, 0); Add(layout_vertical); // Cancel button Button cancel_button = new Button(cancelText); cancel_button.Clicked += delegate { Controller.PageCancelled(); }; // Continue button Button continue_button = new Button(continueText) { Sensitive = false }; continue_button.Clicked += delegate { // Show wait cursor this.GdkWindow.Cursor = wait_cursor; // Try to find the CMIS server (asynchronous using a delegate) GetRepositoriesFuzzyDelegate dlgt = new GetRepositoriesFuzzyDelegate(CmisUtils.GetRepositoriesFuzzy); IAsyncResult ar = dlgt.BeginInvoke(new Uri(address_entry.Text), user_entry.Text, password_entry.Text, null, null); while (!ar.AsyncWaitHandle.WaitOne(100)) { while (Application.EventsPending()) { Application.RunIteration(); } } CmisServer cmisServer = dlgt.EndInvoke(ar); Controller.repositories = cmisServer.Repositories; address_entry.Text = cmisServer.Url.ToString(); // Hide wait cursor this.GdkWindow.Cursor = default_cursor; if (Controller.repositories == null) { // Show warning address_error_label.Markup = "<span foreground=\"red\">" + CmisSync.Properties_Resources.ResourceManager.GetString("Sorry", CultureInfo.CurrentCulture) + "</span>"; address_error_label.Show(); } else { // Continue to folder selection Controller.Add1PageCompleted( address_entry.Text, user_entry.Text, password_entry.Text); } }; Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) { Application.Invoke(delegate { continue_button.Sensitive = button_enabled; }); }; AddButton(continue_button); AddButton(cancel_button); address_entry.GrabFocus(); }