コード例 #1
0
        // gman3001: Method Added 2004/10/06
        // Method determines if the current PageStripDetails contains the active tab, by checking all of its descendants
        /// <summary>
        /// Determines whether [is active tab in] [the specified active page ID].
        /// </summary>
        /// <param name="activePageID">The active page ID.</param>
        /// <param name="PageStripDetails">The page strip details.</param>
        /// <returns>
        ///     <c>true</c> if [is active tab in] [the specified active page ID]; otherwise, <c>false</c>.
        /// </returns>
        private bool isActiveTabIn(int activePageID, PageStripDetails PageStripDetails)
        {
            if (PageStripDetails.PageID == activePageID)
            {
                return(true);
            }
            PagesBox childTabs = PageStripDetails.Pages;

            if (childTabs.Count > 0)
            {
                for (int c = 0; c < childTabs.Count; c++)
                {
                    PageStripDetails mySubTab = childTabs[c];
                    if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
                    {
                        if (isActiveTabIn(activePageID, mySubTab))
                        {
                            return(true);
                        }
                    }
                }
                childTabs = null;
            }
            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Search a text asynchronously.
        /// </summary>
        /// <param name="text">text</param>
        public void SearchAsync(string text, int pagenum)
        {
            SearchText = text;

            long aid = FindAid(text);

            if (aid >= 0)
            {
                HistoryBox.Insert(text);
                VideoSelected?.Invoke("Av" + aid.ToString(), aid);
                return;
            }

            if (cancellationTokenSource != null)
            {
                cancellationTokenSource.Cancel();
            }
            ContentViewer.ScrollToHome();
            ContentPanel.Children.Clear();
            PagesBox.Visibility = Visibility.Hidden;
            if (text != null && text.Trim() != string.Empty)
            {
                HistoryBox.Insert(text);
                HistoryBox.Visibility = Visibility.Hidden;
                TypeBtn.IsChecked     = true;

                cancellationTokenSource = new CancellationTokenSource();
                CancellationToken cancellationToken = cancellationTokenSource.Token;

                LoadingPrompt.Visibility = Visibility.Visible;
                NoMoreGrid.Visibility    = Visibility.Collapsed;
                ContentViewer.Visibility = Visibility.Collapsed;
                Task task = new Task(() =>
                {
                    string type     = NavType;
                    Json.Value json = GetResult(text, type, pagenum);
                    if (json != null)
                    {
                        Dispatcher.Invoke(new Action(() =>
                        {
                            if (cancellationToken.IsCancellationRequested)
                            {
                                return;
                            }
                            ShowResult(json, type);
                            PagesBox.SetPage((int)json["data"]["numPages"], (int)json["data"]["page"], false);
                            PagesBox.Visibility      = Visibility.Visible;
                            LoadingPrompt.Visibility = Visibility.Hidden;
                        }));
                    }
                });
                task.Start();
            }
            else
            {
                HistoryBox.Visibility = Visibility.Visible;
            }
        }
コード例 #3
0
ファイル: FavList.xaml.cs プロジェクト: jangocheng/Bili-dl
        private void ShowFolder(int mediaId, int pagenum, bool init)
        {
            if (cancellationTokenSource != null)
            {
                cancellationTokenSource.Cancel();
            }
            ContentViewer.ScrollToHome();
            ContentPanel.Children.Clear();
            MediaId = mediaId;
            cancellationTokenSource = new CancellationTokenSource();
            CancellationToken cancellationToken = cancellationTokenSource.Token;

            LoadingPrompt.Visibility = Visibility.Visible;
            PagesBox.Visibility      = Visibility.Hidden;

            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("media_id", mediaId.ToString());
            dic.Add("pn", pagenum.ToString());
            dic.Add("ps", "20");
            dic.Add("keyword", "");
            dic.Add("order", "mtime");
            dic.Add("type", "0");
            dic.Add("tid", "0");
            dic.Add("jsonp", "jsonp");
            Task task = new Task(() =>
            {
                IJson json = BiliApi.GetJsonResult("https://api.bilibili.com/medialist/gateway/base/spaceDetail", dic, false);
                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }
                if (json.GetValue("code").ToLong() == 0)
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        foreach (IJson media in json.GetValue("data").GetValue("medias"))
                        {
                            FavItem favItem = new FavItem(media.GetValue("title").ToString(), media.GetValue("cover").ToString(), media.GetValue("fav_time").ToLong(), media.GetValue("id").ToLong(), false);
                            favItem.PreviewMouseLeftButtonDown += FavItem_PreviewMouseLeftButtonDown;
                            ContentPanel.Children.Add(favItem);
                        }
                        if (init)
                        {
                            PagesBox.SetPage((int)Math.Ceiling((double)json.GetValue("data").GetValue("info").GetValue("media_count").ToLong() / 20), 1, true);
                        }
                        PagesBox.Visibility = Visibility.Visible;
                    }));
                }
                Dispatcher.Invoke(new Action(() =>
                {
                    LoadingPrompt.Visibility = Visibility.Hidden;
                }));
            });

            task.Start();
        }
