Revision aba9e6d9 trunk/Pithos.Client.WPF/FileProperties/FilePropertiesViewModel.cs

b/trunk/Pithos.Client.WPF/FileProperties/FilePropertiesViewModel.cs
7 7
using System.Collections;
8 8
using System.Collections.Concurrent;
9 9
using System.Collections.ObjectModel;
10
using System.Collections.Specialized;
10 11
using System.ComponentModel.Composition;
11 12
using System.Diagnostics;
12 13
using System.Diagnostics.Contracts;
......
16 17
using System.Windows.Media.Imaging;
17 18
using Caliburn.Micro;
18 19
using Pithos.Client.WPF.FileProperties;
20
using Pithos.Client.WPF.Properties;
19 21
using Pithos.Interfaces;
22
using Pithos.Network;
20 23

  
21 24
namespace Pithos.Client.WPF
22 25
{
......
42 45
            }
43 46
        }
44 47

  
48

  
49
        private bool _isPublic;
50
        public bool IsPublic
51
        {
52
            get { return _isPublic; }
53
            set
54
            {
55
                _isPublic = value;
56
                NotifyOfPropertyChange(()=>IsPublic);
57
            }
58
        }
59

  
60
        private string _contentDisposition;
61
        public string ContentDisposition
62
        {
63
            get { return _contentDisposition; }
64
            set
65
            {
66
                _contentDisposition = value;
67
                NotifyOfPropertyChange(() => ContentDisposition);
68
            }
69
        }
70

  
71
        private string _contentEncoding;
72
        public string ContentEncoding
73
        {
74
            get { return _contentEncoding; }
75
            set
76
            {
77
                _contentEncoding = value;
78
                NotifyOfPropertyChange(() => ContentEncoding);
79
            }
80
        }
81

  
82

  
83
        private string _manifest;
84
        public string Manifest
85
        {
86
            get { return _manifest; }
87
            set
88
            {
89
                _manifest = value;
90
                NotifyOfPropertyChange(() => Manifest);
91
            }
92
        }
93

  
45 94
        public string Kind { get; set; }
46 95
        public string Size { get; set; }
47 96
        public string ShortSize { get; set; }
......
51 100
        public long Version { get; set; }
52 101
        protected string LocalFileName { get; set; }
53 102
        public BitmapSource FileIcon { get; set; }
103
        public string PublicUrl { get; set; }
54 104

  
55 105
        public string FileName { get; set; }
56 106
        public string Container { get; set; }
57 107

  
108
        public bool TagsChanged { get; private set; }
109
        public bool PermissionsChanged { get; private set; }
110

  
58 111
        public FilePropertiesViewModel(ShellViewModel shell,ObjectInfo pithosFile,string localFileName)
59 112
        {
60 113
            if (shell==null)
......
65 118
                throw new ArgumentNullException("localFileName");
66 119
            Contract.EndContractBlock();
67 120

  
121

  
122
            _tags = new ObservableCollection<Tag>();
123
            _tags.CollectionChanged += (sender, evt) => { TagsChanged = true; };
124
            _permissions = new ObservableCollection<Permission>();
125
            _permissions.CollectionChanged += (sender, evt) => { PermissionsChanged = true; };
126
            
68 127
            Shell = shell;
69 128
            LocalFileName = localFileName;
70 129
            PithosFile = pithosFile;
71 130
            Title = String.Format("{0} Properties", pithosFile.Name);
72 131
        }
73 132

  
133
        
74 134

  
75 135
        protected ShellViewModel Shell { get; set; }
76 136

  
......
103 163
                ModifiedBy = value.ModifiedBy;
104 164
                Version = value.Version??0;
105 165

  
166
                ContentDisposition = value.ContendDisposition;
167
                ContentEncoding = value.ContentEncoding;
168
                Manifest = value.Manifest;
169
                IsPublic = value.IsPublic;
170
                
171
                PublicUrl = String.Format("{0}/v1{1}", Settings.Default.PithosSite ,value.PublicUrl);
172

  
106 173
                using (var icon = Icon.ExtractAssociatedIcon(LocalFileName))
107 174
                {
108 175
                    FileIcon = Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty,
......
113 180
        }
114 181

  
115 182

  
116

  
117
        private readonly ObservableCollection<Tag> _tags = new ObservableCollection<Tag>();
183
        private readonly ObservableCollection<Tag> _tags ;
118 184
        public ObservableCollection<Tag> Tags
119 185
        {
120
            get { return _tags; }
186
            get { return _tags;}
121 187
        }
122 188

  
123
        private readonly ObservableCollection<Permission> _permissions = new ObservableCollection<Permission>();
189
        private readonly ObservableCollection<Permission> _permissions ;
190
        
191

  
124 192
        public ObservableCollection<Permission> Permissions
125 193
        {
126 194
            get { return _permissions; }
......
154 222

  
155 223
        private void DoSave()
156 224
        {
225
            if (TagsChanged)
226
            {
227
                PithosFile.Tags = this.Tags.ToDictionary(tag => tag.Name, tag => tag.Value);
228
            }
157 229
            
230
            if (PermissionsChanged)
231
            {
232
                PithosFile.Permissions = this.Permissions.ToDictionary(perm => perm.UserName, perm => perm.Value);
233
            }
234

  
235
            PithosFile.ContendDisposition = ContentDisposition;
236
            PithosFile.ContentEncoding = ContentEncoding;
237
            PithosFile.Manifest = Manifest;
238
            PithosFile.IsPublic = IsPublic;
239

  
240
            var monitor = Shell.Monitors[PithosFile.Account];
241
            monitor.CloudClient.UpdateMetadata(PithosFile);
242

  
243

  
244
            TagsChanged = false;
245
            PermissionsChanged = false;
158 246
        }
159 247

  
160 248

  

Also available in: Unified diff