Esempio n. 1
0
        void SetMarkHandler(object sender, EventArgs e)
        {
            var menu = sender as ToolStripMenuItem;
            var mark = menu.Tag == null ? null : menu.Text;

            using (lv.CreateBatchOperationDispatcher())
            {
                var selectedResources = lv.SelectedItems.Cast <ListViewItem>().ToArray();
                foreach (var listViewItem in selectedResources)
                {
                    TorrentOperation.SetTorrentMask(mark, listViewItem.Tag as ITorrentResourceInfo);
                }
            }
        }
Esempio n. 2
0
        public EngineTabContent(ITorrentResourceProvider provider)
        {
            InitializeComponent();

            TorrentResourceProvider = provider;
            _engineProperty         = GetTorrentProviderDesc();
            lblSearchProgress.Text  = "引擎特性:" + _engineProperty;

            InitSort();
            //lv.ListViewItemSorter = _sorter = new ResourceListViewItemSorter();
            //lv.ColumnClick += (s, e) =>
            //{
            //	if (e.Column == 2 || e.Column == 3)
            //		return;

            //	var sortType = e.Column == 0 ? SortType.Title : e.Column == 1 ? SortType.FileSize : SortType.PubDate;
            //	if (sortType == Context.Instance.Options.SortType)
            //	{
            //		Context.Instance.Options.SortDirection = 1 - Context.Instance.Options.SortDirection;
            //	}
            //	else
            //	{
            //		Context.Instance.Options.SortType = sortType;
            //		Context.Instance.Options.SortDirection = 0;
            //	}
            //};
            lblCancelSearch.Click += (s, e) =>
            {
                if (!Question("当前正在搜索,需要取消当前搜索吗?", true))
                {
                    return;
                }

                CancelCurrentLoad();
            };

            ////注册排序
            //Context.Instance.Options.PropertyChanged += (s, e) =>
            //{
            //	if (e.PropertyName == "SortType" || e.PropertyName == "SortDirection")
            //	{
            //		lv.Sort();
            //	}
            //};
            lv.SelectedIndexChanged += lv_SelectedIndexChanged;
            lv.MouseDoubleClick     += (s, e) =>
            {
                if (lv.SelectedItems.Count == 0)
                {
                    return;
                }

                ctxMarkType.Show(lv.PointToScreen(e.Location));
            };

            //图标
            ilLv.Images.Add(FSLib.Windows.Utility.Get20PxImageFrom16PxImg(Properties.Resources.File___Torrent));
            ctxMarkType.Opening += (s, e) =>
            {
                if (lv.SelectedItems.Count == 0)
                {
                    e.Cancel = true;
                    return;
                }
            };
            mViewContent.Enabled    = TorrentResourceProvider.SupportLookupTorrentContents;
            mViewDetail.Click      += (s, e) => TorrentOperation.ViewDetail(TorrentResourceProvider, SelectedResouce);
            mCopyMagnet.Click      += (s, e) => TorrentOperation.CopyMagnetLink(CurrentSelection.Select(x => x.Key).ToArray());
            mViewContent.Click     += (s, e) => TorrentOperation.ViewTorrentContents(TorrentResourceProvider, SelectedResouce);
            mDownloadTorrent.Click += (s, e) => TorrentOperation.AccquireDownloadTorrent(CurrentSelection.Select(x => x.Key).ToArray());
            mSearchBaiDu.Click     += (s, e) => TorrentOperation.BaiduSearch(SelectedResouce);
            mSearchGoogle.Click    += (s, e) => TorrentOperation.GoogleSearch(SelectedResouce);
            mCopyHash.Click        += (s, e) => TorrentOperation.CopyHash(CurrentSelection.Select(x => x.Key).ToArray());
            mCopyTitle.Click       += (s, e) => TorrentOperation.CopyTitle(CurrentSelection.Select(x => x.Key).ToArray());

            TorrentOperation.TorrentMarked += TorrentOperation_TorrentMarked;
            TorrentOperation.RequestRefreshMarkCollection += (s, e) => RefreshMarkMenu();
            RefreshMarkMenu();
            mMarkColor.DropDownOpening += mMarkColor_DropDownOpening;
            mMarkOption.Click          += (s, e) =>
            {
                using (var dlg = new Option())
                {
                    dlg.CurrentTabIndex = 1;
                    dlg.ShowDialog();
                }
            };
            mMarkNone.Click += SetMarkHandler;
            pWarning.KeepCenter();
        }