コード例 #4
0
ファイル: UserVideoList.xaml.cs プロジェクト: qlmgg/Bili-dl
        public void LoadAsync(int mid, int page, bool init)
        {
            Mid = mid;
            if (cancellationTokenSource != null)
            {
                cancellationTokenSource.Cancel();
            }
            ContentViewer.ScrollToHome();
            ContentPanel.Children.Clear();
            PagesBox.Visibility = Visibility.Hidden;

            cancellationTokenSource = new CancellationTokenSource();
            CancellationToken cancellationToken = cancellationTokenSource.Token;

            LoadingPrompt.Visibility = Visibility.Visible;
            Task task = new Task(() =>
            {
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("mid", mid.ToString());
                dic.Add("ps", "30");
                dic.Add("pn", page.ToString());
                try
                {
                    Json.Value json = BiliApi.GetJsonResult("https://api.bilibili.com/x/space/arc/search", dic, true);
                    Dispatcher.Invoke(new Action(() =>
                    {
                        foreach (Json.Value v in json["data"]["list"]["vlist"])
                        {
                            ResultBox.Video video   = new ResultBox.Video(v);
                            ResultVideo resultVideo = new ResultVideo(video);
                            resultVideo.PreviewMouseLeftButtonDown += ResultVideo_PreviewMouseLeftButtonDown;
                            ContentPanel.Children.Add(resultVideo);
                        }
                        if (init)
                        {
                            int pages = (int)Math.Ceiling((double)json["data"]["page"]["count"] / json["data"]["page"]["ps"]);
                            PagesBox.SetPage(pages, 1, true);
                        }
                        PagesBox.Visibility      = Visibility.Visible;
                        LoadingPrompt.Visibility = Visibility.Hidden;
                    }));
                }
                catch (Exception)
                {
                }
                Dispatcher.Invoke(new Action(() =>
                {
                    LoadingPrompt.Visibility = Visibility.Hidden;
                }));
            }, cancellationTokenSource.Token);

            task.Start();
        }
コード例 #5
0
        public void LoadAsync(int mid, int page, bool init)
        {
            Mid = mid;
            if (cancellationTokenSource != null)
            {
                cancellationTokenSource.Cancel();
            }
            ContentViewer.ScrollToHome();
            ContentPanel.Children.Clear();
            PagesBox.Visibility = Visibility.Hidden;

            cancellationTokenSource = new CancellationTokenSource();
            CancellationToken cancellationToken = cancellationTokenSource.Token;

            LoadingPrompt.Visibility = Visibility.Visible;
            Task task = new Task(() =>
            {
                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("mid", mid.ToString());
                dic.Add("pagesize", "30");
                dic.Add("page", page.ToString());
                try
                {
                    IJson json = BiliApi.GetJsonResult("https://space.bilibili.com/ajax/member/getSubmitVideos", dic, true);
                    Dispatcher.Invoke(new Action(() =>
                    {
                        foreach (IJson v in json.GetValue("data").GetValue("vlist"))
                        {
                            ResultBox.Video video   = new ResultBox.Video(v);
                            ResultVideo resultVideo = new ResultVideo(video);
                            resultVideo.PreviewMouseLeftButtonDown += ResultVideo_PreviewMouseLeftButtonDown;
                            ContentPanel.Children.Add(resultVideo);
                        }
                        if (init)
                        {
                            PagesBox.SetPage((int)json.GetValue("data").GetValue("pages").ToLong(), 1, true);
                        }
                        PagesBox.Visibility      = Visibility.Visible;
                        LoadingPrompt.Visibility = Visibility.Hidden;
                    }));
                }
                catch (Exception)
                {
                }
                Dispatcher.Invoke(new Action(() =>
                {
                    LoadingPrompt.Visibility = Visibility.Hidden;
                }));
            }, cancellationTokenSource.Token);

            task.Start();
        }
