Exemple #1
0
        private void DataGridView_Sorted(object sender, EventArgs e)
        {
            /*regenerate row number after header clicked*/
            /*give row number*/
            DataGridView dgv = (DataGridView)(sender);

            ProvinceRank.generateRowNumber(dgv);
        }
Exemple #2
0
        public void initControls()
        {
            /*load overall info control*/
            int[] todayData = { 0, 0, 0 }, sumData = { 0, 0, 0 };
            /*get data from DB*/
            IProvinceSumDataBLL    psdb = new ProvinceSumDataBLL();
            List <ProvinceSumData> psd  = psdb.selectALL();

            foreach (var data in psd)
            {
                sumData[0] += data.confirmed;
                sumData[1] += data.suspect;
                sumData[2] += data.death;
            }
            this.overallInfo = new Overallinfo(new Label[] { (Label)Controls.Find("LabelSumConfirmed", true)[0],
                                                             (Label)Controls.Find("LabelSumSuspect", true)[0],
                                                             (Label)Controls.Find("LabelSumDeath", true)[0], },
                                               todayData,
                                               sumData);
            /*load province rank control*/
            String[] proName = { };
            int[][]  datas   = { };
            /*get data from DB*/
            Dictionary <String, int[]> proData = new Dictionary <string, int[]>();

            foreach (var data in psd)
            {
                proData[data.province] = new int[] { data.confirmed, data.suspect, data.death }
            }
            ;
            this.provinceRank = new ProvinceRank(proData, (DataGridView)Controls.Find("DataGridView", true)[0]);
            /*load history chart control*/
            IProvinceDailyDataBLL      pddb       = new ProvinceDailyDataBLL();
            List <ProvinceDailyData>   pdd        = pddb.selectALL();
            Dictionary <String, int[]> sdd        = new Dictionary <string, int[]>();
            List <DailyData>           dailydatas = new List <DailyData>();

            for (int i = 0; i < pdd.Count; i++)
            {
                sdd[pdd[i].date] = new int[] { 0, 0, 0 };
            }
            foreach (var pair in sdd)
            {
                List <ProvinceDailyData> dd = pddb.selectByDate(pair.Key);
                foreach (var day in dd)
                {
                    sdd[pair.Key][0] += day.confirmed;
                    sdd[pair.Key][1] += day.suspect;
                    sdd[pair.Key][2] += day.death;
                }
            }

            int yesterdayCon = 0;

            foreach (var pair in sdd)
            {
                dailydatas.Add(new DailyData(pair.Key, pair.Value[0] - yesterdayCon, pair.Value[1], pair.Value[2]));
                yesterdayCon = pair.Value[0];
            }
            this.historyChart = new HistoryChart(dailydatas, (Chart)Controls.Find("Chart1", true)[0]);
            /*load news*/
            INewsDataBLL    ndb      = new NewsDataBLL();
            List <NewsData> nd       = ndb.selectALL();
            List <String[]> newsList = new List <string[]>();

            foreach (var news in nd)
            {
                newsList.Add(new String[] { news.title, news.url });
            }

            this.plagueNews = new PlagueNews(newsList, (ListBox)Controls.Find("listbox1", true)[0]);
            /*load knowledges*/
            IKnowledgeDataBLL    kdb      = new KnowledgeDataBLL();
            List <KnowledgeData> kd       = kdb.selectALL();
            List <string[]>      knowList = new List <string[]>();

            foreach (var strArr in kd)
            {
                knowList.Add(new string[] { strArr.title, strArr.type, strArr.content });
            }
            this.plagueKnowledge = new PlagueKnowledge(knowList, (RichTextBox)Controls.Find("richTextBox1", true)[0],
                                                       (Label)Controls.Find("label13", true)[0], (Label)Controls.Find("label14", true)[0],
                                                       (Button)Controls.Find("button1", true)[0], (Button)Controls.Find("button2", true)[0]);
            /*load plauge map*/
            IProvinceDefaultColorBLL    pdcb      = new ProvinceDefaultColorBLL();
            List <ProvinceDefaultColor> pdc       = pdcb.selectALL();
            Dictionary <String, Color>  befColor  = new Dictionary <string, Color>(),
                                        colOffset = new Dictionary <string, Color>();

            foreach (var prov in pdc)
            {
                befColor[prov.province]  = Color.FromArgb(255, prov.r, prov.g, prov.b);
                colOffset[prov.province] = Color.FromArgb(prov.rOffset, prov.gOffset, prov.bOffset);
            }

            IPlagueColorBLL         pcb      = new PlagueColorBLL();
            List <PlagueColor>      pc       = pcb.selectALL();
            Dictionary <int, Color> plgColor = new Dictionary <int, Color>();

            foreach (var p in pc)
            {
                plgColor[p.floor] = Color.FromArgb(255, p.r, p.g, p.b);
            }

            this.plagueMap = new PlagueMap(this.toolTip1, befColor, colOffset, proData, plgColor, this);
        }