public void ShowAccountForm() { Reset(); VBox layout_vertical = new VBox(false, 0); Deletable = false; Label header = new Label("<span size='large'><b>" + _("Welcome to SparkleShare!") + "</b></span>") { UseMarkup = true, Xalign = 0 }; Label information = new Label(_("Before we can create a SparkleShare folder on this " + "computer, we need a few bits of information from you.")) { Xalign = 0, Wrap = true }; Table table = new Table(4, 2, true) { RowSpacing = 6 }; string full_name = new UnixUserInfo(UnixEnvironment.UserName).RealName; if (string.IsNullOrEmpty(full_name)) { full_name = ""; } Label name_label = new Label("<b>" + _("Full Name:") + "</b>") { UseMarkup = true, Xalign = 0 }; NameEntry = new Entry(full_name.TrimEnd(",".ToCharArray())); NameEntry.Changed += delegate { CheckAccountForm(); }; EmailEntry = new Entry(SparkleShare.Controller.UserEmail); EmailEntry.Changed += delegate { CheckAccountForm(); }; Label email_label = new Label("<b>" + _("Email:") + "</b>") { UseMarkup = true, Xalign = 0 }; table.Attach(name_label, 0, 1, 0, 1); table.Attach(NameEntry, 1, 2, 0, 1); table.Attach(email_label, 0, 1, 1, 2); table.Attach(EmailEntry, 1, 2, 1, 2); NextButton = new Button(_("Next")) { Sensitive = false }; NextButton.Clicked += delegate(object o, EventArgs args) { NextButton.Remove(NextButton.Child); NextButton.Add(new Label(_("Configuring…"))); NextButton.Sensitive = false; table.Sensitive = false; NextButton.ShowAll(); SparkleShare.Controller.UserName = NameEntry.Text; SparkleShare.Controller.UserEmail = EmailEntry.Text; SparkleShare.Controller.GenerateKeyPair(); SparkleShare.Controller.AddKey(); SparkleShare.Controller.FirstRun = false; Deletable = true; ShowServerForm(); }; AddButton(NextButton); layout_vertical.PackStart(header, false, false, 0); layout_vertical.PackStart(information, false, false, 21); layout_vertical.PackStart(new Label(""), false, false, 0); layout_vertical.PackStart(table, false, false, 0); Add(layout_vertical); CheckAccountForm(); ShowAll(); }
public void ShowAccountForm() { Reset(); Header = "Welcome to SparkleShare!"; Description = "Before we can create a SparkleShare folder on this " + "computer, we need some information from you."; UserInfoForm = new NSForm(new RectangleF(250, 115, 350, 64)); UserInfoForm.AddEntry("Full Name:"); UserInfoForm.AddEntry("Email Address:"); UserInfoForm.CellSize = new SizeF(280, 22); UserInfoForm.IntercellSpacing = new SizeF(4, 4); string full_name = new UnixUserInfo(UnixEnvironment.UserName).RealName; if (string.IsNullOrEmpty(full_name)) { full_name = ""; } UserInfoForm.Cells [0].StringValue = full_name.TrimEnd(",".ToCharArray());; UserInfoForm.Cells [1].StringValue = SparkleShare.Controller.UserEmail; ContinueButton = new NSButton() { Title = "Continue", Enabled = false }; ContinueButton.Activated += delegate { SparkleShare.Controller.UserName = UserInfoForm.Cells [0].StringValue.Trim(); SparkleShare.Controller.UserEmail = UserInfoForm.Cells [1].StringValue.Trim(); SparkleShare.Controller.GenerateKeyPair(); SparkleShare.Controller.FirstRun = false; InvokeOnMainThread(delegate { ShowServerForm(); }); }; // TODO: Ugly hack, do properly with events Timer timer = new Timer() { Interval = 50 }; timer.Elapsed += delegate { InvokeOnMainThread(delegate { bool name_is_correct = !UserInfoForm.Cells [0].StringValue.Trim().Equals(""); bool email_is_correct = SparkleShare.Controller.IsValidEmail (UserInfoForm.Cells [1].StringValue.Trim()); ContinueButton.Enabled = (name_is_correct && email_is_correct); }); }; timer.Start(); ContentView.AddSubview(UserInfoForm); Buttons.Add(ContinueButton); ShowAll(); }