コード例 #6
0
ファイル: ResultBox.xaml.cs プロジェクト: jangocheng/Bili-dl
        /// <summary>
        /// Search a text asynchronously.
        /// </summary>
        /// <param name="text">text</param>
        public void SearchAsync(string text, int pagenum)
        {
            if (cancellationTokenSource != null)
            {
                cancellationTokenSource.Cancel();
            }
            ContentViewer.ScrollToHome();
            ContentPanel.Children.Clear();
            PagesBox.Visibility = Visibility.Hidden;
            if (text != null && text.Trim() != string.Empty)
            {
                HistoryBox.Insert(text);
                HistoryBox.Visibility = Visibility.Hidden;
                TypeBtn.IsChecked     = true;

                cancellationTokenSource = new CancellationTokenSource();
                CancellationToken cancellationToken = cancellationTokenSource.Token;

                LoadingPrompt.Visibility = Visibility.Visible;
                Task task = new Task(() =>
                {
                    string type = NavType;
                    IJson json  = GetResult(text, type, pagenum);
                    if (json != null)
                    {
                        Dispatcher.Invoke(new Action(() =>
                        {
                            if (cancellationToken.IsCancellationRequested)
                            {
                                return;
                            }
                            ShowResult(json, type);
                            PagesBox.SetPage((int)json.GetValue("data").GetValue("numpages").ToLong(), (int)json.GetValue("data").GetValue("page").ToLong(), false);
                            PagesBox.Visibility      = Visibility.Visible;
                            LoadingPrompt.Visibility = Visibility.Hidden;
                        }));
                    }
                });
                task.Start();
            }
            else
            {
                HistoryBox.Visibility = Visibility.Visible;
            }
        }
コード例 #7
0
        /// <summary>
        /// Shops the menu.
        /// </summary>
        /// <param name="PageStripDetails">The page strip details.</param>
        /// <param name="activePageID">The active page ID.</param>
        protected virtual void ShopMenu(PageStripDetails PageStripDetails, int activePageID)
        {
            PagesBox childTabs = PageStripDetails.Pages;

            if (childTabs.Count > 0)
            {
                for (int c = 0; c < childTabs.Count; c++)
                {
                    PageStripDetails mySubTab = childTabs[c];
                    if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
                    {
                        AddGraphMenuItem(PageStripDetails.PageID.ToString(), mySubTab.PageID.ToString(),
                                         mySubTab.PageName, mySubTab.PageImage,
                                         HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, activePageID,
                                                                 "ItemID=" + mySubTab.PageID.ToString()), false);
                        ShopMenu(mySubTab, activePageID);
                    }
                }
                childTabs = null;
            }
        }
コード例 #8
0
 // modified to transmit the PageID and TabIndex for the shop page
 /// <summary>
 /// Recourses the menu.
 /// </summary>
 /// <param name="tabIDShop">The tab ID shop.</param>
 /// <param name="t">The t.</param>
 /// <param name="mn">The mn.</param>
 /// <returns></returns>
 private MenuTreeNode RecourseMenu(int tabIDShop, PagesBox t, MenuTreeNode mn)
 {
     if (t.Count > 0)
     {
         for (int c = 0; c < t.Count; c++)
         {
             PageStripDetails mySubTab = (PageStripDetails)t[c];
             if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
             {
                 MenuTreeNode mnc = new MenuTreeNode(mySubTab.PageName);
                 // change PageID into ItemID for the product module on the same page
                 mnc.Link =
                     HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, tabIDShop,
                                             "ItemID=" + mySubTab.PageID);
                 mnc.Width = mn.Width;
                 mnc       = RecourseMenu(tabIDShop, mySubTab.Pages, mnc);
                 mn.Childs.Add(mnc);
             }
         }
     }
     return(mn);
 }
