Ejemplo n.º 1
0
        /// <summary>
        /// 选择文件夹和下载项
        /// </summary>
        /// <param name="dialogService"></param>
        public string SetDirectory(IDialogService dialogService)
        {
            // 选择的下载文件夹
            string directory = string.Empty;

            // 是否使用默认下载目录
            if (SettingsManager.GetInstance().IsUseSaveVideoRootPath() == AllowStatus.YES)
            {
                // 下载内容
                VideoContentSettings videoContent = SettingsManager.GetInstance().GetVideoContent();
                downloadAudio    = videoContent.DownloadAudio;
                downloadVideo    = videoContent.DownloadVideo;
                downloadDanmaku  = videoContent.DownloadDanmaku;
                downloadSubtitle = videoContent.DownloadSubtitle;
                downloadCover    = videoContent.DownloadCover;

                directory = SettingsManager.GetInstance().GetSaveVideoRootPath();
            }
            else
            {
                // 打开文件夹选择器
                dialogService.ShowDialog(ViewDownloadSetterViewModel.Tag, null, result =>
                {
                    if (result.Result == ButtonResult.OK)
                    {
                        // 选择的下载文件夹
                        directory = result.Parameters.GetValue <string>("directory");

                        // 下载内容
                        downloadAudio    = result.Parameters.GetValue <bool>("downloadAudio");
                        downloadVideo    = result.Parameters.GetValue <bool>("downloadVideo");
                        downloadDanmaku  = result.Parameters.GetValue <bool>("downloadDanmaku");
                        downloadSubtitle = result.Parameters.GetValue <bool>("downloadSubtitle");
                        downloadCover    = result.Parameters.GetValue <bool>("downloadCover");
                    }
                });
            }

            // 下载设置dialog中如果点击取消或者关闭窗口,
            // 会返回空字符串,
            // 这时直接退出
            if (directory == null || directory == string.Empty)
            {
                return(null);
            }

            // 文件夹不存在则创建
            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            return(directory);
        }
        /// <summary>
        /// 保存下载视频内容到设置
        /// </summary>
        private void SetVideoContent()
        {
            VideoContentSettings videoContent = new VideoContentSettings
            {
                DownloadAudio    = DownloadAudio,
                DownloadVideo    = DownloadVideo,
                DownloadDanmaku  = DownloadDanmaku,
                DownloadSubtitle = DownloadSubtitle,
                DownloadCover    = DownloadCover
            };

            SettingsManager.GetInstance().SetVideoContent(videoContent);
        }
        public ViewDownloadSetterViewModel(IEventAggregator eventAggregator)
        {
            this.eventAggregator = eventAggregator;

            #region 属性初始化

            Title = DictionaryResource.GetString("DownloadSetter");

            CloudDownloadIcon      = NormalIcon.Instance().CloudDownload;
            CloudDownloadIcon.Fill = DictionaryResource.GetColor("ColorPrimary");

            FolderIcon      = NormalIcon.Instance().Folder;
            FolderIcon.Fill = DictionaryResource.GetColor("ColorPrimary");

            // 下载内容
            VideoContentSettings videoContent = SettingsManager.GetInstance().GetVideoContent();

            DownloadAudio    = videoContent.DownloadAudio;
            DownloadVideo    = videoContent.DownloadVideo;
            DownloadDanmaku  = videoContent.DownloadDanmaku;
            DownloadSubtitle = videoContent.DownloadSubtitle;
            DownloadCover    = videoContent.DownloadCover;

            if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
            {
                DownloadAll = true;
            }
            else
            {
                DownloadAll = false;
            }

            // 历史下载目录
            DirectoryList = SettingsManager.GetInstance().GetHistoryVideoRootPaths();
            string directory = SettingsManager.GetInstance().GetSaveVideoRootPath();
            if (!DirectoryList.Contains(directory))
            {
                ListHelper.InsertUnique(DirectoryList, directory, 0);
            }
            Directory = directory;

            // 是否使用默认下载目录
            IsDefaultDownloadDirectory = SettingsManager.GetInstance().IsUseSaveVideoRootPath() == AllowStatus.YES;

            #endregion
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 设置下载内容
 /// </summary>
 /// <param name="videoContent"></param>
 /// <returns></returns>
 public bool SetVideoContent(VideoContentSettings videoContent)
 {
     appSettings.Video.VideoContent = videoContent;
     return(SetSettings());
 }