Пример #1
0
        public void DataBinding(IBaseModel datalist)
        {
            if (datalist == null)
            {
                return;
            }
            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker) delegate() { this.DataBinding(datalist); });
            }
            else
            {
                AMR_MST04Model model = new AMR_MST04Model();

                model = (AMR_MST04Model)datalist;
                //gridControl1.DataSource = null;
                //gridControl1.DataSource = model.DataTable;

                this.chartControl1.Series[0].Points.BeginUpdate();
                this.chartControl1.Series[0].Points.Clear();

                foreach (DataRow row in model.DataTable.Rows)
                {
                    string time = row["TOT00DAT"].ToString();
                    // 그래프 Y값 추출
                    DateTime datetime = DateTime.ParseExact(time, "yyyy-MM-dd HH", null);

                    // 센서 값 넣기
                    //double value = Convert.ToDouble(row.ItemArray[1]);
                    double value = Convert.ToDouble(row["TOT00VALUE"]);
                    //double[] value = new double[] { Convert.ToDouble(row.ItemArray[1]), Convert.ToDouble(row.ItemArray[2]),
                    //                            Convert.ToDouble(row.ItemArray[3]), Convert.ToDouble(row.ItemArray[4]), Convert.ToDouble(row.ItemArray[5]) };


                    // 센서별 데이터 넣기
                    ChartVariable2 chartValue = new ChartVariable2();
                    chartValue.data = new SeriesPoint(datetime, value);
                    this.chartControl1.Series[0].Points.Add(chartValue.data);
                }

                this.chartControl1.Series[0].Points.EndUpdate();

                this.chartControl1.Titles.RemoveAt(0);
                ChartTitle chartTitle1 = new ChartTitle();
                chartTitle1.Text      = string.Format("{0}동 {1}호 - {2}", model.MST04DON, model.MST04HNO, this.radioGroup1.Text);
                chartTitle1.Alignment = System.Drawing.StringAlignment.Center;
                chartTitle1.Dock      = DevExpress.XtraCharts.ChartTitleDockStyle.Top;
                this.chartControl1.Titles.Add(chartTitle1);

                //    ChartTitle chartTitle1 = new ChartTitle();
                //    ChartTitle chartTitle2 = new ChartTitle();
                //    chartTitle1.Text = "Great Lakes Gross State Product";
                //    chartTitle2.Alignment = System.Drawing.StringAlignment.Far;
                //    chartTitle2.Dock = DevExpress.XtraCharts.ChartTitleDockStyle.Bottom;
                //    chartTitle2.Font = new System.Drawing.Font("Tahoma", 8F);
                //    chartTitle2.Text = "From www.bea.gov";
                //    chartTitle2.TextColor = System.Drawing.Color.Gray;
                //    this.chartControl1.Titles.AddRange(new DevExpress.XtraCharts.ChartTitle[] {
                //chartTitle1,
                //chartTitle2});
            }
        }
Пример #2
0
        /// <summary>
        /// 그래프 및 그리드뷰 출력 백그라운드 작업
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Dictionary <string, ChartVariable2> chartData = new Dictionary <string, ChartVariable2>();

            mIsLoding = true;

            if (sumTable.Rows.Count == 0)
            {
                MetroMessageBox.Show(mParent, "데이터가 없습니다.", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                mIsLoding = false;
                return;
            }


            string       warningMsg = sumTable.Rows.Count.ToString() + "건의 데이터가 검색되었습니다.\n화면에 출력합니다. 계속진행할까요?";
            DialogResult rtn        = MetroMessageBox.Show(mParent, warningMsg, "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

            if (rtn == DialogResult.No || rtn == DialogResult.Cancel)
            {
                sumTable.Clear();
                mIsLoding = false;
                return;
            }


            foreach (string key in mKey)
            {
                ChartVariable2 chartValue = new ChartVariable2();
                chartData.Add(key, chartValue);
            }

            // 프로그레스바

            metroProgressBar1.SafeInvoke(d => d.Minimum = 0);
            //metroProgressBar1.SafeInvoke(d => d.Maximum = foundRowsFrom.Length + foundRows.Length);
            metroProgressBar1.SafeInvoke(d => d.Maximum = sumTable.Rows.Count);
            metroProgressBar1.SafeInvoke(d => d.Step    = 1);
            metroProgressBar1.SafeInvoke(d => d.Value   = 0);


            foreach (string key in mKey)
            {
                this.chartControl1.SafeInvoke(d => d.Series[key].Points.BeginUpdate());
                this.chartControl1.SafeInvoke(d => d.Series[key].Points.Clear());
            }
            // 검색된 데이터 컨트롤에 출력
            foreach (DataRow row in sumTable.Rows)
            {
                metroProgressBar1.SafeInvoke(d => d.PerformStep());

                // 그리드뷰 출력

                this.dataGridViewLoadBackUp.SafeInvoke(d => d.Rows.Add(row["시간"], row["전압"], row["전류"], row["온도1"], row["온도2"], row["온도3"], row["온도4"], row["온도5"], row["온도6"]));



                string time = row["시간"].ToString();
                // 그래프 Y값 추출
                DateTime datetime = DateTime.ParseExact(time, "yyyy-MM-dd HH:mm:ss", null);

                // 센서 값 넣기
                double[] value = new double[] { Convert.ToDouble(row.ItemArray[1]), Convert.ToDouble(row.ItemArray[2]),
                                                Convert.ToDouble(row.ItemArray[3]), Convert.ToDouble(row.ItemArray[4]), Convert.ToDouble(row.ItemArray[5]),
                                                Convert.ToDouble(row.ItemArray[6]), Convert.ToDouble(row.ItemArray[7]), Convert.ToDouble(row.ItemArray[8]) };



                int sensorOffset = 0;

                // 센서별 데이터 넣기
                foreach (string key in mKey)
                {
                    chartData[key].data = new SeriesPoint(datetime, value[sensorOffset++]);
                    this.chartControl1.SafeInvoke(d => d.Series[key].Points.Add(chartData[key].data));
                }
            }

            this.dataGridViewLoadBackUp.SafeInvoke(d => d.CurrentCell = d.Rows[d.Rows.Count - 1].Cells[0]);
            foreach (string key in mKey)
            {
                this.chartControl1.SafeInvoke(d => d.Series[key].Points.EndUpdate());
            }
        }