Пример #1
0
 private void ShowContextMenuSearch(TorrentLink torLink)
 {
     ContextMenu cmenu = new ContextMenu(Translation.Search);
     cmenu.AddAction(Translation.DownloadViaTorrent, () =>
     {
         if (torLink != null)
         {
             MainWindow.uTorrent.AddTorrentFromURL(torLink.TorrentDownloadLink);
             LoadUTorrentListAsync();
         }
     });
     cmenu.AddAction(Translation.ManualSearch, () =>
     {
         string criteria = "";
         if (Utils.DialogText(ref criteria, GetID))
         {
             MainWindow.currentDownloadSearch = new DownloadSearchCriteria(DownloadSearchType.Manual, criteria);
             PerformTorrentSearchAsync();
         }
     });
     cmenu.Add(Translation.RecentSearches + " >>>", ShowRecentSearches);
     cmenu.AddAction(Translation.ClearSearchHistory, () =>
     {
         MainWindow.downloadSearchHistory.Clear();
         MainWindow.downloadSearchResultsHistory.Clear();
         ClearGUIProperty(GuiProperty.Search_ResultDescription);
         ClearGUIProperty(GuiProperty.Search_Summary);
         if (dummyPageSearch.Visible) m_Facade.Clear();
     });
     cmenu.Show();
 }
Пример #2
0
        public override bool OnMessage(GUIMessage message)
        {
            switch (message.Message)
            {
            case GUIMessage.MessageType.GUI_MSG_ITEM_FOCUS_CHANGED:
            {
                int iControl = message.SenderControlId;
                if (iControl == (int)m_Facade.GetID)
                {
                    GUIListItem item = m_Facade.SelectedListItem;

                    if (item == null || item.TVTag == null)
                    {
                        return(true);
                    }

                    //BaseConfig.MyAnimeLog.Write("Type: {0}", item.TVTag.GetType());

                    // torrents
                    if (item.TVTag.GetType() == typeof(Torrent))
                    {
                        Torrent torItem = item.TVTag as Torrent;
                        if (torItem != null)
                        {
                            curTorrent = torItem;
                            DisplayTorrentDetails(torItem);
                        }
                    }

                    // torrent file
                    if (item.TVTag.GetType() == typeof(TorrentFile))
                    {
                        TorrentFile torFile = item.TVTag as TorrentFile;
                        if (torFile != null)
                        {
                            //curTorrent = torItem;
                            DisplayTorrentFileDetails(torFile);
                        }
                    }

                    // search results
                    if (item.TVTag.GetType() == typeof(TorrentLink))
                    {
                        TorrentLink torLink = item.TVTag as TorrentLink;
                        if (torLink != null)
                        {
                            //curTorrent = torItem;
                            DisplayTorrentLinkDetails(torLink);
                        }
                    }
                }
            }

                return(true);

            default:
                return(base.OnMessage(message));
            }
        }
        private void ShowTorrentDetails(TorrentLink torLink)
        {
            SetAttachedSeries(null);

            if (!torrentDetailsWorker.IsBusy)
            {
                torrentDetailsWorker.RunWorkerAsync(torLink);
            }
        }
Пример #4
0
 private void DisplayTorrentLinkDetails(TorrentLink tor)
 {
     SetGUIProperty(GuiProperty.TorrentLink_Name, tor.TorrentName);
     SetGUIProperty(GuiProperty.TorrentLink_Size, tor.Size);
     SetGUIProperty(GuiProperty.TorrentLink_Seeders, tor.Seeders);
     SetGUIProperty(GuiProperty.TorrentLink_Leechers, tor.Leechers);
     SetGUIProperty(GuiProperty.TorrentLink_Source, tor.Source);
     SetGUIProperty(GuiProperty.TorrentLink_SourceLong, tor.SourceLong);
 }
Пример #5
0
        private TextSyndicationContent BuildContent(TorrentLink link)
        {
            StringBuilder sb = new StringBuilder();

            foreach (File f in link.Files)
            {
                var episode = f.Episode ?? new Episode();
                sb.AppendLine(String.Format("{0} (s{1:00}e{2:00})", f.Filename, episode.Season, episode.Opus));
            }
            return(new TextSyndicationContent(sb.ToString(), TextSyndicationContentKind.Plaintext));
        }
Пример #6
0
 private ContextMenuAction ShowContextMenuBrowse(TorrentLink torLink)
 {
     ContextMenu cmenu = new ContextMenu(Translation.Browse);
     cmenu.AddAction(Translation.DownloadViaTorrent, () =>
     {
         MainWindow.uTorrent.AddTorrentFromURL(torLink.TorrentDownloadLink);
         LoadUTorrentListAsync();
     });
     cmenu.Add(Translation.SelectSource, () => ShowBrowseSources(torLink));
     return cmenu.Show();
 }
        void dgTorrents_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid _DataGrid = sender as DataGrid;

            TorrentLink torLink = _DataGrid.SelectedItem as TorrentLink;

            if (torLink == null)
            {
                return;
            }

            ShowTorrentDetails(torLink);
        }
        void dgTorrents_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            DataGrid _DataGrid = sender as DataGrid;

            TorrentLink torLink = _DataGrid.SelectedItem as TorrentLink;

            if (torLink == null)
            {
                return;
            }

            ShowTorrentDetails(torLink);
        }
