Example #1
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (await MainPage.CurrentPage.CheckLoadState(true) != 0)
            {
                return;
            }

            RefreshMessage refresh = new RefreshMessage();

            refresh.CheckNewMessage();

            try
            {
                var    check1   = string.Format(@"document.getElementById('article_content').getElementsByTagName('img').length.toString();");
                string result1a = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { check1 });

                int result1b = Convert.ToInt16(result1a);

                for (int i = 0; i < result1b; i++)
                {
                    var check2  = string.Format(@"document.getElementsByClassName('vwtb')[0].getElementsByTagName('img')[{0}].src;", i);
                    Uri result2 = new Uri(await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { check2 }));
                    var btmp    = new BitmapImage(result2);

                    图片.Items.Add(new ShowNEWSc {
                        Images = btmp
                    });
                }

                var check3 = string.Format(@"document.getElementsByClassName('ph')[0].innerText;");
                标题.Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { check3 });

                var check4 = string.Format(@"document.getElementsByClassName('xg1')[0].innerText;");
                信息.Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { check4 });

                var check5 = string.Format(@"document.getElementById('article_content').innerText;");
                内容.Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { check5 });

                BTSelect();
                var check7a = string.Format(@"document.getElementsByClassName('atd')[0].getElementsByTagName('a')[0].href");
                get7a = new Uri(await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { check7a }));
                var check7b = string.Format(@"document.getElementsByClassName('atd')[0].getElementsByTagName('a')[1].href");
                get7b = new Uri(await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { check7b }));
                var check7c = string.Format(@"document.getElementsByClassName('atd')[0].getElementsByTagName('a')[2].href");
                get7c = new Uri(await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { check7c }));
                var check7d = string.Format(@"document.getElementsByClassName('atd')[0].getElementsByTagName('a')[3].href");
                get7d = new Uri(await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { check7d }));
                var check7e = string.Format(@"document.getElementsByClassName('atd')[0].getElementsByTagName('a')[4].href");
                get7e = new Uri(await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { check7e }));
            }
            catch (Exception)
            {
                MainPage.CurrentPage.ShowNotifi("抱歉,新闻内容加载失败,请稍后重试     加载失败");
            }

            GetComm();
        }
Example #2
0
        public async void LoadNEWS(bool noclear)
        {
            滚动条.Visibility = 0;
            滚动条.IsActive   = true;
            if (await MainPage.CurrentPage.CheckLoadState(true) != 0)
            {
                滚动条.Visibility    = (Visibility)1;
                滚动条.IsActive      = false;
                JumpBtn.IsEnabled = true;
                return;
            }

            RefreshMessage refresh = new RefreshMessage();

            refresh.CheckNewMessage();

            if (!noclear)
            {
                NewsList.Items.Clear();
            }

            try
            {
                for (int i = 0; i < 45; i++)
                {
                    var    newsImg = string.Format(@"document.getElementById('pt_list').getElementsByTagName('img')[{0}].src;", i);
                    string get1    = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { newsImg });

                    var    bitmap    = new BitmapImage(new Uri(get1));
                    var    newsTitle = string.Format(@"document.getElementById('pt_list').getElementsByTagName('h3')[{0}].innerText;", i);
                    string get2      = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { newsTitle });

                    var    newsNotes = string.Format(@"document.getElementById('pt_list').getElementsByTagName('p')[{0}].innerText;", i);
                    string get3      = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { newsNotes });

                    var    newsPost = string.Format(@"document.getElementById('pt_list').getElementsByTagName('span')[{0}].innerText;", i);
                    string get4     = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { newsPost });

                    var newsLink = string.Format(@"document.getElementsByClassName('thumb')[{0}].href;", i);
                    Uri get5     = new Uri(await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { newsLink }));

                    NewsList.Items.Add(new NEWSIfm {
                        Tittle = get2, Preview = get3, Information = get4, NEWSICON = bitmap, NEWSUri = get5
                    });
                }
            }
            catch (Exception)
            {
                MainPage.CurrentPage.ShowNotifi("新闻加载失败,请稍后重试");
            }

            滚动条.Visibility    = (Visibility)1;
            滚动条.IsActive      = false;
            JumpBtn.IsEnabled = true;
        }
Example #3
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (await MainPage.CurrentPage.CheckLoadState(true) != 0)
            {
                return;
            }

            RefreshMessage refresh = new RefreshMessage();

            refresh.CheckNewMessage();

            LoadMyThread();
        }
