From f4a72cb82507039e6b20379c0c7b3e7771a0c8c4 Mon Sep 17 00:00:00 2001 From: pkanavos Date: Fri, 6 Apr 2012 22:48:59 +0300 Subject: [PATCH] Notification changes Fixed the way folders appear in Selective Synch Added form with conflicts --- trunk/Pithos.Client.WPF.Test/NodeTest.cs | 125 ++++++++++++++++++++ .../Pithos.Client.WPF.Test.csproj | 73 ++++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++ trunk/Pithos.Client.WPF.Test/packages.config | 4 + .../Converters/EnumTypeConverter.cs | 59 +++++++++ .../FileProperties/ConflictsView.xaml | 53 +++++++++ .../FileProperties/ConflictsView.xaml.cs | 26 ++++ .../FileProperties/ConflictsViewModel.cs | 123 +++++++++++++++++++ trunk/Pithos.Client.WPF/Pithos.Client.WPF.csproj | 12 ++ trunk/Pithos.Client.WPF/Properties/AssemblyInfo.cs | 6 +- .../SelectiveSynch/DirectoryRecord.cs | 62 +++++++--- .../SelectiveSynch/SelectiveSynchView.xaml | 4 +- .../SelectiveSynch/SelectiveSynchViewModel.cs | 33 +++--- trunk/Pithos.Client.WPF/Shell/AboutViewModel.cs | 2 + trunk/Pithos.Client.WPF/Shell/FeedbackView.xaml | 2 +- trunk/Pithos.Client.WPF/Shell/FeedbackViewModel.cs | 1 + trunk/Pithos.Client.WPF/Shell/ShellView.xaml | 1 + trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs | 22 +++- .../Utils/EnumerableExtensions.cs | 108 +++++++++++++++++ trunk/Pithos.Client.WPF/Utils/Node.cs | 72 +++++++++++ trunk/Pithos.Core/Agents/FileAgent.cs | 18 +-- trunk/Pithos.Core/Agents/Notifier.cs | 47 ++++++++ trunk/Pithos.Core/Agents/Uploader.cs | 79 +++++++------ trunk/Pithos.Core/IStatusNotification.cs | 2 + trunk/Pithos.Core/Pithos.Core.csproj | 1 + trunk/Pithos.Network/RestClient.cs | 2 +- trunk/Pithos.sln | 33 ++++++ trunk/packages/repositories.config | 7 +- 28 files changed, 924 insertions(+), 89 deletions(-) create mode 100644 trunk/Pithos.Client.WPF.Test/NodeTest.cs create mode 100644 trunk/Pithos.Client.WPF.Test/Pithos.Client.WPF.Test.csproj create mode 100644 trunk/Pithos.Client.WPF.Test/Properties/AssemblyInfo.cs create mode 100644 trunk/Pithos.Client.WPF.Test/packages.config create mode 100644 trunk/Pithos.Client.WPF/Converters/EnumTypeConverter.cs create mode 100644 trunk/Pithos.Client.WPF/FileProperties/ConflictsView.xaml create mode 100644 trunk/Pithos.Client.WPF/FileProperties/ConflictsView.xaml.cs create mode 100644 trunk/Pithos.Client.WPF/FileProperties/ConflictsViewModel.cs create mode 100644 trunk/Pithos.Client.WPF/Utils/EnumerableExtensions.cs create mode 100644 trunk/Pithos.Client.WPF/Utils/Node.cs create mode 100644 trunk/Pithos.Core/Agents/Notifier.cs diff --git a/trunk/Pithos.Client.WPF.Test/NodeTest.cs b/trunk/Pithos.Client.WPF.Test/NodeTest.cs new file mode 100644 index 0000000..db834fc --- /dev/null +++ b/trunk/Pithos.Client.WPF.Test/NodeTest.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NUnit.Framework; +using Pithos.Client.WPF.Utils; + +namespace Pithos.Client.WPF.Test +{ + [TestFixture] + class NodeTest + { + [Test] + public void TestIteration() + { + var root = new Node{Path = "Root", + Children = + { + new Node {Path = "Root/Path1", + Children = + { + new Node{Path="Root/Path1/Path11", + Children= + { + new Node{Path="Root/Path1/Path11/Path111", + Children= + { + new Node{Path="Root/Path1/Path11/Path111/File1"} + }} + } + }, + new Node{Path="Root/Path1/File2"} + } + }, + } + }; + Assert.That(root.Count(), Is.EqualTo(6)); + } + + [Test] + public void TestEquals() + { + var target = new Node{Path = "Root", + Children = + { + new Node {Path = "Root/Path1", + Children = + { + new Node{Path="Root/Path1/Path11", + Children= + { + new Node{Path="Root/Path1/Path11/Path111", + Children= + { + new Node{Path="Root/Path1/Path11/Path111/File1"} + }} + } + }, + new Node{Path="Root/Path1/File2"} + } + }, + } + }; + var source= new Node{Path = "Root", + Children = + { + new Node{Path = "Root/Path1", + Children = + { + new Node{Path="Root/Path1/Path11", + Children= + { + new Node{Path="Root/Path1/Path11/Path111", + Children= + { + new Node{Path="Root/Path1/Path11/Path111/File1"} + }} + } + }, + new Node{Path="Root/Path1/File2"} + } + }, + } + }; + Assert.That(source.Equals(target), Is.True); + } + + [Test] + public void TestToTree() + { + var target = new Node{Path = "Root", + Children = + { + new Node{Path = "Root/Path1", + Children = + { + new Node{Path="Root/Path1/File2"}, + new Node{Path="Root/Path1/Path11", + Children= + { + new Node{Path="Root/Path1/Path11/Path111", + Children= + { + new Node{Path="Root/Path1/Path11/Path111/File1"} + }} + } + }, + } + }, + } + }; + var source= new[] + { + Tuple.Create("Root",0), + Tuple.Create("Root/Path1",0), + Tuple.Create("Root/Path1/Path11",0), + Tuple.Create("Root/Path1/Path11/Path111",0), + Tuple.Create("Root/Path1/Path11/Path111/File1",0), + Tuple.Create("Root/Path1/File2",0) + }; + + Assert.That(source.ToTree(s=>s.Item1,s=>s.Item2).First().Equals(target), Is.True); + } + } +} diff --git a/trunk/Pithos.Client.WPF.Test/Pithos.Client.WPF.Test.csproj b/trunk/Pithos.Client.WPF.Test/Pithos.Client.WPF.Test.csproj new file mode 100644 index 0000000..1639c2a --- /dev/null +++ b/trunk/Pithos.Client.WPF.Test/Pithos.Client.WPF.Test.csproj @@ -0,0 +1,73 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {7B5BFE77-FC4D-43B3-84A0-9CB457238951} + Library + Properties + Pithos.Client.WPF.Test + Pithos.Client.WPF.Test + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + ..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll + + + ..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll + + + ..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll + + + + + + + + + + + + + + + + + + + {4D9406A3-50ED-4672-BB97-A0B3EA4946FE} + Pithos.Client.WPF + + + + + \ No newline at end of file diff --git a/trunk/Pithos.Client.WPF.Test/Properties/AssemblyInfo.cs b/trunk/Pithos.Client.WPF.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b47c7c6 --- /dev/null +++ b/trunk/Pithos.Client.WPF.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Pithos.Client.WPF.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP")] +[assembly: AssemblyProduct("Pithos.Client.WPF.Test")] +[assembly: AssemblyCopyright("Copyright © HP 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("75c60907-2488-4b7b-9b03-2e923a17e92a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/trunk/Pithos.Client.WPF.Test/packages.config b/trunk/Pithos.Client.WPF.Test/packages.config new file mode 100644 index 0000000..0c82178 --- /dev/null +++ b/trunk/Pithos.Client.WPF.Test/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/trunk/Pithos.Client.WPF/Converters/EnumTypeConverter.cs b/trunk/Pithos.Client.WPF/Converters/EnumTypeConverter.cs new file mode 100644 index 0000000..ee8ca84 --- /dev/null +++ b/trunk/Pithos.Client.WPF/Converters/EnumTypeConverter.cs @@ -0,0 +1,59 @@ +using System; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Windows.Markup; + +namespace Pithos.Client.WPF.Converters +{ + public class EnumTypeConverter : EnumConverter + { + public EnumTypeConverter(Type enumType) : base(enumType) { } + + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == typeof(string) && value != null) + { + var enumType = value.GetType(); + if (enumType.IsEnum) + return GetDisplayName(value); + } + + return base.ConvertTo(context, culture, value, destinationType); + } + private string GetDisplayName(object enumValue) + { + var displayNameAttribute = EnumType.GetField(enumValue.ToString()) + .GetCustomAttributes(typeof(DescriptionAttribute), false) + .FirstOrDefault() as DescriptionAttribute; + if (displayNameAttribute != null) + return displayNameAttribute.Description; + + return Enum.GetName(EnumType, enumValue); + } + } + + [MarkupExtensionReturnType(typeof(object[]))] + public class EnumValuesExtension : MarkupExtension + { + public EnumValuesExtension() + { + } + + public EnumValuesExtension(Type enumType) + { + EnumType = enumType; + } + + [ConstructorArgument("enumType")] + public Type EnumType { get; set; } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + if (EnumType == null) + throw new ArgumentException("The enum type is not set"); + return Enum.GetValues(EnumType); + } + } + +} diff --git a/trunk/Pithos.Client.WPF/FileProperties/ConflictsView.xaml b/trunk/Pithos.Client.WPF/FileProperties/ConflictsView.xaml new file mode 100644 index 0000000..ee3ddc1 --- /dev/null +++ b/trunk/Pithos.Client.WPF/FileProperties/ConflictsView.xaml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +