Esempio n. 1
0
        private void load()
        {
            if (Global.Cookie == null || Global.aspxauth == null)
            {
                GUI_login.Text   = "登录";
                GUI_refresh.Text = "刷新";
                barLoad.Hide();
                loadText.Hide();
                GUI_tips.Show();
                return;
            }
            else
            {
                GUI_login.Text = "注销";
            }

            GUI_tips.Hide();
            GUI_week.Items.AddRange(new object[5] {
                1, 2, 3, 4, 5
            });
            for (int i = 1; i < 31; i++)
            {
                GUI_week.Items.Add(i);
            }

            GUI_refresh.Text  = "刷新";
            GUI_semester.Text = Current_semester().Value;

            foreach (string value in Global.semester.Values)
            {
                GUI_semester.Items.Add(value);
            }

            timetable = HttpHelp.HttpGet("http://jw.jltc.edu.cn/JWXS/pkgl/XsKB_List.aspx", Global.LoginCookie);
            ShowTimeTable(timetable);
        }
Esempio n. 2
0
        private void ShowTimeTable(string timetable)
        {
            //lvkb.Clear();
            Task.Factory.StartNew(() =>
            {
                Thread.Sleep(1000);
                lvkb.BeginInvoke(new Action(() =>
                {
                    GUI_tips.Hide();
                    lvkb.Clear();
                    barLoad.Show();
                    loadText.Show();
                    barLoad.Value = 0;
                    loadText.Text = "正在准备数据";
                }));
                //timetable = HttpHelp.HttpGet("http://jw.jltc.edu.cn/JWXS/pkgl/XsKB_List.aspx", Global.LoginCookie);
                List <List <string> > data = HtmlHelp.GetTable(timetable);
                if (data == null)
                {
                    lvkb.BeginInvoke(new Action(() => { loadText.Text = "数据准备完毕"; }));
                    Thread.Sleep(1000);
                    for (int i = 0; i < barLoad.Maximum; i++)
                    {
                        lvkb.BeginInvoke(new Action(() => { barLoad.Value = i; }));
                        Thread.Sleep(10);
                    }

                    lvkb.BeginInvoke(new Action(() =>
                    {
                        GUI_tips.Text = "检测到当前课表为空";
                        barLoad.Hide();
                        loadText.Hide();
                        GUI_tips.Show();
                    }));
                    return;
                }

                itemCount = data[0].Count;
                lvkb.BeginInvoke(new Action(() => { loadText.Text = "数据准备完毕"; }));
                Thread.Sleep(1000);
                for (int i = 0; i < barLoad.Maximum; i++)
                {
                    lvkb.BeginInvoke(new Action(() => { barLoad.Value = i; }));
                    Thread.Sleep(10);
                }

                lvkb.BeginInvoke(new Action(() =>
                {
                    barLoad.Hide();
                    loadText.Hide();
                    ImageList imgList = new ImageList
                    {
                        ImageSize = new Size(1, 100)
                    };
                    lvkb.SmallImageList            = imgList;
                    int itemwidth                  = Width / data[0].Count;
                    List <ListViewItem> table_data = new List <ListViewItem> {
                    };
                    data[0][0] = "";
                    foreach (string s1 in data[0])
                    {
                        lvkb.Columns.Add(s1, itemwidth, HorizontalAlignment.Left);
                    }

                    for (int i = 1; i < data.Count; i++)
                    {
                        ListViewItem item = new ListViewItem(data[i][0], 0);
                        for (int j = 1; j < data[i].Count; j++)
                        {
                            item.SubItems.Add(data[i][j]);
                        }

                        table_data.Add(item);
                    }

                    lvkb.Items.AddRange(table_data.ToArray());
                }));
            });
        }