* -----------------------------------------------------------------------
*/
#endregion
-using System.Collections;
-using System.Collections.Concurrent;
+
using System.Collections.ObjectModel;
-using System.Collections.Specialized;
using System.ComponentModel.Composition;
-using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Drawing;
using System.IO;
using System.Windows.Media.Imaging;
using Caliburn.Micro;
using Pithos.Client.WPF.FileProperties;
-using Pithos.Client.WPF.Properties;
using Pithos.Core;
using Pithos.Interfaces;
using Pithos.Network;
namespace Pithos.Client.WPF
{
using System;
- using System.Collections.Generic;
using System.Linq;
- using System.Text;
/// <summary>
/// TODO: Update summary.
NotifyOfPropertyChange(()=>SynchStatus);
}
}
-
- private string _permissionName;
- public string PermissionName
- {
- get { return _permissionName; }
- set
- {
- _permissionName = value;
- NotifyOfPropertyChange(()=>PermissionName);
- NotifyOfPropertyChange(() => CanAddPermission);
- }
- }
-
+
private Permission _currentPermission;
public Permission CurrentPermission
{
get { return _currentPermission; }
set
- {
- _currentPermission = value;
- PermissionName = CurrentPermission.UserName;
- PermissionRead = CurrentPermission.Read;
+ {
+ _currentPermission = (value==null)?new Permission() : value.Clone();
+ _currentPermission.PropertyChanged += (o, e) => NotifyOfPropertyChange(() => CanAddPermission);
NotifyOfPropertyChange(()=>CurrentPermission);
- NotifyOfPropertyChange(() => PermissionName);
- }
- }
-
-
- private bool _permissionRead=true;
- public bool PermissionRead
- {
- get { return _permissionRead; }
- set
- {
- _permissionRead = value;
- NotifyOfPropertyChange(()=>PermissionRead);
- NotifyOfPropertyChange(() => PermissionWrite);
- }
- }
-
- public bool PermissionWrite
- {
- get
- {
- return !PermissionRead;
- }
- set
- {
- _permissionRead = !value;
- NotifyOfPropertyChange(() => PermissionRead);
- NotifyOfPropertyChange(()=>PermissionWrite);
+ NotifyOfPropertyChange(() => CanAddPermission);
}
}
public bool CanAddPermission
{
- get { return !String.IsNullOrWhiteSpace(PermissionName); }
+ get { return !String.IsNullOrWhiteSpace(CurrentPermission.UserName); }
}
public void AddPermission()
{
- Permissions.Add(new Permission{Read=PermissionRead,UserName=PermissionName,Write=!PermissionRead});
+ var existingPermission = Permissions.FirstOrDefault(perm => perm.UserName == CurrentPermission.UserName);
+ if (existingPermission==null)
+ Permissions.Add(CurrentPermission.Clone());
+ else
+ {
+ existingPermission.Read = CurrentPermission.Read;
+ }
}
public bool CanAddTag
{
- get { return CurrentTag!=null && !String.IsNullOrWhiteSpace(CurrentTag.Name); }
+ get { return !String.IsNullOrWhiteSpace(CurrentTag.Name); }
}
public void AddTag()
{
- Tags.Add(CurrentTag);
+ var existingTag = Tags.FirstOrDefault(tag => tag.Name == CurrentTag.Name);
+ if (existingTag == null)
+ Tags.Add(CurrentTag.Clone());
+ else
+ {
+ existingTag.Value = CurrentTag.Value;
+ }
}
_permissions = new ObservableCollection<Permission>();
_permissions.CollectionChanged += (sender, evt) => { PermissionsChanged = true; };
+
+ CurrentPermission=new Permission();
+ CurrentTag=new MetaValue();
+
+
Shell = shell;
LocalFileName = localFileName;
+
+ var name=Path.GetFileName(localFileName);
+ DisplayName = String.Format("{0} File Properties", name);
+
pithosFile.ContinueWith(t =>
{
if (t.IsFaulted)
private void ShowError(AggregateException exception)
{
- MessageView view = null;
+ MessageView view;
if (exception.InnerException is RetryException)
view = new MessageView(exception.InnerException as RetryException);
else if (exception.InnerException is WebException)
get { return _currentTag; }
set
{
- _currentTag = value;
+ _currentTag = (value==null)?new MetaValue() : value.Clone();
+ _currentTag.PropertyChanged += (o, e) => NotifyOfPropertyChange(() => CanAddTag);
+
NotifyOfPropertyChange(()=>CurrentTag);
+ NotifyOfPropertyChange(() => CanAddTag);
}
}