/// <summary> /// 请求下载资源 /// </summary> /// <param name="torrents"></param> public void AccquireDownloadTorrent(params IResourceInfo[] torrents) { var ts = torrents.Where(s => s.ResourceType == ResourceType.BitTorrent).ToArray(); if (ts.Length == 0) { return; } if (DownloadQueue == null) { DownloadQueue = new DownloadQueue(); DownloadQueue.Show(); } else { if (DownloadQueue.WindowState == FormWindowState.Minimized) { DownloadQueue.WindowState = FormWindowState.Normal; } Utility.ShowWindowAsync(DownloadQueue.Handle, Utility.SW_SHOWNOACTIVATE); } DownloadQueue.AddResourceToQueue(ts); MainForm.ShowFloatTip(string.Format("已加入 {1} 等 {0} 个种子到下载队列。", ts.Length, ts[0].Title)); //显示安全警告 SecurityWarning.CheckShowSecurityWarning(); }
public void CopyMagnetLink(params IResourceInfo[] torrents) { if (torrents == null || torrents.Length == 0) { return; } torrents = torrents.Where(s => s.ResourceType == ResourceType.BitTorrent).ToArray(); PrepareFullDetail(torrents); var successItems = torrents.Where(s => s.IsHashLoaded).ToArray(); var failedItemsCount = torrents.Length - successItems.Length; var successItemsCount = successItems.Length; try { if (successItemsCount > 0) { Clipboard.SetText(successItems.Select(s => s.CreateMagnetLink(true)).JoinAsString(Environment.NewLine)); //显示安全警告 SecurityWarning.CheckShowSecurityWarning(); } MainForm.ShowFloatTip(string.Format("复制 {0} 条磁力链成功!{1}", successItems.Length, failedItemsCount > 0 ? string.Format("{0} 条资源因为无法获得信息没有复制成功。", failedItemsCount) : "")); } catch (Exception) { MainForm.Error("无法复制磁力链到剪贴板。"); } }