From d2cb17a4b3ed7c48739508d1ffceeddb18c848ef Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Wed, 7 Mar 2012 02:26:52 +0000 Subject: [PATCH] windows: add cancel buttons to Setup and Add pages --- SparkleShare/SparkleControllerBase.cs | 8 ------ SparkleShare/SparkleSetupController.cs | 11 +++++--- SparkleShare/SparkleStatusIconController.cs | 5 ++++ SparkleShare/Windows/SparkleSetup.cs | 31 +++++++++++++++++++-- SparkleShare/Windows/SparkleStatusIcon.cs | 3 +- 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/SparkleShare/SparkleControllerBase.cs b/SparkleShare/SparkleControllerBase.cs index eec58872..a7fa91cd 100644 --- a/SparkleShare/SparkleControllerBase.cs +++ b/SparkleShare/SparkleControllerBase.cs @@ -25,11 +25,7 @@ using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading; -using System.Xml; -#if __MonoCS__ -using Mono.Unix; -#endif using SparkleLib; namespace SparkleShare { @@ -1138,11 +1134,7 @@ namespace SparkleShare { repo.Dispose (); } -#if __MonoCS__ Environment.Exit (0); -#else - System.Windows.Forms.Application.Exit(); -#endif } diff --git a/SparkleShare/SparkleSetupController.cs b/SparkleShare/SparkleSetupController.cs index c871dabc..16170042 100755 --- a/SparkleShare/SparkleSetupController.cs +++ b/SparkleShare/SparkleSetupController.cs @@ -203,7 +203,13 @@ namespace SparkleShare { UpdateSetupContinueButtonEvent (fields_valid); } - + + public void SetupPageCancelled () + { + Program.Controller.Quit (); + } + + public void SetupPageCompleted (string full_name, string email) { Program.Controller.UserName = full_name; @@ -449,9 +455,6 @@ namespace SparkleShare { public void ErrorPageCompleted () { - if (ChangePageEvent == null) - return; - if (PendingInvite != null) ChangePageEvent (PageType.Invite, null); else diff --git a/SparkleShare/SparkleStatusIconController.cs b/SparkleShare/SparkleStatusIconController.cs index 05671aec..81a41adb 100755 --- a/SparkleShare/SparkleStatusIconController.cs +++ b/SparkleShare/SparkleStatusIconController.cs @@ -159,5 +159,10 @@ namespace SparkleShare { { Program.Controller.ShowAboutWindow (); } + + public void QuitClicked () + { + Program.Controller.Quit (); + } } } diff --git a/SparkleShare/Windows/SparkleSetup.cs b/SparkleShare/Windows/SparkleSetup.cs index 6146ce58..66f101f8 100644 --- a/SparkleShare/Windows/SparkleSetup.cs +++ b/SparkleShare/Windows/SparkleSetup.cs @@ -89,6 +89,11 @@ namespace SparkleShare { }; + + Button cancel_button = new Button () { + Content = "Cancel" + }; + Button continue_button = new Button () { Content = "Continue", IsEnabled = false @@ -112,6 +117,7 @@ namespace SparkleShare { Canvas.SetTop (email_box, 230); Buttons.Add (continue_button); + Buttons.Add (cancel_button); Controller.UpdateSetupContinueButtonEvent += delegate (bool enabled) { @@ -128,6 +134,13 @@ namespace SparkleShare { Controller.CheckSetupPage (name_box.Text, email_box.Text); }; + cancel_button.Click += delegate { + Dispatcher.Invoke ((Action) delegate { + SparkleUI.StatusIcon.Dispose (); + Controller.SetupPageCancelled (); + }); + }; + continue_button.Click += delegate { Controller.SetupPageCompleted (name_box.Text, email_box.Text); }; @@ -371,13 +384,25 @@ namespace SparkleShare { // TODO: Bullet points - Button try_again_button = new Button () { - Content = "Try again…" + + Button cancel_button = new Button () { + Content = "Cancel" }; + + Button try_again_button = new Button () { + Content = "Try again…" + }; + Buttons.Add (try_again_button); + Buttons.Add (cancel_button); - try_again_button.Click += delegate { + + cancel_button.Click += delegate { + Controller.PageCancelled (); + }; + + try_again_button.Click += delegate { Controller.ErrorPageCompleted (); }; diff --git a/SparkleShare/Windows/SparkleStatusIcon.cs b/SparkleShare/Windows/SparkleStatusIcon.cs index efb3ad81..32fe8e22 100644 --- a/SparkleShare/Windows/SparkleStatusIcon.cs +++ b/SparkleShare/Windows/SparkleStatusIcon.cs @@ -17,7 +17,6 @@ using System; using System.Drawing; -using System.IO; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Controls; @@ -213,7 +212,7 @@ namespace SparkleShare { this.exit_item.Click += delegate { this.notify_icon.Dispose (); - Program.Controller.Quit (); + Controller.QuitClicked (); };