-// -----------------------------------------------------------------------
-// <copyright file="FilePropertiesViewModel.cs" company="Microsoft">
-// TODO: Update copyright text.
-// </copyright>
-// -----------------------------------------------------------------------
-
-using System.Collections;
-using System.Collections.Concurrent;
+#region
+/* -----------------------------------------------------------------------
+ * <copyright file="FilePropertiesViewModel.cs" company="GRNet">
+ *
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ * </copyright>
+ * -----------------------------------------------------------------------
+ */
+#endregion
+
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.Net;
using System.Threading.Tasks;
using System.Windows;
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.
}
}
+ private string _synchStatus;
+ public string SynchStatus
+ {
+ get { return _synchStatus; }
+ set
+ {
+ _synchStatus = value;
+ NotifyOfPropertyChange(()=>SynchStatus);
+ }
+ }
+
+ private Permission _currentPermission;
+ public Permission CurrentPermission
+ {
+ get { return _currentPermission; }
+ set
+ {
+ _currentPermission = (value==null)?new Permission() : value.Clone();
+ _currentPermission.PropertyChanged += (o, e) => NotifyOfPropertyChange(() => CanAddPermission);
+
+ NotifyOfPropertyChange(()=>CurrentPermission);
+ NotifyOfPropertyChange(() => CanAddPermission);
+ }
+ }
+
+ public bool CanAddPermission
+ {
+ get { return !String.IsNullOrWhiteSpace(CurrentPermission.UserName); }
+ }
+
+ public void AddPermission()
+ {
+ 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 !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;
+ }
+ }
+
+
public bool TagsChanged { get; private set; }
public bool PermissionsChanged { get; private set; }
_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)
}
else
Execute.OnUIThread(() => PithosFile = t.Result);
- });
+ });
+
}
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)
if (IsPublic)
PublicUrl = String.Format("{0}/v1{1}", Shell.Accounts.First(account=>account.UserName==PithosFile.Account).SiteUri,value.PublicUrl);
- using (var icon = Icon.ExtractAssociatedIcon(LocalFileName))
+ if (Directory.Exists(LocalFileName))
{
- FileIcon = Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty,
- BitmapSizeOptions.FromEmptyOptions());
+ FileIcon= new BitmapImage(new Uri("../Images/Folder.ico",UriKind.Relative));
}
+ else if (File.Exists(LocalFileName))
+ {
+ using (var icon = Icon.ExtractAssociatedIcon(LocalFileName))
+ {
+ FileIcon = Imaging.CreateBitmapSourceFromHIcon(icon.Handle, Int32Rect.Empty,
+ BitmapSizeOptions.FromEmptyOptions());
+ }
+ }
+
+ var status=Shell.GetFileStatus(LocalFileName);
+ SynchStatus = Enum.GetName(typeof (FileStatus), status);
+
+
NotifyOfPropertyChange(()=>PithosFile);
IsBusy = false;
}
}
+ 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
if (PermissionsChanged)
{
- PithosFile.Permissions = this.Permissions.ToDictionary(perm => perm.UserName, perm => perm.Value);
+ PithosFile.Permissions = this.Permissions.ToDictionary(perm => perm.UserName, perm =>
+ (perm.Value.Trim()));
}
PithosFile.ContendDisposition = ContentDisposition;
PithosFile.ContentEncoding = ContentEncoding;
PithosFile.Manifest = Manifest;
PithosFile.IsPublic = IsPublic;
-
- var monitor = Shell.Monitors[PithosFile.Account];
+
+ var monitor = Shell.Monitors[PithosFile.AccountKey];
monitor.CloudClient.UpdateMetadata(PithosFile);