2 using System.Collections.Generic;
3 using System.Collections.ObjectModel;
4 using System.ComponentModel;
5 using System.ComponentModel.Composition;
6 using System.Diagnostics;
11 using Pithos.Client.WPF.Converters;
13 using Pithos.Interfaces;
15 namespace Pithos.Client.WPF.FileProperties
17 [TypeConverter(typeof(EnumTypeConverter))]
18 public enum ConflictAction
20 [Description("Defer Decision")]
22 [Description("Keep Local")]
24 [Description("Keep Server")]
26 [Description("Keep Both")]
28 [Description("Clear Record")]
32 public class ConflictFile:PropertyChangedBase
34 private string _filePath;
35 public string FilePath
37 get { return _filePath; }
41 NotifyOfPropertyChange(()=>FilePath);
45 private ConflictAction _action;
47 public ConflictAction Action
49 get { return _action; }
53 NotifyOfPropertyChange(()=>Action);
57 [Export(typeof(ConflictsViewModel))]
58 class ConflictsViewModel:Screen
61 public IStatusKeeper StatusKeeper { get; set; }
64 public IConflictResolver Resolver { get; set; }
66 private readonly ObservableCollection<ConflictFile> _conflicts;
68 public ObservableCollection<ConflictFile> Conflicts
70 get { return _conflicts; }
73 public string[] Actions
75 get { return new[] {"Keep Local", "Keep Server", "Keep Both"}; }
78 public ConflictsViewModel()
80 this.DisplayName="Conflicts";
81 var conflicts = from state in FileState.Queryable
82 /*where state.FileStatus == FileStatus.Conflict ||
83 state.OverlayStatus == FileOverlayStatus.Conflict*/
84 select new ConflictFile {FilePath = state.FilePath};
85 _conflicts = new ObservableCollection<ConflictFile>(conflicts.ToList());
90 /// Open an explorer window to the target path's directory
91 /// and select the file
93 /// <param name="entry"></param>
94 public void GoToFile(string fullPath)
96 if (!File.Exists(fullPath) && !Directory.Exists(fullPath))
98 Process.Start("explorer.exe", "/select, " + fullPath);
103 var conflicts = from conflict in Conflicts
104 where conflict.Action != ConflictAction.Defer
106 Resolver.Resolve(conflicts);
119 internal interface IConflictResolver
121 void Resolve(IEnumerable<ConflictFile> conflicts);