Example #4
0
        public async void LoginEvent()
        {
            await Task.Delay(1000);

            try
            {
                var value1 = string.Format(@"document.getElementsByClassName('xw1')[0].innerText;");
                UserName.Text = await WebView1.InvokeScriptAsync("eval", new string[] { value1 });
            }
            catch (Exception)
            {
            }

            for (int i = 0; i < 30; i++)
            {
                try
                {
                    var txicon = string.Format(@"document.getElementById('pcd').getElementsByTagName('img')[0].src;");
                    TempAvatarURL = await WebView1.InvokeScriptAsync("eval", new string[] { txicon });

                    var gicon = string.Format(@"document.getElementsByClassName('vm')[1].src;");
                    TempLVLURL = await WebView1.InvokeScriptAsync("eval", new string[] { gicon });

                    RefreshMessage gx = new RefreshMessage();
                    gx.CheckNewMessage();

                    G1();
                    break;
                }
                catch (Exception)
                {
                }

                if (i == 29)
                {
                    ShowNotifi("头像获取失败,请稍后再试");
                }
                await Task.Delay(1000);
            }

            ShowNotifi("登陆成功,欢迎您回来!");
        }
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            pageURL = MainPage.CurrentPage.WebView1.Source;
            try
            {
                滚动条.Visibility = Visibility.Visible;
                滚动条.IsActive   = true;

                if (await MainPage.CurrentPage.CheckLoadState(true) != 0)
                {
                    滚动条.Visibility = (Visibility)1;
                    滚动条.IsActive   = false;
                    return;
                }

                RefreshMessage refresh = new RefreshMessage();
                refresh.CheckNewMessage();

                ThreadList.Items.Clear();

                BlockNText.Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { "document.querySelectorAll(\".xs2 a[href *= 'bbs.pcbeta.com/forum-']\")[0].innerText;" });

                if (await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { "document.querySelectorAll('h1.xs2 .y').length.toString();" }) == "0")
                {
                    BZText.Text = "该板块暂无版主";
                }
                else
                {
                    BZText.Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { "document.querySelectorAll('h1.xs2 .y')[0].innerText;" });
                }
                TodayText.Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { "document.getElementsByClassName('xs1 xw0 i')[0].querySelector('.xi1').innerText;" });

                var    ckCount  = string.Format(@"document.querySelectorAll('.icn').length.toString();");
                string ckResult = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { ckCount });

                int count = Convert.ToInt32(ckResult);

                await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { "document.getElementById('separatorline').remove(); " });

                for (int i = 0; i < count; i++)
                {
                    ThreadTags = "";

                    var    getTag = string.Format(@"document.querySelectorAll('.icn')[{0}].innerHTML;", i);
                    string thTag  = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getTag });

                    if (thTag.Contains("公告"))
                    {
                        ThreadTags += "*全站公告*\n";
                        ThreadTags += "【已高亮】\n";
                        ThreadTags += "【已加粗】\n";
                    }
                    if (thTag.Contains("全局置顶"))
                    {
                        ThreadTags += "*全局置顶*\n";
                    }
                    if (thTag.Contains("本版置顶"))
                    {
                        ThreadTags += "*本版置顶*\n";
                    }
                    if (thTag.Contains("分类置顶"))
                    {
                        ThreadTags += "*分类置顶*\n";
                    }
                    if (thTag.Contains("关闭的"))
                    {
                        ThreadTags += "[已关闭]\n";
                    }
                    if (thTag.Contains("投票"))
                    {
                        ThreadTags += "[投票帖]\n";
                    }
                    if (thTag.Contains("辩论"))
                    {
                        ThreadTags += "[辩论帖]\n";
                    }
                    if (thTag.Contains("悬赏"))
                    {
                        ThreadTags += "[悬赏帖]\n";
                    }

                    var    getTittle    = string.Format("document.querySelectorAll(\"table[summary*='forum']\")[0].querySelectorAll('th')[{0}].innerText;", i);
                    string ThreadTittle = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getTittle });

                    var    getPost = string.Format("document.querySelectorAll(\"table[summary*='forum']\")[0].querySelectorAll('tbody')[{0}].querySelectorAll('.by')[0].innerText;", i);
                    string TPostby = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getPost });

                    var    getCV    = string.Format("document.querySelectorAll(\"table[summary*='forum']\")[0].querySelectorAll('tbody')[{0}].querySelectorAll('td')[2].innerText;", i);
                    string ThreadCV = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getCV });

                    var    getLastPost = string.Format("document.querySelectorAll(\"table[summary*='forum']\")[0].querySelectorAll('tbody')[{0}].querySelectorAll('.by')[1].innerText;", i);
                    string TLastpost   = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getLastPost });

                    Uri ThreadURL = null;
                    if (i == 0)
                    {
                        ThreadURL = new Uri("http://bbs.pcbeta.com/viewthread-1079227-1-1.html");
                    }
                    else
                    {
                        var getURL = string.Format(@"document.querySelectorAll('.xst')[{0}].href;", i);
                        ThreadURL = new Uri(await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getURL }));

                        var    getHL       = string.Format(@"document.querySelectorAll('.xst')[{0}].style.color;", i);
                        string thHighlight = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getHL });

                        if (thHighlight.Contains("rgb"))
                        {
                            ThreadTags += "【已高亮】\n";
                        }
                        var    getBL  = string.Format(@"document.querySelectorAll('.xst')[{0}].style.fontWeight;", i);
                        string thBold = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getBL });

                        if (thBold.Contains("bold"))
                        {
                            ThreadTags += "【已加粗】\n";
                        }
                    }


                    ThreadList.Items.Add(new ThreadsIfm {
                        Tags = ThreadTags, Tittle = ThreadTittle, Postby = TPostby, CheckViewNum = ThreadCV, LastReply = TLastpost, ThrUri = ThreadURL
                    });
                }
            }
            catch (Exception)
            {
            }

            滚动条.IsActive   = false;
            滚动条.Visibility = (Visibility)1;
        }
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (!MainPage.CurrentPage.noCheck)
            {
                if (await MainPage.CurrentPage.CheckLoadState(true) != 0)
                {
                    return;
                }
            }

            RefreshMessage refresh = new RefreshMessage();

            refresh.CheckNewMessage();

            MainPage.CurrentPage.noCheck = false;

            try
            {
                var    getCount = string.Format(@"document.getElementsByClassName('bm_c')[0].querySelectorAll('.mbn').length.toString();");
                string result   = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getCount });

                int count = Convert.ToInt32(result);

                for (int i = 0; i < count; i++)
                {
                    var    getTittle = string.Format(@"document.getElementsByClassName('bm_c')[0].querySelectorAll('.mbn')[{0}].innerText;", i);
                    string tittle    = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getTittle });

                    if (tittle.Contains("勋章"))
                    {
                        var    getCount2 = string.Format(@"document.querySelectorAll('.bm_c .md_ctrl img').length.toString();");
                        string result2   = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { getCount2 });

                        int count2 = Convert.ToInt32(result2);

                        for (int j = 0; j < count2; j++)
                        {
                            var    send = string.Format(@"document.querySelectorAll('.bm_c .md_ctrl img')[{0}].alt;", j);
                            string get  = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send });

                            var    send2 = string.Format(@"document.querySelectorAll('.bm_c .md_ctrl img')[{0}].src;", j);
                            string get2  = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send2 });

                            Image image = new Image();
                            image.Height = image.Width = 100;
                            image.Source = new BitmapImage(new Uri(get2));

                            StackPanel stackPanel = new StackPanel();
                            stackPanel.Children.Add(image);
                            stackPanel.Children.Add(new TextBlock()
                            {
                                Text = get
                            });
                            stackPanel.Margin = new Thickness(0, 0, 20, 0);

                            XZList.Children.Add(stackPanel);
                        }

                        XZPanel.Visibility = 0;
                    }
                    else if (tittle.Contains("管理以下版块"))
                    {
                        var send = string.Format(@"document.querySelector('.bm_c').children[{0}].innerText.replace('管理以下版块','');", i);
                        userAdmin.Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send });

                        BZPanel.Visibility = 0;
                    }
                    else if (tittle.Contains("活跃概况"))
                    {
                        var    send = string.Format(@"document.querySelector('.bm_c').children[{0}].querySelector('ul').querySelectorAll('img').length.toString();", i);
                        string get  = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send });

                        if (get == "1")
                        {
                            var    send2 = string.Format(@"document.querySelector('.bm_c').children[{0}].querySelector('ul').querySelector('li').innerText;", i);
                            var    send3 = string.Format(@"document.querySelector('.bm_c').children[{0}].querySelector('ul').querySelector('img').src;", i);
                            string get3  = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send3 });

                            UGroupPanel.Children.Add(new TextBlock()
                            {
                                Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send2 })
                            });
                            UGroupPanel.Children.Add(new Image()
                            {
                                Source = new BitmapImage(new Uri(get3))
                            });
                        }
                        else
                        {
                            var    send2 = string.Format(@"document.querySelector('.bm_c').children[{0}].querySelector('ul').querySelectorAll('li')[0].innerText;", i);
                            var    send3 = string.Format(@"document.querySelector('.bm_c').children[{0}].querySelector('ul').querySelectorAll('img')[0].src;", i);
                            string get3  = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send3 });

                            UGroupPanel.Children.Add(new TextBlock()
                            {
                                Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send2 })
                            });
                            UGroupPanel.Children.Add(new Image()
                            {
                                Source = new BitmapImage(new Uri(get3))
                            });

                            send2 = string.Format(@"document.querySelector('.bm_c').children[{0}].querySelector('ul').querySelectorAll('li')[1].innerText;", i);
                            send3 = string.Format(@"document.querySelector('.bm_c').children[{0}].querySelector('ul').querySelectorAll('img')[1].src;", i);
                            get3  = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send3 });

                            UGroupPanel.Children.Add(new TextBlock()
                            {
                                Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send2 })
                            });
                            UGroupPanel.Children.Add(new Image()
                            {
                                Source = new BitmapImage(new Uri(get3))
                            });
                        }

                        var send4 = string.Format(@"document.getElementById('pbbs').innerText;");
                        userData.Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send4 });
                    }
                    else if (tittle.Contains("统计信息"))
                    {
                        var send = string.Format(@"document.querySelector('#psts ul').innerText;");
                        userAcc.Text += "\n\n" + await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { send });
                    }
                    else
                    {
                        var    ckonline = string.Format(@"document.getElementsByClassName('bm_c')[0].querySelectorAll('.mbn img').length.toString();");
                        string isonline = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { ckonline });

                        var username = string.Format(@"document.getElementsByClassName('bm_c')[0].querySelectorAll('.mbn')[0].innerText;");
                        userAcc.Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { username });

                        if (isonline == "1")
                        {
                            userAcc.Text += " 当前在线";
                        }
                        var other = string.Format("document.getElementsByClassName('bm_c')[0].children[0].children[1].innerText;");
                        userAcc.Text += "\n\n" + await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { other });

                        var mydata = string.Format(@"document.getElementsByClassName('bm_c')[0].children[0].children[2].innerText;");
                        userIfm.Text = await MainPage.CurrentPage.WebView1.InvokeScriptAsync("eval", new string[] { mydata });
                    }
                }
            }
            catch (Exception)
            {
                MainPage.CurrentPage.ShowNotifi("个人资料加载失败!请稍后重试。");
            }
        }
