Esempio n. 1
0
        private void SelectAnswer(object sender, EventArgs e)
        {
            InteractiveSelectButton btn = (InteractiveSelectButton)sender;

            foreach (Button button in buttons)
            {
                if (button.id != btn.uniqueid)
                {
                    continue;
                }

                IntereactiveVideo v = new IntereactiveVideo
                {
                    aid    = aid,
                    cid    = button.cid,
                    name   = btn.Text,
                    nodeid = button.edgeid
                };
                edgeid = button.edgeid;
                cid    = button.cid;
                videos.Add(v);
                LoadEdge();
                break;
            }
        }
Esempio n. 2
0
        public void LoadEdge()
        {
            try
            {
                buttons.Clear();
                SelectionPanel.Controls.Clear();
                WebClient MyWebClient = new WebClient();
                MyWebClient.Credentials = CredentialCache.DefaultCredentials;                                                                                                                                        //获取或设置用于向Internet资源的请求进行身份验证的网络凭据
                MyWebClient.Headers.Add("Cookie", cookie);
                string callback = Encoding.UTF8.GetString(MyWebClient.DownloadData(string.Format("https://api.bilibili.com/x/stein/edgeinfo_v2?aid={0}&edge_id={1}&graph_version={2}", aid, edgeid, graphversion))); //如果获取网站页面采用的是UTF-8,则使用这句
                edgeInfo = JsonConvert.DeserializeObject <JSONCallback.EdgeInfo.EdgeInfo>(callback);
                MyWebClient.Dispose();
                if (!Settings.lowcache)
                {
                    try
                    {
                        if (cid == "")
                        {
                            cid = edgeInfo.data.story_list[0].cid;
                        }
                        new WebClient().DownloadFile(string.Format("http://i0.hdslb.com/bfs/steins-gate/{0}_screenshot.jpg", cid), Environment.CurrentDirectory + string.Format("/temp/av{0}-edge{1}.jpg", aid, edgeid));
                    }
                    catch (Exception e)
                    {
                    }
                    if (File.Exists(Environment.CurrentDirectory + string.Format("/temp/av{0}-edge{1}.jpg", aid, edgeid)))
                    {
                        SelectionPanel.BackgroundImage = Image.FromFile(Environment.CurrentDirectory + string.Format("/temp/av{0}-edge{1}.jpg", aid, edgeid));
                    }
                }
                if (edgeInfo.data.edges.questions == null)
                {
                    Dialog.Show("您无法继续选择,请直接开始下载");
                    return;
                }
                for (int i = 0; i < edgeInfo.data.edges.questions[0].choices.Count; i++)
                {
                    JSONCallback.EdgeInfo.ChoicesItem choice = edgeInfo.data.edges.questions[0].choices[i];
                    Button button;
                    button.edgeid = choice.id;
                    button.cid    = choice.cid;
                    button.option = choice.option;
                    if (choice.x != 0 && choice.y != 0)
                    {
                        button.x = Convert.ToInt32(Math.Floor(choice.x / 1.5));
                        button.y = Convert.ToInt32(Math.Floor(choice.y / 1.5));
                    }
                    else
                    {
                        button.x = 0;
                        button.y = (edgeInfo.data.edges.questions[0].choices.Count * 40) - (i * 38);
                    }
                    button.id = random.Next();
                    buttons.Add(button);

                    InteractiveSelectButton btn = new InteractiveSelectButton();
                    SelectionPanel.Controls.Add(btn);
                    btn.Text     = button.option;
                    btn.uniqueid = button.id;
                    btn.Location = new Point(button.x, button.y);
                    btn.Click   += SelectAnswer;
                }
            }
            catch (Exception e)
            {
                Dialog.Show("您无法继续选择,请直接开始下载");
            }
        }