Fixed error that caused continuous credential retrieval in Auto account page
[pithos-ms-client] / trunk / Pithos.Client.WPF / Preferences / AddAccountView.xaml
1 <Window x:Class="Pithos.Client.WPF.Preferences.AddAccountView"
2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4         xmlns:cal="http://www.caliburnproject.org"
5         xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
6         Title="AddAccountView" Height="300" Width="467" xmlns:my="clr-namespace:Microsoft.Windows.Controls.Core.Converters;assembly=WPFToolkit.Extended"
7         xmlns:Preferences="clr-namespace:Pithos.Client.WPF.Preferences">
8     <Window.Resources>
9         <my:InverseBoolConverter x:Key="InverseBool" />
10         <BooleanToVisibilityConverter x:Key="BoolToVisible" />
11     </Window.Resources>
12     <extToolkit:Wizard FinishButtonClosesWindow="True" Name="AccountWizard" PageChanged="AccountWizard_PageChanged">
13         <extToolkit:WizardPage x:Name="IntroPage" 
14                                    Title="Add new Pithos Account"
15                                    Description="This Wizard will walk you through adding a new Pithos account and retrieving an authentication token" />
16         <extToolkit:WizardPage x:Name="ChooseServer" PageType="Interior"
17                                    Title="Where do you want to connect?"
18                                    Description="You can connect to the production or development server, or enter your own server URL"                               
19                                     CanSelectNextPage="{Binding IsValidServer}"
20                                     >
21             <StackPanel >
22                 <Label Content="Pithos Server" Target="{Binding ElementName=Servers}"  />
23                 <ComboBox x:Name="Servers" IsEditable="True" ItemsSource="{Binding Servers}"
24                           Text="{Binding CurrentServer,ValidatesOnExceptions=True, Mode=TwoWay}" >                        
25                     <Validation.ErrorTemplate>
26                         <ControlTemplate>
27                             <StackPanel>
28                                 <AdornedElementPlaceholder />
29                                 <TextBlock Foreground="Red" >Invalid Path</TextBlock>
30                             </StackPanel>
31                         </ControlTemplate>
32                     </Validation.ErrorTemplate>
33                 </ComboBox>                
34             </StackPanel>
35         </extToolkit:WizardPage>
36         <extToolkit:WizardPage x:Name="ChooseMethodPage" PageType="Interior"
37                                    Title="How do you want to add the account?"
38                                    Description="You can add an account either by logging in the Pithos Web Site or by entering your username and password manually"                               
39                                     CanSelectNextPage="False">
40             <StackPanel >
41                 <RadioButton x:Name="Automatic" Content="By logging to Pithos" Checked="Automatic_Checked" Margin="5"/>
42                 <RadioButton x:Name="Manually" Content="Manually" Checked="Manually_Checked" Margin="5"/>
43             </StackPanel>
44         </extToolkit:WizardPage>
45         <extToolkit:WizardPage x:Name="ManualAccountPage" PageType="Interior"
46                                    Title="Add an account manually"
47                                    Description="Please enter the account credentials and press &quot;Validate Credentials&quot;"
48                                NextPage="{Binding ElementName=AccountPathPage}"                               
49                                CanSelectNextPage="{Binding HasValidCredentials}" 
50                                >
51             <extToolkit:BusyIndicator x:Name="ManualBusyIndicator" IsBusy="{Binding IsWorking,NotifyOnSourceUpdated=true}" DisplayAfter="0" >
52                 <extToolkit:BusyIndicator.BusyContent>
53                     <TextBlock x:Name="ManualBusyMessage" Text="{Binding BusyTitle}" HorizontalAlignment="Center" />
54                 </extToolkit:BusyIndicator.BusyContent>
55                 <extToolkit:BusyIndicator.Content>
56                     <Grid>
57                         <Grid.ColumnDefinitions>
58                             <ColumnDefinition Width="Auto"/>
59                             <ColumnDefinition Width="91*"/>
60                         </Grid.ColumnDefinitions>
61                         <Grid.RowDefinitions>
62                             <RowDefinition Height="Auto"/>
63                             <RowDefinition Height="Auto"/>
64                             <RowDefinition Height="Auto"/>
65                             <RowDefinition />
66                         </Grid.RowDefinitions>
67                         <Label Content="Account" Grid.Column="0" Grid.Row="0" Margin="0,5" HorizontalAlignment="Left"/>
68                         <TextBox Name="AccountName" Grid.Column="1" Grid.Row="0" Margin="5"/>
69                         <Label Content="API Key" Grid.Column="0" Grid.Row="1" Margin="0,5" HorizontalAlignment="Left"/>
70                         <TextBox  Name="Token" Grid.Column="1" Grid.Row="1" Margin="5"/>
71                         <Button x:Name="TestManualAccount" Content="Validate Credentials" IsEnabled="{Binding HasCredentials}" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" cal:Message.Attach="TestAccount" Margin="5"/>
72                     </Grid>
73                 </extToolkit:BusyIndicator.Content>
74             </extToolkit:BusyIndicator>
75         </extToolkit:WizardPage>
76         <extToolkit:WizardPage x:Name="AutoAccountPage" PageType="Interior"
77                                    Title="Add an account automatically"
78                                    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."
79                                NextPage="{Binding ElementName=AutoConfirmedPage}"                               
80                                CanSelectNextPage="{Binding HasValidCredentials}"                               
81                                >
82             <extToolkit:BusyIndicator x:Name="AutoBusyIndicator" IsBusy="{Binding IsWorking,NotifyOnSourceUpdated=true}" DisplayAfter="0">
83                 <extToolkit:BusyIndicator.BusyContent>
84                     <TextBlock  TextWrapping="Wrap">
85                         <TextBlock HorizontalAlignment="Center" Text="{Binding BusyTitle}"/>
86                         <TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding BusyDetail}"/>
87                     </TextBlock>                    
88                 </extToolkit:BusyIndicator.BusyContent>
89                 <extToolkit:BusyIndicator.Content>
90                     <StackPanel x:Name="AutoPanel" VerticalAlignment="Center" >
91                         <Button Margin="5" Name="RetrieveCredentials" Content="Retrieve Credentials" Width="150"/>
92
93                         <TextBlock Text="Credentials Retrieved Succesfully" Visibility="{Binding Converter={StaticResource BoolToVisible}, Path=HasCredentials}" Margin="10" HorizontalAlignment="Center"/>
94                         <Button x:Name="TestAutoAccount" Content="Validate Credentials" IsEnabled="{Binding HasCredentials}" HorizontalAlignment="Center" cal:Message.Attach="TestAccount" Margin="5"/>
95                     </StackPanel>
96                 </extToolkit:BusyIndicator.Content>
97                 </extToolkit:BusyIndicator>
98         </extToolkit:WizardPage>
99         <extToolkit:WizardPage x:Name="AccountPathPage" PageType="Interior"
100                                    Title="Select Account Path"
101                                    Description="Please select the roor path for your account"
102                                NextPage="{Binding ElementName=LastPage}"
103                                CanSelectNextPage="{Binding HasAccountPath}"
104                                    >
105             <StackPanel>
106                 <Label Content="Path:" Target="{Binding ElementName=AccountPath}"/>
107                 <Grid HorizontalAlignment="Stretch">
108                     <Grid.ColumnDefinitions>
109                         <ColumnDefinition />
110                         <ColumnDefinition Width="Auto" />
111                     </Grid.ColumnDefinitions>
112                     <TextBox x:Name="AccountPath" HorizontalAlignment="Stretch" Grid.Column="0" >
113                         <TextBox.Text>
114                             <Binding Path="AccountPath" Mode="TwoWay">
115                                 <Binding.ValidationRules>
116                                     <Preferences:DirectoryExistsRule/>
117                                 </Binding.ValidationRules>
118                             </Binding>
119                         </TextBox.Text>
120                        <Validation.ErrorTemplate>
121                             <ControlTemplate>
122                                 <StackPanel>                                    
123                                     <AdornedElementPlaceholder />
124                                     <TextBlock Foreground="Red" >Invalid Path</TextBlock>
125                                 </StackPanel>
126                             </ControlTemplate>
127                         </Validation.ErrorTemplate>
128                     </TextBox>
129                     <Button x:Name="SelectAccount" Content="Select ..." HorizontalAlignment="Right" Grid.Column="1"/>
130                 </Grid>
131             </StackPanel>
132         </extToolkit:WizardPage>
133         <extToolkit:WizardPage x:Name="LastPage" PageType="Interior"
134                                    Title="Finish"
135                                    Description="Press finish to create the account"
136                                    CanFinish="True">
137             <Grid>
138                 <Grid.RowDefinitions>
139                     <RowDefinition Height="Auto"/>
140                     <RowDefinition Height="Auto"/>
141                     <RowDefinition Height="Auto"/>
142                     <RowDefinition Height="Auto"/>
143                     <RowDefinition Height="Auto"/>
144                     <RowDefinition />
145                 </Grid.RowDefinitions>
146                 <Grid.ColumnDefinitions>
147                     <ColumnDefinition Width="Auto"/>
148                     <ColumnDefinition />
149                 </Grid.ColumnDefinitions>
150                 <TextBlock Text="Server:" Grid.Column="0" Grid.Row="0" Margin="5,2"/>
151                 <TextBlock Text="{Binding CurrentServer}" Grid.Column="1" Grid.Row="0" Margin="5,2"/>
152                 <TextBlock Text="Account Name:" Grid.Column="0" Grid.Row="1" Margin="5,2"/>
153                 <TextBlock Text="{Binding AccountName}" Grid.Column="1" Grid.Row="1" Margin="5,2"/>
154                 <TextBlock Text="Token:" Grid.Column="0" Grid.Row="2" Margin="5,2"/>
155                 <TextBlock Text="{Binding Token}" Grid.Column="1" Grid.Row="2" Margin="5,2"/>
156                 <TextBlock Text="Account Path:" Grid.Column="0" Grid.Row="3" Margin="5,2"/>
157                 <TextBlock Text="{Binding AccountPath}" Grid.Column="1" Grid.Row="3" Margin="5,2"/>
158
159                 <CheckBox x:Name="IsAccountActive" Content="Start using the account immediatelly" Grid.ColumnSpan="2" Grid.Row="5" Margin="5"/>
160             </Grid>
161         </extToolkit:WizardPage>
162     </extToolkit:Wizard>
163     
164 </Window>