Example #7
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            RefreshMessage refresh = new RefreshMessage();

            refresh.CheckNewMessage();
        }
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            LoadRing.Visibility = 0;
            LoadRing.IsActive   = true;

            try
            {
                MainPage.CurrentPage.WebView1.Source = new Uri("http://bbs.pcbeta.com");
                if (await MainPage.CurrentPage.CheckLoadState(true) != 0)
                {
                    LoadRing.Visibility = (Visibility)1;
                    LoadRing.IsActive   = false;
                    return;
                }

                RefreshMessage refresh = new RefreshMessage();
                refresh.CheckNewMessage();

                /*
                 * string get1 = "document.querySelectorAll('#category_213 .fl_g').length.toString();";
                 * string result1 = await ConnToWV(new string[] { get1 });
                 * int count = Convert.ToInt32(result1);
                 */

                //板块1:Windows 10
                //1a Win10区;1b 经典区;1c 设备及硬件;1d MS其他产品
                for (int i = 0; i < 9; i++)
                {
                    GetAndAddItems("category_213", i, List1a);
                    await Task.Delay(100);
                }

                for (int i = 0; i < 2; i++)
                {
                    GetAndAddItems("category_181", i, List1b);
                    await Task.Delay(100);
                }

                GetAndAddItems("category_263", 1, List1b);
                await Task.Delay(100);

                GetAndAddItems("category_263", 3, List1b);
                await Task.Delay(100);

                GetAndAddItems("category_106", 2, List1b);
                await Task.Delay(100);

                for (int i = 0; i < 9; i++)
                {
                    GetAndAddItems("category_287", i, List1c);
                    await Task.Delay(100);
                }

                GetAndAddItems("category_106", 3, List1d);
                await Task.Delay(100);

                GetAndAddItems("category_106", 4, List1d);
                await Task.Delay(100);

                GetAndAddItems("category_533", 2, List1d);
                await Task.Delay(100);


                //板块2:Office
                for (int i = 9; i < 12; i++)
                {
                    GetAndAddItems("category_213", i, List2);
                    await Task.Delay(100);
                }


                //板块3:苹果
                for (int i = 0; i < 6; i++)
                {
                    GetAndAddItems("category_86", i, List3);
                    await Task.Delay(100);
                }


                //板块4:Linux
                GetAndAddItems("category_508", 0, List4);
                await Task.Delay(100);

                GetAndAddItems("category_508", 1, List4);
                await Task.Delay(100);


                //板块5:俱乐部
                GetAndAddItems("category_15", 0, List5);
                await Task.Delay(100);

                GetAndAddItems("category_156", 0, List5);
                await Task.Delay(100);

                GetAndAddItems("category_156", 3, List5);
                await Task.Delay(100);


                //板块6:站务
                for (int i = 0; i < 3; i++)
                {
                    GetAndAddItems("category_7", i, List6);
                    await Task.Delay(100);
                }
            }
            catch (Exception)
            {
            }

            LoadRing.Visibility = Visibility.Collapsed;
            LoadRing.IsActive   = false;
        }