private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
try
{
if (e.CellValue != null)
{
if (e.CellValue != DBNull.Value)
{
int b = 0;
int cellvalue = 0;
if (m_viewtype == ViewType.Hexadecimal)
{
b = Convert.ToInt32(e.CellValue.ToString(), 16);
cellvalue = b;
}
else
{
b = Convert.ToInt32(e.CellValue.ToString());
cellvalue = b;
}
b *= 255;
if (m_MaxValueInTable != 0)
{
b /= m_MaxValueInTable;
}
// new version
b = 0;
double td = 0;
int tempcellvalue = 0;
if (m_viewtype == ViewType.Hexadecimal)
{
b = Convert.ToInt32(e.CellValue.ToString(), 16);
td = b;
if (m_viewtype == ViewType.Easy)
{
td *= correction_factor;
td += correction_offset;
}
tempcellvalue = Convert.ToInt32(td);
}
else
{
b = Convert.ToInt32(ConvertToDouble(e.CellValue.ToString()));
td = b;
if (m_viewtype == ViewType.Easy)
{
td *= correction_factor;
td += correction_offset;
}
tempcellvalue = Convert.ToInt32(td);
}
td *= 255;
b = Convert.ToInt32(td);
if (now_realMaxValue != double.MinValue && now_realMaxValue != 0)
{
b /= Convert.ToInt32(now_realMaxValue);
}
// upto here
int red = 128;
int green = 128;
int blue = 128;
Color c = Color.White;
if (m_OnlineMode)
{
b /= 2;
red = b;
if (red < 0) red = 0;
if (red > 255) red = 255;
if (b > 255) b = 255;
green = 255 - red;
blue = 255 - red;
c = Color.FromArgb(red, green, blue);
// if (b == 0) c = Color.Transparent;
}
else if (!m_isRedWhite)
{
red = b;
if (red < 0) red = 0;
if (red > 255) red = 255;
if (b > 255) b = 255;
blue = 0;
green = 255 - red;
c = Color.FromArgb(red, green, blue);
}
else
{
if (b < 0) b = -b;
if (b > 255) b = 255;
c = Color.FromArgb(b, Color.Red);
}
if (m_viewtype == ViewType.Easy )
{
float dispvalue = 0;
dispvalue = (float)cellvalue;
if (correction_offset != 0 || correction_factor != 1)
{
dispvalue = (float)((float)cellvalue * (float)correction_factor) + (float)correction_offset;
if (m_viewtype != ViewType.Hexadecimal)
//if (!m_isHexMode)
{
if (m_map_name.StartsWith("Injector duration") || m_map_name.StartsWith("Start of injection"))
{
e.DisplayText = dispvalue.ToString("F1") + "\u00b0";
/*if (dispvalue < 0)
{
Console.WriteLine("Negative value: " + cellvalue.ToString());
}*/
}
else if (m_map_name.StartsWith("N75"))
{
e.DisplayText = dispvalue.ToString("F0") + @"%";
}
else
{
e.DisplayText = dispvalue.ToString("F2");
}
}
else
{
//e.DisplayText = dispvalue.ToString();
}
}
else if (m_map_name.StartsWith("N75"))
{
e.DisplayText = dispvalue.ToString("F0") + @"%";
}
}
//if (m_map_name == "BFuelCal.Map" || m_map_name == "IgnNormCal.Map" || m_map_name == "TargetAFR" || m_map_name == "FeedbackAFR" || m_map_name == "FeedbackvsTargetAFR")
if (X_axis_name.ToLower() == "mg/c" && Y_axis_name.ToLower() == "rpm")
{
try
{
if (open_loop != null)
{
int airmassvalue = GetXaxisValue(e.Column.AbsoluteIndex);
int rpmvalue = GetYaxisValue(e.RowHandle);
if (open_loop.Length > 0)
{
int mapopenloop = GetOpenLoopValue(e.RowHandle);
if (mapopenloop > airmassvalue)
{
if (m_StandardFill == 0)
{
}
else if (m_StandardFill == 1)
{
Pen p = new Pen(Brushes.Black, 2);
e.Graphics.DrawRectangle(p, e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Width - 2, e.Bounds.Height - 2);
p.Dispose();
}
else
{
Point[] pnts = new Point[4];
pnts.SetValue(new Point(e.Bounds.X + e.Bounds.Width, e.Bounds.Y), 0);
pnts.SetValue(new Point(e.Bounds.X + e.Bounds.Width - (e.Bounds.Height / 2), e.Bounds.Y), 1);
pnts.SetValue(new Point(e.Bounds.X + e.Bounds.Width, e.Bounds.Y + (e.Bounds.Height / 2)), 2);
pnts.SetValue(new Point(e.Bounds.X + e.Bounds.Width, e.Bounds.Y), 3);
e.Graphics.FillPolygon(Brushes.SeaGreen, pnts, System.Drawing.Drawing2D.FillMode.Winding);
}
}
}
}
}
catch (Exception E)
{
Console.WriteLine(E.Message);
}
}
if (!m_disablecolors)
{
SolidBrush sb = new SolidBrush(c);
e.Graphics.FillRectangle(sb, e.Bounds);
}
}
}
if (m_selectedrowhandle >= 0 && m_selectedcolumnindex >= 0)
{
if (e.RowHandle == m_selectedrowhandle && e.Column.AbsoluteIndex == m_selectedcolumnindex)
{
SolidBrush sbsb = new SolidBrush(Color.Yellow);
e.Graphics.FillRectangle(sbsb, e.Bounds);
}
}
}
catch (Exception E)
{
Console.WriteLine(E.Message);
}
}