Пример #9
0
        private SyndicationItem BuildItems(TorrentLink link)
        {
            var item = new SyndicationItem
            {
                Title       = new TextSyndicationContent(link.Filename, TextSyndicationContentKind.Plaintext),
                Summary     = BuildContent(link),
                PublishDate = new DateTimeOffset(link.CreatedAt),
                Id          = link.Id
            };
            var uri = new Uri(link.Url);

            item.ElementExtensions.Add(BuildLink(link.Url));
            return(item);
        }
Пример #10
0
        public void ShouldRetrieveFileInfos()
        {
            TorrentLink link = new TorrentLink
            {
                Url = "http://www.omgtorrent.com/torrents/Series/californication/californication_saison_1.torrent"
            };
            TorrentAnalyzer analyzer = new TorrentAnalyzer();

            analyzer.Analyze(link);

            Assert.NotNull(link.Files);
            Assert.NotEmpty(link.Files);
            Assert.True(link.Files.All(f => f.Episode != null));
        }
Пример #11
0
 private ContextMenuAction ShowBrowseSources(TorrentLink torLink)
 {
     ContextMenu cmenu = new ContextMenu(Translation.SelectSource);
     cmenu.Add("<<< " + Translation.Browse, () => ShowContextMenuBrowse(torLink));
     foreach (TorrentSource src in Enum.GetValues(typeof(TorrentSource)))
     {
         TorrentSource local = src;
         cmenu.AddAction(DownloadHelper.GetTorrentSourceDescription(src), () =>
         {
             curBrowseSource = local;
             PerformTorrentBrowseAsync();
         });
     }
     return cmenu.Show();
 }
Пример #12
0
        private void DisplayTorrentLinkDetails(TorrentLink tor)
        {
            clearGUIProperty("TorrentLink.Name");
            clearGUIProperty("TorrentLink.Size");
            clearGUIProperty("TorrentLink.Seeders");
            clearGUIProperty("TorrentLink.Leechers");
            clearGUIProperty("TorrentLink.Source");
            clearGUIProperty("TorrentLink.SourceLong");

            setGUIProperty("TorrentLink.Name", tor.TorrentName);
            setGUIProperty("TorrentLink.Size", tor.Size);
            setGUIProperty("TorrentLink.Seeders", tor.Seeders);
            setGUIProperty("TorrentLink.Leechers", tor.Leechers);
            setGUIProperty("TorrentLink.Source", tor.Source);
            setGUIProperty("TorrentLink.SourceLong", tor.SourceLong);
        }
        void torrentDetailsWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            TorrentLink torLink = e.Argument as TorrentLink;

            // try and find the series
            foreach (VM_AniDB_Anime anime in VM_AniDB_Anime.BestLevenshteinDistanceMatchesCache(torLink.ClosestAnimeMatchString, 10))
            {
                // get the series for the anime
                VM_AnimeSeries_User ser = VM_MainListHelper.Instance.GetSeriesForAnime(anime.AnimeID);
                if (ser != null)
                {
                    e.Result = ser;
                    return;
                }
            }

            e.Result = null;
        }
Пример #14
0
        protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType)
        {
            if (MA3WindowManager.HandleWindowChangeButton(control))
            {
                return;
            }

            if (control == this.btnTorrentsUIPage)
            {
                this.btnTorrentsUIPage.IsFocused = false;
                ShowPageTorrents();
                m_Facade.Focus = true;
            }

            if (control == this.btnSearchPage)
            {
                this.btnSearchPage.Focus = false;
                ShowPageSearch(true);
                m_Facade.Focus = true;
            }

            if (control == this.btnBrowseTorrentsPage)
            {
                this.btnBrowseTorrentsPage.Focus = false;
                ShowPageBrowseTorrents();
                m_Facade.Focus = true;
            }

            if (control == this.m_Facade)
            {
                // show the files if we are looking at a torrent
                GUIListItem item = m_Facade.SelectedListItem;

                //BaseConfig.MyAnimeLog.Write("Type: {0}", item.TVTag.GetType());

                // torrents
                // show the files if we are looking at a torrent
                if (item.TVTag.GetType() == typeof(Torrent))
                {
                    Torrent torItem = item.TVTag as Torrent;
                    if (torItem != null)
                    {
                        curTorrent = torItem;
                        List <TorrentFile> torfiles = new List <TorrentFile>();
                        if (MainWindow.uTorrent.GetFileList(torItem.Hash, ref torfiles))
                        {
                            ShowPageTorrentFiles(torfiles);
                        }
                    }
                }

                if (item.TVTag.GetType() == typeof(TorrentFile))
                {
                    if (item.Label == UpFolder)
                    {
                        ShowPageTorrents();
                    }
                }

                if (item.TVTag.GetType() == typeof(TorrentLink) && dummyPageSearch.Visible)
                {
                    TorrentLink torLink = item.TVTag as TorrentLink;
                    if (torLink == null)
                    {
                        return;
                    }

                    ShowContextMenuSearch(torLink);
                }

                if (item.TVTag.GetType() == typeof(TorrentLink) && dummyPageBrowse.Visible)
                {
                    TorrentLink torLink = item.TVTag as TorrentLink;
                    if (torLink == null)
                    {
                        return;
                    }

                    ShowContextMenuBrowse(torLink);
                }
            }

            base.OnClicked(controlId, control, actionType);
        }
