Fixed error that caused continuous credential retrieval in Auto account page
authorPanagiotis Kanavos <pkanavos@gmail.com>
Thu, 15 Dec 2011 18:39:58 +0000 (20:39 +0200)
committerPanagiotis Kanavos <pkanavos@gmail.com>
Thu, 15 Dec 2011 18:39:58 +0000 (20:39 +0200)
trunk/Pithos.Client.WPF/Preferences/AddAccountView.xaml
trunk/Pithos.Client.WPF/Preferences/AddAccountView.xaml.cs
trunk/Pithos.Client.WPF/Preferences/AddAccountViewModel.cs
trunk/Pithos.Client.WPF/Properties/AssemblyInfo.cs

index 68fda6e..eb30b76 100644 (file)
@@ -48,9 +48,9 @@
                                NextPage="{Binding ElementName=AccountPathPage}"                               
                                CanSelectNextPage="{Binding HasValidCredentials}" 
                                >
-            <extToolkit:BusyIndicator x:Name="ManualBusyIndicator" IsBusy="{Binding IsValidating,NotifyOnSourceUpdated=true}" DisplayAfter="0" >
+            <extToolkit:BusyIndicator x:Name="ManualBusyIndicator" IsBusy="{Binding IsWorking,NotifyOnSourceUpdated=true}" DisplayAfter="0" >
                 <extToolkit:BusyIndicator.BusyContent>
-                    <TextBlock x:Name="ManualBusyMessage" Text="Validating credentials"  />
+                    <TextBlock x:Name="ManualBusyMessage" Text="{Binding BusyTitle}" HorizontalAlignment="Center" />
                 </extToolkit:BusyIndicator.BusyContent>
                 <extToolkit:BusyIndicator.Content>
                     <Grid>
                                    Title="Add an account automatically"
                                    Description="By clicking on the button below you will be taken to the Pithos web site where you can login with your username and password."
                                NextPage="{Binding ElementName=AutoConfirmedPage}"                               
-                               CanSelectNextPage="{Binding HasValidCredentials}"
-                               cal:Message.Attach="[Event GotFocus] = [Action RetrieveCredentials()]"
+                               CanSelectNextPage="{Binding HasValidCredentials}"                               
                                >
-            <extToolkit:BusyIndicator IsBusy="{Binding IsRetrieving}">
+            <extToolkit:BusyIndicator x:Name="AutoBusyIndicator" IsBusy="{Binding IsWorking,NotifyOnSourceUpdated=true}" DisplayAfter="0">
                 <extToolkit:BusyIndicator.BusyContent>
                     <TextBlock  TextWrapping="Wrap">
-                        <TextBlock HorizontalAlignment="Center">Waiting for credentials. </TextBlock>
-                        <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap">Please enter your credentials in the Pithos logon page</TextBlock>
+                        <TextBlock HorizontalAlignment="Center" Text="{Binding BusyTitle}"/>
+                        <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding BusyDetail}"/>
                     </TextBlock>                    
                 </extToolkit:BusyIndicator.BusyContent>
                 <extToolkit:BusyIndicator.Content>
-                    <StackPanel VerticalAlignment="Center" >
+                    <StackPanel x:Name="AutoPanel" VerticalAlignment="Center" >
                         <Button Margin="5" Name="RetrieveCredentials" Content="Retrieve Credentials" Width="150"/>
 
                         <TextBlock Text="Credentials Retrieved Succesfully" Visibility="{Binding Converter={StaticResource BoolToVisible}, Path=HasCredentials}" Margin="10" HorizontalAlignment="Center"/>
index 5f4aa9b..14af650 100644 (file)
@@ -25,6 +25,7 @@ namespace Pithos.Client.WPF.Preferences
             
             //When the busy indicator changes, force a focus change. Workaround for delayed change of the Next button's visibility
             ManualBusyMessage.IsVisibleChanged += (sender, evt) => Token.Focus(); ;
+            AutoBusyIndicator.IsVisibleChanged += (sender, evt) => RetrieveCredentials.BringIntoView();
         }
 
 
index c295e4b..8ee783b 100644 (file)
@@ -149,20 +149,9 @@ namespace Pithos.Client.WPF.Preferences
         }
 
 
-        private bool _isRetrieving;
-        public bool IsRetrieving
-        {
-            get { return _isRetrieving; }
-            set
-            {
-                _isRetrieving = value;
-                NotifyOfPropertyChange(() => IsRetrieving);
-            }
-        }
-
         public async void RetrieveCredentials()
         {
-            IsRetrieving = true;
+            SetBusy("Waiting for credentials.", "Please enter your credentials in the Pithos logon page");
             IsConfirmed = false;
 
             try
@@ -179,7 +168,12 @@ namespace Pithos.Client.WPF.Preferences
                 MessageBox.Show(exc.ToString(), "Error");
                 throw;
             }
-            IsRetrieving = false;
+            finally
+            {
+                ClearBusy();
+                
+                (this.GetView() as Window).Activate();
+            }
 
         }
 
@@ -205,22 +199,59 @@ namespace Pithos.Client.WPF.Preferences
         }
 
 
-        private bool _isValidating;
-        public bool IsValidating
+        private bool _isWorking;
+        public bool IsWorking
         {
-            get { return _isValidating; }
+            get { return _isWorking; }
             set
             {
-                _isValidating = value;
-                NotifyOfPropertyChange(()=>IsValidating);
+                _isWorking = value;
+                NotifyOfPropertyChange(()=>IsWorking);
             }
         }
 
+        private string _busyTitle;
+        public string BusyTitle
+        {
+            get { return _busyTitle; }
+            set
+            {
+                _busyTitle = value;
+                NotifyOfPropertyChange(()=>BusyTitle);
+            }
+        }
+
+        private string _busyDetail;
+        public string BusyDetail
+        {
+            get { return _busyDetail; }
+            set
+            {
+                _busyDetail = value;
+                NotifyOfPropertyChange(()=>BusyDetail);
+            }
+        }
+
+        private void SetBusy(string title,string detail)
+        {
+            IsWorking = true;
+            BusyTitle = title;
+            BusyDetail = detail;
+        }
+
+        private void ClearBusy()
+        {
+            IsWorking = false;
+            BusyTitle = "";
+            BusyDetail = "";
+            
+        }
+
         public async void TestAccount()
         {
             try
             {
-                IsValidating = true;
+                SetBusy("Validating Credentials","");
                 var client = new CloudFilesClient(AccountName, Token) {AuthenticationUrl = CurrentServer};                
                 var containers = await TaskEx.Run(()=>
                                                       {
@@ -237,7 +268,7 @@ namespace Pithos.Client.WPF.Preferences
             }
             finally
             {
-                IsValidating = false;
+                ClearBusy();
             }
         }
 
index 754c04e..30c6b2b 100644 (file)
@@ -52,4 +52,4 @@ using System.Windows;
 // You can specify all the values or you can default the Build and Revision Numbers 
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.26000")]
+[assembly: AssemblyVersion("1.0.0.26001")]