diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config new file mode 100644 index 0000000..67f8ea0 --- /dev/null +++ b/.nuget/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe new file mode 100644 index 0000000..c41a0d0 Binary files /dev/null and b/.nuget/NuGet.exe differ diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets new file mode 100644 index 0000000..3f8c37b --- /dev/null +++ b/.nuget/NuGet.targets @@ -0,0 +1,144 @@ + + + + $(MSBuildProjectDirectory)\..\ + + + false + + + false + + + true + + + false + + + + + + + + + + + $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) + + + + + $(SolutionDir).nuget + + + + $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config + $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config + + + + $(MSBuildProjectDirectory)\packages.config + $(PackagesProjectConfig) + + + + + $(NuGetToolsPath)\NuGet.exe + @(PackageSource) + + "$(NuGetExePath)" + mono --runtime=v4.0.30319 "$(NuGetExePath)" + + $(TargetDir.Trim('\\')) + + -RequireConsent + -NonInteractive + + "$(SolutionDir) " + "$(SolutionDir)" + + + $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) + $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols + + + + RestorePackages; + $(BuildDependsOn); + + + + + $(BuildDependsOn); + BuildPackage; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CloudDriveShell.CloudDriveContent/CloudDriveContentModule.cs b/CloudDriveShell.CloudDriveContent/CloudDriveContentModule.cs new file mode 100644 index 0000000..ee0aa3a --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/CloudDriveContentModule.cs @@ -0,0 +1,14 @@ +using Prism.Modularity; +using Prism.Regions; +using System; +using System.ComponentModel.Composition; +using CloudDriveShell.Infrastructure; +using Prism.Mef.Modularity; + +namespace CloudDriveShell.CloudDriveContent +{ + public class CloudDriveContentModule + { + //This is for mef + } +} \ No newline at end of file diff --git a/CloudDriveShell.CloudDriveContent/CloudDriveShell.CloudDriveContent.csproj b/CloudDriveShell.CloudDriveContent/CloudDriveShell.CloudDriveContent.csproj new file mode 100644 index 0000000..3f0f933 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/CloudDriveShell.CloudDriveContent.csproj @@ -0,0 +1,231 @@ + + + + + Debug + AnyCPU + {B26AB6F9-294F-4E47-B0EC-46922A778C3A} + library + Properties + CloudDriveShell.CloudDriveContent + CloudDriveShell.CloudDriveContent + v4.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + ..\ + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + + + ..\packages\Prism.Core.6.2.0\lib\net45\Prism.dll + True + + + ..\packages\Prism.Mef.6.2.0\lib\net45\Prism.Mef.Wpf.dll + + + ..\packages\Prism.Wpf.6.2.0\lib\net45\Prism.Wpf.dll + True + + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll + + + + + + ..\packages\Prism.Wpf.6.2.0\lib\net45\System.Windows.Interactivity.dll + True + + + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll + + + + + + + 4.0 + + + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll + + + + ..\packages\WpfAnimatedGif.1.4.14\lib\net\WpfAnimatedGif.dll + + + ..\packages\Extended.Wpf.Toolkit.3.0\lib\net40\Xceed.Wpf.Toolkit.dll + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + + CloudDriveContent.xaml + + + CloudDriveExplorer.xaml + + + CloudDriveTransfer.xaml + + + CloudLogsContent.xaml + + + CreateFolderWindow.xaml + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + {0a123c1b-f316-447d-99a5-44ccf8023683} + CloudDriveShell.Infrastructure + + + {fc8a5d35-6b80-4db1-8da5-0271677967e3} + Transitionals + + + {f21eb154-c84e-4390-87cf-271e3df4f059} + WebDAVClient + + + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/CloudDriveShell.CloudDriveContent/NavigateMeta.cs b/CloudDriveShell.CloudDriveContent/NavigateMeta.cs new file mode 100644 index 0000000..a549f90 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/NavigateMeta.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CloudDriveShell.Infrastructure; +using CloudDriveShell.Infrastructure.Interfaces; +using CloudDriveShell.Infrastructure.Models; + +namespace CloudDriveShell.CloudDriveContent +{ + [Export(typeof(INavigateMeta))] + public class NavigateMeta : INavigateMeta + { + public NavigateMenu LoadNavigateMenu() + { + return new NavigateMenu() + { + MenuName = "云盘", + MenuIcon = "Resources/cloud.png", + RegionViewName = RegionNames.CloudDriveContentView, + AssemblyName = GetType().Assembly.FullName, + SortIndex = 1 + }; + } + } +} diff --git a/CloudDriveShell.CloudDriveContent/Properties/AssemblyInfo.cs b/CloudDriveShell.CloudDriveContent/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..45513e0 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Properties/AssemblyInfo.cs @@ -0,0 +1,56 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 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("CloudDriveShell.CloudDriveContent")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CloudDriveShell.CloudDriveContent")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[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)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// 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/CloudDriveShell.CloudDriveContent/Properties/Resources.Designer.cs b/CloudDriveShell.CloudDriveContent/Properties/Resources.Designer.cs new file mode 100644 index 0000000..ef31b23 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CloudDriveShell.CloudDriveContent.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CloudDriveShell.CloudDriveContent.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/CloudDriveShell.CloudDriveContent/Properties/Resources.resx b/CloudDriveShell.CloudDriveContent/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CloudDriveShell.CloudDriveContent/Properties/Settings.Designer.cs b/CloudDriveShell.CloudDriveContent/Properties/Settings.Designer.cs new file mode 100644 index 0000000..5761da4 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace CloudDriveShell.CloudDriveContent.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/CloudDriveShell.CloudDriveContent/Properties/Settings.settings b/CloudDriveShell.CloudDriveContent/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/CloudDriveShell.CloudDriveContent/Resources/AutoScrollListBoxDictionary.xaml b/CloudDriveShell.CloudDriveContent/Resources/AutoScrollListBoxDictionary.xaml new file mode 100644 index 0000000..30167e0 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Resources/AutoScrollListBoxDictionary.xaml @@ -0,0 +1,318 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CloudDriveShell.CloudDriveContent/Resources/back.png b/CloudDriveShell.CloudDriveContent/Resources/back.png new file mode 100644 index 0000000..dd5d109 Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/back.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/cancel.png b/CloudDriveShell.CloudDriveContent/Resources/cancel.png new file mode 100644 index 0000000..86517dd Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/cancel.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/clear.png b/CloudDriveShell.CloudDriveContent/Resources/clear.png new file mode 100644 index 0000000..8c3a317 Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/clear.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/cloud.png b/CloudDriveShell.CloudDriveContent/Resources/cloud.png new file mode 100644 index 0000000..20de5e6 Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/cloud.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/delete.png b/CloudDriveShell.CloudDriveContent/Resources/delete.png new file mode 100644 index 0000000..8c3a317 Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/delete.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/download-status.png b/CloudDriveShell.CloudDriveContent/Resources/download-status.png new file mode 100644 index 0000000..d1b03b7 Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/download-status.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/download.png b/CloudDriveShell.CloudDriveContent/Resources/download.png new file mode 100644 index 0000000..89756d1 Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/download.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/folder.png b/CloudDriveShell.CloudDriveContent/Resources/folder.png new file mode 100644 index 0000000..240061b Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/folder.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/home.png b/CloudDriveShell.CloudDriveContent/Resources/home.png new file mode 100644 index 0000000..9335b4d Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/home.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/link.png b/CloudDriveShell.CloudDriveContent/Resources/link.png new file mode 100644 index 0000000..a94e0af Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/link.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/loading.gif b/CloudDriveShell.CloudDriveContent/Resources/loading.gif new file mode 100644 index 0000000..7e717cd Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/loading.gif differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/logs.png b/CloudDriveShell.CloudDriveContent/Resources/logs.png new file mode 100644 index 0000000..d482d6b Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/logs.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/ls.png b/CloudDriveShell.CloudDriveContent/Resources/ls.png new file mode 100644 index 0000000..652cb7a Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/ls.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/right.png b/CloudDriveShell.CloudDriveContent/Resources/right.png new file mode 100644 index 0000000..217be48 Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/right.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/transfer.png b/CloudDriveShell.CloudDriveContent/Resources/transfer.png new file mode 100644 index 0000000..d858305 Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/transfer.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/upload-status.png b/CloudDriveShell.CloudDriveContent/Resources/upload-status.png new file mode 100644 index 0000000..3b16cc6 Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/upload-status.png differ diff --git a/CloudDriveShell.CloudDriveContent/Resources/upload.png b/CloudDriveShell.CloudDriveContent/Resources/upload.png new file mode 100644 index 0000000..dc8e76e Binary files /dev/null and b/CloudDriveShell.CloudDriveContent/Resources/upload.png differ diff --git a/CloudDriveShell.CloudDriveContent/ViewModels/CloudDriveContentViewModel.cs b/CloudDriveShell.CloudDriveContent/ViewModels/CloudDriveContentViewModel.cs new file mode 100644 index 0000000..0543a84 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/ViewModels/CloudDriveContentViewModel.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using CloudDriveShell.Infrastructure.Models; +using Prism.Mvvm; +using System.Globalization; +using CloudDriveShell.Infrastructure; +using CloudDriveShell.Infrastructure.Interfaces; +using Prism.Events; +using Prism.Regions; +using Microsoft.Practices.ServiceLocation; +using Transitionals; +using Transitionals.Transitions; + +namespace CloudDriveShell.CloudDriveContent.ViewModels +{ + [Export] + class CloudDriveContentViewModel : BindableBase + { + public List LeftMenus { set; get; } + + private LeftMenu _selectedMenu; + public LeftMenu SelectedMenu + { + get { return this._selectedMenu; } + set + { + SetProperty(ref this._selectedMenu, value); + } + } + + public Transition TransitionToUse + { + get + { + return new FadeTransition(); + } + } + + private readonly IRegionManager _regionManager; + + private readonly IEventAggregator _eventAggregator; + + private readonly ISwitchContentService _switchContentService; + + public Action ViewLoadedAction; + + [ImportingConstructor] + public CloudDriveContentViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, ISwitchContentService switchContentService) + { + this._regionManager = regionManager; + this._eventAggregator = eventAggregator; + this._switchContentService = switchContentService; + this.PropertyChanged += CloudDriveContentViewModel_PropertyChanged; + this.ViewLoadedAction = () => + { + this._switchContentService.SwitchContentView(RegionNames.ActionCloudDriveRightRegion, this.SelectedMenu.ViewName); + this.ViewLoadedAction = () => { }; + }; + this.LeftMenus = new List() + { + new LeftMenu("我的云盘", string.Format("/{0};component/Resources/{1}", GetType().Assembly.FullName, "folder.png"),RegionNames.CloudDriveExplorerView), + new LeftMenu("操作日志",string.Format("/{0};component/Resources/{1}", GetType().Assembly.FullName, "logs.png"),RegionNames.CloudDriveLogsView), + }; + this.SelectedMenu = LeftMenus.First(); + } + + void CloudDriveContentViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + if (e.PropertyName == "SelectedMenu") + { + this._switchContentService.SwitchContentView(RegionNames.ActionCloudDriveRightRegion, this.SelectedMenu.ViewName); + } + } + + + } +} diff --git a/CloudDriveShell.CloudDriveContent/ViewModels/CloudDriveExplorerViewModel.cs b/CloudDriveShell.CloudDriveContent/ViewModels/CloudDriveExplorerViewModel.cs new file mode 100644 index 0000000..00194c6 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/ViewModels/CloudDriveExplorerViewModel.cs @@ -0,0 +1,849 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.ComponentModel.Composition; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CloudDriveShell.Infrastructure.Interfaces; +using CloudDriveShell.Infrastructure.Models; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; +using Prism.Regions; +using System.Net; +using System.Net.Mime; +using Microsoft.Practices.ServiceLocation; +using System.Windows; +using System.Windows.Data; +using System.Windows.Forms; +using System.Windows.Input; +using CloudDriveShell.Infrastructure; +using CloudDriveShell.Infrastructure.Utils; +using CloudDriveShell.Infrastructure.Views; +using Application = System.Windows.Application; +using OpenFileDialog = Microsoft.Win32.OpenFileDialog; + +namespace CloudDriveShell.CloudDriveContent.ViewModels +{ + [Export] + class CloudDriveExplorerViewModel : BindableBase + { + private bool _isAllSelected; + public bool IsAllSelected + { + get { return this._isAllSelected; } + set + { + SetProperty(ref this._isAllSelected, value); + } + } + + private string _messageInfo; + public string MessageInfo + { + get { return this._messageInfo; } + set + { + SetProperty(ref this._messageInfo, value); + } + } + + private string _messageExtensionInfo; + public string MessageExtensionInfo + { + get { return this._messageExtensionInfo; } + set + { + SetProperty(ref this._messageExtensionInfo, value); + } + } + + private string _messageExtensionInfoTooltip; + public string MessageExtensionInfoTooltip + { + get { return this._messageExtensionInfoTooltip; } + set + { + SetProperty(ref this._messageExtensionInfoTooltip, value); + } + } + + private bool _hasRunningTransfers; + public bool HasRunningTransfers + { + get { return this._hasRunningTransfers; } + set + { + SetProperty(ref this._hasRunningTransfers, value); + } + } + + private int _transfersProgress; + public int TransfersProgress + { + get { return this._transfersProgress; } + set + { + SetProperty(ref this._transfersProgress, value); + } + } + + + private ResourceItem _currentSelectResourceItem; + public ResourceItem CurrentSelectResourceItem + { + get { return this._currentSelectResourceItem; } + set + { + SetProperty(ref this._currentSelectResourceItem, value); + } + } + + + private ResourceItem _currentNavigateResourceItem; + + public ResourceItem CurrentNavigateResourceItem + { + get { return this._currentNavigateResourceItem; } + set + { + SetProperty(ref this._currentNavigateResourceItem, value); + } + } + + + private ResourceItem _lastRenameResourceItem; + public ResourceItem LastRenameResourceItem + { + get { return this._lastRenameResourceItem; } + set + { + SetProperty(ref this._lastRenameResourceItem, value); + } + } + + + private ObservableCollection _lastCutOrCopyResourceItems; + + public ObservableCollection LastCutOrCopyResourceItems + { + get { return this._lastCutOrCopyResourceItems; } + set + { + SetProperty(ref this._lastCutOrCopyResourceItems, value); + } + } + + public bool IsMouseRightClick = false; + + private CutOrCopyEnum _cutOrCopyStatus = CutOrCopyEnum.None; + + public ObservableCollection CurrentPathList { get; set; } + + public ObservableCollection ResourceItems { get; set; } + + public DelegateCommand ResourceEditCommand { get; private set; } + public DelegateCommand ResouceHomeCommand { get; private set; } + public DelegateCommand ResourceRefreshCommand { get; private set; } + public DelegateCommand ResouceOpenCommand { get; private set; } + public DelegateCommand ResourceCreateCommand { get; private set; } + public DelegateCommand ResourceUploadCommand { get; private set; } + public DelegateCommand ResourceCopyCommand { get; private set; } + public DelegateCommand ResourceCutCommand { get; private set; } + public DelegateCommand ResourcePasteCommand { get; private set; } + public DelegateCommand ResourceRenameCommand { get; private set; } + public DelegateCommand TransferListViewCommand { get; private set; } + public DelegateCommand DeleteSelectedCommand { get; private set; } + public DelegateCommand DownloadSelectedCommand { get; private set; } + public DelegateCommand UploadSelectedCommand { get; private set; } + + public DelegateCommand ResouceNavigateCommand { get; private set; } + + + + public Action DropUploadCallbackAction; + + public Action RenameCallbackAction; + + public Action ResourceItemClickAction; + + private readonly IEventAggregator _eventAggregator; + + private readonly IWebDavClientService _webDavClientService; + + private readonly ISwitchContentService _switchContentService; + + [ImportingConstructor] + public CloudDriveExplorerViewModel(IEventAggregator eventAggregator, + IWebDavClientService webDavClientService, ISwitchContentService switchContentService) + { + this._eventAggregator = eventAggregator; + this._webDavClientService = webDavClientService; + this._switchContentService = switchContentService; + + this.ResouceNavigateCommand = new DelegateCommand(this.ResouceNavigate, this.CanResouceNavigate); + this.ResourceEditCommand = new DelegateCommand(this.ResouceEdit, this.CanResouceEdit); + this.ResouceHomeCommand = new DelegateCommand(this.ResouceHome, this.CanResouceHome); + this.ResouceOpenCommand = new DelegateCommand(this.ResouceOpen, this.CanResouceOpen); + this.ResourceCreateCommand = new DelegateCommand(this.ResouceCreate, this.CanResouceCreate); + this.ResourceUploadCommand = new DelegateCommand(this.ResouceUpload, this.CanResouceUpload); + this.ResourceCopyCommand = new DelegateCommand(this.ResouceCopy, this.CanResouceCopy); + this.ResourceCutCommand = new DelegateCommand(this.ResouceCut, this.CanResouceCut); + this.ResourcePasteCommand = new DelegateCommand(this.ResoucePaste, this.CanResoucePaste); + this.ResourceRenameCommand = new DelegateCommand(this.ResouceRename, this.CanResouceRename); + this.ResourceRefreshCommand = new DelegateCommand(this.ResouceRefresh, this.CanResouceRefresh); + this.DeleteSelectedCommand = new DelegateCommand(this.DeleteSelected, this.CanDeleteSelected); + this.DownloadSelectedCommand = new DelegateCommand(this.DownloadSelected, this.CanDownloadSelected); + this.UploadSelectedCommand = new DelegateCommand(this.UploadSelected, this.CanUploadSelected); + this.TransferListViewCommand = new DelegateCommand(this.TransferList, this.CanTransferList); + + this.PropertyChanged += OnPropertyChanged; + this.RenameCallbackAction = RenameCallbackFunction; + this.ResourceItemClickAction = ResourceItemClickFunction; + this.DropUploadCallbackAction = DropUploadCallbackFunction; + + this.ResourceItems = new ObservableCollection(); + this.CurrentPathList = new ObservableCollection(); + this.LastCutOrCopyResourceItems = new ObservableCollection(); + this.LastCutOrCopyResourceItems.CollectionChanged += LastCutOrCopyResourceItems_CollectionChanged; + this._eventAggregator.GetEvent().Subscribe(path => + { + if (path == null) + path = this.CurrentNavigateResourceItem != null ? this.CurrentNavigateResourceItem.ItemHref : WebDavConstant.RootPath; + this.RefreshCurrentResource(path); + }); + this._eventAggregator.GetEvent().Subscribe(files => + { + if (files != null) + this.DropUploadCallbackFunction(files); + }); + this._eventAggregator.GetEvent().Subscribe(() => + { + //Ctrl V Just Need Current Folder + this.ResoucePasteAction(true); + }); + this._eventAggregator.GetEvent().Subscribe(process => + { + this.TransfersProgress = process; + this.HasRunningTransfers = process < 100; + if (!this.HasRunningTransfers) + this.RefreshCurrentResource(); + }); + this._eventAggregator.GetEvent().Subscribe((message) => + { + this.NotifyMessageInfo(string.Format("操作异常:{0}", message)); + }); + this._eventAggregator.GetEvent().Subscribe(CreateFolderCallback); + this.RefreshCurrentResource(); + } + + + #region PropertyChanged + private void OnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) + { + if (propertyChangedEventArgs.PropertyName == "IsAllSelected") + { + foreach (var resourceItem in ResourceItems) + { + resourceItem.IsSelected = this.IsAllSelected; + } + RaiseAllCanExecuteChanged(); + } + + if (propertyChangedEventArgs.PropertyName == "CurrentSelectResourceItem") + { + if (this.CurrentSelectResourceItem == null) + { + foreach (var resourceItem in this.ResourceItems) + { + if (resourceItem.IsEdit) + resourceItem.IsEdit = false; + if (resourceItem.IsSelected) + resourceItem.IsSelected = false; + } + } + + RaiseAllCanExecuteChanged(); + } + } + + + void resourceItem_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == "IsSelected") + { + RaiseAllCanExecuteChanged(); + } + } + + void LastCutOrCopyResourceItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + foreach (var resourceItem in this.ResourceItems) + { + resourceItem.IsCopyOrCut = this.LastCutOrCopyResourceItems.Any(cutOrCopyItem => cutOrCopyItem.ItemHref == resourceItem.ItemHref); + } + } + + #endregion + + #region Method + + private void RaiseAllCanExecuteChanged() + { + this.ResourceEditCommand.RaiseCanExecuteChanged(); + this.ResouceNavigateCommand.RaiseCanExecuteChanged(); + this.ResouceHomeCommand.RaiseCanExecuteChanged(); + this.ResouceOpenCommand.RaiseCanExecuteChanged(); + this.ResourceCreateCommand.RaiseCanExecuteChanged(); + this.ResourceUploadCommand.RaiseCanExecuteChanged(); + this.ResourceCopyCommand.RaiseCanExecuteChanged(); + this.ResourceCutCommand.RaiseCanExecuteChanged(); + this.ResourcePasteCommand.RaiseCanExecuteChanged(); + this.ResourceRenameCommand.RaiseCanExecuteChanged(); + this.ResourceRefreshCommand.RaiseCanExecuteChanged(); + this.DeleteSelectedCommand.RaiseCanExecuteChanged(); + this.DownloadSelectedCommand.RaiseCanExecuteChanged(); + this.UploadSelectedCommand.RaiseCanExecuteChanged(); + this.TransferListViewCommand.RaiseCanExecuteChanged(); + } + + + private void ResourceItemClickFunction(bool isCtrl, bool isRight, ResourceItem clickedResourceItem) + { + var preSelectResourceItem = this.CurrentSelectResourceItem; + if (isCtrl) + { + clickedResourceItem.IsSelected = !clickedResourceItem.IsSelected; + } + else + { + if (isRight) + { + if (preSelectResourceItem != clickedResourceItem) + { + clickedResourceItem.IsSelected = true; + } + } + else + { + foreach (var resourceItem in this.ResourceItems) + { + resourceItem.IsSelected = resourceItem == clickedResourceItem; + } + } + } + } + + + + private void RefreshCurrentResource() + { + var path = this.CurrentNavigateResourceItem != null ? this.CurrentNavigateResourceItem.ItemHref : WebDavConstant.RootPath; + RefreshCurrentResource(path); + } + + private async void RefreshCurrentResource(string itemHref) + { + this.NotifyMessageInfo("正在刷新文件夹,请稍后..."); + this.IsAllSelected = false; + this.CurrentSelectResourceItem = null; + if (itemHref == null) + { + this.CurrentNavigateResourceItem = null; + var resourceItems = await this._webDavClientService.GetList(WebDavConstant.RootPath); + this.ResourceItems.Clear(); + resourceItems.ForEach(this.ResourceItems.Add); + foreach (var resourceItem in this.ResourceItems) + { + resourceItem.PropertyChanged += resourceItem_PropertyChanged; + } + this.CurrentPathList.Clear(); + } + else + { + this.CurrentNavigateResourceItem = await this._webDavClientService.GetFolder(itemHref); + var resourceItems = await this._webDavClientService.GetList(itemHref); + this.ResourceItems.Clear(); + resourceItems.ForEach(this.ResourceItems.Add); + foreach (var resourceItem in this.ResourceItems) + { + resourceItem.PropertyChanged += resourceItem_PropertyChanged; + } + this.CurrentPathList.Clear(); + + var pathArray = itemHref.Split('/'); + var pathList = new List(); + for (int i = 0; i < pathArray.Length; i++) + { + var pathStr = string.Empty; + for (int j = 0; j < i; j++) + { + pathStr += pathArray[j] + "/"; + } + pathList.Add(pathStr); + } + + var index = pathList.IndexOf(WebDavConstant.RootPath); + pathList.Skip(index + 1).ToList().ForEach(this.CurrentPathList.Add); + } + + //For Update IsCopyOrCut Status + foreach (var resourceItem in this.ResourceItems) + { + resourceItem.IsCopyOrCut = this.LastCutOrCopyResourceItems.Any(cutOrCopyItem => cutOrCopyItem.ItemHref == resourceItem.ItemHref); + } + + NotifyMessageInfo(string.Empty); + RaiseAllCanExecuteChanged(); + } + + + private void NotifyMessageInfo(string actionInfo) + { + this.MessageInfo = string.Format("{0}个文件夹,{1}个文件 {2}", + this.ResourceItems.Count(item => item.IsFolder), + this.ResourceItems.Count(item => !item.IsFolder), + actionInfo); + } + + private async void RenameCallbackFunction(ResourceItem item) + { + if (this.LastRenameResourceItem != null && item != null) + { + var lastItem = this.LastRenameResourceItem; + item.IsEdit = false; + if (lastItem.ItemName != item.ItemName && !string.IsNullOrEmpty(item.ItemName.Trim())) + { + if (this.ResourceItems.Where(resourceItem => resourceItem != item).All(resourceItem => resourceItem.ItemName != item.ItemName)) + { + var oldHref = WebUtility.UrlDecode(lastItem.ItemHref); + var newHref = WebUtility.UrlDecode(string.Format("{0}/{1}/", item.ItemHref.TrimEnd('/').Substring(0, item.ItemHref.TrimEnd('/').LastIndexOf('/')), item.ItemName.Trim())); + this.NotifyMessageInfo("正在重命名文件,请稍后..."); + await this._webDavClientService.RenameItem(item, oldHref, newHref); + } + else + { + var dialogView = ServiceLocator.Current.GetInstance(RegionNames.DialogWindowView); + dialogView.ShowDialog(DialogEnum.Ok, "提示", "指定文件夹中已存在同名文件(夹)!"); + } + } + } + this.LastRenameResourceItem = null; + RefreshCurrentResource(); + } + + private void DropUploadCallbackFunction(string[] files) + { + if (files.Length == 0) return; + var view = ServiceLocator.Current.GetInstance(RegionNames.CloudDriveTransferView); + if (view == null) return; + this.NotifyMessageInfo("正在上传文件,请稍后..."); + this._eventAggregator.GetEvent>().Publish(new TransferActionInfo() + { + UploadFileList = files, + TargetPath = this.CurrentNavigateResourceItem == null ? WebDavConstant.RootPath : WebUtility.UrlDecode(this.CurrentNavigateResourceItem.ItemHref), + WorkingType = WorkingTypeEnum.Upload + }); + //TransferList(); + } + #endregion + + #region CommandMethod + + + private bool CanResouceRefresh() + { + return true; + } + + private void ResouceRefresh() + { + this.RefreshCurrentResource(); + } + + + private void ResouceEdit() + { + if (this.CurrentSelectResourceItem == null || this.CurrentSelectResourceItem.IsFolder) return; + var tempFolder = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetRandomFileName()); + if (!System.IO.Directory.Exists(tempFolder)) + System.IO.Directory.CreateDirectory(tempFolder); + var view = ServiceLocator.Current.GetInstance(RegionNames.CloudDriveTransferView); + if (view == null) return; + this.NotifyMessageInfo("正在下载文件,请稍后..."); + this._eventAggregator.GetEvent>().Publish(new EditorActionInfo() + { + DownloadFile = this.CurrentSelectResourceItem, + TargetPath = tempFolder, + }); + //TransferList(); + } + + private bool CanResouceEdit() + { + return this.CurrentSelectResourceItem != null && !this.CurrentSelectResourceItem.IsFolder; + } + + private bool CanResouceNavigate(object arg) + { + return true; + } + + private void ResouceNavigate(object obj) + { + if (obj == null) return; + if (obj is string) + { + RefreshCurrentResource(obj.ToString()); + } + else if (obj is ResourceItem) + { + var resourceItem = (ResourceItem)obj; + if (resourceItem.IsFolder && !resourceItem.IsEdit) + { + RefreshCurrentResource(resourceItem.ItemHref); + } + } + } + + private void ResouceHome() + { + this.CurrentNavigateResourceItem = this.CurrentSelectResourceItem = null; + RefreshCurrentResource(); + } + + private bool CanResouceHome() + { + return true; + } + + private bool CanResouceOpen() + { + return this.CurrentSelectResourceItem != null && this.CurrentSelectResourceItem.IsFolder; + } + + private void ResouceOpen() + { + if (this.CurrentSelectResourceItem != null && this.CurrentSelectResourceItem.IsFolder && !this.CurrentSelectResourceItem.IsEdit) + { + this.CurrentNavigateResourceItem = this.CurrentSelectResourceItem; + RefreshCurrentResource(); + } + if (this.CurrentSelectResourceItem != null && !this.CurrentSelectResourceItem.IsFolder && !this.CurrentSelectResourceItem.IsEdit) + { + ResouceEdit(); + } + } + + private bool CanResouceCreate() + { + return this.CurrentSelectResourceItem == null; + } + + private void ResouceCreate() + { + var view = ServiceLocator.Current.GetInstance(RegionNames.CloudDriveCreateFolderView) as Window; + if (view == null) return; + view.Owner = Application.Current.MainWindow; + view.ShowDialog(); + } + + private async void CreateFolderCallback(string folderName) + { + if (string.IsNullOrEmpty(folderName)) return; + ResourceItem targetFolder = this.CurrentNavigateResourceItem; + this.NotifyMessageInfo("正在创建文件夹,请稍后..."); + await this._webDavClientService.CreateDir(WebUtility.UrlDecode(targetFolder == null ? WebDavConstant.RootPath : targetFolder.ItemHref), WebUtility.UrlDecode(folderName)); + RefreshCurrentResource(); + } + + + private bool CanResouceUpload() + { + return this.CurrentSelectResourceItem == null || this.CurrentSelectResourceItem.IsFolder; + } + + private void ResouceUpload() + { + var view = ServiceLocator.Current.GetInstance(RegionNames.CloudDriveTransferView); + if (view == null) return; + OpenFileDialog openFileDialog = new OpenFileDialog + { + Multiselect = true, + Filter = "All files (*.*)|*.*", + InitialDirectory = KnownFolders.GetPath(KnownFolder.Downloads) + }; + if (openFileDialog.ShowDialog() == true) + { + var targetResource = this.CurrentSelectResourceItem == null ? this.CurrentNavigateResourceItem : ( + this.CurrentSelectResourceItem.IsFolder ? this.CurrentSelectResourceItem : this.CurrentNavigateResourceItem + ); + this.NotifyMessageInfo("正在上传文件,请稍后..."); + this._eventAggregator.GetEvent>().Publish(new TransferActionInfo() + { + UploadFileList = openFileDialog.FileNames, + TargetPath = targetResource == null ? WebDavConstant.RootPath : WebUtility.UrlDecode(targetResource.ItemHref), + WorkingType = WorkingTypeEnum.Upload + }); + //TransferList(); + } + } + + + private bool CanResouceRename() + { + return this.CurrentSelectResourceItem != null; + } + + private void ResouceRename() + { + if (this.CurrentSelectResourceItem != null) + { + this.LastRenameResourceItem = this.CurrentSelectResourceItem.CloneJson(); + this.CurrentSelectResourceItem.IsEdit = true; + } + } + + private bool CanResoucePaste() + { + return this._cutOrCopyStatus != CutOrCopyEnum.None + && this.LastCutOrCopyResourceItems.Any() + && (this.CurrentSelectResourceItem == null || this.CurrentSelectResourceItem.IsFolder); + } + + private void ResoucePaste() + { + //Right ContextMenu Has Selected Folder + ResoucePasteAction(false); + } + + private async void ResoucePasteAction(bool isCtrlV) + { + ResourceItem targetFolderResourceItem; + if (isCtrlV) + { + targetFolderResourceItem = this.CurrentNavigateResourceItem; + } + else + { + if (this.CurrentSelectResourceItem == null) + { + targetFolderResourceItem = this.CurrentNavigateResourceItem; + } + else + { + targetFolderResourceItem = this.CurrentSelectResourceItem.IsFolder ? this.CurrentSelectResourceItem : this.CurrentNavigateResourceItem; + } + } + foreach (var lastItem in this.LastCutOrCopyResourceItems) + { + var oldHref = WebUtility.UrlDecode(lastItem.ItemHref).TrimEnd('/'); + string newHref; + if (targetFolderResourceItem == null) + { + newHref = WebUtility.UrlDecode(string.Format("{0}/{1}/", WebDavConstant.RootPath.TrimEnd('/'), lastItem.ItemName)).TrimEnd('/'); + } + else + { + if (targetFolderResourceItem.IsFolder) + { + newHref = WebUtility.UrlDecode(string.Format("{0}/{1}/", targetFolderResourceItem.ItemHref.TrimEnd('/'), + lastItem.ItemName)).TrimEnd('/'); + } + else + { + newHref = WebUtility.UrlDecode(string.Format("{0}/{1}/", targetFolderResourceItem.ParentHref.TrimEnd('/'), + lastItem.ItemName)).TrimEnd('/'); + } + } + if (oldHref != newHref) + { + var isExistSameNameItem = this.ResourceItems.All(item => item.ItemName != lastItem.ItemName); + if (this.CurrentNavigateResourceItem != targetFolderResourceItem) + { + var selectedFolderItemList = await this._webDavClientService.GetList(targetFolderResourceItem == null ? WebDavConstant.RootPath : targetFolderResourceItem.ItemHref); + isExistSameNameItem = selectedFolderItemList.All(item => item.ItemName != lastItem.ItemName); + } + if (isExistSameNameItem) + { + if (lastItem.IsFolder && string.Format("{0}/", newHref).IndexOf(string.Format("{0}/", oldHref), StringComparison.CurrentCulture) == 0) + { + var dialogView = ServiceLocator.Current.GetInstance(RegionNames.DialogWindowView); + dialogView.ShowDialog(DialogEnum.Ok, "提示", "指定文件夹是移动/复制文件夹的子文件夹!"); + } + else + { + if (this._cutOrCopyStatus == CutOrCopyEnum.Cut) + { + this.NotifyMessageInfo(string.Format("正在移动资源:[{0}],请稍后...", lastItem.ItemName)); + await this._webDavClientService.MoveItem(lastItem, oldHref, newHref); + } + if (this._cutOrCopyStatus == CutOrCopyEnum.Copy) + { + this.NotifyMessageInfo(string.Format("正在复制资源:[{0}],请稍后...", lastItem.ItemName)); + await this._webDavClientService.CopyItem(lastItem, oldHref, newHref); + } + } + } + else + { + var dialogView = ServiceLocator.Current.GetInstance(RegionNames.DialogWindowView); + dialogView.ShowDialog(DialogEnum.Ok, "提示", string.Format("指定文件夹中已存在同名文件{0}:[{1}]!", + lastItem.IsFolder ? "夹" : "", lastItem.ItemName)); + } + } + else + { + var dialogView = ServiceLocator.Current.GetInstance(RegionNames.DialogWindowView); + dialogView.ShowDialog(DialogEnum.Ok, "提示", string.Format("不能{0}文件{1}:[{2}]至原目录!", + this._cutOrCopyStatus == CutOrCopyEnum.Cut ? "移动" : "复制", lastItem.IsFolder ? "夹" : "", lastItem.ItemName)); + } + } + this._cutOrCopyStatus = CutOrCopyEnum.None; + this.MessageExtensionInfo = string.Empty; + this.MessageExtensionInfoTooltip = string.Empty; + this.LastCutOrCopyResourceItems.Clear(); + RefreshCurrentResource(); + } + + private bool CanResouceCut() + { + return this.ResourceItems.Any(item => item.IsSelected); + } + + private void ResouceCut() + { + this.LastCutOrCopyResourceItems.Clear(); + this.MessageExtensionInfo = this.MessageExtensionInfoTooltip = string.Empty; + if (ResourceItems.Any(item => item.IsSelected)) + { + var tootipInfo = new StringBuilder(); + foreach (var resourceItem in this.ResourceItems) + { + if (resourceItem.IsSelected) + { + this.LastCutOrCopyResourceItems.Add(resourceItem.CloneJson()); + resourceItem.IsSelected = false; + tootipInfo.AppendLine(resourceItem.ItemName); + } + } + this._cutOrCopyStatus = CutOrCopyEnum.Cut; + System.Windows.Forms.Clipboard.SetData(CommonConstant.ClipboardCopyResourceItemsDataFormats, "移动"); + this.MessageExtensionInfo = string.Format("选定{0}个移动的资源", this.LastCutOrCopyResourceItems.Count); + this.MessageExtensionInfoTooltip = tootipInfo.ToString().TrimEnd(Environment.NewLine.ToCharArray()); + } + } + + private bool CanResouceCopy() + { + return this.ResourceItems.Any(item => item.IsSelected); + } + + private void ResouceCopy() + { + this.LastCutOrCopyResourceItems.Clear(); + this.MessageExtensionInfo = this.MessageExtensionInfoTooltip = string.Empty; + if (ResourceItems.Any(item => item.IsSelected)) + { + var tootipInfo = new StringBuilder(); + foreach (var resourceItem in this.ResourceItems) + { + if (resourceItem.IsSelected) + { + this.LastCutOrCopyResourceItems.Add(resourceItem.CloneJson()); + resourceItem.IsSelected = false; + tootipInfo.AppendLine(resourceItem.ItemName); + } + } + this._cutOrCopyStatus = CutOrCopyEnum.Copy; + System.Windows.Forms.Clipboard.SetData(CommonConstant.ClipboardCopyResourceItemsDataFormats, "复制"); + this.MessageExtensionInfo = string.Format("选定{0}个复制的资源", this.LastCutOrCopyResourceItems.Count); + this.MessageExtensionInfoTooltip = tootipInfo.ToString().TrimEnd(Environment.NewLine.ToCharArray()); + } + } + + private bool CanTransferList() + { + return true; + } + + private void TransferList() + { + this._switchContentService.SwitchContentView(RegionNames.ActionCloudDriveRightRegion, RegionNames.CloudDriveTransferView); + } + + + private async void DeleteSelected() + { + var dialogView = ServiceLocator.Current.GetInstance(RegionNames.DialogWindowView); + if (!dialogView.ShowDialog(DialogEnum.OkOrCanel, "请确认", + string.Format("是否删除选定资源({0}个)?", this.ResourceItems.Count(item => item.IsSelected)))) return; + this.NotifyMessageInfo("正在删除文件(夹),请稍后..."); + foreach (var resourceItem in this.ResourceItems) + { + if (resourceItem.IsSelected) + await this._webDavClientService.DeleteItem(resourceItem); + } + RefreshCurrentResource(); + } + + private bool CanDeleteSelected() + { + return this.ResourceItems.Any(item => item.IsSelected); + } + + private bool CanUploadSelected() + { + return true; + } + + private void UploadSelected() + { + this.ResouceUpload(); + } + + private bool CanDownloadSelected() + { + return this.ResourceItems.Any(item => item.IsSelected && !item.IsFolder); + } + + private void DownloadSelected() + { + var view = ServiceLocator.Current.GetInstance(RegionNames.CloudDriveTransferView); + if (view == null) return; + FolderBrowserDialog openBrowserDialog = new FolderBrowserDialog { ShowNewFolderButton = true, SelectedPath = KnownFolders.GetPath(KnownFolder.Downloads) }; + DialogResult result = openBrowserDialog.ShowDialog(); + if (result == DialogResult.OK) + { + this.NotifyMessageInfo("正在下载文件,请稍后..."); + var downloadItems = ResourceItems.Where(resourceItem => resourceItem.IsSelected && !resourceItem.IsFolder).ToList(); + this._eventAggregator.GetEvent>().Publish(new TransferActionInfo() + { + DownloadFileList = downloadItems, + TargetPath = openBrowserDialog.SelectedPath, + WorkingType = WorkingTypeEnum.Download + }); + //TransferList(); + } + } + + #endregion + + } + public class RefreshEvent : PubSubEvent + { + } + + public class TransferStatusEvent : PubSubEvent + { + } + + enum CutOrCopyEnum + { + None, + Cut, + Copy + } +} diff --git a/CloudDriveShell.CloudDriveContent/ViewModels/CloudDriveTransferViewModel.cs b/CloudDriveShell.CloudDriveContent/ViewModels/CloudDriveTransferViewModel.cs new file mode 100644 index 0000000..9c6f00d --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/ViewModels/CloudDriveTransferViewModel.cs @@ -0,0 +1,297 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.Composition; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CloudDriveShell.Infrastructure; +using CloudDriveShell.Infrastructure.Interfaces; +using CloudDriveShell.Infrastructure.Models; +using CloudDriveShell.Infrastructure.Utils; +using CloudDriveShell.Infrastructure.Views; +using Microsoft.Practices.ServiceLocation; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; + +namespace CloudDriveShell.CloudDriveContent.ViewModels +{ + [Export] + class CloudDriveTransferViewModel : BindableBase + { + private int _currentRunningTransferCount; + + public ObservableCollection TransferInfos { get; set; } + + private readonly IEventAggregator _eventAggregator; + + private readonly IWebDavClientService _webDavClientService; + + private readonly ITransferDataService _transferDataService; + + private readonly ISwitchContentService _switchContentService; + + public DelegateCommand BackCommand { get; private set; } + public DelegateCommand ClearCommand { get; private set; } + public DelegateCommand CancelAllCommand { get; private set; } + public DelegateCommand CancelTransferCommand { get; private set; } + public DelegateCommand NavigateItemCommand { get; private set; } + + [ImportingConstructor] + public CloudDriveTransferViewModel(IEventAggregator eventAggregator, + IWebDavClientService webDavClientService, ISwitchContentService switchContentService + , ITransferDataService transferDataService) + { + this._eventAggregator = eventAggregator; + this._webDavClientService = webDavClientService; + this._switchContentService = switchContentService; + this._transferDataService = transferDataService; + + this.TransferInfos = new ObservableCollection(this._transferDataService.RetriveHistory()); + + this.BackCommand = new DelegateCommand(this.Back, this.CanBack); + this.ClearCommand = new DelegateCommand(this.Clear, this.CanClear); + this.CancelAllCommand = new DelegateCommand(this.CancelAll, this.CanCancelAll); + this.NavigateItemCommand = new DelegateCommand(this.NavigateItem, this.CanNavigateItem); + this.CancelTransferCommand = new DelegateCommand(this.CancelTransfer, this.CanCancelTransfer); + this._eventAggregator.GetEvent>().Subscribe(UploadOrDownloadAction); + this._eventAggregator.GetEvent>().Subscribe(EditorAction); + this._eventAggregator.GetEvent().Subscribe(SaveTransferInfos, ThreadOption.UIThread); + } + + private void ComputeTransferProcess() + { + if (_currentRunningTransferCount == 0) + { + this._eventAggregator.GetEvent().Publish(100); + } + else + { + var nowWokingCount = this.TransferInfos.Count(t => t.StartWorking); + var currentProgress = 100 - nowWokingCount * 100 / _currentRunningTransferCount; + if (nowWokingCount == 0) currentProgress = 100; + this._eventAggregator.GetEvent().Publish(currentProgress); + } + + } + + private bool CanCancelAll() + { + return true; + } + + private void CancelAll() + { + var dialogView = ServiceLocator.Current.GetInstance(RegionNames.DialogWindowView); + if (!dialogView.ShowDialog(DialogEnum.OkOrCanel, "请确认", "是否取消所有任务?")) return; + foreach (var transferInfo in TransferInfos) + CancelTransfer(transferInfo); + } + + private void CancelTransfer(TransferInfo transferInfo) + { + var tasker = transferInfo.GeTasker(); + if (tasker == null || !transferInfo.StartWorking) return; + transferInfo.IsFailed = true; + transferInfo.StartWorking = false; + transferInfo.FailedInfo = "操作被取消"; + tasker.Cancel(); + } + + private bool CanCancelTransfer(TransferInfo transferInfo) + { + return transferInfo.StartWorking; + } + + + private void SaveTransferInfos(System.ComponentModel.CancelEventArgs obj) + { + this._transferDataService.SaveHistory(this.TransferInfos.ToList()); + } + + private void UploadOrDownloadAction(TransferActionInfo transferActionInfo) + { + if (transferActionInfo.WorkingType == WorkingTypeEnum.Upload) + { + foreach (var fileFullPath in transferActionInfo.UploadFileList) + { + var transferInfo = new TransferInfo() + { + FileName = Path.GetFileName(fileFullPath), + FileSize = new FileInfo(fileFullPath).Length, + FileLocalPath = fileFullPath, + FileCloudPath = transferActionInfo.TargetPath, + FinishSize = 0, + ProgressPercentage = 0, + StartWorking = false, + TransferTime = DateTime.Now, + WorkingType = transferActionInfo.WorkingType + }; + this.TransferInfos.Add(transferInfo); + new TransferTasker(transferInfo).UploadFile(transferInfo.FileLocalPath, + string.Format("{0}/{1}", transferInfo.FileCloudPath.TrimEnd('/'), transferInfo.FileName), transferInfo.FileSize, + null, + (sender, args) => + { + ComputeTransferProcess(); + }); + } + } + else if (transferActionInfo.WorkingType == WorkingTypeEnum.Download) + { + foreach (var resourceFile in transferActionInfo.DownloadFileList) + { + var transferInfo = new TransferInfo() + { + FileName = resourceFile.ItemName, + FileSize = resourceFile.ItemSize ?? 0, + FileLocalPath = Path.Combine(transferActionInfo.TargetPath, resourceFile.ItemName), + FileCloudPath = resourceFile.ItemHref, + FinishSize = 0, + ProgressPercentage = 0, + StartWorking = false, + TransferTime = DateTime.Now, + WorkingType = transferActionInfo.WorkingType + }; + this.TransferInfos.Add(transferInfo); + new TransferTasker(transferInfo).DownloadFile(transferInfo.FileLocalPath, resourceFile.ItemHref, + null, + (sender, args) => + { + ComputeTransferProcess(); + }); + } + } + _currentRunningTransferCount = this.TransferInfos.Count(t => t.StartWorking); + this._eventAggregator.GetEvent().Publish(0); + } + + private void EditorAction(EditorActionInfo info) + { + var transferDownloadInfo = new TransferInfo() + { + FileName = info.DownloadFile.ItemName, + FileSize = info.DownloadFile.ItemSize ?? 0, + FileLocalPath = Path.Combine(info.TargetPath, info.DownloadFile.ItemName), + FileCloudPath = info.DownloadFile.ItemHref, + FinishSize = 0, + ProgressPercentage = 0, + StartWorking = false, + TransferTime = DateTime.Now, + WorkingType = WorkingTypeEnum.Download + }; + this.TransferInfos.Add(transferDownloadInfo); + new TransferTasker(transferDownloadInfo).DownloadFile(transferDownloadInfo.FileLocalPath, info.DownloadFile.ItemHref, null, (obj, e) => + { + ComputeTransferProcess(); + if (transferDownloadInfo.IsFailed) return; + var dateTime = File.GetLastWriteTime(transferDownloadInfo.FileLocalPath); + var psi = new ProcessStartInfo(transferDownloadInfo.FileLocalPath) { UseShellExecute = true }; + var process = Process.Start(psi); + if (process != null) process.WaitForExit(); + var modifyTime = File.GetLastWriteTime(transferDownloadInfo.FileLocalPath); + if (modifyTime > dateTime) + { + var dialogView = ServiceLocator.Current.GetInstance(RegionNames.DialogWindowView); + if (!dialogView.ShowDialog(DialogEnum.OkOrCanel, "请确认", "文件已改动,是否重新上传至服务器?")) return; + var transferUploadInfo = new TransferInfo() + { + FileName = Path.GetFileName(transferDownloadInfo.FileLocalPath), + FileSize = new FileInfo(transferDownloadInfo.FileLocalPath).Length, + FileLocalPath = transferDownloadInfo.FileLocalPath, + FileCloudPath = transferDownloadInfo.FileCloudPath.Substring(0, transferDownloadInfo.FileCloudPath.LastIndexOf('/')), + FinishSize = 0, + ProgressPercentage = 0, + StartWorking = false, + TransferTime = DateTime.Now, + WorkingType = WorkingTypeEnum.Upload + }; + this.TransferInfos.Add(transferUploadInfo); + new TransferTasker(transferUploadInfo).UploadFile(transferUploadInfo.FileLocalPath, string.Format("{0}/{1}", + transferUploadInfo.FileCloudPath.TrimEnd('/'), transferUploadInfo.FileName), transferUploadInfo.FileSize, + null, + (sender, args) => + { + ComputeTransferProcess(); + }); + + _currentRunningTransferCount = this.TransferInfos.Count(t => t.StartWorking); + this._eventAggregator.GetEvent().Publish(0); + } + }); + _currentRunningTransferCount = this.TransferInfos.Count(t => t.StartWorking); + this._eventAggregator.GetEvent().Publish(0); + } + + + private void Clear() + { + var dialogView = ServiceLocator.Current.GetInstance(RegionNames.DialogWindowView); + if (!dialogView.ShowDialog(DialogEnum.OkOrCanel, "请确认", "是否清除所有任务记录?")) return; + foreach (var transferInfo in TransferInfos) + CancelTransfer(transferInfo); + this.TransferInfos.Clear(); + this._transferDataService.SaveHistory(this.TransferInfos.ToList()); + } + + private bool CanClear() + { + return true; + } + + private bool CanBack() + { + return true; + } + + private void Back() + { + this._eventAggregator.GetEvent().Publish(null); + this._switchContentService.SwitchContentView(RegionNames.ActionCloudDriveRightRegion, RegionNames.CloudDriveExplorerView); + } + + + private void NavigateItem(TransferInfo transferInfo) + { + if (transferInfo == null || transferInfo.StartWorking) return; + if (transferInfo.WorkingType == WorkingTypeEnum.Download) + { + var lastIndex = transferInfo.FileCloudPath.LastIndexOf('/'); + var pathStr = string.Format("{0}/", transferInfo.FileCloudPath.Substring(0, lastIndex).TrimEnd('/')); + this._eventAggregator.GetEvent().Publish(pathStr); + } + else + { + this._eventAggregator.GetEvent().Publish(transferInfo.FileCloudPath); + } + this._switchContentService.SwitchContentView(RegionNames.ActionCloudDriveRightRegion, RegionNames.CloudDriveExplorerView); + } + + private bool CanNavigateItem(TransferInfo transferInfo) + { + return true; + } + + } + + public class TransferActionInfo + { + public IList UploadFileList { set; get; } + + public IList DownloadFileList { set; get; } + + public WorkingTypeEnum WorkingType { set; get; } + + public string TargetPath { set; get; } + } + + public class EditorActionInfo + { + public ResourceItem DownloadFile { set; get; } + + public string TargetPath { set; get; } + } +} diff --git a/CloudDriveShell.CloudDriveContent/ViewModels/CloudLogsContentViewModel.cs b/CloudDriveShell.CloudDriveContent/ViewModels/CloudLogsContentViewModel.cs new file mode 100644 index 0000000..d71fed8 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/ViewModels/CloudLogsContentViewModel.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using CloudDriveShell.Infrastructure.Models; +using Prism.Mvvm; +using System.Globalization; +using CloudDriveShell.Infrastructure; +using CloudDriveShell.Infrastructure.Interfaces; +using Prism.Events; +using Prism.Regions; +using Microsoft.Practices.ServiceLocation; +using CloudDriveShell.Infrastructure.Services; +using CloudDriveShell.Infrastructure.Utils; + +namespace CloudDriveShell.CloudDriveContent.ViewModels +{ + [Export] + class CloudLogsContentViewModel : BindableBase + { + } +} diff --git a/CloudDriveShell.CloudDriveContent/ViewModels/CreateFolderWindowViewModel.cs b/CloudDriveShell.CloudDriveContent/ViewModels/CreateFolderWindowViewModel.cs new file mode 100644 index 0000000..ae80c75 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/ViewModels/CreateFolderWindowViewModel.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CloudDriveShell.Infrastructure.Utils; +using Prism.Commands; +using Prism.Events; +using Prism.Mvvm; +using Prism.Regions; + +namespace CloudDriveShell.CloudDriveContent.ViewModels +{ + [Export] + class CreateFolderWindowViewModel : BindableBase + { + + private string _folderName; + + public string FolderName + { + get { return this._folderName; } + set + { + SetProperty(ref this._folderName, FileHelper.RemovePathUnSupportChart(value)); + } + } + + public event EventHandler RequestClose; + + public DelegateCommand SaveCommand { get; private set; } + public DelegateCommand CloseCommand { get; private set; } + + private readonly IRegionManager _regionManager; + + private readonly IEventAggregator _eventAggregator; + + [ImportingConstructor] + public CreateFolderWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator) + { + this._regionManager = regionManager; + this._eventAggregator = eventAggregator; + this.SaveCommand = new DelegateCommand(this.Save, this.CanSave); + this.CloseCommand = new DelegateCommand(this.Close, this.CanClose); + this.PropertyChanged += OnPropertyChanged; + } + + private bool CanClose() + { + return true; + } + + private void Close() + { + if (RequestClose != null) + { + RequestClose(this, null); + } + } + + private bool CanSave() + { + return !string.IsNullOrEmpty(FolderName); + } + + private void Save() + { + if (RequestClose != null) + { + RequestClose(this, null); + if (FolderName != null && !string.IsNullOrEmpty(FolderName.Trim())) + this._eventAggregator.GetEvent().Publish(FolderName.Trim()); + this.FolderName = string.Empty; + } + } + + private void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + + if (e.PropertyName == "FolderName") + { + this.SaveCommand.RaiseCanExecuteChanged(); + } + } + } + + public class CreateFolderStatusEvent : PubSubEvent + { + } +} diff --git a/CloudDriveShell.CloudDriveContent/Views/CloudDriveContent.xaml b/CloudDriveShell.CloudDriveContent/Views/CloudDriveContent.xaml new file mode 100644 index 0000000..8ebc4c5 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Views/CloudDriveContent.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CloudDriveShell.CloudDriveContent/Views/CloudDriveContent.xaml.cs b/CloudDriveShell.CloudDriveContent/Views/CloudDriveContent.xaml.cs new file mode 100644 index 0000000..85eced2 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Views/CloudDriveContent.xaml.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using CloudDriveShell.CloudDriveContent.ViewModels; +using CloudDriveShell.Infrastructure; +using CloudDriveShell.Infrastructure.Behaviors; +using CloudDriveShell.Infrastructure.Interfaces; +using CloudDriveShell.Infrastructure.Models; + +namespace CloudDriveShell.CloudDriveContent.Views +{ + /// + /// Interaction logic for CloudDriveContent.xaml + /// + [Export(RegionNames.CloudDriveContentView, typeof(IContentView))] + [PartCreationPolicy(CreationPolicy.Shared)] + public partial class CloudDriveContent : UserControl, IContentView + { + public CloudDriveContent() + { + InitializeComponent(); + } + + [Import] + private CloudDriveContentViewModel ViewModel + { + set + { + this.DataContext = value; + this.Loaded += (sender, args) => + { + value.ViewLoadedAction(); + }; + } + } + } +} diff --git a/CloudDriveShell.CloudDriveContent/Views/CloudDriveExplorer.xaml b/CloudDriveShell.CloudDriveContent/Views/CloudDriveExplorer.xaml new file mode 100644 index 0000000..9775c8c --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Views/CloudDriveExplorer.xaml @@ -0,0 +1,252 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CloudDriveShell.CloudDriveContent/Views/CloudDriveExplorer.xaml.cs b/CloudDriveShell.CloudDriveContent/Views/CloudDriveExplorer.xaml.cs new file mode 100644 index 0000000..147db34 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Views/CloudDriveExplorer.xaml.cs @@ -0,0 +1,153 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using CloudDriveShell.CloudDriveContent.ViewModels; +using CloudDriveShell.Infrastructure; +using CloudDriveShell.Infrastructure.Interfaces; +using CloudDriveShell.Infrastructure.Models; +using CloudDriveShell.Infrastructure.Utils; +using Clipboard = System.Windows.Clipboard; +using DataFormats = System.Windows.DataFormats; +using DragEventArgs = System.Windows.DragEventArgs; +using KeyEventArgs = System.Windows.Input.KeyEventArgs; +using ListView = System.Windows.Controls.ListView; +using TextBox = System.Windows.Controls.TextBox; +using CheckBox = System.Windows.Controls.CheckBox; +using ListViewItem = System.Windows.Controls.ListBoxItem; +using UserControl = System.Windows.Controls.UserControl; + +namespace CloudDriveShell.CloudDriveContent.Views +{ + /// + /// Interaction logic for CloudDriveExplorer.xaml + /// + [Export(RegionNames.CloudDriveExplorerView, typeof(IContentView))] + [PartCreationPolicy(CreationPolicy.Shared)] + public partial class CloudDriveExplorer : UserControl, IContentView + { + public CloudDriveExplorer() + { + InitializeComponent(); + } + + [Import] + private CloudDriveExplorerViewModel ViewModel + { + set + { + this.DataContext = value; + } + } + + private bool CheckIsClickCheckBox(object obj) + { + if (XamlHelper.FindUpVisualTree(obj as DependencyObject) != null) + return true; + return false; + } + + + private void ListViewMouseDown_OnHandler(object sender, MouseButtonEventArgs e) + { + ((CloudDriveExplorerViewModel)this.DataContext).CurrentSelectResourceItem = null; + } + + + private void ListViewItemPreviewMouseDown_OnHandler(object sender, MouseButtonEventArgs e) + { + if (CheckIsClickCheckBox(e.OriginalSource)) return; + var clickResourceItem = (ResourceItem)((ListViewItem)sender).DataContext; + ((CloudDriveExplorerViewModel) this.DataContext).ResourceItemClickAction(Keyboard.IsKeyDown(Key.LeftCtrl), + e.RightButton == MouseButtonState.Pressed, clickResourceItem); + } + + private void ListViewItemMouseDoubleClick_OnHandler(object sender, MouseButtonEventArgs e) + { + ((CloudDriveExplorerViewModel)this.DataContext).ResouceOpenCommand.Execute(); + } + + private void ListBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + ((CloudDriveExplorerViewModel)this.DataContext).ResouceNavigateCommand.Execute(((ListBoxItem)sender).Content); + } + + protected void Txtbox_LostFocus(object sender, RoutedEventArgs e) + { + var textBox = (TextBox)sender; + var resourceItem = textBox.DataContext as ResourceItem; + if (resourceItem == null) return; + ((CloudDriveExplorerViewModel)this.DataContext).RenameCallbackAction(resourceItem); + } + + private void Txtbox_OnKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + var textBox = (TextBox)sender; + textBox.Visibility = Visibility.Collapsed; + } + else if (e.Key == Key.Escape) + { + ((CloudDriveExplorerViewModel)this.DataContext).RenameCallbackAction(null); + } + } + + private void ListView_OnDrop(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); + if (files != null) + ((CloudDriveExplorerViewModel)this.DataContext).DropUploadCallbackAction(files.ToList().Where(System.IO.File.Exists).ToArray()); + } + } + + private void ListView_OnKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.F2) + { + ((CloudDriveExplorerViewModel)this.DataContext).ResourceRenameCommand.Execute(); + } + else if (e.Key == Key.C && Keyboard.IsKeyDown(Key.LeftCtrl)) + { + Clipboard.SetData(CommonConstant.ClipboardCopyResourceItemsDataFormats, "复制"); + ((CloudDriveExplorerViewModel)this.DataContext).ResourceCopyCommand.Execute(); + } + else if (e.Key == Key.X && Keyboard.IsKeyDown(Key.LeftCtrl)) + { + Clipboard.SetData(CommonConstant.ClipboardCopyResourceItemsDataFormats, "移动"); + ((CloudDriveExplorerViewModel)this.DataContext).ResourceCutCommand.Execute(); + } + + } + + private void ListView_OnPreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Space) + { + var resourceItem = ((ListView)sender).SelectedItem as ResourceItem; + if (resourceItem == null) return; + resourceItem.IsSelected = !resourceItem.IsSelected; + } + else if (e.Key == Key.Enter) + { + var resourceItem = ((ListView)sender).SelectedItem as ResourceItem; + if (resourceItem == null) return; + ((CloudDriveExplorerViewModel)this.DataContext).ResouceNavigateCommand.Execute(resourceItem); + } + } + } +} diff --git a/CloudDriveShell.CloudDriveContent/Views/CloudDriveTransfer.xaml b/CloudDriveShell.CloudDriveContent/Views/CloudDriveTransfer.xaml new file mode 100644 index 0000000..622dcd4 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Views/CloudDriveTransfer.xaml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CloudDriveShell.CloudDriveContent/Views/CloudDriveTransfer.xaml.cs b/CloudDriveShell.CloudDriveContent/Views/CloudDriveTransfer.xaml.cs new file mode 100644 index 0000000..28a3783 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Views/CloudDriveTransfer.xaml.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using CloudDriveShell.CloudDriveContent.ViewModels; +using CloudDriveShell.Infrastructure; +using CloudDriveShell.Infrastructure.Interfaces; +using CloudDriveShell.Infrastructure.Models; + +namespace CloudDriveShell.CloudDriveContent.Views +{ + /// + /// Interaction logic for CloudDriveTransfer.xaml + /// + [Export(RegionNames.CloudDriveTransferView, typeof(IContentView))] + [PartCreationPolicy(CreationPolicy.Shared)] + public partial class CloudDriveTransfer : UserControl, IContentView + { + public CloudDriveTransfer() + { + InitializeComponent(); + } + + + [Import] + private CloudDriveTransferViewModel ViewModel + { + set + { + this.DataContext = value; + } + } + + private void MouseDoubleClick_OnHandler(object sender, MouseButtonEventArgs e) + { + var textBox = (ListBoxItem)sender; + var transferInfo = textBox.DataContext as TransferInfo; + if (transferInfo == null) return; + if (Keyboard.IsKeyDown(Key.LeftCtrl)) + { + var filePath = System.IO.Path.GetDirectoryName(transferInfo.FileLocalPath); + if (System.IO.Directory.Exists(filePath)) + { + Process.Start("explorer.exe", filePath); + } + } + else + { + ((CloudDriveTransferViewModel)this.DataContext).NavigateItemCommand.Execute(transferInfo); + } + } + } +} diff --git a/CloudDriveShell.CloudDriveContent/Views/CloudLogsContent.xaml b/CloudDriveShell.CloudDriveContent/Views/CloudLogsContent.xaml new file mode 100644 index 0000000..74070bb --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Views/CloudLogsContent.xaml @@ -0,0 +1,11 @@ + + + + + diff --git a/CloudDriveShell.CloudDriveContent/Views/CloudLogsContent.xaml.cs b/CloudDriveShell.CloudDriveContent/Views/CloudLogsContent.xaml.cs new file mode 100644 index 0000000..a965032 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Views/CloudLogsContent.xaml.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.Composition; +using System.Windows.Controls; +using CloudDriveShell.CloudDriveContent.ViewModels; +using CloudDriveShell.Infrastructure; +using CloudDriveShell.Infrastructure.Interfaces; + + +namespace CloudDriveShell.CloudDriveContent.Views +{ + /// + /// Interaction logic for CloudSettingCommon.xaml + /// + [Export(RegionNames.CloudDriveLogsView, typeof(IContentView))] + [PartCreationPolicy(CreationPolicy.Shared)] + public partial class CloudLogsContent : UserControl, IContentView + { + public CloudLogsContent() + { + InitializeComponent(); + } + + [Import] + private CloudLogsContentViewModel ViewModel + { + set + { + this.DataContext = value; + } + } + + + } +} diff --git a/CloudDriveShell.CloudDriveContent/Views/CreateFolderWindow.xaml b/CloudDriveShell.CloudDriveContent/Views/CreateFolderWindow.xaml new file mode 100644 index 0000000..80f7840 --- /dev/null +++ b/CloudDriveShell.CloudDriveContent/Views/CreateFolderWindow.xaml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + 新建文件夹 + + + + + + + + + + + + + + + + +