Fix incorrect check in Selective Sync that prevented folder changes to propagate...
[pithos-ms-client] / trunk / Pithos.Client.WPF / FileProperties / ContainerPropertiesViewModel.cs
index 1424a16..8a7ffc5 100644 (file)
@@ -45,6 +45,7 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.ComponentModel.Composition;
 using System.Diagnostics.Contracts;
+using System.IO;
 using System.Linq;
 using System.Net;
 using System.Text;
@@ -283,12 +284,42 @@ namespace Pithos.Client.WPF.FileProperties
             items.Apply(collection.Add);
         }
 
+        private MetaValue _currentTag;
+        public MetaValue CurrentTag
+        {
+            get { return _currentTag; }
+            set
+            {
+                _currentTag = (value == null) ? new MetaValue() : value.Clone();
+                _currentTag.PropertyChanged += (o, e) => NotifyOfPropertyChange(() => CanAddTag);
+
+                NotifyOfPropertyChange(() => CurrentTag);
+                NotifyOfPropertyChange(() => CanAddTag);
+            }
+        }
+
         private readonly ObservableCollection<MetaValue> _tags;
         public ObservableCollection<MetaValue> Tags
         {
             get { return _tags; }
         }
 
+        public bool CanAddTag
+        {
+            get { return !String.IsNullOrWhiteSpace(CurrentTag.Name); }
+        }
+
+        public void AddTag()
+        {
+            var existingTag = Tags.FirstOrDefault(tag => tag.Name == CurrentTag.Name);
+            if (existingTag == null)
+                Tags.Add(CurrentTag.Clone());
+            else
+            {
+                existingTag.Value = CurrentTag.Value;
+            }
+        }
+
        /* private readonly ObservableCollection<MetaValue> _policies;
         public ObservableCollection<MetaValue> Policies
         {
@@ -333,10 +364,14 @@ namespace Pithos.Client.WPF.FileProperties
             _tags = new ObservableCollection<MetaValue>();
             _tags.CollectionChanged += (sender, evt) => { TagsChanged = true; };
 
+            CurrentTag=new MetaValue();
             /*_policies = new ObservableCollection<MetaValue>();
             _policies.CollectionChanged += (sender, evt) => { PoliciesChanged = true; };
 */
 
+            var name = Path.GetFileName(localFolderName);
+            DisplayName = String.Format("{0} Container Properties", name);
+
             Shell = shell;
             ContainerName = localFolderName;
             container.ContinueWith(t =>{