コード例 #9
0
        /// <summary>
        /// Recourses the menu.
        /// </summary>
        /// <param name="tabIndex">Index of the tab.</param>
        /// <param name="t">The t.</param>
        /// <param name="mn">The mn.</param>
        /// <returns></returns>
        protected virtual MenuTreeNode RecourseMenu(int tabIndex, PagesBox t, MenuTreeNode mn) //mh:
        {
            if (t.Count > 0)
            {
                for (int c = 0; c < t.Count; c++)
                {
                    PageStripDetails mySubTab = t[c];
                    if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
                    {
                        MenuTreeNode mnc = new MenuTreeNode(mySubTab.PageName);

                        mnc.Link  = giveMeUrl(mySubTab.PageName, mySubTab.PageID);
                        mnc.Width = mn.Width;

                        mnc = RecourseMenu(tabIndex, mySubTab.Pages, mnc);

                        mn.Childs.Add(mnc);
                    }
                }
            }
            return(mn);
        }
コード例 #10
0
        /// <summary>
        /// Recourses the menu.
        /// </summary>
        /// <param name="PageStripDetails">The page strip details.</param>
        /// <param name="activePageID">The active page ID.</param>
        protected virtual void RecourseMenu(PageStripDetails PageStripDetails, int activePageID)
        {
            PagesBox childTabs = PageStripDetails.Pages;

            if (childTabs.Count > 0)
            {
                for (int c = 0; c < childTabs.Count; c++)
                {
                    PageStripDetails mySubTab = childTabs[c];
                    if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
                    {
                        if (mySubTab.PageImage == null)
                        {
                            mySubTab.PageImage =
                                (new PageSettings().GetPageCustomSettings(mySubTab.PageID))["CustomMenuImage"].ToString();
                        }
                        if (products(mySubTab.PageID))
                        {
                            AddGraphMenuItem(PageStripDetails.PageID.ToString(), mySubTab.PageID.ToString(),
                                             mySubTab.PageName, mySubTab.PageImage,
                                             giveMeUrl(mySubTab.PageName, mySubTab.PageID), false);
                            if (activePageID == mySubTab.PageID)
                            {
                                ShopMenu(mySubTab, activePageID);
                            }
                        }
                        else
                        {
                            AddGraphMenuItem(PageStripDetails.PageID.ToString(), mySubTab.PageID.ToString(),
                                             mySubTab.PageName, mySubTab.PageImage,
                                             giveMeUrl(mySubTab.PageName, mySubTab.PageID), false);
                            RecourseMenu(mySubTab, activePageID);
                        }
                    }
                }
                childTabs = null;
            }
        }
コード例 #11
0
        /// <summary>
        /// Recourses the menu shop.
        /// </summary>
        /// <param name="tabIndex">Index of the tab.</param>
        /// <param name="t">The t.</param>
        /// <param name="mn">The mn.</param>
        /// <param name="idShop">The id shop.</param>
        /// <returns></returns>
        protected virtual MenuTreeNode RecourseMenuShop(int tabIndex, PagesBox t, MenuTreeNode mn, int idShop)
        {
            if (t.Count > 0)
            {
                for (int c = 0; c < t.Count; c++)
                {
                    PageStripDetails mySubTab = t[c];

                    if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles))
                    {
                        MenuTreeNode mnc = new MenuTreeNode(mySubTab.PageName);

                        mnc.Link =
                            HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, idShop,
                                                    "ItemID=" + mySubTab.PageID.ToString());
                        mnc.Width = mn.Width;
                        mnc       = RecourseMenuShop(tabIndex, mySubTab.Pages, mnc, idShop);
                        mn.Childs.Add(mnc);
                    }
                }
            }
            return(mn);
        }