コード例 #1
0
        private void ExecuteStartSelectedProgramsDrag(object parameter)
        {
            var itemsToDrag = new List <ProgramDescription>();

            _dragProgramsStartCommand.Programs = itemsToDrag;
            itemsToDrag.AddRange(CurrentSelection.Select(p => p.Model));
        }
コード例 #2
0
        /// <summary>
        /// Removes the selected ROMs from the list.
        /// </summary>
        /// <param name="parameter">This argument is not used.</param>
        internal void RemoveRoms(object parameter)
        {
            var itemsToDelete = new List <ProgramDescription>(CurrentSelection.Select(p => p.Model));
            var deletedItems  = new List <ProgramDescription>();

            foreach (var item in itemsToDelete)
            {
                if (Model.Remove(item))
                {
                    deletedItems.Add(item);
                }
            }
            if (deletedItems.Any())
            {
                RetainFocus = deletedItems.GetHashCode();
                var collectionChanged = CollectionChanged;
                if (collectionChanged != null)
                {
                    collectionChanged(this, new System.Collections.Specialized.NotifyCollectionChangedEventArgs(System.Collections.Specialized.NotifyCollectionChangedAction.Remove, deletedItems));
                }
                SaveRomList(true);
            }
        }
コード例 #3
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();
        }
コード例 #4
0
        void InitMark()
        {
            ctxMarkType.Opening += (s, e) =>
            {
                if (lv.FocusedItem == null)
                {
                    e.Cancel = true;
                    return;
                }

                var items    = lv.SelectedFullItems;
                var rawItems = lv.SelectedItems;
                mDownloadTorrent.Visible  = items.Any(x => x.BasicInfo.ResourceType == ResourceType.BitTorrent);
                mOpenDownloadPage.Visible = items.Any(x => x.BasicInfo.ResourceType == ResourceType.NetDisk);
                mCopyDownloadLink.Visible = items.Any(x => !x.BasicInfo.HasSubResources);                //items.Any(x => x.BasicInfo.ResourceType == ResourceType.Ed2K);
                tsMultiResNotLoad.Visible = rawItems.Any(x => x.Resource.HasSubResources && x.Resource.SubResources == null);

                var itemView = lv.FocusedItem?.TopItem.ResourceIdentities.FirstOrDefault()?.FindResourceToViewDetail();
                mViewContent.Enabled = itemView?.ResourceType == ResourceType.BitTorrent;
                mViewDetail.Enabled  = !string.IsNullOrEmpty(itemView?.Provider?.GetDetailUrl(itemView));

                //resources
                mMarkDone.Enabled = mMarkUndone.Enabled = mMarkColor.Enabled = items.Any(x => x.BasicInfo.ResourceType == ResourceType.Ed2K || x.BasicInfo.ResourceType == ResourceType.BitTorrent);
            };
            mViewDetail.Click += (s, e) =>
            {
                var resource = lv.FocusedItem?.TopItem.ResourceIdentities.FirstOrDefault()?.FindResourceToViewDetail();
                if (resource != null)
                {
                    AppContext.Instance.ResourceOperation.ViewDetail(resource.Provider, resource);
                }
            };
            mCopyDownloadLink.Click += (s, e) => AppContext.Instance.ResourceOperation.CopyDownloadLink(CurrentSelection.Select(x => x.FindResourceToCopyLink()).ToArray());
            mMarkDone.Click         += (s, e) => AppContext.Instance.ResourceOperation.MarkDone(CurrentSelection.Select(x => x.FindResourceToCopyLink()).ToArray());
            mMarkUndone.Click       += (s, e) => AppContext.Instance.ResourceOperation.MarkUndone(CurrentSelection.Select(x => x.FindResourceToCopyLink()).ToArray());
            tsMultiResNotLoad.Click += (s, e) =>
            {
                foreach (var item in lv.SelectedItems.Where(x => x.Resource.HasSubResources && x.Resource.SubResources == null))
                {
                    item.IsExpanded = true;
                }
            };
            mViewContent.Click += (s, e) =>
            {
                var resource = lv.FocusedItem?.TopItem.ResourceIdentities.FirstOrDefault()?.FindResourceToViewDetail();
                if (resource != null)
                {
                    AppContext.Instance.ResourceOperation.ViewTorrentContents(resource.Provider, resource);
                }
            };
            mDownloadTorrent.Click += (s, e) =>
            {
                var items = lv.SelectedFullItems;
                AppContext.Instance.ResourceOperation.AccquireDownloadTorrent(items.SelectMany(x => x.FindResourceDownloadInfo()).ToArray());
            };
            mOpenDownloadPage.Click += (s, e) =>
            {
                var items = lv.SelectedFullItems;
                AppContext.Instance.ResourceOperation.OpenDownloadPage(items.SelectMany(x => x.FindResourceDownloadInfo()).ToArray());
            };
            lv.MouseDoubleClick += (s, e) =>
            {
                var item = lv.FocusedItem;
                if (item == null)
                {
                    return;
                }

                if (item.ChildItems.Count > 0)
                {
                    item.IsExpanded = !item.IsExpanded;
                }
                else
                {
                    ctxMarkType.Show(lv.PointToScreen(e.Location));
                }
            };
            lv.ItemExpand += (s, e) =>
            {
                var item = e.Item as ResourceListViewItem;
                if (item.Resource.HasSubResources && item.Resource.SubResources == null)
                {
                    Task.Factory.StartNew(() => item.Resource.Provider.LoadSubResources(item.Resource));
                }
            };

            AppContext.Instance.RequestRefreshMarkCollection += (s, e) => RefreshMarkMenu();
            RefreshMarkMenu();
            mMarkColor.DropDownOpening += mMarkColor_DropDownOpening;
            mMarkOption.Click          += (s, e) =>
            {
                using (var dlg = new ConfigCenter())
                {
                    dlg.SelectedConfig = dlg.FindConfigUI <MarkOption>().First();
                    dlg.ShowDialog();
                }
            };
            mMarkNone.Click += SetMarkHandler;
        }
コード例 #5
0
 public void ChoosePokemon(Pokemon choice)
 {
     player.PlayGame(CurrentSelection.Select(p => p.Poke).ToArray(), choice);
     UpdateSelection();
 }
コード例 #6
0
 public void Select()
 {
     CurrentSelection.Select();
 }