Moved the "Selective Sync Enabled" to the main preferences page
authorpkanavos <pkanavos@gmail.com>
Thu, 24 May 2012 19:43:10 +0000 (22:43 +0300)
committerpkanavos <pkanavos@gmail.com>
Thu, 24 May 2012 19:43:10 +0000 (22:43 +0300)
trunk/Pithos.Client.WPF/Preferences/AccountViewModel.cs
trunk/Pithos.Client.WPF/Preferences/PreferencesView.xaml
trunk/Pithos.Client.WPF/Preferences/PreferencesViewModel.cs
trunk/Pithos.Client.WPF/SelectiveSynch/SelectiveSynchView.xaml
trunk/Pithos.Client.WPF/SelectiveSynch/SelectiveSynchViewModel.cs

index 212bef0..7abeabd 100644 (file)
@@ -69,6 +69,16 @@ namespace Pithos.Client.WPF.Preferences
             get { return new Uri(new Uri(_account.ServerUrl) , _account.AccountName); }
         }
 
+        public bool SelectiveSyncEnabled
+        {
+            get { return _account.SelectiveSyncEnabled; }
+            set
+            {
+                _account.SelectiveSyncEnabled = value;
+                NotifyOfPropertyChange(() => SelectiveSyncEnabled);
+            }
+        }
+
         public string AccountName
         {
             get {
index 63dee68..f36e707 100644 (file)
@@ -92,7 +92,7 @@
                             No account is selected. Please select an account or add a new one.
                         </TextBlock>    
                     </GroupBox>
-                    <GroupBox Header="Account" Padding="5" Margin="5,5,5,0" Height="266" HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.Column="1" Visibility="{Binding Path=CurrentAccount, Converter={StaticResource NullToVisible}}">
+                    <GroupBox Header="Account" Padding="5" Margin="5,5,5,0" Height="286" HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.Column="1" Visibility="{Binding Path=CurrentAccount, Converter={StaticResource NullToVisible}}">
                             <Grid>
                             <Grid.ColumnDefinitions>
                                 <ColumnDefinition Width="Auto"/>
                                 </Grid.ColumnDefinitions>
                                 <TextBox  Name="CurrentAccount_RootPath" Margin="5" HorizontalAlignment="Stretch" IsReadOnly="True" ToolTip="{Binding CurrentAccount.RootPath}" Height="61" TextWrapping="WrapWithOverflow" />
                             </Grid>
-                            <StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="1">
-                                <Button Name="SelectiveSyncFolders" Content="Selective Sync" Width="100" Style="{StaticResource ButtonStyle}" />
-                                <Button Name="MoveAccountFolder" Content="Move ..." Width="100" Style="{StaticResource ButtonStyle}"/>
+                            <CheckBox Name="CurrentAccount_IsActive" Content="Account is Active" Grid.Row="6"  Grid.Column="1"  />
+                            <CheckBox Name="CurrentAccount_SelectiveSyncEnabled" Content="Selective Sync Enabled" Grid.Row="7" Grid.Column="1"/>
+                            <StackPanel Orientation="Horizontal" Grid.Row="8" Grid.Column="1">
+                                <Button Name="SelectiveSyncFolders" Width="100" Style="{StaticResource ButtonStyle}" Content="Selective Sync" />
+                                <Button Name="MoveAccountFolder" Content="Move ..." Width="100" Style="{StaticResource ButtonStyle}" Margin="20,5,5,5"/>
                                 <Button Name="ClearAccountCache" Content="Clear Cache" Width="100" Style="{StaticResource ButtonStyle}"/>
                             </StackPanel>
-                            <CheckBox  Name="CurrentAccount_IsActive" Content="Account is Active" Grid.Row="7"  Grid.Column="1"  />
                         </Grid>
                         
                     </GroupBox>
index 3582c0a..a1000e8 100644 (file)
@@ -218,7 +218,7 @@ namespace Pithos.Client.WPF.Preferences
         \r
         public bool CanSelectiveSyncFolders\r
         {\r
-            get { return CurrentAccount != null; }\r
+            get { return CurrentAccount != null && CurrentAccount.SelectiveSyncEnabled; }\r
         }\r
 \r
         public void SelectiveSyncFolders()\r
@@ -619,7 +619,10 @@ namespace Pithos.Client.WPF.Preferences
             set\r
             {\r
                 _currentAccount = value;\r
-                NotifyOfPropertyChange(()=>CurrentAccount);\r
+\r
+                _currentAccount.PropertyChanged += (o, e) => NotifyOfPropertyChange(() => CanSelectiveSyncFolders);\r
+\r
+                NotifyOfPropertyChange(() => CurrentAccount);\r
                 NotifyOfPropertyChange(() => CanRemoveAccount);\r
                 NotifyOfPropertyChange(() => CanSelectiveSyncFolders);\r
                 NotifyOfPropertyChange(() => CanMoveAccountFolder);\r
index fa3a497..d654eca 100644 (file)
     <extToolkit:BusyIndicator Name="IsBusy" BusyContent="Retrieving folders ..." DisplayAfter="0">
         <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="Auto"/>
             <RowDefinition Height="*"/>
             <RowDefinition Height="Auto"/>
         </Grid.RowDefinitions>
-        <CheckBox x:Name="IsEnabled" Content="Enable Selective Syncing" Margin="5" Grid.Row="0"/>
-        <TreeView  Name="RootNodes" Margin="5" Grid.Row="1"
+        <TreeView  Name="RootNodes" Margin="5" Grid.Row="0"
                 ItemContainerStyle="{StaticResource TreeItemStyle}" 
                 ItemTemplate="{StaticResource CheckboxStyle}"
                     IsEnabled="{Binding IsEnabled}" >
         </TreeView>
-        <StackPanel Grid.Row="2">
+        <StackPanel Grid.Row="1">
             <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right">
                 <Button Name="SaveChanges" Content="OK" Margin="5,5,10,5"  Style="{StaticResource ButtonStyle}"/>
                 <Button Name="RejectChanges" Content="Cancel" Margin="5,5,10,5"  Style="{StaticResource ButtonStyle}"/>                
index c614eef..2b29e0c 100644 (file)
@@ -94,7 +94,7 @@ namespace Pithos.Client.WPF.SelectiveSynch
             //_monitor = monitor;\r
             _events = events;\r
             _apiKey = apiKey;\r
-            IsEnabled = account.SelectiveSyncEnabled;\r
+            //IsEnabled = account.SelectiveSyncEnabled;\r
             TaskEx.Run(LoadRootNode);\r
         }\r
 \r
@@ -269,7 +269,7 @@ namespace Pithos.Client.WPF.SelectiveSynch
                           where record.Removed && record.Uri != null\r
                          select record.Uri).ToArray();\r
             //TODO: Include Uris for the containers as well\r
-            _events.Publish(new SelectiveSynchChanges{Enabled=IsEnabled, Account=Account,Uris=uris,Added=added,Removed=removed});\r
+            _events.Publish(new SelectiveSynchChanges{Enabled=true, Account=Account,Uris=uris,Added=added,Removed=removed});\r
             \r
 \r
             \r
@@ -277,6 +277,7 @@ namespace Pithos.Client.WPF.SelectiveSynch
             TryClose(true);\r
         }\r
 \r
+/*\r
         private bool _isEnabled;\r
         public bool IsEnabled\r
         {\r
@@ -287,11 +288,12 @@ namespace Pithos.Client.WPF.SelectiveSynch
                 NotifyOfPropertyChange(()=>IsEnabled);\r
             }\r
         }\r
+*/\r
 \r
         private void SaveSettings(IEnumerable<Uri> uris)\r
         {\r
             var selections = uris.Select(uri => uri.ToString()).ToArray();\r
-            Account.SelectiveSyncEnabled = IsEnabled;\r
+            //Account.SelectiveSyncEnabled = IsEnabled;\r
             Account.SelectiveFolders.Clear();\r
             Account.SelectiveFolders.AddRange(selections);\r
             Settings.Default.Save();            \r