123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450 |
- using OTSCommon.Model;
- using OTSIncAReportApp.OTSSampleReportInfo;
- using OTSIncAReportApp.SysMgrTools;
- using OTSIncAReportGB;
- using OTSIncAReportGrids;
- using SourceGrid;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- namespace OTSIncAReportApp.OTSDataMgrFunction
- {
- /// <summary>
- /// 属性Grid相关操作封装类
- /// </summary>
- public class OTSSourceGrid
- {
- #region 变量定义
- /// <summary>
- /// 主框架窗体
- /// </summary>
- public frmReportConditionChoose m_frmPropCondition = null;
-
- /// <summary>
- /// 当grid被click时,确定点击的行
- /// </summary>
- public int m_ClickRow = 0;
- /// <summary>
- /// 当grid被click时,确定点击的列
- /// </summary>
- public int m_ClickColumn = 0;
- /// <summary>
- /// 当改变ProperyWindow窗口大小时,窗口响应Resize(object sender, EventArgs e),返回改变后的尺寸,利用改变后的窗口尺寸重回Grid的行宽和列宽
- /// </summary>
- public int m_PropWindow_X = 0;
- /// <summary>
- /// 当改变ProperyWindow窗口大小时,窗口响应Resize(object sender, EventArgs e),返回改变后的尺寸,利用改变后的窗口尺寸重回Grid的行宽和列宽
- /// </summary>
- public int m_PropWindow_Y = 0;
- /// <summary>
- /// 临时用于计算用的grid行号 总行数
- /// </summary>
- public static int m_Const_Grid_Row = 42; //总行数
- /// <summary>
- /// 临时用于计算用的grid行号 总列数
- /// </summary>
- public static int m_Const_Grid_Column = 3; //总列数
- /// <summary>
- /// 当选择了Grid的某个row ,修改Row的值,引发的事件
- /// </summary>
- ChangeGridCellValEvent m_ChangeCellValEvent = null;
- /// <summary>
- /// 选择COMBOBOX值引发的事件
- /// </summary>
- ItemValueChange2 m_ValChangeEvent2 = null;
- /// <summary>
- /// 定义分栏表头样式
- /// </summary>
- public SourceGrid.Cells.Views.Cell m_Col_HeaderMode = null;
- /// <summary>
- /// 定义大表头grid表头样式
- /// </summary>
- SourceGrid.Cells.Views.Cell m_CellTitleModel = null;
- /// <summary>
- /// 定义分栏标题格样式
- /// </summary>
- SourceGrid.Cells.Views.Cell m_Col_NameMode = null;
- /// <summary>
- /// 定义分栏内容格样式
- /// </summary>
- SourceGrid.Cells.Views.Cell m_Col_ValMode = null;
- /// <summary>
- /// 只读样式cell设置
- /// </summary>
- SourceGrid.Cells.Views.Cell M_Col_readonly = null;
- /// <summary>
- /// 通用参数组的标题名
- /// </summary>
- public String m_Display_Mode_Name = "parameter";
- /// <summary>
- /// 通用参数组的GRID行数
- /// </summary>
- public int m_Display_Mode_Row = 0;
- Language lan = new Language();
- Hashtable table;
-
- ResultDataMgr m_DataMgr;
- #endregion
- #region 构造函数及初始化函数
- public OTSSourceGrid(frmReportConditionChoose Propwindow)
- {
- m_DataMgr = Propwindow.m_ReportApp.m_rstDataMgr;
- m_frmPropCondition = Propwindow;
- m_frmPropCondition.PropGrid.Rows.Clear();
- m_frmPropCondition.PropGrid.Redim(m_Const_Grid_Row, m_Const_Grid_Column);
- table = lan.GetNameTable("SampleGrid");
- string str = table["str1"].ToString();
- m_Display_Mode_Name = str;
- }
- /// <summary>
- /// 初始化Grid修改值事件
- /// </summary>
- void InitChangeValEvent()
- {
- m_ChangeCellValEvent = new ChangeGridCellValEvent(this);
- m_ValChangeEvent2 = new ItemValueChange2(this);
- }
- #endregion
- #region 初始化属性Grid相关方法
- /// <summary>
- /// 初始化属性Grid相关样式
- /// </summary>
- public void InitGrid()
- {
- //初始化Grid修改值事件
- InitChangeValEvent();
- //定义大表头grid表头样式
- {
- m_CellTitleModel = new SourceGrid.Cells.Views.Cell();
- m_CellTitleModel.BackColor = Color.LightGray;
- m_CellTitleModel.ForeColor = Color.Black;
- m_CellTitleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft;
- }
- //定义分栏表头样式
- {
- m_Col_HeaderMode = new SourceGrid.Cells.Views.Cell();
- m_Col_HeaderMode.BackColor = Color.LightGray; //背景色
- m_Col_HeaderMode.ForeColor = Color.Black; //字体颜色
- m_Col_HeaderMode.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
- }
- //定义分栏标题格样式
- {
- m_Col_NameMode = new SourceGrid.Cells.Views.Cell();
- m_Col_NameMode.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft;
- }
- //定义分栏内容格样式
- {
- m_Col_ValMode = new SourceGrid.Cells.Views.Cell();
- m_Col_ValMode.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleLeft;
- }
- //只读样式cell设置
- {
- M_Col_readonly = new SourceGrid.Cells.Views.Cell();
- M_Col_readonly.ForeColor = Color.Gray;
- }
- }
- /// <summary>
- /// 初始化属性Grid相关表头
- /// </summary>
- public void InitGridTitlet()
- {
- int firstColumnWidth = 15; //第一列的宽度
- int SecondColumnWidth = 150;
- //设备各单元格宽度---------------------------------------------
- m_frmPropCondition.PropGrid.Columns.SetWidth(0, firstColumnWidth); //设置第一列宽度
- m_frmPropCondition.PropGrid.Columns.AutoSizeColumn(2); //固定进度条
- //ProperyWindows的窗口宽度包括是第二列和第三列的长度总和
- m_frmPropCondition.PropGrid.Columns.SetWidth(1, 150); //第二列宽度
- m_frmPropCondition.PropGrid.Columns.SetWidth(2, (m_PropWindow_X - firstColumnWidth - SecondColumnWidth - 18)); //第三列宽度
- }
- /// <summary>
- /// 初始化组的标题栏 iRow:GroupTitle的行号, sGroupName: GroupTitle的名字
- /// </summary>
- /// <param name="iRow"></param>
- /// <param name="sGroupName"></param>
- public void InitGroupTitle(int iRow, String sGroupName)
- {
- if (null == m_frmPropCondition.PropGrid[iRow, 0])
- {
- m_frmPropCondition.PropGrid[iRow, 0] = new SourceGrid.Cells.Link("-");//第一行,上面用来折叠的"-",一会点击后变成"+"
- m_frmPropCondition.PropGrid[iRow, 0].View = m_CellTitleModel; //设置表头的样式
- //设置表头"-"按钮,点击后的事件
- }
- if (null == m_frmPropCondition.PropGrid[iRow, 1])
- {
- m_frmPropCondition.PropGrid[iRow, 1] = new SourceGrid.Cells.Cell(sGroupName); // 设置GroupTitle的名字
- m_frmPropCondition.PropGrid[iRow, 1].View = m_CellTitleModel;
- m_frmPropCondition.PropGrid[iRow, 1].ColumnSpan = 2; //设置第二列与第三列合并,表头效果完成。 2:从当前列开始合并2列
- }
- }
- #endregion
- #region 属性Grid显示相关方法
- public void ShowGeneralGrid(ReportCondition conditionInfo)
- {
- if (conditionInfo.ConditionItemList.Count() == 0)
- return;
- int nGridRow = 0;
- string str = table["str2"].ToString();
- this.InitGroupTitle(nGridRow, str);
- nGridRow++;
- int Display_Mode_Row = 1;//确定跨行样式的跨行数变量
- // 设置样品Grid数据
- for (int i = 0; i < conditionInfo.ConditionItemList.Count; i++)
- {
- Display_Mode_Row++;
- //显示样品的属性值
- ConditionItem SData = conditionInfo.ConditionItemList[i];
- this.SetGridCellVal(nGridRow, SData);
- nGridRow++;
- }
- //控制左边的竖形条框栏的显示
- //第二行,第一列,为了效果美化,向下跨行,共跨m_Grid_TotleRow - 1行
- if (Display_Mode_Row > 1) //有通用参数组的Grid值显示
- {
- //获取Grid组Title所在的行号
- int iCurRow = Display_Mode_Row;
- //第二行的时候,需要定义左边的条框栏
- if (m_frmPropCondition.tabIndex == DisplayPicutureType.AnalyzeImg)
- {
- if (null == m_frmPropCondition.PropGrid[1 + 1, 0])
- {
- m_frmPropCondition.PropGrid[1, 0] = new SourceGrid.Cells.Cell("");
- m_frmPropCondition.PropGrid[1, 0].View = m_Col_HeaderMode;
- }
- else
- {
- m_frmPropCondition.PropGrid[iCurRow + 1, 0].Value = "";
- }
- if (iCurRow == 0)
- {
- m_frmPropCondition.PropGrid[iCurRow + 1, 0].RowSpan = iCurRow + Display_Mode_Row - 1; //iCurRow + General_Totle_Row-1 : 去掉标题栏计数
- }
- else
- {
- m_frmPropCondition.PropGrid[1, 0].RowSpan = Display_Mode_Row - 1; //iCurRow + General_Totle_Row-1 : 去掉标题栏计数
- }
- }
- if (m_frmPropCondition.tabIndex == DisplayPicutureType.AnalyzeDataTable)
- {
- //第二行的时候,需要定义左边的条框栏
- if (null == m_frmPropCondition.PropGrid[1 + 1, 0])
- {
- m_frmPropCondition.PropGrid[1, 0] = new SourceGrid.Cells.Cell("");
- m_frmPropCondition.PropGrid[1, 0].View = m_Col_HeaderMode;
- }
- else
- {
- m_frmPropCondition.PropGrid[iCurRow + 1, 0].Value = "";
- }
- if (iCurRow == 0)
- {
- m_frmPropCondition.PropGrid[iCurRow + 1, 0].RowSpan = iCurRow + Display_Mode_Row - 1; //iCurRow + General_Totle_Row-1 : 去掉标题栏计数
- }
- else
- {
- m_frmPropCondition.PropGrid[1, 0].RowSpan = Display_Mode_Row - 1; //iCurRow + General_Totle_Row-1 : 去掉标题栏计数
- }
- }
- if (m_frmPropCondition.tabIndex == DisplayPicutureType.AnalyzeDataChart)
- {
- //第二行的时候,需要定义左边的条框栏
- if (null == m_frmPropCondition.PropGrid[1, 0])
- {
- m_frmPropCondition.PropGrid[1, 0] = new SourceGrid.Cells.Cell("");
- m_frmPropCondition.PropGrid[1, 0].View = m_Col_HeaderMode;
- }
- else
- {
- m_frmPropCondition.PropGrid[iCurRow + 1, 0].Value = "";
- }
- if (iCurRow == 0)
- {
- m_frmPropCondition.PropGrid[iCurRow + 1, 0].RowSpan = iCurRow + Display_Mode_Row - 1; //iCurRow + General_Totle_Row-1 : 去掉标题栏计数
- }
- else
- {
- m_frmPropCondition.PropGrid[1, 0].RowSpan = Display_Mode_Row - 1; //iCurRow + General_Totle_Row-1 : 去掉标题栏计数
- }
- }
- }
- }
- /// <summary>
- /// 显示Chart图表相关属性Grid
- /// </summary>
- /// <param name="note"></param>
- public void SetPictureType(DisplayPicutureType note)
- {
- m_frmPropCondition.tabIndex = note;
-
- }
- public void SetGridCellVal(int Row, ConditionItem SData)
- {
- OTS_REPORT_PROP_GRID_ITEMS SampleID = SData.iItemId;
- String sCaptionName = SData.sSCaptionName;
- object SampleVal = SData.itemDisplayVal;
- List<String> comboDownList = SData.comboDownList;
- OTS_ITEM_TYPES SampleValType = SData.iItemValType;
- bool bReadOnly = SData.bReadOnly;
- //每行的第一列显示属性名称
- if (null == m_frmPropCondition.PropGrid[Row, 1])
- {
- m_frmPropCondition.PropGrid[Row, 1] = new SourceGrid.Cells.Cell(sCaptionName);
- }
- else
- {
- m_frmPropCondition.PropGrid[Row, 1].Value = sCaptionName;
- }
- m_frmPropCondition.PropGrid[Row, 1].View = m_Col_NameMode;
- //每行的第二列显示属性值
- if (null == m_frmPropCondition.PropGrid[Row, 2])
- {
- switch (SData.iItemValType)
- {
- case OTS_ITEM_TYPES.COMBO:
- try
- {
- SourceGrid.Cells.Editors.ComboBox m_ComboboxText = null;
- List<string> ValList = new List<string>();
- string[] arraySample;
- if (null == comboDownList)
- {
- List<string> sSampleVal = new List<string>();
- ValList = sSampleVal;
- }
- else
- {
- ValList = (List<string>)comboDownList;
- }
- int iValCount = ValList.Count();
- if (iValCount > 0)
- {
- arraySample = new string[iValCount];
- for (int i = 0; i < iValCount; i++)
- {
- arraySample[i] = ValList[i];
- }
- }
- else
- {
- arraySample = new string[3] { "", "", "" };
- }
- m_frmPropCondition.PropGrid[Row, 2] = new SourceGrid.Cells.Cell(SampleVal);
- m_ComboboxText = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true);
- m_frmPropCondition.PropGrid[Row, 2].Editor = m_ComboboxText;
- m_ComboboxText.Control.DropDownStyle = ComboBoxStyle.DropDownList; //设置下拉框为不可以编辑的状态
- m_frmPropCondition.PropGrid[Row, 2].Value = SampleVal;
- m_frmPropCondition.PropGrid[Row, 2].AddController(m_ChangeCellValEvent);
- m_frmPropCondition.PropGrid[Row, 2].AddController(m_ValChangeEvent2);
- m_ComboboxText.EditableMode = EditableMode.SingleClick;
- }
- catch (Exception)
- {
- }
- break;
- case OTS_ITEM_TYPES.DOUBLE:
- var txtbox = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double));
- m_frmPropCondition.PropGrid[Row, 2] = new SourceGrid.Cells.Cell(SampleVal);
- txtbox.EditableMode = EditableMode.SingleClick;
- m_frmPropCondition.PropGrid[Row, 2].Editor = txtbox;
- m_frmPropCondition.PropGrid[Row, 2].AddController(m_ChangeCellValEvent);
- m_frmPropCondition.PropGrid[Row, 2].AddController(m_ValChangeEvent2);
- break;
- default:
- break;
- }
- if (bReadOnly) //只读模式
- {
- m_frmPropCondition.PropGrid[Row, 2].Editor = null;
- m_frmPropCondition.PropGrid[Row, 2].View = M_Col_readonly;// 设置只读
- }
- else
- {
- m_frmPropCondition.PropGrid[Row, 2].View = m_Col_ValMode;
- }
- //行绑定ID值
- m_frmPropCondition.PropGrid.Rows[Row].Tag = SampleID;
- //数据位置绑定数据类型
- m_frmPropCondition.PropGrid[Row, 2].Tag = SampleValType;
- }
- else
- {
- m_frmPropCondition.PropGrid[Row, 2].Value = SampleVal;
- }
- }
- #endregion
-
-
-
- }
- }
|