Пример #15
0
        protected override void OnShowContextMenu()
        {
            GUIListItem currentitem = this.m_Facade.SelectedListItem;

            if (currentitem == null)
            {
                if (dummyPageSearch.Visible)
                {
                    ShowContextMenuSearch(null);
                }
                if (dummyPageBrowse.Visible)
                {
                    ShowContextMenuBrowse(null);
                }

                return;
            }

            if (currentitem.TVTag == null)
            {
                return;
            }

            if (currentitem.TVTag.GetType() == typeof(Torrent))
            {
                Torrent tor = currentitem.TVTag as Torrent;
                if (tor == null)
                {
                    return;
                }

                ShowContextMenuTorrents(tor);
            }

            if (currentitem.TVTag.GetType() == typeof(TorrentFile))
            {
                TorrentFile tor = currentitem.TVTag as TorrentFile;
                if (tor == null)
                {
                    return;
                }

                int idx = -1;
                for (int itemIndex = 0; itemIndex < GUIControl.GetItemCount(this.GetID, this.m_Facade.GetID); itemIndex++)
                {
                    GUIListItem item    = GUIControl.GetListItem(this.GetID, this.m_Facade.GetID, itemIndex);
                    TorrentFile torTemp = item.TVTag as TorrentFile;

                    if (torTemp != null)
                    {
                        if (torTemp.FileName == tor.FileName)
                        {
                            idx = itemIndex;
                            break;
                        }
                    }
                }

                if (idx >= 0)
                {
                    idx = idx - 1;
                    ShowContextMenuTorrentFiles(tor, idx);
                }
            }

            if (currentitem.TVTag.GetType() == typeof(TorrentLink) && dummyPageSearch.Visible)
            {
                TorrentLink torLink = currentitem.TVTag as TorrentLink;
                if (torLink == null)
                {
                    return;
                }

                ShowContextMenuSearch(torLink);
            }

            if (currentitem.TVTag.GetType() == typeof(TorrentLink) && dummyPageBrowse.Visible)
            {
                TorrentLink torLink = currentitem.TVTag as TorrentLink;
                if (torLink == null)
                {
                    return;
                }

                ShowContextMenuBrowse(torLink);
            }
        }
Пример #16
0
        protected override void OnClicked(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType)
        {
            MainMenu menu = new MainMenu();
            menu.Add(btnTorrentsUIPage, () =>
            {
                ShowPageTorrents();
                m_Facade.Focus = true;
            });
            menu.Add(btnSearchPage, () =>
            {
                ShowPageSearch(true);
                m_Facade.Focus = true;
            });
            menu.Add(btnBrowseTorrentsPage, () =>
            {
                ShowPageBrowseTorrents();
                m_Facade.Focus = true;
            });
            if (menu.Check(control))
                return;

            if (control == this.m_Facade)
			{
				// show the files if we are looking at a torrent
				GUIListItem item = m_Facade.SelectedListItem;

				//BaseConfig.MyAnimeLog.Write("Type: {0}", item.TVTag.GetType());

				// torrents
				// show the files if we are looking at a torrent
				if (item.TVTag.GetType() == typeof(Torrent))
				{
					Torrent torItem = item.TVTag as Torrent;
					if (torItem != null)
					{
						curTorrent = torItem;
						List<TorrentFile> torfiles = new List<TorrentFile>();
						if (MainWindow.uTorrent.GetFileList(torItem.Hash, ref torfiles))
						{
							ShowPageTorrentFiles(torfiles);
						}
					}
				}

				if (item.TVTag.GetType() == typeof(TorrentFile))
				{
					if (item.Label == Translation.BackToTorrents)
					{

						ShowPageTorrents();
					}
				}
                
				if (item.TVTag.GetType() == typeof(TorrentLink) && dummyPageSearch.Visible)
				{
					TorrentLink torLink = item.TVTag as TorrentLink;
					if (torLink == null)
						return;

					ShowContextMenuSearch(torLink);
				}

				if (item.TVTag.GetType() == typeof(TorrentLink) && dummyPageBrowse.Visible)
				{
					TorrentLink torLink = item.TVTag as TorrentLink;
					if (torLink == null)
						return;

					ShowContextMenuBrowse(torLink);
				}
			}

			base.OnClicked(controlId, control, actionType);
		}