/// <summary> /// 重绘方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="rect">矩形</param> /// <param name="clipRect">裁剪矩形</param> /// <param name="isAlternate">是否交替行</param> public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate) { int clipW = clipRect.right - clipRect.left; int clipH = clipRect.bottom - clipRect.top; if (clipW > 0 && clipH > 0) { GridA grid = Grid; GridRow row = Row; GridColumn column = Column; if (grid != null && row != null && column != null) { //判断选中 String text = Text; bool selected = false; List <GridRow> selectedRows = grid.SelectedRows; int selectedRowsSize = selectedRows.Count; for (int i = 0; i < selectedRowsSize; i++) { if (selectedRows[i] == row) { selected = true; break; } } //获取颜色 FONT font = null; long foreColor = COLOR.EMPTY; GridCellStyle style = Style; if (style != null) { if (style.Font != null) { font = style.Font; } foreColor = style.ForeColor; } SecurityFilterInfo info = (row as SecurityFilterResultRow).Info; if (info.GetValue("FILTER") != 1) { foreColor = CDraw.PCOLORS_FORECOLOR8; } SIZE tSize = paint.TextSize(text, font); POINT tPoint = new POINT(rect.left + 1, rect.top + clipH / 2 - tSize.cy / 2); if (column.Name == "colCode") { tPoint.x = rect.right - tSize.cx; } RECT tRect = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy); paint.DrawText(text, foreColor, font, tRect); if (selected) { paint.DrawLine(CDraw.PCOLORS_LINECOLOR, 2, 0, rect.left, rect.bottom - 1, rect.right, rect.bottom - 1); } } } }
/// <summary> /// 重绘方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="rect">矩形</param> /// <param name="clipRect">裁剪矩形</param> /// <param name="isAlternate">是否交替行</param> public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate) { int clipW = clipRect.right - clipRect.left; int clipH = clipRect.bottom - clipRect.top; if (clipW > 0 && clipH > 0) { GridA grid = Grid; GridRow row = Row; GridColumn column = Column; if (grid != null && row != null && column != null) { //判断选中 String text = "-"; bool selected = false; List <GridRow> selectedRows = grid.SelectedRows; int selectedRowsSize = selectedRows.Count; for (int i = 0; i < selectedRowsSize; i++) { if (selectedRows[i] == row) { selected = true; break; } } //获取颜色 FONT font = null; long foreColor = COLOR.EMPTY; GridCellStyle style = Style; if (style != null) { foreColor = style.ForeColor; if (style.Font != null) { font = style.Font; } } SecurityFilterInfo info = (row as SecurityFilterResultRow).Info; double value = GetDouble(); if (!double.IsNaN(value)) { if (m_fieldName != null && m_fieldName.Length > 0) { if (m_fieldName == "FILTER") { if (value == 1) { foreColor = CDraw.PCOLORS_FORECOLOR9; text = "是"; } else { foreColor = CDraw.PCOLORS_FORECOLOR7; text = "否"; } } else { foreColor = CDraw.GetPriceColor(value, 0); text = value.ToString("0.0000"); } } else { SecurityLatestData data = info.LatestData; String columnName = column.Name; int dataSize = data != null ? data.m_securityCode.Length : 0; if (columnName == "colNo") { foreColor = CDraw.PCOLORS_FORECOLOR7; text = ((int)value + 1).ToString(); } else if (columnName == "colAmount" || columnName == "colVolume") { if (dataSize > 0) { foreColor = CDraw.PCOLORS_FORECOLOR9; text = ((long)value).ToString(); } } else if (columnName == "colDiff") { if (dataSize > 0) { foreColor = CDraw.GetPriceColor(value, 0); text = value.ToString("0.00"); } } else if (columnName == "colDiffRange") { if (dataSize > 0) { foreColor = CDraw.GetPriceColor(data.m_close, data.m_lastClose); text = value.ToString("0.00") + "%"; } } else if (columnName == "colLastClose") { if (dataSize > 0) { foreColor = CDraw.PCOLORS_FORECOLOR9; text = value.ToString("0.00"); } } else { if (dataSize > 0) { foreColor = CDraw.GetPriceColor(value, data.m_lastClose); text = value.ToString("0.00"); } } } } if (info.GetValue("FILTER") != 1) { foreColor = CDraw.PCOLORS_FORECOLOR8; } SIZE tSize = paint.TextSize(text, font); POINT tPoint = new POINT(rect.right - tSize.cx, rect.top + clipH / 2 - tSize.cy / 2); RECT tRect = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy); paint.DrawText(text, foreColor, font, tRect); if (selected) { paint.DrawLine(CDraw.PCOLORS_LINECOLOR, 2, 0, rect.left, rect.bottom - 1, rect.right, rect.bottom - 1); } } } }
/// <summary> /// 获取浮点型数值 /// </summary> /// <returns>浮点型数值</returns> public override double GetDouble() { GridRow row = Row; SecurityFilterInfo info = (row as SecurityFilterResultRow).Info; if (m_fieldName != null && m_fieldName.Length > 0) { return(info.GetValue(m_fieldName)); } else { SecurityLatestData data = info.LatestData; int dataSize = data != null ? data.m_securityCode.Length : 0; GridColumn column = Column; String columnName = column.Name; if (columnName == "colNo") { return(row.Index); } else if (columnName == "colAmount") { if (dataSize > 0) { return(data.m_amount); } } else if (columnName == "colClose") { if (dataSize > 0) { return(data.m_close); } } else if (columnName == "colDiff") { if (dataSize > 0) { return(data.m_close - data.m_lastClose); } } else if (columnName == "colHigh") { if (dataSize > 0) { return(data.m_high); } } else if (columnName == "colLow") { if (dataSize > 0) { return(data.m_low); } } else if (columnName == "colBuy") { if (dataSize > 0) { return(data.m_buyPrice1); } } else if (columnName == "colSell") { if (dataSize > 0) { return(data.m_sellPrice1); } } else if (columnName == "colDiffRange") { if (dataSize > 0) { if (data.m_lastClose != 0) { return(100 * (data.m_close - data.m_lastClose) / data.m_lastClose); } } } else if (columnName == "colOpen") { if (dataSize > 0) { return(data.m_open); } } else if (columnName == "colLastClose") { if (dataSize > 0) { return(data.m_lastClose); } } else if (columnName == "colVolume") { if (dataSize > 0) { return(data.m_volume); } } } return(0); }