├── docs └── images │ ├── preview.png │ ├── login_page.png │ ├── configure_page.png │ ├── downloaded_page.png │ └── downloading_page.jpg ├── binaries └── FirstFloor.ModernUI.dll ├── BaiduPanDownloadWpf ├── Assets │ ├── Images │ │ ├── NewYear.jpg │ │ ├── YourName.jpg │ │ ├── DonateLink.jpg │ │ ├── Mrs4sHead.jpg │ │ ├── DefaultUserHead.jpg │ │ ├── DingpingZhangHead.jpg │ │ └── FileTypes │ │ │ ├── ApkType.png │ │ │ ├── DocType.png │ │ │ ├── ExeType.png │ │ │ ├── ImgType.png │ │ │ ├── PdfType.png │ │ │ ├── PptType.png │ │ │ ├── RarType.png │ │ │ ├── TxtType.png │ │ │ ├── XlsType.png │ │ │ ├── FolderType.png │ │ │ ├── MixFileType.png │ │ │ ├── MusicType.png │ │ │ ├── OtherType.png │ │ │ ├── TorrentType.png │ │ │ └── VideoType.png │ └── Themes │ │ ├── ModernUI.NewYearTheme.xaml │ │ └── ModernUI.YourNameTheme.xaml ├── App.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Views │ ├── Home.xaml.cs │ ├── Settings │ │ ├── LoginPage.xaml.cs │ │ ├── ConfigurePage.xaml.cs │ │ ├── About.xaml.cs │ │ ├── OptionPage.xaml.cs │ │ ├── About.xaml │ │ └── ConfigurePage.xaml │ ├── DownloadedPage.xaml.cs │ ├── DownloadingPage.xaml.cs │ ├── SharedPage.xaml.cs │ ├── SettingsPage.xaml.cs │ ├── Dialogs │ │ ├── MessageDialog.xaml │ │ ├── SignInDialog.xaml.cs │ │ ├── ShareFileDialog.xaml.cs │ │ ├── SignInDialog.xaml │ │ ├── MessageDialog.xaml.cs │ │ └── ShareFileDialog.xaml │ ├── RecycleBinPage.xaml.cs │ ├── SharedPage.xaml │ ├── RecycleBinPage.xaml │ └── SettingsPage.xaml ├── MainWindow.xaml.cs ├── App.xaml.cs ├── ViewModels │ ├── RecycleBinPage.vm.cs │ ├── SharedPage.vm.cs │ ├── Dialogs │ │ └── ShareFileDialog.vm.cs │ ├── ViewModelBase.cs │ ├── Items │ │ ├── DownloadTaskItem.vm.cs │ │ ├── DownloadedTaskItem.vm.cs │ │ ├── DownloadingTaskItem.vm.cs │ │ └── NetDiskFileNode.vm.cs │ ├── Settings │ │ ├── ConfigurePage.vm.cs │ │ └── LoginPage.vm.cs │ ├── DownloadedPage.vm.cs │ └── Home.vm.cs ├── packages.config ├── Converters │ └── LongToDataSizeConverter.cs ├── Commands │ ├── CommandBase.cs │ ├── Command.cs │ └── Command{T}.cs ├── App.xaml ├── Controls │ ├── AsyncButton.xaml │ └── AsyncButton.xaml.cs ├── MainWindow.xaml └── Bootstrapper.cs ├── BaiduPanDownloadWpf.Infrastructure ├── Events │ ├── EventArgsBase.cs │ ├── NetDiskUserSwitchedEvent.cs │ ├── DownloadProgressChangedEvent.cs │ └── DownloadStateChangedEvent.cs ├── Interfaces │ ├── Files │ │ ├── IDeletedFile.cs │ │ ├── ILocalDiskFile.cs │ │ ├── ISharedFile.cs │ │ ├── IFile.cs │ │ ├── IDiskFile.cs │ │ └── INetDiskFile.cs │ ├── ILocalConfigInfo.cs │ ├── ILocalDiskUserRepository.cs │ ├── IRepository{T}.cs │ ├── ILocalDiskUser.cs │ └── INetDiskUser.cs ├── packages.config ├── Exceptions │ ├── LoginException.cs │ ├── RegisterException.cs │ ├── ServerException.cs │ └── InvalidDownloadStateChangeException.cs ├── SignInInfo.cs ├── Properties │ └── AssemblyInfo.cs ├── FileLocation.cs ├── BaiduPanDownloadWpf.Infrastructure.csproj ├── DataSize.cs └── Enumerations.cs ├── BaiduPanDownloadWpf.Core ├── DownloadEngine │ ├── DownloadTaskThread.cs │ ├── DownloadTaskToken.cs │ ├── DownloadTaskTokenSource.cs │ ├── DownloadTask.cs │ └── DownloadTaskManager.cs ├── NetWork │ ├── Packets │ │ ├── ListSharePacket.cs │ │ ├── PacketBase.cs │ │ ├── BindingCookiesPacket.cs │ │ ├── ListFilePacket.cs │ │ ├── DeleteFilePacket.cs │ │ ├── CreateLinkPacket.cs │ │ ├── LoginPacket.cs │ │ ├── RegisterPacket.cs │ │ ├── ShareFilePacket.cs │ │ └── DownloadPacket.cs │ ├── Server.cs │ └── Cookies.cs ├── packages.config ├── DownloadMethod.cs ├── ModelBase.cs ├── ResultData │ ├── CheckResult.cs │ ├── ShareResult.cs │ ├── DownloadResult.cs │ └── ShareListResult.cs ├── LocalConfigInfo.cs ├── LocalDiskFile.cs ├── DownloadCoreModule.cs ├── Properties │ └── AssemblyInfo.cs ├── Download │ └── DownloadCore │ │ ├── DownloadInfo.cs │ │ └── DownloadThread.cs ├── NetDiskUser.cs ├── LocalDiskUser.cs └── LocalDiskUserRepository.cs ├── .gitattributes ├── .github └── ISSUE_TEMPLATE.md ├── LICENSE.TXT ├── README.md ├── BaiduPanDownloadWpf.sln └── .gitignore /docs/images/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/docs/images/preview.png -------------------------------------------------------------------------------- /docs/images/login_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/docs/images/login_page.png -------------------------------------------------------------------------------- /docs/images/configure_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/docs/images/configure_page.png -------------------------------------------------------------------------------- /docs/images/downloaded_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/docs/images/downloaded_page.png -------------------------------------------------------------------------------- /binaries/FirstFloor.ModernUI.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/binaries/FirstFloor.ModernUI.dll -------------------------------------------------------------------------------- /docs/images/downloading_page.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/docs/images/downloading_page.jpg -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/NewYear.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/NewYear.jpg -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/YourName.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/YourName.jpg -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/DonateLink.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/DonateLink.jpg -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/Mrs4sHead.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/Mrs4sHead.jpg -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/DefaultUserHead.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/DefaultUserHead.jpg -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/DingpingZhangHead.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/DingpingZhangHead.jpg -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/ApkType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/ApkType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/DocType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/DocType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/ExeType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/ExeType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/ImgType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/ImgType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/PdfType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/PdfType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/PptType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/PptType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/RarType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/RarType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/TxtType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/TxtType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/XlsType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/XlsType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/FolderType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/FolderType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/MixFileType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/MixFileType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/MusicType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/MusicType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/OtherType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/OtherType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/TorrentType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/TorrentType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Images/FileTypes/VideoType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wingsziye/BaiduPanDownloadWpf/HEAD/BaiduPanDownloadWpf/Assets/Images/FileTypes/VideoType.png -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Events/EventArgsBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPanDownloadWpf.Infrastructure.Events 4 | { 5 | public class EventArgsBase : EventArgs 6 | { 7 | public DateTime Timestamp { get; } = DateTime.Now; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Interfaces/Files/IDeletedFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPanDownloadWpf.Infrastructure.Interfaces.Files 4 | { 5 | public interface IDeletedFile : IDiskFile 6 | { 7 | DateTime DeletedTime { get; } 8 | 9 | int LeftDays { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/DownloadEngine/DownloadTaskThread.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaiduPanDownloadWpf.Core.DownloadEngine 8 | { 9 | internal class DownloadTaskThread 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Packets/ListSharePacket.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Core.NetWork.Packets 2 | { 3 | class ListSharePacket : PacketBase 4 | { 5 | public ListSharePacket() 6 | { 7 | PacketID = 11; 8 | } 9 | 10 | public int Page { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Interfaces/Files/ILocalDiskFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | 6 | namespace BaiduPanDownloadWpf.Infrastructure.Interfaces.Files 7 | { 8 | public interface ILocalDiskFile : IDiskFile 9 | { 10 | DateTime CompletedTime { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Home.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace BaiduPanDownloadWpf.Views 4 | { 5 | /// 6 | /// Interaction logic for Home.xaml 7 | /// 8 | public partial class Home : UserControl 9 | { 10 | public Home() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using FirstFloor.ModernUI.Windows.Controls; 2 | 3 | namespace BaiduPanDownloadWpf 4 | { 5 | /// 6 | /// Interaction logic for MainWindow.xaml 7 | /// 8 | public partial class MainWindow : ModernWindow 9 | { 10 | public MainWindow() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Packets/PacketBase.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Core.NetWork.Packets 2 | { 3 | public class PacketBase 4 | { 5 | /// 6 | /// 封包ID 7 | /// 8 | public int PacketID { get; set; } 9 | /// 10 | /// 用户Token 11 | /// 12 | public string Token { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Settings/LoginPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | 3 | namespace BaiduPanDownloadWpf.Views.Settings 4 | { 5 | /// 6 | /// Interaction logic for LoginPage.xaml 7 | /// 8 | public partial class LoginPage : UserControl 9 | { 10 | public LoginPage() 11 | { 12 | InitializeComponent(); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Packets/BindingCookiesPacket.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Core.NetWork.Packets 2 | { 3 | class BindingCookiesPacket : PacketBase 4 | { 5 | public BindingCookiesPacket() 6 | { 7 | PacketID = 4; 8 | } 9 | /// 10 | /// 账号Cookies 11 | /// 12 | public Cookies cookies { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Packets/ListFilePacket.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Core.NetWork.Packets 2 | { 3 | class ListFilePacket : PacketBase 4 | { 5 | public ListFilePacket() 6 | { 7 | PacketID = 5; 8 | } 9 | 10 | /// 11 | /// 需要列出的目录 12 | /// 13 | public string Path { get; set; } 14 | 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace BaiduPanDownloadWpf 4 | { 5 | /// 6 | /// Interaction logic for App.xaml 7 | /// 8 | public partial class App : Application 9 | { 10 | protected override void OnStartup(StartupEventArgs e) 11 | { 12 | base.OnStartup(e); 13 | new Bootstrapper().Run(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Exceptions/LoginException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPanDownloadWpf.Infrastructure.Exceptions 4 | { 5 | public class LoginException: Exception 6 | { 7 | public ClientLoginStateEnum LoginType { get; private set; } 8 | 9 | public LoginException(string message, ClientLoginStateEnum loginType) : base(message) 10 | { 11 | LoginType = loginType; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/DownloadedPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using BaiduPanDownloadWpf.ViewModels; 2 | using System.Windows.Controls; 3 | 4 | namespace BaiduPanDownloadWpf.Views 5 | { 6 | /// 7 | /// Interaction logic for DownloadedPage.xaml 8 | /// 9 | public partial class DownloadedPage : UserControl 10 | { 11 | public DownloadedPage() 12 | { 13 | InitializeComponent(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/DownloadingPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using BaiduPanDownloadWpf.ViewModels; 2 | using System.Windows.Controls; 3 | 4 | namespace BaiduPanDownloadWpf.Views 5 | { 6 | /// 7 | /// Interaction logic for DownloadingPage.xaml 8 | /// 9 | public partial class DownloadingPage : UserControl 10 | { 11 | public DownloadingPage() 12 | { 13 | InitializeComponent(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Packets/DeleteFilePacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaiduPanDownloadWpf.Core.NetWork.Packets 8 | { 9 | class DeleteFilePacket : PacketBase 10 | { 11 | public DeleteFilePacket() 12 | { 13 | PacketID = 12; 14 | } 15 | public string Path { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Exceptions/RegisterException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPanDownloadWpf.Infrastructure.Exceptions 4 | { 5 | public class RegisterException: Exception 6 | { 7 | public RegisterStateEnum RegisterType { get; private set; } 8 | 9 | public RegisterException(string message, RegisterStateEnum registerType) : base(message) 10 | { 11 | RegisterType = registerType; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Settings/ConfigurePage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Controls; 2 | using BaiduPanDownloadWpf.ViewModels; 3 | 4 | namespace BaiduPanDownloadWpf.Views.Settings 5 | { 6 | /// 7 | /// Interaction logic for TransmissionPage.xaml 8 | /// 9 | public partial class ConfigurePage : UserControl 10 | { 11 | public ConfigurePage() 12 | { 13 | InitializeComponent(); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Packets/CreateLinkPacket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaiduPanDownloadWpf.Core.NetWork.Packets 8 | { 9 | class CreateLinkPacket : PacketBase 10 | { 11 | public CreateLinkPacket() 12 | { 13 | PacketID = 13; 14 | } 15 | 16 | public NetDiskFile Info { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/RecycleBinPage.vm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.Practices.Unity; 7 | 8 | namespace BaiduPanDownloadWpf.ViewModels 9 | { 10 | internal class RecycleBinPageViewModel : ViewModelBase 11 | { 12 | public RecycleBinPageViewModel(IUnityContainer container) : base(container) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/DownloadEngine/DownloadTaskToken.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaiduPanDownloadWpf.Core.DownloadEngine 8 | { 9 | public class DownloadTaskToken 10 | { 11 | private volatile bool _isCancellationRequested; 12 | public bool IsCancellationRequested { get { return _isCancellationRequested; } } 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/SharedPage.vm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.Practices.Unity; 7 | 8 | namespace BaiduPanDownloadWpf.ViewModels 9 | { 10 | internal class SharedPageViewModel : ViewModelBase 11 | { 12 | public SharedPageViewModel(IUnityContainer container) : base(container) 13 | { 14 | } 15 | 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 发现了bug?(bug) 2 | * 系统版本:[您操作系统的版本] 3 | * 重现步骤: 4 | 1. [请描述一下重现的步骤,越详细越好] 5 | 2. 6 | * 异常信息: 7 | 8 | > [可选,如:软件崩溃时的异常提示、日志信息等] 9 | 10 | 11 | --- 12 | 13 | 请求新功能?(new featrue) 14 | * [你想要什么功能?] 15 | * [请描述一下该功能具体是怎样的?如:软件的行为、软件的外观等。] 16 | * [你为什么需要这个功能?] 17 | 18 | 19 | --- 20 | 21 | 使用时遇到了问题?(question) 22 | * [你希望进行何种操作?/你操作的目的是什么?] 23 | * [阻碍你达到该目的的原因是什么?] 24 | 25 | 26 | 27 | [如果你有log文件或截图,请上传至附件(点击下方**selecting them**)] 28 | 29 | [中括号(“[]”)内的文字为提示内容,请于提交前覆盖或删除] 30 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Interfaces/Files/ISharedFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace BaiduPanDownloadWpf.Infrastructure.Interfaces.Files 5 | { 6 | public interface ISharedFile : IFile 7 | { 8 | Uri ShareLink { get; } 9 | string Password { get; } 10 | DateTime SharedTime { get; } 11 | long VisitedNumber { get; } 12 | long DownloadedNumber { get; } 13 | long SavedNumber { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/Dialogs/ShareFileDialog.vm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.Practices.Unity; 7 | 8 | namespace BaiduPanDownloadWpf.ViewModels.Dialogs 9 | { 10 | internal class ShareFileDialogViewModel : ViewModelBase 11 | { 12 | public ShareFileDialogViewModel(IUnityContainer container) : base(container) 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Packets/LoginPacket.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Core.NetWork.Packets 2 | { 3 | class LoginPacket : PacketBase 4 | { 5 | public LoginPacket() 6 | { 7 | PacketID = 2; 8 | } 9 | /// 10 | /// 用户名 11 | /// 12 | public string Name { get; set; } 13 | 14 | /// 15 | /// 用户名 16 | /// 17 | public string Password { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Packets/RegisterPacket.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Core.NetWork.Packets 2 | { 3 | class RegisterPacket : PacketBase 4 | { 5 | public RegisterPacket() 6 | { 7 | PacketID = 1; 8 | } 9 | /// 10 | /// 用户名 11 | /// 12 | public string Name { get; set; } 13 | /// 14 | /// 密码 15 | /// 16 | public string Password { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Packets/ShareFilePacket.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Core.NetWork.Packets 2 | { 3 | class ShareFilePacket : PacketBase 4 | { 5 | public ShareFilePacket() 6 | { 7 | PacketID = 8; 8 | } 9 | /// 10 | /// 文件信息 11 | /// 12 | public long[] FileIds { get; set; } 13 | 14 | /// 15 | /// 密码 16 | /// 17 | public string Password { get; set; } = null; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Packets/DownloadPacket.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Core.NetWork.Packets 2 | { 3 | class DownloadPacket : PacketBase 4 | { 5 | public DownloadPacket() 6 | { 7 | PacketID = 7; 8 | } 9 | 10 | 11 | /// 12 | /// 文件信息 13 | /// 14 | public NetDiskFile[] Info { get; set; } 15 | 16 | /// 17 | /// 下载方法 18 | /// 19 | public int Method { get; set; } = 1; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Exceptions/ServerException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPanDownloadWpf.Infrastructure.Exceptions 4 | { 5 | public class ServerException : Exception 6 | { 7 | public ServerException() : base() 8 | { 9 | } 10 | 11 | public ServerException(string message) : base(message) 12 | { 13 | } 14 | 15 | public ServerException(string message, Exception innerException) : base(message, innerException) 16 | { 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Events/NetDiskUserSwitchedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Prism.Events; 3 | 4 | namespace BaiduPanDownloadWpf.Infrastructure.Events 5 | { 6 | public class NetDiskUserSwitchedEvent : PubSubEvent 7 | { 8 | } 9 | 10 | public class NetDiskUserSwitchedEventArgs : EventArgsBase 11 | { 12 | public NetDiskUserSwitchedEventArgs(Guid userId) 13 | { 14 | UserId = userId; 15 | } 16 | 17 | public Guid UserId { get; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Interfaces/Files/IFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | 6 | namespace BaiduPanDownloadWpf.Infrastructure.Interfaces.Files 7 | { 8 | public interface IFile 9 | { 10 | /// 11 | /// Gets the ID of the file. 12 | /// 13 | long FileId { get; } 14 | 15 | /// 16 | /// Gets the type of the file. 17 | /// 18 | FileTypeEnum FileType { get; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/DownloadEngine/DownloadTaskTokenSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaiduPanDownloadWpf.Core.DownloadEngine 8 | { 9 | public class DownloadTaskTokenSource 10 | { 11 | public DownloadTaskToken Token { get; } 12 | 13 | 14 | public void Pause() 15 | { 16 | 17 | } 18 | 19 | public void Restart() 20 | { 21 | 22 | } 23 | 24 | public void Cancel() 25 | { 26 | 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/SignInInfo.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Infrastructure 2 | { 3 | public enum SignInState 4 | { 5 | 6 | } 7 | public class SignInInfo 8 | { 9 | public string UserName { get; } 10 | public string Password { get; } 11 | public string VerificationCode { get; } 12 | public SignInState State { get; set; } 13 | 14 | public SignInInfo(string userName, string password, string verficationCode) 15 | { 16 | UserName = userName; 17 | Password = password; 18 | VerificationCode = verficationCode; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Interfaces/ILocalConfigInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaiduPanDownloadWpf.Infrastructure.Interfaces 8 | { 9 | public interface ILocalConfigInfo 10 | { 11 | int ThreadNumber { get; set; } 12 | int ParellelTaskNumber { get; set; } 13 | string DownloadPath { get; set; } 14 | LanguageEnum Language { get; set; } 15 | string Theme { get; set; } 16 | string Background { get; set; } 17 | bool IsDisplayDownloadDialog { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Interfaces/ILocalDiskUserRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | 6 | namespace BaiduPanDownloadWpf.Infrastructure.Interfaces 7 | { 8 | /// 9 | /// A interface represents the repository of . 10 | /// 11 | public interface ILocalDiskUserRepository : IRepository 12 | { 13 | Task SignInAsync(string userName, string password); 14 | Task SignOutAsync(); 15 | Task SignUpAsync(string userName, string password); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/DownloadEngine/DownloadTask.cs: -------------------------------------------------------------------------------- 1 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 2 | using Microsoft.Practices.Unity; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace BaiduPanDownloadWpf.Core.DownloadEngine 10 | { 11 | internal class DownloadTask : ModelBase 12 | { 13 | 14 | 15 | public DownloadTask(IUnityContainer container, INetDiskFile file, DownloadTaskToken token) : base(container) 16 | { 17 | 18 | } 19 | 20 | public void Start() 21 | { 22 | 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/DownloadMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaiduPanDownloadWpf.Core 8 | { 9 | /// 10 | /// 下载方法 11 | /// 12 | public enum DownloadMethod 13 | { 14 | /// 15 | /// 直接下载 16 | /// 17 | DirectDownload = 1, 18 | /// 19 | /// 中转下载 20 | /// 21 | JumpDownload = 2, 22 | /// 23 | /// APPID下载 24 | /// 25 | AppidDownload = 3 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/ModelBase.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Practices.Unity; 2 | using Prism.Events; 3 | using Prism.Logging; 4 | 5 | namespace BaiduPanDownloadWpf.Core 6 | { 7 | public abstract class ModelBase 8 | { 9 | protected IUnityContainer Container { get; } 10 | protected IEventAggregator EventAggregator { get; } 11 | protected ILoggerFacade Logger { get; } 12 | 13 | 14 | protected ModelBase(IUnityContainer container) 15 | { 16 | Container = container.CreateChildContainer(); 17 | EventAggregator = container.Resolve(); 18 | Logger = container.Resolve(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Exceptions/InvalidDownloadStateChangeException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaiduPanDownloadWpf.Infrastructure.Exceptions 8 | { 9 | public class InvalidDownloadStateChangeException : Exception 10 | { 11 | public DownloadStateEnum OldState { get; } 12 | public DownloadStateEnum NewState { get; } 13 | 14 | public InvalidDownloadStateChangeException(DownloadStateEnum oldState, DownloadStateEnum newState, string message) : base(message) 15 | { 16 | NewState = newState; 17 | OldState = oldState; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Events/DownloadProgressChangedEvent.cs: -------------------------------------------------------------------------------- 1 | using Prism.Events; 2 | 3 | namespace BaiduPanDownloadWpf.Infrastructure.Events 4 | { 5 | public class DownloadProgressChangedEvent : PubSubEvent 6 | { 7 | } 8 | 9 | public class DownloadProgressChangedEventArgs : EventArgsBase 10 | { 11 | public long FileId { get; } 12 | public DataSize CurrentProgress { get; } 13 | public DataSize CurrentSpeed { get; } 14 | 15 | 16 | public DownloadProgressChangedEventArgs(long fileId, DataSize currentProgress, DataSize currentSpeed) 17 | { 18 | FileId = fileId; 19 | CurrentProgress = currentProgress; 20 | CurrentSpeed = currentSpeed; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Settings/About.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace BaiduPanDownloadWpf.Views.Settings 17 | { 18 | /// 19 | /// Interaction logic for About.xaml 20 | /// 21 | public partial class About : UserControl 22 | { 23 | public About() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/SharedPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace BaiduPanDownloadWpf.Views 17 | { 18 | /// 19 | /// Interaction logic for SharedPage.xaml 20 | /// 21 | public partial class SharedPage : UserControl 22 | { 23 | public SharedPage() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Converters/LongToDataSizeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows.Data; 8 | using BaiduPanDownloadWpf.Infrastructure; 9 | 10 | namespace BaiduPanDownloadWpf.Converters 11 | { 12 | public class LongToDataSizeConverter : IValueConverter 13 | { 14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 15 | { 16 | return new DataSize((long)value); 17 | } 18 | 19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | throw new NotImplementedException(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/SettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace BaiduPanDownloadWpf.Views 17 | { 18 | /// 19 | /// Interaction logic for SettingsPage.xaml 20 | /// 21 | public partial class SettingsPage : UserControl 22 | { 23 | public SettingsPage() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Dialogs/MessageDialog.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/RecycleBinPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace BaiduPanDownloadWpf.Views 17 | { 18 | /// 19 | /// Interaction logic for RecycleBinPage.xaml 20 | /// 21 | public partial class RecycleBinPage : UserControl 22 | { 23 | public RecycleBinPage() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Settings/OptionPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace BaiduPanDownloadWpf.Views.Settings 17 | { 18 | /// 19 | /// Interaction logic for OptionPage.xaml 20 | /// 21 | public partial class OptionPage : UserControl 22 | { 23 | public OptionPage() 24 | { 25 | InitializeComponent(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Interfaces/Files/IDiskFile.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Infrastructure.Interfaces.Files 2 | { 3 | /// 4 | /// A entity contains the basic information of the file, which can represents a local disk file or provites information for the file in download. 5 | /// 6 | public interface IDiskFile : IFile 7 | { 8 | /// 9 | /// Gets a instance of which represents the file location information. 10 | /// 11 | FileLocation FilePath { get; } 12 | 13 | /// 14 | /// Gets the size of the file based on byte. If the is , return 0. 15 | /// 16 | long FileSize { get; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Commands/CommandBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Input; 3 | 4 | namespace BaiduPanDownloadWpf.Commands 5 | { 6 | internal abstract class CommandBase : ICommand 7 | { 8 | public event EventHandler CanExecuteChanged 9 | { 10 | add { CommandManager.RequerySuggested += value; } 11 | remove { CommandManager.RequerySuggested -= value; } 12 | } 13 | 14 | void ICommand.Execute(object parameter) 15 | { 16 | Execute(parameter); 17 | } 18 | 19 | bool ICommand.CanExecute(object parameter) 20 | { 21 | return CanExecute(parameter); 22 | } 23 | 24 | protected abstract void Execute(object parameter); 25 | 26 | protected abstract bool CanExecute(object parameter); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Interfaces/IRepository{T}.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Infrastructure.Interfaces 2 | { 3 | /// 4 | /// A interface for repository pattern. 5 | /// 6 | /// The type of entity. 7 | public interface IRepository 8 | { 9 | /// 10 | /// Returns the first or default element in the collection. 11 | /// 12 | /// The first or default element, will return null if there are nothing in the collection. 13 | TEntity FirstOrDefault(); 14 | 15 | /// 16 | /// Persistences the entity parameter. 17 | /// 18 | /// The entity that needs to be persisted. 19 | void Save(TEntity entity); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/ResultData/CheckResult.cs: -------------------------------------------------------------------------------- 1 | namespace BaiduPanDownloadWpf.Core.ResultData 2 | { 3 | /// 4 | /// 验证码检查返回值 5 | /// 6 | public class CheckResult 7 | { 8 | /// 9 | /// 是否需要验证码 10 | /// 11 | public bool NeedCode { get; set; } 12 | 13 | /// 14 | /// BaiduID 15 | /// 16 | public string BaiduId { get; set; } 17 | 18 | /// 19 | /// Token 20 | /// 21 | public string Token { get; set; } 22 | 23 | /// 24 | /// 验证码图片 25 | /// 26 | public string ImageUrl { get; set; } 27 | 28 | /// 29 | /// 验证码字符串 30 | /// 31 | public string CodeString { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Dialogs/SignInDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using FirstFloor.ModernUI.Windows.Controls; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Navigation; 15 | using System.Windows.Shapes; 16 | 17 | namespace BaiduPanDownloadWpf.Views.Dialogs 18 | { 19 | /// 20 | /// Interaction logic for SignInDialog.xaml 21 | /// 22 | public partial class SignInDialog : ModernWindow 23 | { 24 | public SignInDialog() 25 | { 26 | InitializeComponent(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/LocalConfigInfo.cs: -------------------------------------------------------------------------------- 1 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 8 | using BaiduPanDownloadWpf.Infrastructure; 9 | 10 | namespace BaiduPanDownloadWpf.Core 11 | { 12 | public class LocalConfigInfo : ILocalConfigInfo 13 | { 14 | public string Background { get; set; } 15 | 16 | public string DownloadPath { get; set; } 17 | 18 | public bool IsDisplayDownloadDialog { get; set; } 19 | 20 | public LanguageEnum Language { get; set; } 21 | 22 | public int ParellelTaskNumber { get; set; } 23 | 24 | public string Theme { get; set; } 25 | 26 | public int ThreadNumber { get; set; } 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/App.xaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Dialogs/ShareFileDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using FirstFloor.ModernUI.Windows.Controls; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Navigation; 15 | using System.Windows.Shapes; 16 | 17 | namespace BaiduPanDownloadWpf.Views.Dialogs 18 | { 19 | /// 20 | /// Interaction logic for ShareFileDialog.xaml 21 | /// 22 | public partial class ShareFileDialog : ModernWindow 23 | { 24 | public ShareFileDialog() 25 | { 26 | InitializeComponent(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Commands/Command.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPanDownloadWpf.Commands 4 | { 5 | internal class Command : CommandBase 6 | { 7 | private readonly Action _execute; 8 | private readonly Func _canExecute; 9 | 10 | 11 | public Command(Action execute, Func canExecute = null) 12 | { 13 | _execute = execute; 14 | _canExecute = canExecute; 15 | } 16 | 17 | protected override bool CanExecute(object parameter) 18 | { 19 | return CanExecute(); 20 | } 21 | 22 | protected override void Execute(object parameter) 23 | { 24 | Execute(); 25 | } 26 | 27 | public bool CanExecute() 28 | { 29 | return _canExecute?.Invoke() ?? true; 30 | } 31 | 32 | public void Execute() 33 | { 34 | _execute?.Invoke(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Themes/ModernUI.NewYearTheme.xaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | #C94626 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Assets/Themes/ModernUI.YourNameTheme.xaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | #aa00ff 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/SharedPage.xaml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/RecycleBinPage.xaml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/LocalDiskFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using BaiduPanDownloadWpf.Infrastructure; 5 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 6 | using BaiduPanDownloadWpf.Core.Download.DwonloadCore; 7 | 8 | namespace BaiduPanDownloadWpf.Core 9 | { 10 | public class LocalDiskFile : ILocalDiskFile 11 | { 12 | public long FileId { get; private set; } 13 | public FileLocation FilePath { get; private set; } 14 | public FileTypeEnum FileType { get; private set; } 15 | public long FileSize { get; private set; } 16 | public DateTime CompletedTime { get; private set; } 17 | 18 | 19 | public LocalDiskFile(long id, string path, FileTypeEnum type, long size, DateTime time) 20 | { 21 | FileId = id; 22 | FilePath = new FileLocation(path); 23 | FileType = type; 24 | FileSize = size; 25 | CompletedTime = time; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Commands/Command{T}.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPanDownloadWpf.Commands 4 | { 5 | internal class Command : CommandBase 6 | { 7 | private readonly Action _execute; 8 | private readonly Predicate _canExecute; 9 | 10 | public Command(Action execute, Predicate canExecute = null) 11 | { 12 | _execute = execute; 13 | _canExecute = canExecute; 14 | } 15 | 16 | protected override bool CanExecute(object parameter) 17 | { 18 | return CanExecute((T)parameter); 19 | } 20 | 21 | protected override void Execute(object parameter) 22 | { 23 | Execute((T)parameter); 24 | } 25 | 26 | public bool CanExecute(T parameter) 27 | { 28 | return _canExecute?.Invoke(parameter) ?? true; 29 | } 30 | 31 | public void Execute(T parameter) 32 | { 33 | _execute?.Invoke(parameter); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Dialogs/SignInDialog.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Dialogs/MessageDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using FirstFloor.ModernUI.Windows.Controls; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Navigation; 15 | using System.Windows.Shapes; 16 | 17 | namespace BaiduPanDownloadWpf.Views.Dialogs 18 | { 19 | /// 20 | /// Interaction logic for LoginExceptionMessageDialog.xaml 21 | /// 22 | public partial class MessageDialog : ModernDialog 23 | { 24 | public MessageDialog(string title, string message) 25 | { 26 | InitializeComponent(); 27 | TextBlock.Text = message; 28 | this.Title = title; 29 | 30 | // define the dialog buttons 31 | this.Buttons = new[] { this.OkButton }; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/ViewModelBase.cs: -------------------------------------------------------------------------------- 1 | using BaiduPanDownloadWpf.Commands; 2 | using Microsoft.Practices.Unity; 3 | using Prism.Events; 4 | using Prism.Logging; 5 | using Prism.Mvvm; 6 | 7 | namespace BaiduPanDownloadWpf.ViewModels 8 | { 9 | internal abstract class ViewModelBase : BindableBase 10 | { 11 | private Command _loadedCommand; 12 | public Command LoadedCommand 13 | { 14 | get { return _loadedCommand; } 15 | set { SetProperty(ref _loadedCommand, value); } 16 | } 17 | 18 | 19 | protected IUnityContainer Container { get; } 20 | protected IEventAggregator EventAggregator { get; } 21 | protected ILoggerFacade Logger { get; } 22 | 23 | protected ViewModelBase(IUnityContainer container) 24 | { 25 | Container = container; 26 | EventAggregator = container.Resolve(); 27 | Logger = container.Resolve(); 28 | LoadedCommand = new Command(OnLoaded); 29 | } 30 | 31 | protected virtual void OnLoaded() { } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Mrs4s and Dingping.Zhang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/ResultData/ShareResult.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace BaiduPanDownloadWpf.Core.ResultData 4 | { 5 | /// 6 | /// 分享返回 7 | /// 8 | public class ShareResult 9 | { 10 | [JsonProperty("errno")] private int _errno; 11 | [JsonProperty("shareid")] private long _shareid; 12 | [JsonProperty("link")] private string _link; 13 | [JsonProperty("shorturl")] private string _shorturl; 14 | [JsonProperty("json")] private string _json; 15 | 16 | /// 17 | /// 错误代码(意义还未完全搞明白) 18 | /// 19 | public int ErrorCode => _errno; 20 | 21 | /// 22 | /// 分享ID 23 | /// 24 | public long ShareId => _shareid; 25 | 26 | /// 27 | /// 分享链接 28 | /// 29 | public string Link => _link; 30 | 31 | /// 32 | /// 分享链接(短) 33 | /// 34 | public string ShortUrl => _shorturl; 35 | 36 | /// 37 | /// 服务器返回完整Json 38 | /// 39 | public string Json => _json; 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace BaiduPanDownloadWpf.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Interfaces/Files/INetDiskFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | 5 | namespace BaiduPanDownloadWpf.Infrastructure.Interfaces.Files 6 | { 7 | /// 8 | /// A entity represents net-disk file. 9 | /// 10 | public interface INetDiskFile : IDiskFile 11 | { 12 | /// 13 | /// Gets the time at which the file was created. 14 | /// 15 | DateTime CreatedTime { get; } 16 | 17 | /// 18 | /// Gets the time at which the file was motified. 19 | /// 20 | DateTime MotifiedTime { get; } 21 | 22 | /// 23 | /// Gets childern file of current flie by asynchronous. 24 | /// If current file is , return a instance of type represents the childern file, 25 | /// otherwise, return null. 26 | /// 27 | /// The children file of current file. 28 | Task> GetChildrenAsync(); 29 | 30 | Task DownloadAsync(); 31 | 32 | Task DeleteAsync(); 33 | 34 | Task RestoreAsync(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/SettingsPage.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/DownloadEngine/DownloadTaskManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using Microsoft.Practices.Unity; 8 | using BaiduPanDownloadWpf.Infrastructure.Events; 9 | using BaiduPanDownloadWpf.Infrastructure; 10 | 11 | namespace BaiduPanDownloadWpf.Core.DownloadEngine 12 | { 13 | internal class DownloadTaskManager : ModelBase 14 | { 15 | public DownloadTaskManager(IUnityContainer container) : base(container) 16 | { 17 | EventAggregator.GetEvent().Subscribe( 18 | OnDownloadStateChanged, 19 | Prism.Events.ThreadOption.BackgroundThread, 20 | keepSubscriberReferenceAlive: false, 21 | filter: e => e.NewState == (e.NewState & (DownloadStateEnum.Completed | DownloadStateEnum.Canceled | DownloadStateEnum.Faulted | DownloadStateEnum.Paused))); 22 | } 23 | 24 | public void Add(DownloadTask task) 25 | { 26 | task.Start(); 27 | 28 | } 29 | 30 | public void AddRange(IEnumerable task) 31 | { 32 | 33 | } 34 | 35 | private void OnDownloadStateChanged(DownloadStateChangedEventArgs e) 36 | { 37 | 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Introduction ![version](https://img.shields.io/badge/BaiduPanDownloadWpf-v0.1.0.63-orange.svg) ![build state](https://img.shields.io/badge/build-passing-brightgreen.svg) 2 | 百度网盘**不限速**下载客户端,此项目源于[BaiduPanDownloadWinform](https://github.com/ResourceHunter/BaiduPanDownloadWinform),旨在使用[WPF](https://msdn.microsoft.com/en-us/library/mt149842.aspx)技术,为其编写一个更为美观的界面,并且重新设计了软件的架构,使之在应对度娘多变的和谐策略的同时,为UI部分代码的复用提供了可能。此项目基于[MUI](https://github.com/firstfloorsoftware/mui)进行开发,并借助[Prism](https://github.com/PrismLibrary/Prism)框架实现了[界面](https://github.com/ResourceHunter/BaiduPanDownloadWpf/tree/master/BaiduPanDownloadWpf)与[业务逻辑](https://github.com/ResourceHunter/BaiduPanDownloadWpf/tree/master/BaiduPanDownloadWpf.Core)的分离。 3 | 4 | ![preview](/docs/images/preview.png) 5 | 6 | # Getting Started 7 | 1. 下载代码,并使用Visual Studio(2015+)打开; 8 | 2. 选中整个解决方案并右键,选择生成解决方案(build / rebulid); 9 | 3. 期间会自动还原NuGet packages,并可能占用一些时间,请耐心等待。 10 | 4. 运行项目后,即可在Settings --> Login页面登入。 11 | 12 | ![login illustration](/docs/images/login_page.png) 13 | 14 | # Screenshots 15 | 16 | ![downloading page](/docs/images/downloading_page.jpg) 17 | 18 | ![downloaded page](/docs/images/downloaded_page.png) 19 | 20 | ![configure page](/docs/images/configure_page.png) 21 | 22 | # Contribute 23 | 如果您对此项目有兴趣并想贡献自己的idea,欢迎通过以下方式参与: 24 | - 加入**QQ群**:553683933或**联系**:1844812067,787673395; 25 | - 在[Issues](https://github.com/ResourceHunter/BaiduPanDownloadWpf/issues)板块进行留言,分享你的建议或需求; 26 | - Fork此项目,并通过[pull request](https://github.com/ResourceHunter/BaiduPanDownloadWpf/pulls)贡献你的代码。 27 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/DownloadCoreModule.cs: -------------------------------------------------------------------------------- 1 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 2 | using Microsoft.Practices.Unity; 3 | using Prism.Modularity; 4 | 5 | namespace BaiduPanDownloadWpf.Core 6 | { 7 | public class DownloadCoreModule : IModule 8 | { 9 | private readonly IUnityContainer _container; 10 | 11 | public DownloadCoreModule(IUnityContainer container) 12 | { 13 | _container = container; 14 | } 15 | 16 | public void Initialize() 17 | { 18 | RegisterTypeIfMissing(true); 19 | } 20 | 21 | /// 22 | /// Registers a type in the container only if that type was not already registered. 23 | /// 24 | /// The interface type to register. 25 | /// The type implementing the interface. 26 | /// Registers the type as a singleton. 27 | protected void RegisterTypeIfMissing(bool registerAsSingleton) where TTo : TForm 28 | { 29 | if (_container.IsRegistered()) return; 30 | 31 | if (registerAsSingleton) 32 | { 33 | _container.RegisterType(new ContainerControlledLifetimeManager()); 34 | } 35 | else 36 | { 37 | _container.RegisterType(); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BaiduPanDownloadWpf.Core")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BaiduPanDownloadWpf.Core")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("51154046-cbd6-4bf7-80ae-356fff2eb1b8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BaiduPanDownloadWpf.Infrastructure")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BaiduPanDownloadWpf.Infrastructure")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e66fd2a2-7398-471c-8b9f-62b4dd0a55fb")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/Items/DownloadTaskItem.vm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using BaiduPanDownloadWpf.Commands; 5 | using BaiduPanDownloadWpf.Infrastructure; 6 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 7 | using Microsoft.Practices.Unity; 8 | using System.Threading.Tasks; 9 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 10 | 11 | namespace BaiduPanDownloadWpf.ViewModels.Items 12 | { 13 | internal abstract class DownloadTaskItemViewModel : ViewModelBase 14 | { 15 | private readonly IDiskFile _diskFile; 16 | private Command _openFolderCommand; 17 | 18 | protected DownloadTaskItemViewModel(IUnityContainer container, IDiskFile diskFile) 19 | : base(container) 20 | { 21 | _diskFile = diskFile; 22 | OpenFolderCommand = new Command(OpenFolderCommandExecuteAsync, () => Directory.Exists(FilePath.FolderPath)); 23 | } 24 | 25 | public long FileId => _diskFile.FileId; 26 | public FileTypeEnum FileType => _diskFile.FileType; 27 | public FileLocation FilePath => _diskFile.FilePath; 28 | public DataSize? FileSize => new DataSize(_diskFile.FileSize); 29 | 30 | public Command OpenFolderCommand 31 | { 32 | get { return _openFolderCommand; } 33 | set { SetProperty(ref _openFolderCommand, value); } 34 | } 35 | private void OpenFolderCommandExecuteAsync() 36 | { 37 | Task.Run(() => 38 | { 39 | try 40 | { 41 | Process.Start("explorer.exe", FilePath.FolderPath); 42 | } 43 | catch { } 44 | }); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using System.Windows.Media; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("BaiduPanDownloadWpf")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("BaiduPanDownloadWpf")] 14 | [assembly: AssemblyCopyright("Copyright © 2017 ")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | [assembly: Guid("b59e69ea-879e-424b-9422-5539563bcbb1")] 25 | 26 | // required to support per-monitor DPI awareness in Windows 8.1+ 27 | // see also https://mui.codeplex.com/wikipage?title=Per-monitor%20DPI%20awareness 28 | [assembly: DisableDpiAwareness] 29 | 30 | // Version information for an assembly consists of the following four values: 31 | // 32 | // Major Version 33 | // Minor Version 34 | // Build Number 35 | // Revision 36 | // 37 | // You can specify all the values or you can default the Build and Revision Numbers 38 | // by using the '*' as shown below: 39 | // [assembly: AssemblyVersion("1.0.*")] 40 | [assembly: AssemblyVersion("0.1.0.63")] 41 | [assembly: AssemblyFileVersion("0.1.0.63")] 42 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Dialogs/ShareFileDialog.xaml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Interfaces/ILocalDiskUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | 6 | namespace BaiduPanDownloadWpf.Infrastructure.Interfaces 7 | { 8 | /// 9 | /// An aggregate object represents local disk user. 10 | /// 11 | public interface ILocalDiskUser 12 | { 13 | /// 14 | /// Gets or sets the current net-disk user. 15 | /// 16 | INetDiskUser CurrentNetDiskUser { get; set; } 17 | 18 | /// 19 | /// The download path of resources. 20 | /// 21 | string DownloadDirectory { get; set; } 22 | 23 | /// 24 | /// The maximum number of parallel download tasks. 25 | /// 26 | int ParallelTaskNumber { get; set; } 27 | 28 | /// 29 | /// The maximum number of download threads. 30 | /// 31 | int DownloadThreadNumber { get; set; } 32 | 33 | /// 34 | /// Gets a boolean value to indicate whether the password is remembered. 35 | /// 36 | bool IsRememberPassword { get; set; } 37 | 38 | /// 39 | /// Gets a boolean value to indicate whether sign in account automatically. 40 | /// 41 | bool IsAutoSignIn { get; set; } 42 | 43 | /// 44 | /// Gets all net-disk user instances. 45 | /// 46 | /// A IEnumerable of contains all net-disk user instances. 47 | Task> GetAllNetDiskUsers(); 48 | 49 | 50 | // TODO: Temporary solution. 51 | void PasueDownloadTask(long fileId); 52 | void RestartDownloadTask(long fileId); 53 | void CancelDownloadTask(long fileId); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/Items/DownloadedTaskItem.vm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using BaiduPanDownloadWpf.Commands; 5 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 6 | using Microsoft.Practices.Unity; 7 | using System.Threading.Tasks; 8 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 9 | 10 | namespace BaiduPanDownloadWpf.ViewModels.Items 11 | { 12 | internal class DownloadedTaskItemViewModel : DownloadTaskItemViewModel 13 | { 14 | private Command _openFileCommand; 15 | private Command _clearRecordCommand; 16 | 17 | public DownloadedTaskItemViewModel(IUnityContainer container, ILocalDiskFile diskFile) 18 | : base(container, diskFile) 19 | { 20 | CompletedTime = diskFile.CompletedTime.ToString("yyyy-MM-dd HH:mm"); 21 | OpenFileCommand = new Command(OpenFileCommandExecuteAsync, () => File.Exists(FilePath.FullPath)); 22 | ClearRecordCommand = new Command(ClearRecordCommandExecute); 23 | } 24 | 25 | public string CompletedTime { get; } 26 | 27 | public Command OpenFileCommand 28 | { 29 | get { return _openFileCommand; } 30 | set { SetProperty(ref _openFileCommand, value); } 31 | } 32 | public Command ClearRecordCommand 33 | { 34 | get { return _clearRecordCommand; } 35 | set { SetProperty(ref _clearRecordCommand, value); } 36 | } 37 | 38 | private void ClearRecordCommandExecute() 39 | { 40 | // TODO 41 | Debug.WriteLine($"{DateTime.Now} : Clear Record Command: {FilePath.FullPath}"); 42 | } 43 | private void OpenFileCommandExecuteAsync() 44 | { 45 | Task.Run(() => 46 | { 47 | try 48 | { 49 | Process.Start(new ProcessStartInfo { FileName = FilePath.FullPath }); 50 | } 51 | catch { } 52 | }); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/ResultData/DownloadResult.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using BaiduPanDownloadWpf.Core.NetWork; 4 | using Newtonsoft.Json; 5 | 6 | namespace BaiduPanDownloadWpf.Core.ResultData 7 | { 8 | /// 9 | /// 下载请求回复 10 | /// 11 | public class DownloadResult 12 | { 13 | [JsonProperty("error")] 14 | private int _error; 15 | 16 | [JsonProperty("urls")] 17 | private Dictionary _urls; 18 | 19 | /// 20 | /// Cookies 21 | /// 22 | public Cookies Cookies { get; set; } 23 | 24 | /// 25 | /// 错误代码 26 | /// 27 | public int ErrorCode => _error; 28 | 29 | /// 30 | /// 下载链接列表 31 | /// 32 | public Dictionary DownloadUrlList => _urls; 33 | 34 | /// 35 | /// 根据文件名获取链接 36 | /// 37 | /// 38 | /// 39 | public string[] GetUrlsByFileName(string fileName) 40 | { 41 | return !DownloadUrlList.ContainsKey(fileName) ? null : DownloadUrlList[fileName].UrlLists; 42 | } 43 | 44 | /// 45 | /// 链接列表 46 | /// 47 | public class UrlList 48 | { 49 | [JsonProperty("urls")] 50 | private SubClass[] _urls; 51 | 52 | /// 53 | /// 链接List 54 | /// 55 | public string[] UrlLists => _urls.Select(v => v.Url).ToArray(); 56 | 57 | /// 58 | /// 子类 59 | /// 60 | public class SubClass 61 | { 62 | [JsonProperty("url")] 63 | private string _url; 64 | 65 | /// 66 | /// 链接 67 | /// 68 | public string Url => _url; 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Events/DownloadStateChangedEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using BaiduPanDownloadWpf.Infrastructure.Exceptions; 5 | using Prism.Events; 6 | 7 | namespace BaiduPanDownloadWpf.Infrastructure.Events 8 | { 9 | public class DownloadStateChangedEvent : PubSubEvent 10 | { 11 | } 12 | 13 | public class DownloadStateChangedEventArgs : EventArgsBase 14 | { 15 | public long FileId { get; } 16 | public DownloadStateEnum OldState { get; } 17 | public DownloadStateEnum NewState { get; } 18 | 19 | public DownloadStateChangedEventArgs(long fileId, DownloadStateEnum oldState, DownloadStateEnum newState) 20 | { 21 | #if DEBUG 22 | if (!CheckArgs(oldState, newState)) 23 | throw new InvalidDownloadStateChangeException(oldState, newState, $"{oldState} can not be converted to {newState}."); 24 | #endif 25 | 26 | FileId = fileId; 27 | OldState = oldState; 28 | NewState = newState; 29 | } 30 | 31 | #if DEBUG 32 | private static readonly Dictionary StateChangeRule = new Dictionary 33 | { 34 | { DownloadStateEnum.Created, DownloadStateEnum.Waiting | DownloadStateEnum.Downloading }, 35 | { DownloadStateEnum.Waiting, DownloadStateEnum.Downloading | DownloadStateEnum.Canceled | DownloadStateEnum.Paused }, 36 | { DownloadStateEnum.Downloading, DownloadStateEnum.Paused | DownloadStateEnum.Completed | DownloadStateEnum.Canceled | DownloadStateEnum.Faulted }, 37 | { DownloadStateEnum.Paused, DownloadStateEnum.Downloading | DownloadStateEnum.Canceled | DownloadStateEnum.Paused } 38 | }; 39 | private bool CheckArgs(DownloadStateEnum oldState, DownloadStateEnum newState) 40 | { 41 | if (oldState == DownloadStateEnum.Canceled || 42 | oldState == DownloadStateEnum.Completed || 43 | oldState == DownloadStateEnum.Faulted || 44 | newState == DownloadStateEnum.Created) return false; 45 | 46 | return (StateChangeRule[oldState] & newState) == newState; 47 | } 48 | #endif 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/FileLocation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Text.RegularExpressions; 4 | 5 | namespace BaiduPanDownloadWpf.Infrastructure 6 | { 7 | public class FileLocation 8 | { 9 | /// 10 | /// Gets a regular expression for splitting the file full path string. 11 | /// In the right case, the group will have four elements: 12 | /// [0]: FullPath 13 | /// [1]: FolderName 14 | /// [2]: FileName 15 | /// [3]: FileExtension 16 | /// 17 | private static readonly Regex RegexFileLocation = new Regex(@"^([\\/]?(?:\w:)?(?:[^\\/]+?[\\/])*?)([^\\/]+?(?:\.(\w+?))?)?$", RegexOptions.Compiled); 18 | 19 | 20 | /// 21 | /// Gets a string representing the full path of the file. 22 | /// 23 | public string FullPath { get; } 24 | 25 | /// 26 | /// Gets a string representing the folder where the file is located. 27 | /// 28 | public string FolderPath { get; } 29 | 30 | /// 31 | /// Gets a stirng representing the file name. 32 | /// 33 | public string FileName { get; } 34 | 35 | /// 36 | /// Gets a string representing the file extension. 37 | /// 38 | public string FileExtension { get; } 39 | 40 | /// 41 | /// Initializes a instance of with specified file full path. 42 | /// 43 | /// A string representing the full path of the file. 44 | public FileLocation(string fileFullPath) 45 | { 46 | Debug.WriteLine($"{DateTime.Now} : {fileFullPath}"); 47 | var matchResult = RegexFileLocation.Match(fileFullPath); 48 | 49 | if (matchResult.Groups == null || matchResult.Groups.Count != 4) throw new ArgumentException($"The file path is not valid: {fileFullPath}", fileFullPath); 50 | 51 | FullPath = matchResult.Groups[0].Value; 52 | var temp = matchResult.Groups[1].Value; 53 | if(!string.IsNullOrEmpty(temp)) FolderPath = temp.Remove(temp.Length - 1); // Remove the "\" or "/" at the end. 54 | FileName = matchResult.Groups[2].Value; 55 | FileExtension = matchResult.Groups[3].Value.ToLower(); 56 | } 57 | 58 | public override string ToString() 59 | { 60 | return FullPath; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Interfaces/INetDiskUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 5 | 6 | namespace BaiduPanDownloadWpf.Infrastructure.Interfaces 7 | { 8 | /// 9 | /// An aggregate object represents net-disk user. 10 | /// 11 | public interface INetDiskUser 12 | { 13 | /// 14 | /// Gets the local path of the user's head image file. 15 | /// 16 | string HeadImagePath { get; } 17 | 18 | /// 19 | /// Gets the name of the user. 20 | /// 21 | string UserName { get; } 22 | 23 | /// 24 | /// Gets the nick name of the user. 25 | /// 26 | string NickName { get; } 27 | 28 | /// 29 | /// Gets the total size(byte) of net-disk. 30 | /// 31 | long TotalSpace { get; } 32 | 33 | /// 34 | /// Gets the free size(byte) of net-disk. 35 | /// 36 | long FreeSpace { get; } 37 | 38 | /// 39 | /// Gets the used size(byte) of net-disk. 40 | /// 41 | long UsedSpace { get; } 42 | 43 | /// 44 | /// Gets the root file, which represents root directory of the net-disk. 45 | /// 46 | INetDiskFile RootFile { get; } 47 | 48 | 49 | /// 50 | /// Gets the uncompleted download tasks. 51 | /// 52 | /// 53 | IEnumerable GetUncompletedFiles(); 54 | 55 | /// 56 | /// Gets the completed download tasks. 57 | /// 58 | /// 59 | IEnumerable GetCompletedFiles(); 60 | 61 | /// 62 | /// 63 | /// 64 | /// 65 | /// 66 | /// 67 | Task ShareFilesAsync(IEnumerable files, string password = null); 68 | 69 | /// 70 | /// Gets the list of the shared files. 71 | /// 72 | /// 73 | Task> GetSharedFilesAsync(); 74 | 75 | /// 76 | /// Gets the list of the deleted files. 77 | /// 78 | /// 79 | Task> GetDeletedFilesAsync(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Controls/AsyncButton.xaml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 18 | 19 | 30 | 31 | 32 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/ResultData/ShareListResult.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace BaiduPanDownloadWpf.Core.ResultData 4 | { 5 | /// 6 | /// 列出文件回复 7 | /// 8 | public class ShareListResult 9 | { 10 | #region 参数 11 | [JsonProperty("count")] private int _count; 12 | [JsonProperty("list")] private ShareItem[] _list; 13 | #endregion 14 | 15 | /// 16 | /// 分享数量 17 | /// 18 | public int Count => _count; 19 | /// 20 | /// 分享列表 21 | /// 22 | public ShareItem[] ItemList => _list; 23 | 24 | /// 25 | /// 分享信息 26 | /// 27 | public class ShareItem 28 | { 29 | #region 参数 30 | [JsonProperty("shareid")] private long _shareid; 31 | [JsonProperty("fsids")] private long[] _fsids; 32 | [JsonProperty("status")] private int _status; 33 | [JsonProperty("passwd")] private string _passwd; 34 | [JsonProperty("name")] private string _name; 35 | [JsonProperty("ctime")] private long _ctime; 36 | [JsonProperty("shortlink")] private string _shortlink; 37 | [JsonProperty("typicalPath")] public string _typicalPath; 38 | #endregion 39 | /// 40 | /// 分享ID 41 | /// 42 | public long ShareId => _shareid; 43 | /// 44 | /// 文件列表 45 | /// 46 | public long[] FileIdList => _fsids; 47 | /// 48 | /// 分享密码 49 | /// 50 | public string Password => _passwd; 51 | /// 52 | /// 名字 53 | /// 54 | public string Name => _name; 55 | /// 56 | /// 分享时间 57 | /// 58 | public long CreateTime => _ctime; 59 | /// 60 | /// 分享链接 61 | /// 62 | public string ShareLink => _shortlink; 63 | /// 64 | /// 文件目录 65 | /// 66 | public string Path => _typicalPath; 67 | /// 68 | /// 分享状态 69 | /// 70 | public ShareStatus States => (ShareStatus) _status; 71 | 72 | } 73 | 74 | /// 75 | /// 分享状态 76 | /// 77 | public enum ShareStatus 78 | { 79 | /// 80 | /// 正常 81 | /// 82 | Normal=0, 83 | /// 84 | /// 文件被删除 85 | /// 86 | Deleted=9, 87 | /// 88 | /// 分享失败 89 | /// 90 | Failure=1, 91 | /// 92 | /// 审核未通过 93 | /// 94 | Notpassed=4 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace BaiduPanDownloadWpf.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BaiduPanDownloadWpf.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Settings/About.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/Settings/ConfigurePage.vm.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Practices.Unity; 2 | using System; 3 | using System.Collections.Generic; 4 | using BaiduPanDownloadWpf.Commands; 5 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 6 | using System.Windows.Forms; 7 | using BaiduPanDownloadWpf.Assets; 8 | using Prism.Unity; 9 | 10 | namespace BaiduPanDownloadWpf.ViewModels.Settings 11 | { 12 | internal class ConfigurePageViewModel : ViewModelBase 13 | { 14 | private readonly ILocalDiskUserRepository _localDiskUserRepository; 15 | private ILocalDiskUser _localDiskUser; 16 | private Command _openFolderBrowserCommand; 17 | 18 | 19 | public ConfigurePageViewModel(IUnityContainer container, ILocalDiskUserRepository localDiskUserRepository) 20 | : base(container) 21 | { 22 | _localDiskUserRepository = localDiskUserRepository; 23 | OpenFolderBrowserCommand = new Command(OpenFolderBrowserCommandExecute, () => _localDiskUser != null); 24 | } 25 | 26 | protected override void OnLoaded() 27 | { 28 | if (SetProperty(ref _localDiskUser, _localDiskUserRepository?.FirstOrDefault())) UpdataAllProperties(); 29 | } 30 | 31 | public string DownloadPath 32 | { 33 | get { return _localDiskUser?.DownloadDirectory; } 34 | set 35 | { 36 | if (_localDiskUser == null) return; 37 | _localDiskUser.DownloadDirectory = value; 38 | OnPropertyChanged(() => DownloadPath); 39 | } 40 | } 41 | public int DownloadSpeedLimit 42 | { 43 | get { return _localDiskUser?.DownloadThreadNumber ?? 0; } 44 | set 45 | { 46 | if (_localDiskUser == null) return; 47 | _localDiskUser.DownloadThreadNumber = value; 48 | OnPropertyChanged(() => DownloadSpeedLimit); 49 | } 50 | } 51 | public int ParallelTaskNumber 52 | { 53 | get { return _localDiskUser?.ParallelTaskNumber ?? 0; } 54 | set 55 | { 56 | if (_localDiskUser == null) return; 57 | _localDiskUser.ParallelTaskNumber = value; 58 | OnPropertyChanged(() => ParallelTaskNumber); 59 | } 60 | } 61 | 62 | public Command OpenFolderBrowserCommand 63 | { 64 | get { return _openFolderBrowserCommand; } 65 | set { SetProperty(ref _openFolderBrowserCommand, value); } 66 | } 67 | 68 | private void OpenFolderBrowserCommandExecute() 69 | { 70 | var dialog = new FolderBrowserDialog { Description = UiStringResources.Please_select_the_download_path }; 71 | if (dialog.ShowDialog() == DialogResult.OK) 72 | { 73 | DownloadPath = dialog.SelectedPath; 74 | } 75 | } 76 | 77 | private void UpdateAllProperties() 78 | { 79 | OnPropertyChanged(() => DownloadPath); 80 | OnPropertyChanged(() => DownloadSpeedLimit); 81 | OnPropertyChanged(() => ParallelTaskNumber); 82 | } 83 | 84 | private void UpdataAllProperties() 85 | { 86 | OnPropertyChanged(() => DownloadPath); 87 | OnPropertyChanged(() => DownloadSpeedLimit); 88 | OnPropertyChanged(() => ParallelTaskNumber); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/DownloadedPage.vm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.ObjectModel; 3 | using System.Linq; 4 | using System.Windows.Input; 5 | using BaiduPanDownloadWpf.Commands; 6 | using BaiduPanDownloadWpf.Infrastructure; 7 | using Microsoft.Practices.Unity; 8 | using BaiduPanDownloadWpf.Infrastructure.Events; 9 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 10 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 11 | using BaiduPanDownloadWpf.ViewModels.Items; 12 | 13 | namespace BaiduPanDownloadWpf.ViewModels 14 | { 15 | internal class DownloadedPageViewModel : ViewModelBase 16 | { 17 | private readonly ILocalDiskUserRepository _localDiskUserRepository; 18 | private INetDiskUser _netDiskUser; 19 | private ObservableCollection _downloadTaskList = new ObservableCollection(); 20 | 21 | public DownloadedPageViewModel(IUnityContainer container, ILocalDiskUserRepository localDiskUserRepository) 22 | : base(container) 23 | { 24 | _localDiskUserRepository = localDiskUserRepository; 25 | 26 | ClearAllRecordCommand = new Command(ClearAllRecordCommandExecute, () => DownloadTaskList?.Any() ?? false); 27 | EventAggregator.GetEvent().Subscribe( 28 | OnDownloadCompleted, 29 | Prism.Events.ThreadOption.UIThread, 30 | keepSubscriberReferenceAlive: false, 31 | filter: e => e.NewState == DownloadStateEnum.Completed); 32 | } 33 | 34 | protected override void OnLoaded() 35 | { 36 | if (!SetProperty(ref _netDiskUser, _localDiskUserRepository?.FirstOrDefault()?.CurrentNetDiskUser)) return; 37 | if (_netDiskUser == null) 38 | { 39 | DownloadTaskList.Clear(); 40 | return; 41 | } 42 | foreach (var item in _netDiskUser.GetCompletedFiles()) 43 | { 44 | if (DownloadTaskList.Any(element => element.FileId == item.FileId)) continue; 45 | DownloadTaskList.Add(Container.Resolve(new DependencyOverride(item))); 46 | } 47 | } 48 | 49 | public ObservableCollection DownloadTaskList 50 | { 51 | get { return _downloadTaskList; } 52 | set { SetProperty(ref _downloadTaskList, value); } 53 | } 54 | 55 | 56 | private ICommand _clearAllRecordCommand; 57 | 58 | public ICommand ClearAllRecordCommand 59 | { 60 | get { return _clearAllRecordCommand; } 61 | set { SetProperty(ref _clearAllRecordCommand, value); } 62 | } 63 | 64 | private void ClearAllRecordCommandExecute() 65 | { 66 | foreach (var item in DownloadTaskList) 67 | { 68 | if (item.ClearRecordCommand.CanExecute()) 69 | item.ClearRecordCommand.Execute(); 70 | } 71 | } 72 | 73 | 74 | private void OnDownloadCompleted(DownloadStateChangedEventArgs e) 75 | { 76 | var temp = _netDiskUser.GetCompletedFiles().FirstOrDefault(element => element.FileId == e.FileId); 77 | if (temp == null) return; 78 | var localFile = Container.Resolve(new DependencyOverride(temp)); 79 | DownloadTaskList.Insert(0, localFile); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Server.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Net; 4 | using System.Net.Sockets; 5 | using System.Runtime.Remoting; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using BaiduPanDownloadWpf.Core.NetWork.Packets; 9 | using Newtonsoft.Json; 10 | 11 | namespace BaiduPanDownloadWpf.Core.NetWork 12 | { 13 | /// 14 | /// 数据服务器 15 | /// 16 | public class Server 17 | { 18 | /// 19 | /// 默认服务器 20 | /// 21 | public static Server DefaultServer { get; } = new Server() 22 | { 23 | ServerAddress = "tool.mrs4s.top", 24 | Port = 10162 25 | }; 26 | 27 | public static Server TestServer { get; }=new Server() 28 | { 29 | ServerAddress = "tool.mrs4s.top", 30 | Port=1024 31 | }; 32 | 33 | /// 34 | /// 服务器IP地址 35 | /// 36 | public string ServerAddress { get; set; } 37 | 38 | /// 39 | /// 服务器端口 40 | /// 41 | public int Port { get; set; } 42 | 43 | /// 44 | /// 连接服务器 45 | /// 46 | /// 47 | public Socket Connect() 48 | { 49 | try 50 | { 51 | var hostinfo = Dns.GetHostByName(ServerAddress); 52 | var ip = hostinfo.AddressList[0]; 53 | var clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 54 | clientSocket.Connect(new IPEndPoint(ip, Port)); 55 | return clientSocket; 56 | } 57 | catch (Exception ex) 58 | { 59 | throw new ServerException("连接服务器时出现错误", ex); 60 | } 61 | } 62 | 63 | /// 64 | /// 发送封包,获取回复(同步) 65 | /// 66 | /// 67 | /// 68 | public string SendPacket(PacketBase packet) 69 | { 70 | var data = 71 | Encoding.UTF8.GetBytes("[$Start]" + 72 | Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(packet))) + 73 | "[$End]"); 74 | using (var client = Connect()) 75 | { 76 | client.Send(data, data.Length, 0); 77 | var tmp = string.Empty; 78 | while (true) 79 | { 80 | var result = new byte[1024]; 81 | var length = client.Receive(result); 82 | tmp += Encoding.UTF8.GetString(result, 0, length); 83 | if (tmp.Contains("[$Start]") && tmp.Contains("[$End]")) 84 | { 85 | return 86 | Encoding.UTF8.GetString( 87 | Convert.FromBase64String(tmp.Replace("[$Start]", string.Empty) 88 | .Replace("[$End]", string.Empty))); 89 | } 90 | } 91 | } 92 | } 93 | 94 | /// 95 | /// 发送封包,获取回复(异步) 96 | /// 97 | /// 98 | /// 99 | public async Task SendPacketAsync(PacketBase packet) 100 | { 101 | return await Task.Run(() => SendPacket(packet)); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetWork/Cookies.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Reflection; 6 | using Newtonsoft.Json; 7 | 8 | namespace BaiduPanDownloadWpf.Core.NetWork 9 | { 10 | /// 11 | /// 传输用Cookies容器 12 | /// 13 | public class Cookies 14 | { 15 | /// 16 | /// Cookies字符串 17 | /// 18 | public string CookiesStr 19 | { 20 | get 21 | { 22 | return JsonConvert.SerializeObject(_cookiesKv); 23 | } 24 | set 25 | { 26 | try 27 | { 28 | _cookiesKv = JsonConvert.DeserializeObject>(value); 29 | } 30 | catch 31 | { 32 | var list = value.Split(';'); 33 | _cookiesKv.Clear(); 34 | foreach (var cookie in list) 35 | { 36 | if (cookie.Contains("=")) 37 | { 38 | _cookiesKv.Add(cookie.Split('=')[0].Replace(" ", string.Empty), cookie.Split('=')[1]); 39 | } 40 | } 41 | } 42 | } 43 | } 44 | 45 | Dictionary _cookiesKv = new Dictionary(); 46 | 47 | public string GetCookie(string Key) 48 | { 49 | return !Contains(Key) ? string.Empty : _cookiesKv[Key].Replace(",", string.Empty); 50 | } 51 | 52 | public string[] GetKeys() 53 | { 54 | var Keys = new string[_cookiesKv.Count]; 55 | var i = 0; 56 | foreach (var key in _cookiesKv) 57 | { 58 | Keys[i] = key.Key; 59 | i++; 60 | } 61 | return Keys; 62 | } 63 | 64 | public bool Contains(string key) 65 | { 66 | return _cookiesKv.ContainsKey(key); 67 | } 68 | 69 | public static Cookies GetCookiesByCookieContainer(CookieContainer cookieContainer) 70 | { 71 | var cookies = new Cookies(); 72 | foreach (Cookie cookie in GetAllCookies(cookieContainer)) 73 | { 74 | cookies.SetData(cookie.Name, cookie.Value); 75 | } 76 | return cookies; 77 | } 78 | 79 | private static CookieCollection GetAllCookies(CookieContainer cookieContainer) 80 | { 81 | var cookies = new CookieCollection(); 82 | foreach (var item in (cookieContainer.GetType().GetRuntimeFields().FirstOrDefault(v => v.Name == "m_domainTable").GetValue(cookieContainer) as IDictionary).Values) 83 | { 84 | var type = item.GetType().GetRuntimeFields().First(v => v.Name == "m_list"); 85 | foreach (var sub in ((IDictionary)type.GetValue(item)).Values) 86 | { 87 | cookies.Add((CookieCollection)sub); 88 | } 89 | } 90 | return cookies; 91 | } 92 | 93 | 94 | public Cookies Copy() 95 | { 96 | return new Cookies { CookiesStr = CookiesStr }; 97 | } 98 | 99 | public void SetData(string K, string V) 100 | { 101 | if (!_cookiesKv.ContainsKey(K)) 102 | { 103 | _cookiesKv.Add(K, V); 104 | return; 105 | } 106 | _cookiesKv[K] = V; 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Controls/AsyncButton.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using System.Windows.Input; 4 | using System.Windows.Media; 5 | 6 | namespace BaiduPanDownloadWpf.Controls 7 | { 8 | /// 9 | /// Interaction logic for AsyncButton.xaml 10 | /// 11 | public partial class AsyncButton : UserControl 12 | { 13 | public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(AsyncButton), new PropertyMetadata(null)); 14 | public static readonly DependencyProperty IsWorkingProperty = DependencyProperty.Register("IsWorking", typeof(bool), typeof(AsyncButton), new PropertyMetadata(false)); 15 | public static readonly DependencyProperty ProgressBarStyleProperty = DependencyProperty.Register("ProgressBarStyle", typeof(Style), typeof(AsyncButton), new PropertyMetadata(null)); 16 | public static readonly DependencyProperty ButtonTipProperty = DependencyProperty.Register("ButtonTip", typeof(string), typeof(AsyncButton), new PropertyMetadata(null)); 17 | public static readonly DependencyProperty IconDataProperty = DependencyProperty.Register("IconData", typeof(Geometry), typeof(AsyncButton), new PropertyMetadata(null)); 18 | public static readonly DependencyProperty IconWidthProperty = DependencyProperty.Register("IconWidth", typeof(double), typeof(AsyncButton), new PropertyMetadata(14.0)); 19 | public static readonly DependencyProperty IconHeightProperty = DependencyProperty.Register("IconHeight", typeof(double), typeof(AsyncButton), new PropertyMetadata(14.0)); 20 | public static readonly DependencyProperty ProgressRingWidthProperty = DependencyProperty.Register("ProgressRingWidth", typeof(double), typeof(AsyncButton), new PropertyMetadata(25.0)); 21 | public static readonly DependencyProperty ProgressRingHeightProperty = DependencyProperty.Register("ProgressRingHeight", typeof(double), typeof(AsyncButton), new PropertyMetadata(25.0)); 22 | public static readonly DependencyProperty IsAutoHideButtonProperty = DependencyProperty.Register("IsAutoHideButton", typeof(bool), typeof(AsyncButton), new PropertyMetadata(true)); 23 | 24 | public ICommand Command 25 | { 26 | get { return (ICommand)GetValue(CommandProperty); } 27 | set { SetValue(CommandProperty, value); } 28 | } 29 | public bool IsWorking 30 | { 31 | get { return (bool)GetValue(IsWorkingProperty); } 32 | set { SetValue(IsWorkingProperty, value); } 33 | } 34 | public Style ProgressBarStyle 35 | { 36 | get { return (Style)GetValue(ProgressBarStyleProperty); } 37 | set { SetValue(ProgressBarStyleProperty, value); } 38 | } 39 | public string ButtonTip 40 | { 41 | get { return (string)GetValue(ButtonTipProperty); } 42 | set { SetValue(ButtonTipProperty, value); } 43 | } 44 | public Geometry IconData 45 | { 46 | get { return (Geometry)GetValue(IconDataProperty); } 47 | set { SetValue(IconDataProperty, value); } 48 | } 49 | public double IconWidth 50 | { 51 | get { return (double)GetValue(IconWidthProperty); } 52 | set { SetValue(IconWidthProperty, value); } 53 | } 54 | public double IconHeight 55 | { 56 | get { return (double)GetValue(IconHeightProperty); } 57 | set { SetValue(IconHeightProperty, value); } 58 | } 59 | public double ProgressRingWidth 60 | { 61 | get { return (double)GetValue(ProgressRingWidthProperty); } 62 | set { SetValue(ProgressRingWidthProperty, value); } 63 | } 64 | public double ProgressRingHeight 65 | { 66 | get { return (double)GetValue(ProgressRingHeightProperty); } 67 | set { SetValue(ProgressRingHeightProperty, value); } 68 | } 69 | public bool IsAutoHideButton 70 | { 71 | get { return (bool)GetValue(IsAutoHideButtonProperty); } 72 | set { SetValue(IsAutoHideButtonProperty, value); } 73 | } 74 | 75 | public AsyncButton() 76 | { 77 | InitializeComponent(); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/Download/DownloadCore/DownloadInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using BaiduPanDownloadWpf.Core.NetWork; 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Security.Cryptography; 8 | using System.Text; 9 | using static System.Web.Security.FormsAuthentication; 10 | 11 | namespace BaiduPanDownloadWpf.Core.Download.DwonloadCore 12 | { 13 | /// 14 | /// 下载数据 15 | /// 16 | public class DownloadInfo 17 | { 18 | /// 19 | /// 总长度 20 | /// 21 | public long ContentLength { get; set; } 22 | /// 23 | /// 下载完成长度 24 | /// 25 | public long CompletedLength { get; set; } 26 | /// 27 | /// 是否完成 28 | /// 29 | public bool Completed { get; set; } 30 | /// 31 | /// 下载链接 32 | /// 33 | public string[] DownloadUrl { get; set; } 34 | /// 35 | /// 下载路径 36 | /// 37 | public string DownloadPath { get; set; } 38 | /// 39 | /// 块大小 40 | /// 41 | public long BlockLength { get; set; } 42 | /// 43 | /// Cookies 44 | /// 45 | public Cookies UserCookies { get; set; } 46 | /// 47 | /// Cookies所使用的Domain 48 | /// 49 | public string Domain { get; set; } = ".baidu.com"; 50 | 51 | /// 52 | /// 下载所使用的的Referer 53 | /// 54 | public string Referer { get; set; } = "http://pan.baidu.com/disk/home"; 55 | 56 | /// 57 | /// 下载所使用的的UA 58 | /// 59 | public string UserAgent { get; set; } = "netdisk;5.5.2.0;PC;PC-Windows;6.1.7601;WindowsBaiduNetdisk"; 60 | 61 | /// 62 | /// 下载分块 63 | /// 64 | public List DownloadBlockList { get; } = new List(); 65 | 66 | /// 67 | /// 完成时间 68 | /// 69 | public DateTime CompletedTime { get; set; } 70 | 71 | /// 72 | /// 初始化分块信息 73 | /// 74 | public void init(string path) 75 | { 76 | init(); 77 | Save(path); 78 | } 79 | 80 | /// 81 | /// 初始化分块信息 82 | /// 83 | public void init() 84 | { 85 | var temp = 0L; 86 | DownloadBlockList.Clear(); 87 | while (temp + BlockLength < ContentLength) 88 | { 89 | DownloadBlockList.Add(new DownloadBlock 90 | { 91 | From = temp, 92 | To = temp + BlockLength - 1, 93 | Completed = false, 94 | }); 95 | temp += BlockLength; 96 | } 97 | DownloadBlockList.Add(new DownloadBlock 98 | { 99 | From = temp, 100 | To = ContentLength, 101 | Completed = false, 102 | }); 103 | CompletedTime=DateTime.Now; 104 | } 105 | /// 106 | /// 保存 107 | /// 108 | /// 109 | public void Save(string path) 110 | { 111 | File.WriteAllText(path, JObject.Parse(JsonConvert.SerializeObject(this)).ToString()); 112 | } 113 | } 114 | /// 115 | /// 下载分块 116 | /// 117 | public class DownloadBlock 118 | { 119 | /// 120 | /// 下载开始处 121 | /// 122 | public long From { get; set; } 123 | /// 124 | /// 下载结束处 125 | /// 126 | public long To { get; set; } 127 | /// 128 | /// 已下载大小 129 | /// 130 | public long CompletedLength { get; set; } = 0L; 131 | /// 132 | /// 是否完成 133 | /// 134 | public bool Completed { get; set; } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/BaiduPanDownloadWpf.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E66FD2A2-7398-471C-8B9F-62B4DD0A55FB} 8 | Library 9 | Properties 10 | BaiduPanDownloadWpf.Infrastructure 11 | BaiduPanDownloadWpf.Infrastructure 12 | v4.5.1 13 | 512 14 | SAK 15 | SAK 16 | SAK 17 | SAK 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | bin\Debug\BaiduPanDownloadWpf.Infrastructure.XML 28 | 29 | 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | ..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll 40 | True 41 | 42 | 43 | ..\packages\Prism.Core.6.2.0\lib\net45\Prism.dll 44 | True 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 85 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/DataSize.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPanDownloadWpf.Infrastructure 4 | { 5 | /// 6 | /// A data structure is used to represent the size, and can be converted to the appropriate size for display. 7 | /// 8 | public struct DataSize : IEquatable 9 | { 10 | public const double ConversionFactor = 1024; 11 | 12 | private SizeUnitEnum _unit; 13 | 14 | public long ValueBasedOnB { get; } 15 | public double Value { get; private set; } 16 | public SizeUnitEnum Unit 17 | { 18 | get { return _unit; } 19 | set 20 | { 21 | if (value == _unit) return; 22 | var loopNumber = value - _unit; 23 | if (loopNumber > 0) 24 | { 25 | for (int i = 0; i < loopNumber; i++) Value /= ConversionFactor; 26 | } 27 | else 28 | { 29 | loopNumber = -loopNumber; 30 | for (int i = 0; i < loopNumber; i++) Value *= ConversionFactor; 31 | } 32 | _unit = value; 33 | } 34 | } 35 | 36 | public DataSize(long size) 37 | { 38 | ValueBasedOnB = size; 39 | Value = size; 40 | _unit = SizeUnitEnum.B; 41 | while (Value >= ConversionFactor) 42 | { 43 | Value /= ConversionFactor; 44 | _unit++; 45 | } 46 | } 47 | public DataSize(double size, SizeUnitEnum sizeUnit = SizeUnitEnum.B) 48 | { 49 | var temp = size; 50 | for (int i = 0; i < sizeUnit - SizeUnitEnum.B; i++) 51 | { 52 | temp *= ConversionFactor; 53 | } 54 | ValueBasedOnB = (long)temp; 55 | while (size >= ConversionFactor && sizeUnit < SizeUnitEnum.P) 56 | { 57 | size /= ConversionFactor; 58 | sizeUnit++; 59 | } 60 | Value = size; 61 | _unit = sizeUnit; 62 | } 63 | 64 | 65 | public bool Equals(DataSize other) 66 | { 67 | return this == other; 68 | } 69 | public override string ToString() 70 | { 71 | return (Unit < SizeUnitEnum.M ? $"{Value:N0} " : $"{Value:N2} ") + (Unit == SizeUnitEnum.B ? $"{Unit}" : $"{Unit}B"); 72 | } 73 | public override bool Equals(object obj) 74 | { 75 | if (ReferenceEquals(null, obj)) return false; 76 | return obj is DataSize && Equals((DataSize)obj); 77 | } 78 | public override int GetHashCode() 79 | { 80 | unchecked 81 | { 82 | return ((int)_unit * 397) ^ Value.GetHashCode(); 83 | } 84 | } 85 | 86 | #region Operators 87 | public static DataSize operator +(DataSize left, DataSize right) 88 | { 89 | return new DataSize(left.ValueBasedOnB + right.ValueBasedOnB); 90 | } 91 | public static DataSize operator +(DataSize left, long right) 92 | { 93 | return new DataSize(left.ValueBasedOnB + right); 94 | } 95 | public static DataSize operator -(DataSize value) 96 | { 97 | return new DataSize(-value.ValueBasedOnB); 98 | } 99 | public static DataSize operator -(DataSize left, DataSize right) 100 | { 101 | return left + -right; 102 | } 103 | public static DataSize operator -(DataSize left, long right) 104 | { 105 | return left + -right; 106 | } 107 | public static DataSize operator *(DataSize left, double right) 108 | { 109 | return new DataSize(left.ValueBasedOnB * right); 110 | } 111 | public static DataSize operator /(DataSize left, double right) 112 | { 113 | return new DataSize(left.ValueBasedOnB / right); 114 | } 115 | public static double operator /(DataSize left, DataSize right) 116 | { 117 | return 1.0 * left.ValueBasedOnB / right.ValueBasedOnB; 118 | } 119 | public static bool operator ==(DataSize left, DataSize right) 120 | { 121 | return left.ValueBasedOnB == right.ValueBasedOnB; 122 | } 123 | public static bool operator !=(DataSize left, DataSize right) 124 | { 125 | return !(left == right); 126 | } 127 | #endregion 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Views/Settings/ConfigurePage.xaml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 40 | 41 | 44 | 45 | 47 | 51 | 53 | 54 | 56 | 59 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/NetDiskUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using BaiduPanDownloadWpf.Core.NetWork; 6 | using BaiduPanDownloadWpf.Core.NetWork.Packets; 7 | using BaiduPanDownloadWpf.Core.ResultData; 8 | using BaiduPanDownloadWpf.Infrastructure; 9 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 10 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 11 | using Newtonsoft.Json; 12 | using Newtonsoft.Json.Linq; 13 | 14 | namespace BaiduPanDownloadWpf.Core 15 | { 16 | /// 17 | /// 网盘账户 18 | /// 19 | public class NetDiskUser : INetDiskUser 20 | { 21 | private readonly LocalDiskUser _account; 22 | 23 | /// 24 | /// 便利方法,获取数据服务器 25 | /// 26 | internal Server DataServer => _account.DataServer; 27 | 28 | /// 29 | /// 便利方法,获取账户Token 30 | /// 31 | internal string Token => _account.Token; 32 | 33 | /// 34 | /// 便利方法,获取下载路径 35 | /// 36 | internal string DownloadDirectory => _account.DownloadDirectory; 37 | 38 | internal LocalDiskUser LocalUser => _account; 39 | 40 | 41 | 42 | public NetDiskUser(LocalDiskUser account) 43 | { 44 | _account = account; 45 | RootFile = new NetDiskFile(this); 46 | } 47 | 48 | 49 | #region Public properties 50 | /// 51 | /// 用户名 52 | /// 53 | public string UserName { get; private set; } 54 | 55 | /// 56 | /// 昵称 57 | /// 58 | public string NickName { get; private set; } 59 | 60 | /// 61 | /// 头像URL 62 | /// 63 | public string HeadImagePath { get; private set; } 64 | 65 | /// 66 | /// 总容量 67 | /// 68 | public long TotalSpace { get; private set; } 69 | 70 | /// 71 | /// 剩余容量 72 | /// 73 | public long FreeSpace { get; private set; } 74 | 75 | /// 76 | /// 已用容量 77 | /// 78 | public long UsedSpace { get; private set; } 79 | 80 | /// 81 | /// Gets the root file, which represents root directory of the net-disk. 82 | /// 83 | public INetDiskFile RootFile { get; } 84 | #endregion 85 | 86 | 87 | public IEnumerable GetUncompletedFiles() 88 | { 89 | return _account.GetUncompletedFiles(); 90 | } 91 | 92 | public IEnumerable GetCompletedFiles() 93 | { 94 | return _account.GetCompletedFiles(); 95 | } 96 | 97 | 98 | public Task DownloadAsync(NetDiskFile[] files) 99 | { 100 | throw new NotImplementedException(); 101 | } 102 | 103 | public async Task ShareFilesAsync(IEnumerable files, string password = null) 104 | { 105 | var temp = JsonConvert.DeserializeObject(await DataServer.SendPacketAsync(new ShareFilePacket 106 | { 107 | Token = Token, 108 | FileIds = files.Select(element=>element.FileId).ToArray(), 109 | Password = password 110 | })); 111 | return new Uri(temp.ShortUrl); 112 | } 113 | 114 | public Task> GetSharedFilesAsync() 115 | { 116 | throw new NotImplementedException(); 117 | //return JsonConvert.DeserializeObject(await DataServer.SendPacketAsync(new ListSharePacket 118 | //{ 119 | // Token = Token, 120 | // Page = page 121 | //})); 122 | } 123 | 124 | public Task> GetDeletedFilesAsync() 125 | { 126 | throw new NotImplementedException(); 127 | } 128 | 129 | /// 130 | /// 更新用户信息 131 | /// 132 | public async Task UpdateUserInfoAsync() 133 | { 134 | var json = JObject.Parse(await DataServer.SendPacketAsync(new PacketBase 135 | { 136 | Token = Token, 137 | PacketID = 10 138 | })); 139 | UserName = (string)json["username"]; 140 | NickName = (string)json["nick_name"]; 141 | HeadImagePath = (string)json["avatar_url"]; 142 | TotalSpace = (long)json["total"]; 143 | FreeSpace = (long)json["free"]; 144 | UsedSpace = (long)json["used"]; 145 | } 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaiduPanDownloadWpf", "BaiduPanDownloadWpf\BaiduPanDownloadWpf.csproj", "{B59E69EA-879E-424B-9422-5539563BCBB1}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaiduPanDownloadWpf.Infrastructure", "BaiduPanDownloadWpf.Infrastructure\BaiduPanDownloadWpf.Infrastructure.csproj", "{E66FD2A2-7398-471C-8B9F-62B4DD0A55FB}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaiduPanDownloadWpf.Core", "BaiduPanDownloadWpf.Core\BaiduPanDownloadWpf.Core.csproj", "{51154046-CBD6-4BF7-80AE-356FFF2EB1B8}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{807026F9-E75B-47D6-98B4-DA2DAA0945D0}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Debug|x86 = Debug|x86 18 | Release|Any CPU = Release|Any CPU 19 | Release|x86 = Release|x86 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {B59E69EA-879E-424B-9422-5539563BCBB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {B59E69EA-879E-424B-9422-5539563BCBB1}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {B59E69EA-879E-424B-9422-5539563BCBB1}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {B59E69EA-879E-424B-9422-5539563BCBB1}.Debug|x86.Build.0 = Debug|Any CPU 26 | {B59E69EA-879E-424B-9422-5539563BCBB1}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {B59E69EA-879E-424B-9422-5539563BCBB1}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {B59E69EA-879E-424B-9422-5539563BCBB1}.Release|x86.ActiveCfg = Release|Any CPU 29 | {B59E69EA-879E-424B-9422-5539563BCBB1}.Release|x86.Build.0 = Release|Any CPU 30 | {E66FD2A2-7398-471C-8B9F-62B4DD0A55FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {E66FD2A2-7398-471C-8B9F-62B4DD0A55FB}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {E66FD2A2-7398-471C-8B9F-62B4DD0A55FB}.Debug|x86.ActiveCfg = Debug|Any CPU 33 | {E66FD2A2-7398-471C-8B9F-62B4DD0A55FB}.Debug|x86.Build.0 = Debug|Any CPU 34 | {E66FD2A2-7398-471C-8B9F-62B4DD0A55FB}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {E66FD2A2-7398-471C-8B9F-62B4DD0A55FB}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {E66FD2A2-7398-471C-8B9F-62B4DD0A55FB}.Release|x86.ActiveCfg = Release|Any CPU 37 | {E66FD2A2-7398-471C-8B9F-62B4DD0A55FB}.Release|x86.Build.0 = Release|Any CPU 38 | {51154046-CBD6-4BF7-80AE-356FFF2EB1B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {51154046-CBD6-4BF7-80AE-356FFF2EB1B8}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {51154046-CBD6-4BF7-80AE-356FFF2EB1B8}.Debug|x86.ActiveCfg = Debug|Any CPU 41 | {51154046-CBD6-4BF7-80AE-356FFF2EB1B8}.Debug|x86.Build.0 = Debug|Any CPU 42 | {51154046-CBD6-4BF7-80AE-356FFF2EB1B8}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {51154046-CBD6-4BF7-80AE-356FFF2EB1B8}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {51154046-CBD6-4BF7-80AE-356FFF2EB1B8}.Release|x86.ActiveCfg = Release|Any CPU 45 | {51154046-CBD6-4BF7-80AE-356FFF2EB1B8}.Release|x86.Build.0 = Release|Any CPU 46 | {807026F9-E75B-47D6-98B4-DA2DAA0945D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {807026F9-E75B-47D6-98B4-DA2DAA0945D0}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {807026F9-E75B-47D6-98B4-DA2DAA0945D0}.Debug|x86.ActiveCfg = Debug|Any CPU 49 | {807026F9-E75B-47D6-98B4-DA2DAA0945D0}.Debug|x86.Build.0 = Debug|Any CPU 50 | {807026F9-E75B-47D6-98B4-DA2DAA0945D0}.Release|Any CPU.ActiveCfg = Release|Any CPU 51 | {807026F9-E75B-47D6-98B4-DA2DAA0945D0}.Release|Any CPU.Build.0 = Release|Any CPU 52 | {807026F9-E75B-47D6-98B4-DA2DAA0945D0}.Release|x86.ActiveCfg = Release|Any CPU 53 | {807026F9-E75B-47D6-98B4-DA2DAA0945D0}.Release|x86.Build.0 = Release|Any CPU 54 | EndGlobalSection 55 | GlobalSection(SolutionProperties) = preSolution 56 | HideSolutionNode = FALSE 57 | EndGlobalSection 58 | GlobalSection(TeamFoundationVersionControl) = preSolution 59 | SccNumberOfProjects = 5 60 | SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} 61 | SccTeamFoundationServer = https://dingpingzhang.visualstudio.com/ 62 | SccLocalPath0 = . 63 | SccProjectUniqueName1 = BaiduPanDownloadWpf\\BaiduPanDownloadWpf.csproj 64 | SccProjectName1 = BaiduPanDownloadWpf 65 | SccLocalPath1 = BaiduPanDownloadWpf 66 | SccProjectUniqueName2 = BaiduPanDownloadWpf.Infrastructure\\BaiduPanDownloadWpf.Infrastructure.csproj 67 | SccProjectName2 = BaiduPanDownloadWpf.Infrastructure 68 | SccLocalPath2 = BaiduPanDownloadWpf.Infrastructure 69 | SccProjectUniqueName3 = BaiduPanDownloadWpf.Core\\BaiduPanDownloadWpf.Core.csproj 70 | SccProjectName3 = BaiduPanDownloadWpf.Core 71 | SccLocalPath3 = BaiduPanDownloadWpf.Core 72 | SccProjectUniqueName4 = Test\\Test.csproj 73 | SccProjectName4 = Test 74 | SccLocalPath4 = Test 75 | EndGlobalSection 76 | EndGlobal 77 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/Home.vm.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using BaiduPanDownloadWpf.Commands; 5 | using BaiduPanDownloadWpf.ViewModels.Items; 6 | using Microsoft.Practices.Unity; 7 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 8 | using BaiduPanDownloadWpf.Infrastructure; 9 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 10 | 11 | namespace BaiduPanDownloadWpf.ViewModels 12 | { 13 | internal class HomeViewModel : ViewModelBase 14 | { 15 | private readonly ILocalDiskUserRepository _localDiskUserRepository; 16 | private INetDiskUser _netDiskUser; 17 | private NetDiskFileNodeViewModel _currentFile; 18 | private bool _isRefreshing; 19 | 20 | 21 | public HomeViewModel(IUnityContainer container, ILocalDiskUserRepository localDiskUserRepository) 22 | : base(container) 23 | { 24 | _localDiskUserRepository = localDiskUserRepository; 25 | 26 | // TODO: Replace the Command to Prism.Commands.DelegateCommand. 27 | ReturnFolderCommand = new Command(() => CurrentFile = CurrentFile.Parent, () => CurrentFile?.Parent != null); 28 | EnterFolderCommand = new Command(file => CurrentFile = file, file => file?.FileType == FileTypeEnum.FolderType); 29 | RefreshFileListCommand = new Command(RefreshFileListCommandExecuteAsync, () => CurrentFile != null); 30 | BatchDownloadFileCommand = new Command(BatchDownloadFileCommandExecute, param => GetSeletedItems(param).Any()); 31 | BatchDeleteFileCommand = new Command(BatchDeleteFileCommandExecute, param => GetSeletedItems(param).Any()); 32 | } 33 | 34 | public NetDiskFileNodeViewModel CurrentFile 35 | { 36 | get { return _currentFile; } 37 | set { SetProperty(ref _currentFile, value); } 38 | } 39 | public bool IsRefreshing 40 | { 41 | get { return _isRefreshing; } 42 | set { SetProperty(ref _isRefreshing, value); } 43 | } 44 | 45 | #region Commands and commands's logic 46 | private Command _returnFolderCommand; 47 | private Command _enterFolderCommand; 48 | private Command _refreshFileListCommand; 49 | private Command _batchDownloadFileCommand; 50 | private Command _batchDeleteFileCommand; 51 | 52 | public Command ReturnFolderCommand 53 | { 54 | get { return _returnFolderCommand; } 55 | set { SetProperty(ref _returnFolderCommand, value); } 56 | } 57 | public Command EnterFolderCommand 58 | { 59 | get { return _enterFolderCommand; } 60 | set { SetProperty(ref _enterFolderCommand, value); } 61 | } 62 | public Command RefreshFileListCommand 63 | { 64 | get { return _refreshFileListCommand; } 65 | set { SetProperty(ref _refreshFileListCommand, value); } 66 | } 67 | public Command BatchDownloadFileCommand 68 | { 69 | get { return _batchDownloadFileCommand; } 70 | set { SetProperty(ref _batchDownloadFileCommand, value); } 71 | } 72 | public Command BatchDeleteFileCommand 73 | { 74 | get { return _batchDeleteFileCommand; } 75 | set { SetProperty(ref _batchDeleteFileCommand, value); } 76 | } 77 | 78 | private async void RefreshFileListCommandExecuteAsync() 79 | { 80 | IsRefreshing = true; 81 | var refreshChildren = CurrentFile.RefreshChildren(); 82 | if (refreshChildren != null) await refreshChildren; 83 | IsRefreshing = false; 84 | } 85 | private void BatchDownloadFileCommandExecute(IList parameter) 86 | { 87 | foreach (var item in GetSeletedItems(parameter)) 88 | { 89 | if (item.DownloadFileCommand.CanExecute()) 90 | item.DownloadFileCommand.Execute(); 91 | } 92 | } 93 | private void BatchDeleteFileCommandExecute(IList parameter) 94 | { 95 | // Remove UI elements 96 | foreach (var item in GetSeletedItems(parameter)) 97 | { 98 | if (item.DeleteFileCommand.CanExecute()) 99 | item.DeleteFileCommand.Execute(); 100 | } 101 | // TODO: Invokes function from model. 102 | 103 | } 104 | 105 | private IEnumerable GetSeletedItems(IList parameter) 106 | { 107 | if (parameter == null) return new NetDiskFileNodeViewModel[0]; 108 | 109 | var tempArray = new NetDiskFileNodeViewModel[parameter.Count]; 110 | for (int i = 0; i < tempArray.Length; i++) 111 | { 112 | tempArray[i] = parameter[i] as NetDiskFileNodeViewModel; 113 | } 114 | return tempArray; 115 | } 116 | #endregion 117 | 118 | protected override void OnLoaded() 119 | { 120 | if (SetProperty(ref _netDiskUser, _localDiskUserRepository?.FirstOrDefault()?.CurrentNetDiskUser) && _netDiskUser != null) 121 | { 122 | CurrentFile = Container.Resolve(new DependencyOverride(_netDiskUser.RootFile)); 123 | if (RefreshFileListCommand.CanExecute()) RefreshFileListCommand.Execute(); 124 | } 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/Items/DownloadingTaskItem.vm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using BaiduPanDownloadWpf.Commands; 6 | using BaiduPanDownloadWpf.Infrastructure; 7 | using BaiduPanDownloadWpf.Infrastructure.Events; 8 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 9 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 10 | using Microsoft.Practices.Unity; 11 | using Prism.Events; 12 | 13 | namespace BaiduPanDownloadWpf.ViewModels.Items 14 | { 15 | internal class DownloadingTaskItemViewModel : DownloadTaskItemViewModel 16 | { 17 | // TODO: Temporary solution. 18 | private ILocalDiskUser _localDiskUser; 19 | 20 | private DataSize _downloadSpeed; 21 | private DataSize _downloadProgerss; 22 | private DownloadStateEnum _downloadState = DownloadStateEnum.Waiting; 23 | 24 | private Command _pauseTaskCommand; 25 | private Command _startTaskCommand; 26 | private Command _cancelTaskCommand; 27 | 28 | public DownloadingTaskItemViewModel(IUnityContainer container, ILocalDiskUser localDiskUser, IDiskFile diskFile) 29 | : base(container, diskFile) 30 | { 31 | // TODO: Temporary solution. 32 | _localDiskUser = localDiskUser; 33 | 34 | PauseTaskCommand = new Command(PauseTaskCommandExecute, () => DownloadState == DownloadStateEnum.Downloading || DownloadState == DownloadStateEnum.Waiting); 35 | StartTaskCommand = new Command(StartTaskCommandExecute, () => DownloadState == DownloadStateEnum.Paused); 36 | CancelTaskCommand = new Command(CancelTaskCommandExecute); 37 | 38 | EventAggregator.GetEvent().Subscribe(OnDownloadProgressChanged, 39 | ThreadOption.UIThread, 40 | keepSubscriberReferenceAlive: false, 41 | filter: e => e.FileId == FileId); 42 | EventAggregator.GetEvent().Subscribe(OnDownloadStateChanged, 43 | ThreadOption.UIThread, 44 | keepSubscriberReferenceAlive: false, 45 | filter: e => e.FileId == FileId); 46 | } 47 | 48 | public TimeSpan? RemainingTime 49 | { 50 | get 51 | { 52 | if (DownloadSpeed.ValueBasedOnB == 0) 53 | return null; 54 | return new TimeSpan(0, 0, (int)Math.Round((1.0 * (FileSize?.ValueBasedOnB ?? 0) - DownloadProgress.ValueBasedOnB) / DownloadSpeed.ValueBasedOnB)); 55 | } 56 | } 57 | 58 | public DataSize DownloadSpeed 59 | { 60 | get { return _downloadSpeed; } 61 | private set { SetProperty(ref _downloadSpeed, value); } 62 | } 63 | public DataSize DownloadProgress 64 | { 65 | get { return _downloadProgerss; } 66 | private set { SetProperty(ref _downloadProgerss, value); } 67 | } 68 | public DownloadStateEnum DownloadState 69 | { 70 | get { return _downloadState; } 71 | private set { SetProperty(ref _downloadState, value); } 72 | } 73 | 74 | #region Commands and logic 75 | public Command PauseTaskCommand 76 | { 77 | get { return _pauseTaskCommand; } 78 | set { SetProperty(ref _pauseTaskCommand, value); } 79 | } 80 | public Command StartTaskCommand 81 | { 82 | get { return _startTaskCommand; } 83 | set { SetProperty(ref _startTaskCommand, value); } 84 | } 85 | public Command CancelTaskCommand 86 | { 87 | get { return _cancelTaskCommand; } 88 | set { SetProperty(ref _cancelTaskCommand, value); } 89 | } 90 | 91 | private void CancelTaskCommandExecute() 92 | { 93 | Debug.WriteLine($"{DateTime.Now}: Cancel Task: {FilePath.FullPath} Command"); 94 | // TODO: TryCancel() the task. 95 | _localDiskUser.CancelDownloadTask(FileId); 96 | } 97 | private void StartTaskCommandExecute() 98 | { 99 | Debug.WriteLine($"{DateTime.Now}: Start Task: {FilePath.FullPath} Command"); 100 | // TODO: TryStart() the task. 101 | _localDiskUser.RestartDownloadTask(FileId); 102 | } 103 | private void PauseTaskCommandExecute() 104 | { 105 | Debug.WriteLine($"{DateTime.Now}: Pause Task: {FilePath.FullPath} Command"); 106 | // TODO: TryPause() the task. 107 | _localDiskUser.PasueDownloadTask(FileId); 108 | } 109 | #endregion 110 | 111 | #region Events 112 | private void OnDownloadProgressChanged(DownloadProgressChangedEventArgs e) 113 | { 114 | // TODO: Temporary solution. 115 | if(DownloadState != DownloadStateEnum.Downloading) 116 | { 117 | var temp = DownloadState; 118 | DownloadState = DownloadStateEnum.Downloading; 119 | EventAggregator.GetEvent().Publish(new DownloadStateChangedEventArgs(FileId, temp, DownloadState)); 120 | } 121 | DownloadProgress = e.CurrentProgress; 122 | DownloadSpeed = e.CurrentSpeed; 123 | OnPropertyChanged(nameof(RemainingTime)); 124 | } 125 | private void OnDownloadStateChanged(DownloadStateChangedEventArgs e) 126 | { 127 | DownloadSpeed = new DataSize(); 128 | DownloadState = e.NewState; 129 | } 130 | #endregion 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/Download/DownloadCore/DownloadThread.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Text; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using BaiduPanDownloadWpf.Core.Download.DwonloadCore; 10 | 11 | namespace BaiduPanDownloadWpf.Core.Download.DownloadCore 12 | { 13 | /// 14 | /// 下载线程 15 | /// 16 | public class DownloadThread 17 | { 18 | #region 19 | public int ID { get; set; } 20 | /// 21 | /// 下载链接 22 | /// 23 | public string DownloadUrl { get; set; } 24 | /// 25 | /// 下载路径 26 | /// 27 | public string Path { get; set; } 28 | /// 29 | /// 下载块信息 30 | /// 31 | public DownloadBlock Block { get; set; } 32 | /// 33 | /// 下载信息 34 | /// 35 | public DownloadInfo Info { get; set; } 36 | #endregion 37 | public event Action ThreadCompletedEvent; 38 | 39 | bool _stoped; 40 | private Thread _workThread; 41 | private HttpWebRequest _request; 42 | private HttpWebResponse _response; 43 | 44 | internal DownloadThread() 45 | { 46 | _workThread = new Thread(Start); 47 | _workThread.Start(); 48 | } 49 | 50 | public void Start() 51 | { 52 | try 53 | { 54 | Thread.Sleep(300); 55 | _request?.Abort(); 56 | _response?.Close(); 57 | if (_stoped) 58 | { 59 | return; 60 | } 61 | if (Block.Completed) 62 | { 63 | ThreadCompletedEvent?.Invoke(); 64 | return; 65 | } 66 | _request = WebRequest.Create(DownloadUrl) as HttpWebRequest; 67 | _request.UserAgent = Info.UserAgent; 68 | _request.Referer = Info.Referer; 69 | if (Info.UserCookies != null) 70 | { 71 | _request.CookieContainer = new CookieContainer(); 72 | foreach (var Key in Info.UserCookies.GetKeys()) 73 | { 74 | var ck = new Cookie(Key, Info.UserCookies.GetCookie(Key)) { Domain = Info.Domain }; 75 | _request.CookieContainer.Add(ck); 76 | } 77 | } 78 | _request.Timeout = 8000; 79 | _request.AddRange(Block.From, Block.To); 80 | _response = _request.GetResponse() as HttpWebResponse; 81 | if (!File.Exists(Path)) 82 | { 83 | return; 84 | } 85 | using (var responseStream = _response.GetResponseStream()) 86 | { 87 | using (var stream = new FileStream(Path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite, 1024 * 1024)) 88 | { 89 | stream.Seek(Block.From, SeekOrigin.Begin); 90 | var array = new byte[1024]; 91 | var i = responseStream.Read(array, 0, array.Length); 92 | while (true) 93 | { 94 | if (i <= 0 && Block.From - 1 != Block.To && Block.From != Block.To) 95 | { 96 | //发送空数据,放弃这个链接重试 97 | _workThread = new Thread(Start); 98 | _workThread.Start(); 99 | return; 100 | } 101 | if (i <= 0) 102 | { 103 | break; 104 | } 105 | stream.Write(array, 0, i); 106 | Block.From += i; 107 | Block.CompletedLength += i; 108 | Info.CompletedLength += i; 109 | Info.DownloadBlockList[ID] = Block; 110 | i = responseStream.Read(array, 0, array.Length); 111 | } 112 | Block.Completed = true; 113 | ThreadCompletedEvent?.Invoke(); 114 | } 115 | } 116 | } 117 | catch (Exception ex) 118 | { 119 | if (ex is ThreadAbortException) 120 | { 121 | return; 122 | } 123 | if (ex.Message.Contains("终止") || ex.Message.Contains("取消")) 124 | { 125 | return; 126 | } 127 | Next(); 128 | _workThread = new Thread(Start); 129 | _workThread.Start(); 130 | } 131 | } 132 | 133 | /// 134 | /// 停止 135 | /// 136 | public void Stop() 137 | { 138 | if (Block.Completed) 139 | { 140 | return; 141 | } 142 | _stoped = true; 143 | _workThread.Abort(); 144 | _request?.Abort(); 145 | _response?.Close(); 146 | } 147 | 148 | private int _num; 149 | 150 | private void Next() 151 | { 152 | _num++; 153 | if (_num == Info.DownloadUrl.Length) 154 | { 155 | _num = 0; 156 | } 157 | DownloadUrl = Info.DownloadUrl[_num]; 158 | } 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/Settings/LoginPage.vm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.Practices.Unity; 7 | using System.Collections.ObjectModel; 8 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 9 | using BaiduPanDownloadWpf.Commands; 10 | using System.Windows.Controls; 11 | using BaiduPanDownloadWpf.Assets; 12 | using BaiduPanDownloadWpf.Infrastructure.Exceptions; 13 | using BaiduPanDownloadWpf.Views.Dialogs; 14 | using Prism.Logging; 15 | 16 | namespace BaiduPanDownloadWpf.ViewModels.Settings 17 | { 18 | internal class LoginPageViewModel : ViewModelBase 19 | { 20 | private ObservableCollection _netDiskUsers; 21 | private bool _isLoginServiceAccount; 22 | private bool _isAddingBaiduAccount; 23 | private string _localDiskUserName; 24 | private bool _isRememberPassword; 25 | private bool _isAutoSignIn; 26 | private bool _isSigningIn; 27 | 28 | private Command _loginServiceAccountCommand; 29 | private Command _signOutServiceAccountCommand; 30 | private Command _loginBaiduAccountCommand; 31 | 32 | public LoginPageViewModel(IUnityContainer container) : base(container) 33 | { 34 | LoginServiceAccountCommand = new Command(LoginServiceAccountCommandExecute); 35 | SignOutServiceAccountCommand = new Command(SignOutServiceAccountCommandExecute); 36 | LoginBaiduAccountCommand = new Command(LoginBaiduAccountCommandExecute); 37 | } 38 | 39 | public bool IsLoginServiceAccount 40 | { 41 | get { return _isLoginServiceAccount; } 42 | set { SetProperty(ref _isLoginServiceAccount, value); } 43 | } 44 | public bool IsAddingBaiduAccount 45 | { 46 | get { return _isAddingBaiduAccount; } 47 | set { SetProperty(ref _isAddingBaiduAccount, value); } 48 | } 49 | public bool IsSigningIn 50 | { 51 | get { return _isSigningIn; } 52 | set { SetProperty(ref _isSigningIn, value); } 53 | } 54 | public string LocalDiskUserName 55 | { 56 | get { return _localDiskUserName; } 57 | set { SetProperty(ref _localDiskUserName, value); } 58 | } 59 | 60 | // 1. If requires automatic login, it is necessary to remember the password. 61 | // 2. If not requires to remember the password, it also does not require automatic login. 62 | public bool IsRememberPassword 63 | { 64 | get { return _isRememberPassword; } 65 | set { if (SetProperty(ref _isRememberPassword, value) && !value) IsAutoSignIn = false; } 66 | } 67 | public bool IsAutoSignIn 68 | { 69 | get { return _isAutoSignIn; } 70 | set { if (SetProperty(ref _isAutoSignIn, value) && value) IsRememberPassword = true; } 71 | } 72 | public ObservableCollection NetDiskUsers 73 | { 74 | get { return _netDiskUsers; } 75 | set { SetProperty(ref _netDiskUsers, value); } 76 | } 77 | 78 | public Command LoginServiceAccountCommand 79 | { 80 | get { return _loginServiceAccountCommand; } 81 | set { SetProperty(ref _loginServiceAccountCommand, value); } 82 | } 83 | public Command SignOutServiceAccountCommand 84 | { 85 | get { return _signOutServiceAccountCommand; } 86 | set { SetProperty(ref _signOutServiceAccountCommand, value); } 87 | } 88 | public Command LoginBaiduAccountCommand 89 | { 90 | get { return _loginBaiduAccountCommand; } 91 | set { SetProperty(ref _loginBaiduAccountCommand, value); } 92 | } 93 | 94 | private async void LoginServiceAccountCommandExecute(PasswordBox password) 95 | { 96 | IsSigningIn = true; 97 | var localDiskUserRepository = Container.Resolve(); 98 | try 99 | { 100 | var localDiskUser = await localDiskUserRepository.SignInAsync(LocalDiskUserName, password.Password); 101 | localDiskUser.IsRememberPassword = IsRememberPassword; 102 | localDiskUser.IsAutoSignIn = IsAutoSignIn; 103 | var netDiskUsers = await localDiskUser.GetAllNetDiskUsers(); 104 | NetDiskUsers = new ObservableCollection(); 105 | foreach (var item in netDiskUsers) 106 | { 107 | NetDiskUsers.Add(item); 108 | } 109 | IsLoginServiceAccount = true; 110 | } 111 | catch (LoginException loginEx) 112 | { 113 | Logger.Log($"Login exception: {loginEx.Message}", Category.Warn, Priority.Low); 114 | new MessageDialog(UiStringResources.MessageDialogTitle_LoginException, loginEx.Message).ShowDialog(); 115 | } 116 | catch (System.Runtime.Remoting.ServerException serverEx) 117 | { 118 | Logger.Log($"Server exception: {serverEx.Message}", Category.Exception, Priority.High); 119 | new MessageDialog(UiStringResources.MessageDialogTitle_LoginException, serverEx.Message).ShowDialog(); 120 | } 121 | IsSigningIn = false; 122 | } 123 | private void SignOutServiceAccountCommandExecute() 124 | { 125 | 126 | IsLoginServiceAccount = false; 127 | IsAddingBaiduAccount = false; 128 | } 129 | private void LoginBaiduAccountCommandExecute() 130 | { 131 | 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/LocalDiskUser.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | using BaiduPanDownloadWpf.Core.Download; 8 | using BaiduPanDownloadWpf.Core.NetWork; 9 | using BaiduPanDownloadWpf.Core.NetWork.Packets; 10 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 11 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 12 | using Newtonsoft.Json.Linq; 13 | using BaiduPanDownloadWpf.Core.Download.DwonloadCore; 14 | using BaiduPanDownloadWpf.Core.ResultData; 15 | using Microsoft.Practices.Unity; 16 | using Newtonsoft.Json; 17 | 18 | namespace BaiduPanDownloadWpf.Core 19 | { 20 | public class LocalDiskUser : ModelBase, ILocalDiskUser 21 | { 22 | #region Public properties 23 | /// 24 | /// 账号Token 25 | /// 26 | public string Token { get; set; } 27 | 28 | /// 29 | /// 是否已绑定百度账户 30 | /// 31 | public bool BoundAccount { get; set; } 32 | 33 | /// 34 | /// 数据服务器 35 | /// 36 | public Server DataServer { get; set; } 37 | 38 | /// 39 | /// 账号 40 | /// 41 | internal string Name { get; set; } 42 | 43 | /// 44 | /// 密码 45 | /// 46 | internal string Password { get; set; } 47 | #endregion 48 | 49 | private List _uncompletedList=new List(); 50 | private List _completedList=new List(); 51 | 52 | /// 53 | /// 绑定百度账号 54 | /// 55 | /// 56 | /// 57 | public async Task BindingBaiduAccountAsync(Cookies baiduCookies) 58 | { 59 | if (baiduCookies == null) return false; 60 | var ret = await DataServer.SendPacketAsync(new BindingCookiesPacket() 61 | { 62 | Token = Token, 63 | cookies = baiduCookies 64 | }); 65 | return ret.Contains("0"); 66 | } 67 | 68 | // TODO: 记得修改。。。 69 | public async Task> GetAllNetDiskUsers() 70 | { 71 | if (!BoundAccount) 72 | { 73 | MessageBox.Show("尚未绑定百度账号,请使用工具绑定"); 74 | throw new NullReferenceException("尚未绑定百度账号"); 75 | } 76 | var user = new NetDiskUser(this); 77 | await user.UpdateUserInfoAsync(); 78 | CurrentNetDiskUser = user; 79 | return new[] { user }; 80 | } 81 | 82 | 83 | public IEnumerable GetUncompletedFiles() 84 | { 85 | return TaskManager.GetTaskManagerByLocalDiskUser(Container, this).GetUncompletedList(); 86 | } 87 | 88 | public IEnumerable GetCompletedFiles() 89 | { 90 | return TaskManager.GetTaskManagerByLocalDiskUser(Container, this).GetCompletedList(); 91 | } 92 | 93 | public void DownloadFile(NetDiskFile file, string path) 94 | { 95 | TaskManager.GetTaskManagerByLocalDiskUser(Container, this).CreateTask(file, path); 96 | } 97 | 98 | public TaskManager GetTaskManger() 99 | { 100 | return TaskManager.GetTaskManagerByLocalDiskUser(Container, this); 101 | } 102 | 103 | /// 104 | /// 下载文件 105 | /// 106 | /// 107 | /// 108 | public async Task DownloadFiles(NetDiskFile[] files, DownloadMethod method) 109 | { 110 | return JsonConvert.DeserializeObject(await DataServer.SendPacketAsync(new DownloadPacket() 111 | { 112 | Token = Token, 113 | Info = files, 114 | Method = (int)method 115 | })); 116 | } 117 | 118 | public override string ToString() 119 | { 120 | var json = new JObject 121 | { 122 | ["Name"] = Name, 123 | ["Pass"] = Password, 124 | ["AutoSignin"] = IsAutoSignIn, 125 | ["DownloadDirectory"] = DownloadDirectory, 126 | ["ParallelTaskNumber"] = ParallelTaskNumber, 127 | ["DwonloadTheradNumber"]=DownloadThreadNumber, 128 | ["RememberPassword"]=IsRememberPassword 129 | }; 130 | return json.ToString(); 131 | } 132 | 133 | public INetDiskUser CurrentNetDiskUser { get; set; } 134 | public string DownloadDirectory { get; set; } = Directory.GetDirectoryRoot(Directory.GetCurrentDirectory()) + "BaiduDownload"; 135 | public int ParallelTaskNumber { get; set; } = 1; 136 | public int DownloadThreadNumber { get; set; } = 32; 137 | public bool IsRememberPassword { get; set; } 138 | public bool IsAutoSignIn { get; set; } 139 | 140 | // TODO: Temporary solution. 141 | public void PasueDownloadTask(long fileId) 142 | { 143 | TaskManager.GetTaskManagerByLocalDiskUser(Container, this).PauseTask(fileId); 144 | } 145 | 146 | // TODO: Temporary solution. 147 | public void RestartDownloadTask(long fileId) 148 | { 149 | TaskManager.GetTaskManagerByLocalDiskUser(Container, this).ContinueTask(fileId); 150 | } 151 | 152 | // TODO: Temporary solution. 153 | public async void CancelDownloadTask(long fileId) 154 | { 155 | await TaskManager.GetTaskManagerByLocalDiskUser(Container, this).RemoveTask(fileId); 156 | } 157 | 158 | public LocalDiskUser(IUnityContainer container) : base(container) 159 | { 160 | 161 | } 162 | } 163 | } -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/Bootstrapper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Net; 5 | using System.Text; 6 | using BaiduPanDownloadWpf.Core; 7 | using Prism.Unity; 8 | using System.Windows; 9 | using System.Windows.Threading; 10 | using Prism.Logging; 11 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 12 | using Microsoft.Practices.Unity; 13 | using BaiduPanDownloadWpf.Assets; 14 | 15 | namespace BaiduPanDownloadWpf 16 | { 17 | public class Bootstrapper : UnityBootstrapper 18 | { 19 | protected override DependencyObject CreateShell() 20 | { 21 | return new MainWindow(); 22 | } 23 | 24 | protected override void InitializeShell() 25 | { 26 | ServicePointManager.DefaultConnectionLimit = 99999; 27 | Application.Current.Exit += OnExit; 28 | Application.Current.DispatcherUnhandledException += OnDispatcherUnhandledExceptionOccurred; 29 | AppDomain.CurrentDomain.UnhandledException += OnUnhandledExceptionOccurred; 30 | Application.Current.MainWindow.Show(); 31 | } 32 | 33 | private void OnExit(object sender, ExitEventArgs e) 34 | { 35 | var localDiskUserRepository = Container.Resolve(); 36 | var localDiskUser = localDiskUserRepository.FirstOrDefault(); 37 | if (localDiskUser != null) 38 | { 39 | localDiskUserRepository.Save(localDiskUser); 40 | } 41 | } 42 | 43 | protected override void InitializeModules() 44 | { 45 | Container.TryResolve().Initialize(); 46 | Logger.Log("Initialize DownloadCoreModule Module.", Category.Debug, Priority.Low); 47 | } 48 | 49 | protected override ILoggerFacade CreateLogger() 50 | { 51 | var filePath = Path.Combine(Directory.GetCurrentDirectory(), "Run log.log"); 52 | if (File.Exists(filePath)) File.Delete(filePath); 53 | var file = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read); 54 | var writer = new StreamWriter(file, Encoding.UTF8) { AutoFlush = true }; 55 | writer.WriteLine(UiStringResources.MWTitile); 56 | return new TextLogger(writer); 57 | //return new TextLogger(); 58 | } 59 | 60 | private void OnUnhandledExceptionOccurred(object sender, UnhandledExceptionEventArgs e) 61 | { 62 | //var message = $"Message: {(e.ExceptionObject as Exception)?.Message}, StackTrace: {(e.ExceptionObject as Exception)?.StackTrace}"; 63 | //Logger.Log(message, Category.Exception, Priority.High); 64 | // ------------------------------------------------------------------------------------------------------------------------------------ 65 | var exception = (Exception)e.ExceptionObject; 66 | var log = new StringBuilder(); 67 | log.AppendLine("程序在运行时遇到不可预料的错误"); 68 | log.AppendLine("=======追踪开始======="); 69 | log.AppendLine(); 70 | log.AppendLine("Time: " + DateTime.Now); 71 | log.AppendLine("Type: " + exception.GetType().Name); 72 | log.AppendLine("Message: " + exception.Message); 73 | log.AppendLine("Version: 0.1.0.63"); 74 | log.AppendLine("StackTrace: "); 75 | log.AppendLine(exception.StackTrace); 76 | log.AppendLine(); 77 | log.AppendLine("=======追踪结束======="); 78 | log.AppendLine("请将以上信息提供给开发者以供参考"); 79 | if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "Error.log"))) 80 | { 81 | try 82 | { 83 | File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "Error.log")); 84 | } 85 | catch 86 | { 87 | throw exception; 88 | } 89 | } 90 | File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "Error.log"), log.ToString()); 91 | throw exception; 92 | } 93 | 94 | private void OnDispatcherUnhandledExceptionOccurred(object sender, DispatcherUnhandledExceptionEventArgs e) 95 | { 96 | var message = $"Message: {e.Exception.Message}, StackTrace: {Environment.NewLine}{e.Exception.StackTrace}{Environment.NewLine}"; 97 | Logger.Log(message, Category.Exception, Priority.High); 98 | // ------------------------------------------------------------------------------------------------------------------------------------ 99 | var log = new StringBuilder(); 100 | log.AppendLine("程序在运行时遇到不可预料的错误"); 101 | log.AppendLine("=======追踪开始======="); 102 | log.AppendLine(); 103 | log.AppendLine("Time: " + DateTime.Now); 104 | log.AppendLine("Type: " + e.GetType().Name); 105 | log.AppendLine("Version: 0.1.0.63"); 106 | log.AppendLine("Message: " + e.Exception == null ? "无信息" : e.Exception.Message); 107 | log.AppendLine("StackTrace: "); 108 | log.AppendLine(e.Exception == null ? "无信息" : e.Exception.StackTrace); 109 | log.AppendLine(); 110 | log.AppendLine("=======追踪结束======="); 111 | log.AppendLine("请将以上信息提供给开发者以供参考"); 112 | if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "Error.log"))) 113 | { 114 | try 115 | { 116 | File.Delete(Path.Combine(Directory.GetCurrentDirectory(), "Error.log")); 117 | } 118 | catch 119 | { 120 | throw e.Exception; 121 | } 122 | } 123 | File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "Error.log"), log.ToString()); 124 | throw e.Exception; 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf/ViewModels/Items/NetDiskFileNode.vm.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | using BaiduPanDownloadWpf.Commands; 3 | using BaiduPanDownloadWpf.Infrastructure; 4 | using Microsoft.Practices.Unity; 5 | using System.Threading.Tasks; 6 | using BaiduPanDownloadWpf.Infrastructure.Interfaces.Files; 7 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 8 | using BaiduPanDownloadWpf.Infrastructure.Events; 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Linq; 12 | 13 | namespace BaiduPanDownloadWpf.ViewModels.Items 14 | { 15 | internal class NetDiskFileNodeViewModel : ViewModelBase 16 | { 17 | private readonly ILocalDiskUserRepository _localDiskUserRepository; 18 | private readonly INetDiskFile _netDiskFile; 19 | private NetDiskFileNodeViewModel _parent; 20 | private ObservableCollection _children; 21 | private bool _isDownloading; 22 | private int _downloadPercentage; 23 | 24 | public NetDiskFileNodeViewModel(IUnityContainer container, ILocalDiskUserRepository localDiskUserRepository, INetDiskFile netDiskFile) 25 | : base(container) 26 | { 27 | _localDiskUserRepository = localDiskUserRepository; 28 | _netDiskFile = netDiskFile; 29 | 30 | DeleteFileCommand = new Command(DeleteFileCommandExecuteAsync); 31 | DownloadFileCommand = new Command(DownloadFileCommandExecuteAsync); 32 | 33 | EventAggregator.GetEvent().Subscribe( 34 | OnDownloadStateChanged, 35 | Prism.Events.ThreadOption.UIThread, 36 | keepSubscriberReferenceAlive: false, 37 | filter: e => e.FileId == FileId); 38 | EventAggregator.GetEvent().Subscribe( 39 | OnDownloadProgressChanged, 40 | Prism.Events.ThreadOption.UIThread, 41 | keepSubscriberReferenceAlive: false, 42 | filter: e => e.FileId == FileId); 43 | } 44 | 45 | public NetDiskFileNodeViewModel Parent 46 | { 47 | get { return _parent; } 48 | set { SetProperty(ref _parent, value); } 49 | } 50 | public ObservableCollection Children 51 | { 52 | get 53 | { 54 | if (_children == null) RefreshChildren(); 55 | return _children; 56 | } 57 | set { SetProperty(ref _children, value); } 58 | } 59 | public long FileId => _netDiskFile.FileId; 60 | public FileTypeEnum FileType => _netDiskFile.FileType; 61 | public DataSize? FileSize => _netDiskFile == null ? default(DataSize) : new DataSize(_netDiskFile.FileSize); 62 | public FileLocation FilePath => _netDiskFile.FilePath; 63 | public string MotifyTime => _netDiskFile?.MotifiedTime.ToString("yyyy-MM-dd HH:mm"); 64 | public bool IsDownloading 65 | { 66 | get { return _isDownloading; } 67 | set { SetProperty(ref _isDownloading, value); } 68 | } 69 | public int DownloadPercentage 70 | { 71 | get { return _downloadPercentage; } 72 | set { SetProperty(ref _downloadPercentage, value); } 73 | } 74 | 75 | #region Commands and their logic 76 | private Command _deleteFileCommand; 77 | private Command _downloadFileCommand; 78 | 79 | public Command DeleteFileCommand 80 | { 81 | get { return _deleteFileCommand; } 82 | set { SetProperty(ref _deleteFileCommand, value); } 83 | } 84 | public Command DownloadFileCommand 85 | { 86 | get { return _downloadFileCommand; } 87 | set { SetProperty(ref _downloadFileCommand, value); } 88 | } 89 | 90 | private async void DeleteFileCommandExecuteAsync() 91 | { 92 | await _netDiskFile.DeleteAsync(); 93 | await Parent.RefreshChildren(); // The result of the deletion is obtained by refreshing the list. 94 | } 95 | private async void DownloadFileCommandExecuteAsync() 96 | { 97 | if (FileType != FileTypeEnum.FolderType) IsDownloading = true; 98 | await _netDiskFile.DownloadAsync(); 99 | } 100 | #endregion 101 | 102 | public Task RefreshChildren() 103 | { 104 | return Task.Run(async () => 105 | { 106 | var children = new ObservableCollection(); 107 | var downloadingFiles = _localDiskUserRepository.FirstOrDefault().CurrentNetDiskUser.GetUncompletedFiles(); 108 | foreach (var item in await _netDiskFile.GetChildrenAsync()) 109 | { 110 | var child = Container.Resolve(new DependencyOverride(item)); 111 | child.Parent = this; 112 | child.IsDownloading = downloadingFiles?.Any(element => element.FileId == child.FileId) ?? false; 113 | children.Add(child); 114 | } 115 | Children = children; 116 | OnPropertyChanged(nameof(FilePath)); 117 | }); 118 | } 119 | 120 | private void OnDownloadStateChanged(DownloadStateChangedEventArgs e) 121 | { 122 | if (e.NewState == DownloadStateEnum.Canceled 123 | || e.NewState == DownloadStateEnum.Completed 124 | || e.NewState == DownloadStateEnum.Faulted) 125 | { 126 | IsDownloading = false; 127 | DownloadPercentage = 0; 128 | } 129 | } 130 | private void OnDownloadProgressChanged(DownloadProgressChangedEventArgs e) 131 | { 132 | DownloadPercentage = (int)Math.Round((e.CurrentProgress / FileSize.Value) * 100); 133 | if (!IsDownloading) IsDownloading = true; 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Core/LocalDiskUserRepository.cs: -------------------------------------------------------------------------------- 1 | using BaiduPanDownloadWpf.Infrastructure.Interfaces; 2 | using System.IO; 3 | using BaiduPanDownloadWpf.Core.NetWork.Packets; 4 | using BaiduPanDownloadWpf.Infrastructure; 5 | using BaiduPanDownloadWpf.Infrastructure.Exceptions; 6 | using Newtonsoft.Json.Linq; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | using BaiduPanDownloadWpf.Core.NetWork; 11 | using System; 12 | using BaiduPanDownloadWpf.Core.Download; 13 | using Microsoft.Practices.Unity; 14 | using System.Diagnostics; 15 | 16 | namespace BaiduPanDownloadWpf.Core 17 | { 18 | public class LocalDiskUserRepository : ModelBase, ILocalDiskUserRepository 19 | { 20 | //.. 21 | private readonly string _userDataSavePath = Directory.GetCurrentDirectory() + @"\Users\"; 22 | private static readonly List _netDiskUserList = new List(); 23 | 24 | public LocalDiskUserRepository(IUnityContainer container) : base(container) 25 | { 26 | if (!Directory.Exists(_userDataSavePath)) 27 | { 28 | Directory.CreateDirectory(_userDataSavePath); 29 | } 30 | } 31 | 32 | public ILocalDiskUser FirstOrDefault() 33 | { 34 | return _netDiskUserList.FirstOrDefault(); 35 | } 36 | 37 | public async Task SignInAsync(string userName, string password) 38 | { 39 | var dataServer = Server.DefaultServer; 40 | var json = JObject.Parse(await dataServer.SendPacketAsync(new LoginPacket() 41 | { 42 | Name = userName, 43 | Password = password, 44 | })); 45 | switch ((int)json["error"]) 46 | { 47 | default: 48 | var result = new LocalDiskUser(Container) 49 | { 50 | Token = (string)json["token"], 51 | BoundAccount = (bool)json["cookies"], 52 | DataServer = dataServer, 53 | Name=userName, 54 | Password=password 55 | }; 56 | if (!Directory.Exists(Path.Combine(_userDataSavePath, userName))) 57 | { 58 | Directory.CreateDirectory(Path.Combine(_userDataSavePath, userName)); 59 | } 60 | try 61 | { 62 | TaskManager.GetTaskManagerByLocalDiskUser(Container, result); 63 | } 64 | catch (Exception ex) 65 | { 66 | Debug.WriteLine(ex.ToString()); 67 | } 68 | _netDiskUserList.Add(result); 69 | var userPath = Path.Combine(_userDataSavePath, userName); 70 | if (Directory.Exists(userPath)) 71 | { 72 | try 73 | { 74 | var info = JObject.Parse(File.ReadAllText(Path.Combine(userPath, "Account.json"))); 75 | result.DownloadDirectory = (string) info["DownloadDirectory"]; 76 | result.ParallelTaskNumber = (int) info["ParallelTaskNumber"]; 77 | result.DownloadThreadNumber = ((int) info["DwonloadTheradNumber"]) > 32 78 | ? 32 79 | : (int) info["DwonloadTheradNumber"]; 80 | } 81 | catch (Exception ex) 82 | { 83 | Debug.WriteLine(ex.ToString()); 84 | } 85 | } 86 | return result; 87 | case 1: 88 | throw new LoginException("用户不存在", ClientLoginStateEnum.NonUser); 89 | case 2: 90 | throw new LoginException("密码错误", ClientLoginStateEnum.PasswordError); 91 | case 3: 92 | throw new LoginException("异地登录", ClientLoginStateEnum.OtherError); 93 | case 4: 94 | throw new LoginException("服务端出现未知错误", ClientLoginStateEnum.OtherError); 95 | case 5: 96 | throw new LoginException("账号被封禁", ClientLoginStateEnum.Baned); 97 | } 98 | } 99 | 100 | public Task SignOutAsync() 101 | { 102 | throw new System.NotImplementedException(); 103 | } 104 | 105 | public async Task SignUpAsync(string userName, string password) 106 | { 107 | var dataServer = Server.DefaultServer; 108 | var json = JObject.Parse(await dataServer.SendPacketAsync(new RegisterPacket() 109 | { 110 | Name = userName, 111 | Password = password, 112 | })); 113 | switch ((int)json["error"]) 114 | { 115 | case 1: 116 | throw new RegisterException("用户名已存在", RegisterStateEnum.ExistingAccount); 117 | case 2: 118 | throw new RegisterException("服务端出现未知错误", RegisterStateEnum.OtherError); 119 | case 3: 120 | throw new RegisterException("注册人数达到服务端设置的上限", RegisterStateEnum.Maximum); 121 | } 122 | } 123 | 124 | public static LocalDiskUser GetLoginedUser() 125 | { 126 | return (LocalDiskUser)_netDiskUserList.FirstOrDefault(); 127 | } 128 | 129 | public void Save(ILocalDiskUser entity) 130 | { 131 | var userPath = Path.Combine(_userDataSavePath,((LocalDiskUser)entity).Name); 132 | if (!Directory.Exists(userPath)) 133 | Directory.CreateDirectory(userPath); 134 | File.WriteAllText(Path.Combine(userPath,"Account.json"),entity.ToString()); 135 | ((LocalDiskUser)entity).GetTaskManger().StopAndSave(); 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | [Bb]uildProcessTemplates/ 25 | [Tt]est/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # DNX 46 | project.lock.json 47 | artifacts/ 48 | 49 | *_i.c 50 | *_p.c 51 | *_i.h 52 | *.ilk 53 | *.meta 54 | *.obj 55 | *.pch 56 | *.pdb 57 | *.pgc 58 | *.pgd 59 | *.rsp 60 | *.sbr 61 | *.tlb 62 | *.tli 63 | *.tlh 64 | *.tmp 65 | *.tmp_proj 66 | *.log 67 | *.vspscc 68 | *.vssscc 69 | .builds 70 | *.pidb 71 | *.svclog 72 | *.scc 73 | 74 | # Chutzpah Test files 75 | _Chutzpah* 76 | 77 | # Visual C++ cache files 78 | ipch/ 79 | *.aps 80 | *.ncb 81 | *.opendb 82 | *.opensdf 83 | *.sdf 84 | *.cachefile 85 | *.VC.db 86 | *.VC.VC.opendb 87 | 88 | # Visual Studio profiler 89 | *.psess 90 | *.vsp 91 | *.vspx 92 | *.sap 93 | 94 | # TFS 2012 Local Workspace 95 | $tf/ 96 | 97 | # Guidance Automation Toolkit 98 | *.gpState 99 | 100 | # ReSharper is a .NET coding add-in 101 | _ReSharper*/ 102 | *.[Rr]e[Ss]harper 103 | *.DotSettings.user 104 | 105 | # JustCode is a .NET coding add-in 106 | .JustCode 107 | 108 | # TeamCity is a build add-in 109 | _TeamCity* 110 | 111 | # DotCover is a Code Coverage Tool 112 | *.dotCover 113 | 114 | # NCrunch 115 | _NCrunch_* 116 | .*crunch*.local.xml 117 | nCrunchTemp_* 118 | 119 | # MightyMoose 120 | *.mm.* 121 | AutoTest.Net/ 122 | 123 | # Web workbench (sass) 124 | .sass-cache/ 125 | 126 | # Installshield output folder 127 | [Ee]xpress/ 128 | 129 | # DocProject is a documentation generator add-in 130 | DocProject/buildhelp/ 131 | DocProject/Help/*.HxT 132 | DocProject/Help/*.HxC 133 | DocProject/Help/*.hhc 134 | DocProject/Help/*.hhk 135 | DocProject/Help/*.hhp 136 | DocProject/Help/Html2 137 | DocProject/Help/html 138 | 139 | # Click-Once directory 140 | publish/ 141 | 142 | # Publish Web Output 143 | *.[Pp]ublish.xml 144 | *.azurePubxml 145 | # TODO: Comment the next line if you want to checkin your web deploy settings 146 | # but database connection strings (with potential passwords) will be unencrypted 147 | *.pubxml 148 | *.publishproj 149 | 150 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 151 | # checkin your Azure Web App publish settings, but sensitive information contained 152 | # in these scripts will be unencrypted 153 | PublishScripts/ 154 | 155 | # NuGet Packages 156 | *.nupkg 157 | # The packages folder can be ignored because of Package Restore 158 | **/packages/* 159 | # except build/, which is used as an MSBuild target. 160 | !**/packages/build/ 161 | # Uncomment if necessary however generally it will be regenerated when needed 162 | #!**/packages/repositories.config 163 | # NuGet v3's project.json files produces more ignoreable files 164 | *.nuget.props 165 | *.nuget.targets 166 | 167 | # Microsoft Azure Build Output 168 | csx/ 169 | *.build.csdef 170 | 171 | # Microsoft Azure Emulator 172 | ecf/ 173 | rcf/ 174 | 175 | # Windows Store app package directories and files 176 | AppPackages/ 177 | BundleArtifacts/ 178 | Package.StoreAssociation.xml 179 | _pkginfo.txt 180 | 181 | # Visual Studio cache files 182 | # files ending in .cache can be ignored 183 | *.[Cc]ache 184 | # but keep track of directories ending in .cache 185 | !*.[Cc]ache/ 186 | 187 | # Others 188 | ClientBin/ 189 | ~$* 190 | *~ 191 | *.dbmdl 192 | *.dbproj.schemaview 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # ========================= 257 | # Operating System Files 258 | # ========================= 259 | 260 | # OSX 261 | # ========================= 262 | 263 | .DS_Store 264 | .AppleDouble 265 | .LSOverride 266 | 267 | # Thumbnails 268 | ._* 269 | 270 | # Files that might appear in the root of a volume 271 | .DocumentRevisions-V100 272 | .fseventsd 273 | .Spotlight-V100 274 | .TemporaryItems 275 | .Trashes 276 | .VolumeIcon.icns 277 | 278 | # Directories potentially created on remote AFP share 279 | .AppleDB 280 | .AppleDesktop 281 | Network Trash Folder 282 | Temporary Items 283 | .apdisk 284 | 285 | # Windows 286 | # ========================= 287 | 288 | # Windows image file caches 289 | Thumbs.db 290 | ehthumbs.db 291 | 292 | # Folder config file 293 | Desktop.ini 294 | 295 | # Recycle Bin used on file shares 296 | $RECYCLE.BIN/ 297 | 298 | # Windows Installer files 299 | *.cab 300 | *.msi 301 | *.msm 302 | *.msp 303 | 304 | # Windows shortcuts 305 | *.lnk 306 | -------------------------------------------------------------------------------- /BaiduPanDownloadWpf.Infrastructure/Enumerations.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaiduPanDownloadWpf.Infrastructure 4 | { 5 | /// 6 | /// An enum is used to mark the file type. 7 | /// 8 | public enum FileTypeEnum 9 | { 10 | /// 11 | /// Unknown type. 12 | /// 13 | OtherType, 14 | 15 | /// 16 | /// 17 | /// 18 | ApkType, 19 | DocType, 20 | ExeType, 21 | FolderType, 22 | ImgType, 23 | MixFileType, 24 | MusicType, 25 | PdfType, 26 | PptType, 27 | RarType, 28 | TorrentType, 29 | TxtType, 30 | VideoType, 31 | XlsType, 32 | } 33 | 34 | /// 35 | /// An enum is used to indicate the status of the download task. 36 | /// 37 | [Flags] 38 | public enum DownloadStateEnum 39 | { 40 | /// 41 | /// The task has been created. Start state. Can be converted to or . 42 | /// 43 | Created = 0, 44 | 45 | /// 46 | /// The task created, waiting to start. Can be converted to or or . 47 | /// 48 | Waiting = 1, 49 | 50 | /// 51 | /// The task is being downloaded. Can be converted to or or or . 52 | /// 53 | Downloading = 2, 54 | 55 | /// 56 | /// The task is Paused. Can be converted to or or . 57 | /// 58 | Paused = 4, 59 | 60 | /// 61 | /// The task has been completed. End state. 62 | /// 63 | Completed = 8, 64 | 65 | /// 66 | /// The task has been canceled. End state. 67 | /// 68 | Canceled = 16, 69 | 70 | /// 71 | /// The task failed. End state. 72 | /// 73 | Faulted = 32 74 | } 75 | 76 | /// 77 | /// The unit of size. 78 | /// 79 | public enum SizeUnitEnum 80 | { 81 | /// 82 | /// Byte. 83 | /// 84 | B, 85 | 86 | /// 87 | /// K byte. 88 | /// 89 | K, 90 | 91 | /// 92 | /// M byte. 93 | /// 94 | M, 95 | 96 | /// 97 | /// G byte. 98 | /// 99 | G, 100 | 101 | /// 102 | /// T byte. 103 | /// 104 | T, 105 | 106 | /// 107 | /// P byte. 108 | /// 109 | P, 110 | } 111 | 112 | /// 113 | /// The result of the login. 114 | /// 115 | public enum ClientLoginStateEnum 116 | { 117 | /// 118 | /// 登录完成 119 | /// 120 | Success = 0, 121 | /// 122 | /// 不存在的用户 123 | /// 124 | NonUser = 1, 125 | /// 126 | /// 密码错误 127 | /// 128 | PasswordError = 2, 129 | /// 130 | /// 被封禁 131 | /// 132 | Baned = 5, 133 | /// 134 | /// 未知错误 135 | /// 136 | OtherError = 4 137 | } 138 | 139 | /// 140 | /// 下载方法 141 | /// 142 | public enum DownloadMethodEnum 143 | { 144 | /// 145 | /// 直接下载 146 | /// 147 | DirectDownload = 1, 148 | /// 149 | /// 中转下载 150 | /// 151 | JumpDownload = 2, 152 | /// 153 | /// APPID下载 154 | /// 155 | AppidDownload = 3 156 | } 157 | 158 | /// 159 | /// 登录状态 160 | /// 161 | public enum LoginStateEnum 162 | { 163 | /// 164 | /// 登录完成,无错误 165 | /// 166 | Success = 0, 167 | /// 168 | /// 系统错误 169 | /// 170 | SystemError = -1, 171 | /// 172 | /// 账号格式不正确 173 | /// 174 | UserNameError = 1, 175 | /// 176 | /// 账号不存在 177 | /// 178 | UserNotExists = 2, 179 | /// 180 | /// 验证码不存在或已过期 181 | /// 182 | VerifyCodeNotExistsOrTimeout = 3, 183 | /// 184 | /// 用户名或密码错误 185 | /// 186 | UserNameOrPasswordError = 4, 187 | /// 188 | /// 验证码错误 189 | /// 190 | VerifyCodeError = 6, 191 | /// 192 | /// 密码错误 193 | /// 194 | PasswordError = 7, 195 | /// 196 | /// 帐号因安全问题已被限制登录 197 | /// 198 | SafeError = 16, 199 | /// 200 | /// 未输入验证码 201 | /// 202 | NoInputVerifyCode = 257, 203 | /// 204 | /// 系统正在升级,无法登陆 205 | /// 206 | SystemUpdate = 100027, 207 | /// 208 | /// 没有权限登录 209 | /// 210 | NoPermission = 21, 211 | 212 | } 213 | 214 | /// 215 | /// The result of the register. 216 | /// 217 | public enum RegisterStateEnum 218 | { 219 | /// 220 | /// 注册完成 221 | /// 222 | Completed, 223 | /// 224 | /// 已有账户 225 | /// 226 | ExistingAccount, 227 | /// 228 | /// 未知错误 229 | /// 230 | OtherError, 231 | /// 232 | /// 最大注册人数 233 | /// 234 | Maximum 235 | } 236 | 237 | /// 238 | /// The result of the share. 239 | /// 240 | public enum ShareStateEnum 241 | { 242 | /// 243 | /// 正常 244 | /// 245 | Normal = 0, 246 | /// 247 | /// 文件被删除 248 | /// 249 | Deleted = 9, 250 | /// 251 | /// 分享失败 252 | /// 253 | Failure = 1, 254 | /// 255 | /// 审核未通过 256 | /// 257 | Notpassed = 4 258 | } 259 | } 260 | --------------------------------------------------------------------------------