Changed listbox in ConflictsView.xaml to datagrid
authorpkanavos <pkanavos@gmail.com>
Fri, 6 Apr 2012 20:27:59 +0000 (23:27 +0300)
committerpkanavos <pkanavos@gmail.com>
Fri, 6 Apr 2012 20:27:59 +0000 (23:27 +0300)
Fixed context menu

trunk/Pithos.Client.WPF/FileProperties/ConflictsView.xaml
trunk/Pithos.Client.WPF/FileProperties/ConflictsViewModel.cs
trunk/Pithos.Core/Agents/NetworkAgent.cs
trunk/Pithos.Core/FileState.cs

index ee3ddc1..dccb7ac 100644 (file)
@@ -8,8 +8,7 @@
     <Window.Resources>
         <ResourceDictionary>
             <ContextMenu  x:Key="RowMenu" DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
-            <MenuItem Header="{Binding FilePath}" cal:Message.Attach="[Event MouseLeftButtonUp]=[Action GoToFile($dataContext)]"
-                      cal:Action.TargetWithoutContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=DataGrid}, Path=DataContext}"/>
+            <MenuItem Header="{Binding FilePath}" cal:Message.Attach="GoToFile"/>
         </ContextMenu>
         <Style x:Key="DefaultRowStyle" TargetType="{x:Type DataGridRow}">
             <Setter Property="ContextMenu" Value="{StaticResource RowMenu}" />
             <RowDefinition Height="Auto"/>
         </Grid.RowDefinitions>
         
-        <ListBox x:Name="Conflicts" HorizontalContentAlignment="Stretch" Grid.Row="0">
-            <ListBox.ItemTemplate>
-                <DataTemplate>
-                    <Grid>
-                        <Grid.ColumnDefinitions>
-                            <ColumnDefinition />
-                            <ColumnDefinition Width="Auto"/>
-                        </Grid.ColumnDefinitions>
-                        <TextBlock x:Name="FilePath" Text="{Binding FilePath}" Grid.Row="0" Margin="5"/>
+        <DataGrid x:Name="Conflicts" HorizontalContentAlignment="Stretch" Grid.Row="0" AutoGenerateColumns="false" RowStyle="{StaticResource DefaultRowStyle}">
+            <DataGrid.Columns>
+                <DataGridTextColumn x:Name="FilePath" Binding="{Binding FilePath}" Header="File" Width="*" />
+                <DataGridTextColumn x:Name="LocalModified" Binding="{Binding LocalModified}" Header="Local Date" Width="Auto" />
+                <DataGridTemplateColumn x:Name="Action" Header="Action" Width="Auto">
+                    <DataGridTemplateColumn.CellTemplate>
+                        <DataTemplate>
                         <ComboBox x:Name="Action" ItemsSource="{cnv:EnumValues model:ConflictAction}" 
-                                  SelectedValue="{Binding Action}" Grid.Row="1" 
+                                  SelectedValue="{Binding Action}" Grid.Column="2" 
                                   HorizontalAlignment="Right" 
                                   HorizontalContentAlignment="Left"
                                   Width="110" Margin="5" Padding="5,2"
                                   />
-                    </Grid>
-                </DataTemplate>
-            </ListBox.ItemTemplate>
-        </ListBox>
+                        </DataTemplate>
+                    </DataGridTemplateColumn.CellTemplate>
+                </DataGridTemplateColumn>
+            </DataGrid.Columns>
+        </DataGrid>
         <StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Right">
             <Button Name="Apply" Content="OK" Margin="5,5,10,5" Style="{StaticResource ButtonStyle}" IsDefault="False" />
             <Button Name="Cancel" Content="Cancel" Margin="5,5,10,5" Style="{StaticResource ButtonStyle}" IsCancel="True" />
index b523742..dcb8356 100644 (file)
@@ -42,8 +42,18 @@ namespace Pithos.Client.WPF.FileProperties
             }
         }
 
-        private ConflictAction _action;
+        private string _reason;
+        public string Reason
+        {
+            get { return _reason; }
+            set
+            {
+                _reason = value;
+                NotifyOfPropertyChange(() => Reason);
+            }
+        }
 
+        private ConflictAction _action;
         public ConflictAction Action
         {
             get { return _action; }
@@ -53,6 +63,17 @@ namespace Pithos.Client.WPF.FileProperties
                 NotifyOfPropertyChange(()=>Action);
             }
         }
+
+        public DateTime LocalModified { get; set; }
+
+        public DateTime CloudModified { get; set; }
+
+        public void GoToFile()
+        {
+            if (!File.Exists(FilePath) && !Directory.Exists(FilePath))
+                return;
+            Process.Start("explorer.exe", "/select, " + FilePath);
+        }
     }
     [Export(typeof(ConflictsViewModel))]
     class ConflictsViewModel:Screen
@@ -81,7 +102,8 @@ namespace Pithos.Client.WPF.FileProperties
             var conflicts = from state in FileState.Queryable
                             /*where state.FileStatus == FileStatus.Conflict ||
                                   state.OverlayStatus == FileOverlayStatus.Conflict*/
-                            select new ConflictFile {FilePath = state.FilePath};          
+                            let info=FileInfoExtensions.FromPath(state.FilePath)
+                            select new ConflictFile {FilePath = state.FilePath,Reason=state.ConflictReason,LocalModified = info.LastWriteTime};          
             _conflicts = new ObservableCollection<ConflictFile>(conflicts.ToList());
             
         }
index 4551602..8d3f6a4 100644 (file)
@@ -358,12 +358,12 @@ namespace Pithos.Core.Agents
                 {
                     //If the previous and local hash don't match, there was a local conflict
                     //that was not uploaded to the server. We have a conflict
-                    ReportConflict(downloadPath);
+                    ReportConflictForMismatch(downloadPath);
                 }
             }
         }
 
-        private void ReportConflict(string downloadPath)
+        private void ReportConflictForMismatch(string downloadPath)
         {
             if (String.IsNullOrWhiteSpace(downloadPath))
                 throw new ArgumentNullException("downloadPath");
index 2c3869a..3bafda0 100644 (file)
@@ -81,6 +81,9 @@ namespace Pithos.Core
         [Property]
         public FileStatus FileStatus { get; set; }
 
+        [Property]
+        public string ConflictReason { get; set; }
+
         private string _checksum;
 
         /// <summary>