private void dataPointListDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } string Function_Name = "dataPointListDataGridView_CellDoubleClick"; FormulaListController controller = (FormulaListController)getController(); string formulaLblName = formulaListDataGridView.Rows[e.RowIndex].Cells[2].Value.ToString(); try { if (e.ColumnIndex == 7) { if ( MessageBoxDialog.Show( StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_Msg_DelConfirm, LanguageHelper.TrendViewer_Msg_DelConfirm_EN), StringHelper.GetInstance().getStringValue(LanguageHelper.TrendViewer_Msg_SysMsg, LanguageHelper.TrendViewer_Msg_SysMsg_EN), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { controller.DeleteByFormulaLblName(formulaLblName); } } else if (e.ColumnIndex == 6) { controller.EditFormula(formulaLblName); } } catch (Exception localException) { LogHelper.Error(CLASS_NAME, Function_Name, localException.ToString()); } }
public void FixtureSetUp() { ViewManager.GetInstance().RegisterViewFactory(new TrendingViewFactory()); formulaList = (FormulaList)(ViewManager.GetInstance().GetView(TrendViewConst.FormulaList, "view_ID")); FormulaListController ctl = (FormulaListController)(formulaList.getController()); ctl.initFormulaTable(); }
public override void AttachListener(IController ctl) { FormulaListController controller = (FormulaListController)ctl; this.addDataPointToolStripMenuItem.Click += controller.AddFormula; this.saveDataConfigToolStripMenuItem.Click += controller.SaveFormula; this.loadDataConfigToolStripMenuItem.Click += controller.LoadFormula; this.FormClosed += controller.FormClose; }
public void TestdataPointListDataGridView_CellDoubleClick02() { //exception Accessor formulaListAccessor = ReflectionAccessor.Wrap(formulaList); DataGridView formulaListDataGridView = (DataGridView)(formulaListAccessor.GetField("formulaListDataGridView")); FormulaListController ctl = (FormulaListController)(formulaList.getController()); EtyFormula formula = new EtyFormula(); formula.DPEquation = "::a::"; ctl.AddFormulaToList(formula); object sender = null; DataGridViewCellEventArgs e = new DataGridViewCellEventArgs(7, 0); formulaListAccessor.Call("dataPointListDataGridView_CellDoubleClick", sender, e); }
public void FixtureSetUp() { if (DBConnectionStrings.GetInstance().GetConnectionStrings().Count < 1) { DBConnectionStrings.GetInstance().AddConnectionString(TestConst.CONNECTION_STR); SimpleDatabase.GetInstance().OpenConnection(); } ViewManager.GetInstance().RegisterViewFactory(new TrendingViewFactory()); IView view = ViewManager.GetInstance().GetView(TrendViewConst.FormulaList, TestConst.TEST_VIEW_ID); formulaListController = (FormulaListController)(view.getController()); formulaListController.initFormulaTable(); FormulaListModel model = new FormulaListModel(); formulaListController.SetFormulaTable(model.GetFormulaListByGrp(TestConst.FORMULA_GROUP_NAME)); formulaListController.SetGrpName(TestConst.FORMULA_GROUP_NAME); }
public IView CreateView(string type, string id) { IView view = null; IController controller = null; IModel model = null; switch (type) { case TrendViewConst.About: view = new About(); view.ViewType = TrendViewConst.About; break; case TrendViewConst.TrendView: view = new TrendView(); view.ViewType = TrendViewConst.TrendView; controller = new TrendViewController(); model = new TrendViewModel(); controller.Attach(model, view); break; // marker related: case TrendViewConst.MarkerList: view = new MarkerList(); view.ViewType = TrendViewConst.MarkerList; controller = new MarkerListController(); model = new MarkerListModel(); controller.Attach(model, view); break; case TrendViewConst.LoadConfigMarker: view = new MarkerGroup(); controller = new MarkerGroupController(); model = new MarkerGroupModel(); controller.Attach(model, view); break; case TrendViewConst.SaveConfigMarker: view = new MarkerGroup(); controller = new MarkerGroupController(); model = new MarkerGroupModel(); controller.Attach(model, view); break; case TrendViewConst.AddMarkerData: view = new MarkerData(); controller = new MarkerDataController(); model = new MarkerDataModel(); controller.Attach(model, view); break; case TrendViewConst.EditMarkerData: view = new MarkerData(); controller = new MarkerDataController(); model = new MarkerDataModel(); controller.Attach(model, view); break; // formula related: case TrendViewConst.FormulaList: view = new FormulaList(); view.ViewType = TrendViewConst.FormulaList; controller = new FormulaListController(); model = new FormulaListModel(); controller.Attach(model, view); break; case TrendViewConst.LoadConfigFormula: view = new FormulaGroup(); controller = new FormulaGroupController(); model = new FormulaGroupModel(); controller.Attach(model, view); break; case TrendViewConst.SaveConfigFormula: view = new FormulaGroup(); controller = new FormulaGroupController(); model = new FormulaGroupModel(); controller.Attach(model, view); break; case TrendViewConst.AddFormulaData: view = new FormulaData(); controller = new FormulaDataController(); model = new FormulaDataModel(); controller.Attach(model, view); break; case TrendViewConst.EditFormulaData: view = new FormulaData(); controller = new FormulaDataController(); model = new FormulaDataModel(); controller.Attach(model, view); break; // DP related: case TrendViewConst.DataPointList: view = new DataPointList(); view.ViewType = TrendViewConst.DataPointList; controller = new DataPointListController(); model = new DataPointListModel(); controller.Attach(model, view); break; case TrendViewConst.LoadConfigDataPoint: view = new DataPointGroup(); controller = new DataPointGroupController(); model = new DataPointGroupModel(); controller.Attach(model, view); break; case TrendViewConst.SaveConfigDataPoint: view = new DataPointGroup(); controller = new DataPointGroupController(); model = new DataPointGroupModel(); controller.Attach(model, view); break; case TrendViewConst.AddDataPointData: view = new DataPointData(); controller = new DataPointDataController(); model = new DataPointDataModel(); controller.Attach(model, view); break; case TrendViewConst.EditDataPointData: view = new DataPointData(); controller = new DataPointDataController(); model = new DataPointDataModel(); controller.Attach(model, view); break; //Hist DP related: case TrendViewConst.HistDataPointList: view = new HistDataPointList(); view.ViewType = TrendViewConst.HistDataPointList; controller = new HistDataPointListController(); model = new HistDataPointListModel(); controller.Attach(model, view); break; case TrendViewConst.LoadConfigHistDataPoint: view = new HistDataPointGroup(); controller = new HistDataPointGroupController(); model = new HistDataPointGroupModel(); controller.Attach(model, view); break; case TrendViewConst.SaveConfigHistDataPoint: view = new HistDataPointGroup(); controller = new HistDataPointGroupController(); model = new HistDataPointGroupModel(); controller.Attach(model, view); break; case TrendViewConst.AddHistDataPointData: view = new HistDataPointData(); controller = new HistDataPointDataController(); model = new HistDataPointDataModel(); controller.Attach(model, view); break; case TrendViewConst.EditHistDataPointData: view = new HistDataPointData(); controller = new HistDataPointDataController(); model = new HistDataPointDataModel(); controller.Attach(model, view); break; case TrendViewConst.OPCDataSelector: view = new OPCDataSelector(); controller = new OPCDataSelectorController(); model = new OPCDataSelectorModel(); controller.Attach(model, view); break; case TrendViewConst.ChangeTrendTitle: view = new EditChartTitle(); controller = new ChangeTrendTitleController(); model = null; controller.Attach(model, view); break; default: break; } view.ViewID = id; return(view); }
public void TestAttachListener01() { IController ctl = new FormulaListController(); /* TODO: Implement me */; formulaList.AttachListener(ctl); }
public void TestPopulateDataPointListDataGridView02() { //ctl.m_FormulaTable has data: DATA_PT_LBL_NAME (>100) //DATA_PT_EQUATION (>100) //DATA_PT_ENABLED ="Y" //DATA_PT_LBL_ENABLED = "Y" //ctl.m_FormulaTable has data: DATA_PT_LBL_NAME (<100) //DATA_PT_EQUATION (<100) //DATA_PT_ENABLED ="N" //DATA_PT_LBL_ENABLED = "N" FormulaListController ctl = (FormulaListController)(formulaList.getController()); Accessor ctlAccessor = ReflectionAccessor.Wrap(ctl); DataTable table = (DataTable)ctlAccessor.GetField("m_FormulaTable"); DataRow row1 = table.NewRow(); row1["DATA_PT_LBL_NAME"] = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; row1["DATA_PT_EQUATION"] = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; row1["DATA_PT_ENABLED"] = "Y"; row1["DATA_PT_LBL_ENABLED"] = "Y"; table.Rows.Add(row1); DataRow row2 = table.NewRow(); row2["DATA_PT_LBL_NAME"] = "12345678901"; row2["DATA_PT_EQUATION"] = "123456789012345"; row2["DATA_PT_ENABLED"] = "N"; row2["DATA_PT_LBL_ENABLED"] = "N"; table.Rows.Add(row2); ctlAccessor.SetField("m_FormulaTable", table); int mode = 0; formulaList.PopulateDataPointListDataGridView(mode); DataRow row3 = table.NewRow(); row3["DATA_PT_LBL_NAME"] = "12345678901"; row3["DATA_PT_EQUATION"] = "123456789012345"; row3["DATA_PT_ENABLED"] = "N"; row3["DATA_PT_LBL_ENABLED"] = "N"; table.Rows.Add(row3); DataRow row4 = table.NewRow(); row4["DATA_PT_LBL_NAME"] = "12345678901"; row4["DATA_PT_EQUATION"] = "123456789012345"; row4["DATA_PT_ENABLED"] = "N"; row4["DATA_PT_LBL_ENABLED"] = "N"; table.Rows.Add(row4); DataRow row5 = table.NewRow(); row5["DATA_PT_LBL_NAME"] = "12345678901"; row5["DATA_PT_EQUATION"] = "123456789012345"; row5["DATA_PT_ENABLED"] = "N"; row5["DATA_PT_LBL_ENABLED"] = "N"; table.Rows.Add(row5); ctlAccessor.SetField("m_FormulaTable", table); formulaList.PopulateDataPointListDataGridView(1); DataRow row6 = table.NewRow(); row6["DATA_PT_LBL_NAME"] = "12345678901"; row6["DATA_PT_EQUATION"] = "123456789012345"; row6["DATA_PT_ENABLED"] = "N"; row6["DATA_PT_LBL_ENABLED"] = "N"; table.Rows.Add(row6); ctlAccessor.SetField("m_FormulaTable", table); formulaList.PopulateDataPointListDataGridView(1); DataRow row7 = table.NewRow(); row7["DATA_PT_LBL_NAME"] = "12345678901"; row7["DATA_PT_EQUATION"] = "123456789012345"; row7["DATA_PT_ENABLED"] = "N"; row7["DATA_PT_LBL_ENABLED"] = "N"; table.Rows.Add(row7); ctlAccessor.SetField("m_FormulaTable", table); formulaList.PopulateDataPointListDataGridView(1); DataRow row8 = table.NewRow(); row8["DATA_PT_LBL_NAME"] = "12345678901"; row8["DATA_PT_EQUATION"] = "123456789012345"; row8["DATA_PT_ENABLED"] = "N"; row8["DATA_PT_LBL_ENABLED"] = "N"; table.Rows.Add(row8); // totalRecord % RECORDSIZE = 0 ctlAccessor.SetField("m_FormulaTable", table); formulaList.PopulateDataPointListDataGridView(1); }
public void PopulateDataPointListDataGridView(int mode) { // <summary> // DataPointListDataGridView Data Population // </summary> string Function_Name = "PopulateDataPointListDataGridView"; formulaListDataGridViewprogressBar.Visible = true; try { formulaListDataGridViewprogressBar.Value = 0; totalDataPointListDataGridView.Text = "1"; if (mode == 1) { pageNumDataPointListDataGridView.Value = 1; } FormulaListController ctl = (FormulaListController)getController(); int totalRecord = ctl.getFormulaTable().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 (formulaListDataGridView.SortedColumn != null && formulaListDataGridView.Rows.Count > 0) { if (formulaListDataGridView.SortedColumn.Name != null && formulaListDataGridView.SortedColumn.Name.Trim() != "") { localSQL = formulaListDataGridView.SortedColumn.Name; if (formulaListDataGridView.SortOrder.ToString().ToLower() != "ascending") { localSQL += " DESC "; } else { localSQL += " ASC "; } } else { localSQL = " DATA_PT_LBL_NAME ASC "; } } else { localSQL = " DATA_PT_LBL_NAME ASC "; } DataRow[] dataRowArray = ctl.getFormulaTable().Select("", localSQL); DataGridViewRow dataGridRow = null; DataRow dataRow = null; if (upperRecord > dataRowArray.Length) { upperRecord = dataRowArray.Length; } int counter = 0; string tempString = ""; formulaListDataGridView.Rows.Clear(); if (lowerRecord > 0) { lowerRecord--; } formulaListDataGridViewprogressBar.Value = 0; for (int i = lowerRecord; i < upperRecord; i++) { formulaListDataGridView.Rows.Add(); formulaListDataGridViewprogressBar.Value++; dataGridRow = formulaListDataGridView.Rows[counter]; dataRow = dataRowArray[i]; tempString = ""; tempString = dataRow["DATA_PT_LBL_NAME"].ToString(); if (tempString.Length > 100) { dataGridRow.Cells[2].Value = tempString.Substring(0, 100) + "..."; } else { dataGridRow.Cells[2].Value = tempString; } dataGridRow.Cells[3].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())); } tempString = ""; tempString = dataRow["DATA_PT_EQUATION"].ToString(); if (tempString.Length > 100) { dataGridRow.Cells[5].Value = tempString.Substring(0, 100) + "..."; } else { dataGridRow.Cells[5].Value = tempString; } if (TrendViewerHelper.ChangeStrToBool(dataRow["DATA_PT_ENABLED"].ToString())) { dataGridRow.Cells[0].Value = Properties.Resources.img_checkmark; } else { dataGridRow.Cells[0].Value = Properties.Resources.blank; } if (TrendViewerHelper.ChangeStrToBool(dataRow["DATA_PT_LBL_ENABLED"].ToString())) { dataGridRow.Cells[1].Value = Properties.Resources.img_checkmark; } else { dataGridRow.Cells[1].Value = Properties.Resources.blank; } counter++; } } catch (Exception localException) { LogHelper.Error(CLASS_NAME, Function_Name, localException.ToString()); } formulaListDataGridViewprogressBar.Visible = false; }