Пример #1
0
        /// <summary>
        /// 绘制图形
        /// </summary>
        /// <param name="addItem"></param>
        private void refreshChart(bool addItem = false)
        {
            try
            {
                if (Type_comboBoxEx.SelectedItem == null)
                {
                    return;
                }

                var beginTime    = long.Parse((Start_dateTimePicker.Value.Date).ToString("yyMMdd") + "000000");
                var endTime      = long.Parse((End_dateTimePicker.Value.Date).ToString("yyMMdd") + "235959");
                var strCondition = " DT_INT between " + beginTime + " and " + endTime;

                var           type      = ((ComboBoxItem)Type_comboBoxEx.SelectedItem).Tag.ToString();
                var           subtitle  = Start_dateTimePicker.Value.ToString("yyyy/MM/dd") + " - " + End_dateTimePicker.Value.ToString("yyyy/MM/dd");
                var           dataSouce = Line_StationAlarm_Bll.Get(strCondition);
                List <string> itemSouce = new List <string>();
                if (XML_Tool.xml.SysConfig.IsChinese)
                {
                    itemSouce.Add("全部");
                }
                else
                {
                    itemSouce.Add("ALL");
                }
                switch (type)
                {
                case "Type":
                    itemSouce.AddRange(dataSouce.Select(n => n.Type).Distinct().ToList());
                    break;

                case "Station":
                    itemSouce.AddRange(dataSouce.Select(n => n.Station).Distinct().ToList());
                    break;

                case "Describtion":
                    itemSouce.AddRange(dataSouce.Select(n => n.Describtion).Distinct().ToList());
                    break;
                }
                if (addItem)
                {
                    Sinton__comboBoxEx.DataSource = itemSouce;
                }
                else
                {
                    switch (Buttom_superTabStrip.SelectedTab.Text)
                    {
                    case "饼状图":
                        plotView1.Model            = PieChart.CreateModel(dataSouce, subtitle, type);
                        plotView1.Controller       = PieChart.CreateController();
                        Sinton__comboBoxEx.Visible = false;
                        Sinton_label.Visible       = false;
                        break;

                    case "柱形图":
                        plotView1.Model            = ColumnChart.CreateModel(dataSouce, subtitle, type, Sinton__comboBoxEx.Text);
                        plotView1.Controller       = PieChart.CreateController();
                        Sinton__comboBoxEx.Visible = true;
                        Sinton_label.Visible       = true;
                        break;

                    case "折线图":
                        plotView1.Model            = LineChart.CreateModel(dataSouce, subtitle, type, Sinton__comboBoxEx.Text);
                        plotView1.Controller       = PieChart.CreateController();
                        Sinton__comboBoxEx.Visible = true;
                        Sinton_label.Visible       = true;
                        break;

                    case "pie chart":
                        plotView1.Model            = PieChart.CreateModel(dataSouce, subtitle, type);
                        plotView1.Controller       = PieChart.CreateController();
                        Sinton__comboBoxEx.Visible = false;
                        Sinton_label.Visible       = false;
                        break;

                    case "column chart":
                        plotView1.Model            = ColumnChart.CreateModel(dataSouce, subtitle, type, Sinton__comboBoxEx.Text);
                        plotView1.Controller       = PieChart.CreateController();
                        Sinton__comboBoxEx.Visible = true;
                        Sinton_label.Visible       = true;
                        break;

                    case "line chart":
                        plotView1.Model            = LineChart.CreateModel(dataSouce, subtitle, type, Sinton__comboBoxEx.Text);
                        plotView1.Controller       = PieChart.CreateController();
                        Sinton__comboBoxEx.Visible = true;
                        Sinton_label.Visible       = true;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }