public void Display(EtyDataPoint dp)
        {
            string Function_Name = "Display";

            colorPanel.BackColor = Color.Black;

            try
            {
                seriesTypeBox.Items.Add(StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_LintTypeLine, LanguageHelper.TrendViewer_LintTypeLine_EN));
                seriesTypeBox.Items.Add(StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_LintTypeSpline, LanguageHelper.TrendViewer_LintTypeSpline_EN));
                seriesTypeBox.Text    = StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_LintTypeLine, LanguageHelper.TrendViewer_LintTypeLine_EN);
                opcServerHostBox.Text = ConfigureFileHelper.GetInstance().HostIPAddress; //dp.DPHost.ToString();
                opcServerNameBox.Text = ConfigureFileHelper.GetInstance().OPCServerName; //dp.DPServer.ToString();

                if (m_formType == FormType.Edit)
                {
                    opcServerHostBox.Text = dp.DPHost.ToString();
                    opcServerNameBox.Text = dp.DPServer.ToString();
                    dataPointBox.Text     = dp.DPName.ToString();
                    seriesTypeBox.Text    = TrendViewerHelper.convertLineTypeToDispLan(dp.DPType);
                    dataLegendBox.Text    = dp.DPLblName;
                    if (TrendViewerHelper.isNumeric(dp.DPColor, System.Globalization.NumberStyles.Number))
                    {
                        colorPanel.BackColor = Color.FromArgb(Convert.ToInt32(dp.DPColor));
                    }
                    dataPointEnabledCb.Checked = dp.DPEnabled;
                    labelEnabledCb.Checked     = dp.DPLblEnabled;
                    dataPointVisibleCb.Checked = dp.DPVisible;
                }
            }
            catch (Exception localException)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, localException.ToString());
            }
        }
Esempio n. 2
0
        public void PopulateDataPointListDataGridView(int mode, DataTable dpList)
        {
            //  <summary>
            //  DataPointListDataGridView Data Population
            //  </summary>

            string Function_Name = "PopulateDataPointListDataGridView";

            dataPointListDataGridViewprogressBar.Visible = true;
            try
            {
                dataPointListDataGridViewprogressBar.Value = 0;

                totalDataPointListDataGridView.Text = "1";
                if (mode == 1)
                {
                    pageNumDataPointListDataGridView.Value = 1;
                }

                int totalRecord = dpList.Rows.Count;
                int upperRecord = 0;
                int lowerRecord = 0;
                if (totalRecord > 0)
                {
                    if (totalRecord % RECORDSIZE > 0)
                    {
                        totalRecord = totalRecord / RECORDSIZE;
                        totalRecord++;
                    }
                    else
                    {
                        totalRecord = totalRecord / RECORDSIZE;
                    }
                    totalDataPointListDataGridView.Text      = totalRecord.ToString();
                    pageNumDataPointListDataGridView.Maximum = totalRecord;
                }
                else
                {
                    pageNumDataPointListDataGridView.Maximum = 1;
                }

                upperRecord = (int)(RECORDSIZE * pageNumDataPointListDataGridView.Value);
                if (pageNumDataPointListDataGridView.Value > 1)
                {
                    lowerRecord = (int)(RECORDSIZE * (pageNumDataPointListDataGridView.Value - 1)) + 1;
                }
                else
                {
                    lowerRecord = (int)(RECORDSIZE * (pageNumDataPointListDataGridView.Value - 1));
                }

                string localSQL = "";
                if (dataPointListDataGridView.SortedColumn != null && dataPointListDataGridView.Rows.Count > 0)
                {
                    if (dataPointListDataGridView.SortedColumn.Name != null && dataPointListDataGridView.SortedColumn.Name.Trim() != "")
                    {
                        localSQL = dataPointListDataGridView.SortedColumn.Name;
                        if (dataPointListDataGridView.SortOrder.ToString().ToLower() != "ascending")
                        {
                            localSQL += " DESC ";
                        }
                        else
                        {
                            localSQL += " ASC ";
                        }
                    }
                    else
                    {
                        localSQL = " DATA_PT_NAME ASC ";
                    }
                }
                else
                {
                    localSQL = " DATA_PT_NAME ASC ";
                }



                DataRow[] dataRowArray = dpList.Select("", localSQL);

                DataGridViewRow dataGridRow = null;
                DataRow         dataRow     = null;


                if (upperRecord > dataRowArray.Length)
                {
                    upperRecord = dataRowArray.Length;
                }

                int    counter    = 0;
                string tempString = "";
                dataPointListDataGridView.Rows.Clear();
                if (lowerRecord > 0)
                {
                    lowerRecord--;
                }
                dataPointListDataGridViewprogressBar.Value = 0;
                for (int i = lowerRecord; i < upperRecord; i++)
                {
                    dataPointListDataGridView.Rows.Add();
                    dataPointListDataGridViewprogressBar.Value++;
                    dataGridRow = dataPointListDataGridView.Rows[counter];
                    dataRow     = dataRowArray[i];

                    tempString = "";
                    tempString = dataRow["DATA_PT_NAME"].ToString();
                    if (tempString.Length > 100)
                    {
                        dataGridRow.Cells[2].Value = tempString.Substring(0, 100) + "...";
                    }
                    else
                    {
                        dataGridRow.Cells[2].Value = tempString;
                    }

                    tempString = "";
                    tempString = dataRow["DATA_PT_LBL_NAME"].ToString();
                    if (tempString.Length > 100)
                    {
                        dataGridRow.Cells[3].Value = tempString.Substring(0, 100) + "...";
                    }
                    else
                    {
                        dataGridRow.Cells[3].Value = tempString;
                    }

                    dataGridRow.Cells[5].Value = dataRow["DATA_PT_TYPE"].ToString();

                    if (TrendViewerHelper.isNumeric(dataRow["DATA_PT_COLOR"].ToString(), System.Globalization.NumberStyles.Number))
                    {
                        dataGridRow.Cells[4].Value           = "";
                        dataGridRow.Cells[4].Style.BackColor = Color.FromArgb(Convert.ToInt32(dataRow["DATA_PT_COLOR"].ToString()));
                    }

                    if (TrendViewerHelper.ChangeStrToBool(dataRow["DATA_PT_ENABLED"].ToString()))
                    {
                        dataGridRow.Cells[6].Value = Properties.Resources.img_checkmark;
                    }
                    else
                    {
                        dataGridRow.Cells[6].Value = Properties.Resources.blank;
                    }

                    if (TrendViewerHelper.ChangeStrToBool(dataRow["DATA_PT_LBL_ENABLED"].ToString()))
                    {
                        dataGridRow.Cells[7].Value = Properties.Resources.img_checkmark;
                    }
                    else
                    {
                        dataGridRow.Cells[7].Value = Properties.Resources.blank;
                    }

                    if (TrendViewerHelper.ChangeStrToBool(dataRow["DATA_PT_VISIBLE"].ToString()))
                    {
                        dataGridRow.Cells[8].Value = Properties.Resources.img_checkmark;
                    }
                    else
                    {
                        dataGridRow.Cells[8].Value = Properties.Resources.blank;
                    }


                    dataGridRow.Cells[9].Value = dataRow["DATA_PT_SERVER"].ToString();

                    dataGridRow.Cells[10].Value = dataRow["DATA_PT_HOST"].ToString();
                    counter++;
                }
            }
            catch (Exception localException)
            {
                LogHelper.Error(CLASS_NAME, Function_Name, localException.ToString());
            }

            dataPointListDataGridViewprogressBar.Visible = false;
        }