public void ShowTable(int tablewidth, bool issixteenbits)
{
double m_realValue;
m_MaxValueInTable = 0;
//if (m_isHexMode)
if (m_viewtype == ViewType.Hexadecimal)
{
int lenvals = m_map_length;
if (issixteenbits) lenvals /= 2;
}
else
{
int lenvals = m_map_length;
if (issixteenbits) lenvals /= 2;
}
m_TableWidth = tablewidth;
m_issixteenbit = issixteenbits;
DataTable dt = new DataTable();
if (m_map_length != 0 && m_map_name != string.Empty)
{
if (tablewidth > 0)
{
int numberrows = (int)(m_map_length / tablewidth);
if (issixteenbits) numberrows /= 2;
int map_offset = 0;
/* if (numberrows > 0)
{*/
// aantal kolommen = 8
dt.Columns.Clear();
for (int c = 0; c < tablewidth; c++)
{
dt.Columns.Add(c.ToString());
}
if (issixteenbits)
{
for (int i = 0; i < numberrows; i++)
{
//ListViewItem lvi = new ListViewItem();
//lvi.UseItemStyleForSubItems = false;
object[] objarr = new object[tablewidth];
int b;
for (int j = 0; j < tablewidth; j++)
{
b = (byte)m_map_content.GetValue(map_offset++);
b *= 256;
b += (byte)m_map_content.GetValue(map_offset++);
/*if ( (b & 0x8000) > 0)
{
//valtot = 0x10000 - valtot;
b &= 0x7FFF;
b = -b;
}*/
if (b > 0xF000)
{
//b ^= 0xFFFF;
b = 0x10000 - b;
b = -b;
}
// TEST!!!
/* else if ((b & 0x8000) > 0)
{
//valtot = 0x10000 - valtot;
b &= 0x7FFF;
b = -b;
}*/
if (b > m_MaxValueInTable) m_MaxValueInTable = b;
m_realValue = b;
m_realValue *= correction_factor;
if (!_isCompareViewer) m_realValue += correction_offset;
if (m_realValue > m_realMaxValue) m_realMaxValue = m_realValue;
if (m_realValue < m_realMinValue) m_realMinValue = m_realValue;
// TEST
//b = (int)(correction_factor * (double)b);
//b = (int)(correction_offset + (double)b);
// TEST
//if (m_isHexMode)
if (m_viewtype == ViewType.Hexadecimal)
{
objarr.SetValue(b.ToString("X4"), j);
}
else if (m_viewtype == ViewType.ASCII)
{
//objarr.SetValue(b.ToString("X4"), j);
// show as ascii characters
try
{
objarr.SetValue(Convert.ToChar(b), j);
}
catch (Exception E)
{
Console.WriteLine("Failed to convert to ascii: " + E.Message);
objarr.SetValue(Convert.ToChar(0x20), j);
}
}
else
{
objarr.SetValue(b.ToString(), j);
}
//lvi.SubItems.Add(b.ToString("X4"));
//lvi.SubItems[j + 1].BackColor = Color.FromArgb((int)(b / 256), 255 - (int)(b / 256), 0);
}
//listView2.Items.Add(lvi);
if (m_isUpsideDown)
{
System.Data.DataRow r = dt.NewRow();
r.ItemArray = objarr;
dt.Rows.InsertAt(r, 0);
}
else
{
dt.Rows.Add(objarr);
}
}
// en dan het restant nog in een nieuwe rij zetten
if (map_offset < m_map_length)
{
object[] objarr = new object[tablewidth];
int b;
int sicnt = 0;
for (int v = map_offset; v < m_map_length - 1; v++)
{
//b = (byte)m_map_content.GetValue(map_offset++);
if (map_offset <= m_map_content.Length - 1)
{
b = (byte)m_map_content.GetValue(map_offset++);
b *= 256;
b += (byte)m_map_content.GetValue(map_offset++);
if (b > 0xF000)
{
// b ^= 0xFFFF;
b = 0x10000 - b;
b = -b;
}
/*if (b > 0x10000)
{
b ^= 0xFFFF;
b = -b;
}*/
// TEST!!!
/* else if ((b & 0x8000) > 0)
{
//valtot = 0x10000 - valtot;
b &= 0x7FFF;
b = -b;
}*/
/*if ((b & 0x8000) > 0)
{
//valtot = 0x10000 - valtot;
b &= 0x7FFF;
b = -b;
}*/
if (b > m_MaxValueInTable) m_MaxValueInTable = b;
m_realValue = b;
m_realValue *= correction_factor;
if (!_isCompareViewer) m_realValue += correction_offset;
if (m_realValue > m_realMaxValue) m_realMaxValue = m_realValue;
if (m_realValue < m_realMinValue) m_realMinValue = m_realValue;
// TEST
//b = (int)(correction_factor * (double)b);
//b = (int)(correction_offset + (double)b);
// TEST
// if (m_isHexMode)
if (m_viewtype == ViewType.Hexadecimal)
{
objarr.SetValue(b.ToString("X4"), sicnt);
}
else if (m_viewtype == ViewType.ASCII)
{
//objarr.SetValue(b.ToString("X4"), j);
// show as ascii characters
objarr.SetValue(Convert.ToChar(b), sicnt);
}
else
{
objarr.SetValue(b.ToString(), sicnt);
}
}
sicnt++;
//lvi.SubItems[lvi.SubItems.Count - 1].BackColor = Color.FromArgb((int)(b / 256), 255 - (int)(b / 256), 0);
}
/*for (int t = 0; t < (tablewidth - 1) - sicnt; t++)
{
lvi.SubItems.Add("");
}*/
//listView2.Items.Add(lvi);
if (m_isUpsideDown)
{
System.Data.DataRow r = dt.NewRow();
r.ItemArray = objarr;
dt.Rows.InsertAt(r, 0);
}
else
{
dt.Rows.Add(objarr);
}
}
}
else
{
for (int i = 0; i < numberrows; i++)
{
object[] objarr = new object[tablewidth];
int b;
for (int j = 0; j < (tablewidth); j++)
{
b = (byte)m_map_content.GetValue(map_offset++);
if (b > m_MaxValueInTable) m_MaxValueInTable = b;
m_realValue = b;
m_realValue *= correction_factor;
if (!_isCompareViewer) m_realValue += correction_offset;
if (m_realValue > m_realMaxValue) m_realMaxValue = m_realValue;
if (m_realValue < m_realMinValue) m_realMinValue = m_realValue;
// TEST
//b = (byte)(correction_factor * (double)b);
//b = (byte)(correction_offset + (double)b);
// TEST
//if (m_isHexMode)
if (m_viewtype == ViewType.Hexadecimal)
{
objarr.SetValue(b.ToString("X2"), j);
}
else if (m_viewtype == ViewType.ASCII)
{
//objarr.SetValue(b.ToString("X4"), j);
// show as ascii characters
objarr.SetValue(Convert.ToChar(b), j);
}
else
{
objarr.SetValue(b.ToString(), j);
}
}
if (m_isUpsideDown)
{
System.Data.DataRow r = dt.NewRow();
r.ItemArray = objarr;
dt.Rows.InsertAt(r, 0);
}
else
{
dt.Rows.Add(objarr);
}
}
// en dan het restant nog in een nieuwe rij zetten
if (map_offset < m_map_length)
{
object[] objarr = new object[tablewidth];
byte b;
int sicnt = 0;
for (int v = map_offset; v < m_map_length /*- 1*/; v++)
{
b = (byte)m_map_content.GetValue(map_offset++);
if (b > m_MaxValueInTable) m_MaxValueInTable = b;
m_realValue = b;
m_realValue *= correction_factor;
if (!_isCompareViewer) m_realValue += correction_offset;
if (m_realValue > m_realMaxValue) m_realMaxValue = m_realValue;
if (m_realValue < m_realMinValue) m_realMinValue = m_realValue;
// TEST
//b = (byte)(correction_factor * (double)b);
//b = (byte)(correction_offset + (double)b);
// TEST
//if (m_isHexMode)
if (m_viewtype == ViewType.Hexadecimal)
{
objarr.SetValue(b.ToString("X2"), sicnt);
}
else if (m_viewtype == ViewType.ASCII)
{
//objarr.SetValue(b.ToString("X4"), j);
// show as ascii characters
objarr.SetValue(Convert.ToChar(b), sicnt);
}
else
{
objarr.SetValue(b.ToString(), sicnt);
}
sicnt++;
}
if (m_isUpsideDown)
{
System.Data.DataRow r = dt.NewRow();
r.ItemArray = objarr;
dt.Rows.InsertAt(r, 0);
}
else
{
dt.Rows.Add(objarr);
}
}
}
}
gridControl1.DataSource = dt;
if (!gridView1.OptionsView.ColumnAutoWidth)
{
for (int c = 0; c < gridView1.Columns.Count; c++)
{
gridView1.Columns[c].Width = 40;
}
}
// set axis
// scale to 3 bar?
int indicatorwidth = -1;
for (int i = 0; i < y_axisvalues.Length; i++)
{
string yval = Convert.ToInt32(y_axisvalues.GetValue(i)).ToString();
if (m_viewtype == ViewType.Hexadecimal)
{
yval = Convert.ToInt32(y_axisvalues.GetValue(i)).ToString("X4");
}
if (m_y_axis_name == "MAP")
{
}
Graphics g = gridControl1.CreateGraphics();
SizeF size = g.MeasureString(yval, this.Font);
if (size.Width > indicatorwidth) indicatorwidth = (int)size.Width;
m_textheight = (int)size.Height;
g.Dispose();
}
if (indicatorwidth > 0)
{
gridView1.IndicatorWidth = indicatorwidth + 6; // keep margin
}
int maxxval = 0;
for (int i = 0; i < x_axisvalues.Length; i++)
{
int xval = Convert.ToInt32(x_axisvalues.GetValue(i));
if (xval > 0xF000)
{
//xval ^= 0xFFFF;
xval = 0x10000 - xval;
xval = -xval;
x_axisvalues.SetValue(xval, i);
}
/* if (xval > 0x10000)
{
xval ^= 0xFFFF;
xval = -xval;
}
else if ((xval & 0x8000) > 0)
{
//valtot = 0x10000 - valtot;
xval &= 0x7FFF;
xval = -xval;
}*/
if (xval > maxxval) maxxval = xval;
}
if (maxxval <= 255) m_xformatstringforhex = "X2";
}
if (m_TableWidth > 1)
{
xtraTabControl1.SelectedTabPage = xtraTabPage1;
SetViewTypeParams(m_vs);
trackBarControl1.Properties.Minimum = 0;
trackBarControl1.Properties.Maximum = x_axisvalues.Length - 1;
labelControl8.Text = X_axis_name + " values";
trackBarControl1.Value = 0;
nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.HighSpeed;
nChartControl1.Controller.Tools.Add(new NSelectorTool());
nChartControl1.Controller.Tools.Add(new NTrackballTool());
// set a chart title
NLabel title = nChartControl1.Labels.AddHeader(m_map_name);
title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
title.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(68, 90, 108));
// setup chart
Console.WriteLine("Number of charts: " + nChartControl1.Charts.Count.ToString());
NChart chart = nChartControl1.Charts[0];
nChartControl1.Legends.Clear();
chart.Enable3D = true;
chart.Width = 60.0f;
chart.Depth = 60.0f;
//chart.Height = 25.0f;
chart.Height = 35.0f;
chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft);
/*NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
ordinalScale.DisplayDataPointsBetweenTicks = false;*/
// oud
NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
scaleConfiguratorX.MaxTickCount = dt.Rows.Count;
scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount;
// nieuw
/*NLinearScaleConfigurator scaleConfiguratorX = new NLinearScaleConfigurator();
chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleConfiguratorX;
scaleConfiguratorX.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
scaleConfiguratorX.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
scaleConfiguratorX.RoundToTickMax = false;
scaleConfiguratorX.RoundToTickMin = false;*/
NScaleTitleStyle titleStyleX = (NScaleTitleStyle)scaleConfiguratorX.Title;
titleStyleX.Text = m_y_axis_name;
//<GS-08032010> as waarden nog omzetten indien noodzakelijk (MAP etc)
scaleConfiguratorX.AutoLabels = false;
scaleConfiguratorX.Labels.Clear();
for (int t = y_axisvalues.Length - 1; t >= 0; t--)
{
string yvalue = ConvertYAxisValue(y_axisvalues.GetValue(t).ToString());
scaleConfiguratorX.Labels.Add(yvalue);
}
NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator;
scaleConfiguratorY.MajorTickMode = MajorTickMode.AutoMaxCount;
scaleConfiguratorY.MaxTickCount = dt.Columns.Count;
NScaleTitleStyle titleStyleY = (NScaleTitleStyle)scaleConfiguratorY.Title;
titleStyleY.Text = m_x_axis_name;
scaleConfiguratorY.Labels.Clear();
scaleConfiguratorY.AutoLabels = false;
for (int t = 0; t < x_axisvalues.Length; t++)
{
string xvalue = ConvertXAxisValue(x_axisvalues.GetValue(t).ToString());
scaleConfiguratorY.Labels.Add(xvalue);
}
NStandardScaleConfigurator scaleConfiguratorZ = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
scaleConfiguratorZ.MajorTickMode = MajorTickMode.AutoMaxCount;
NScaleTitleStyle titleStyleZ = (NScaleTitleStyle)scaleConfiguratorZ.Title;
titleStyleZ.Text = m_z_axis_name;
scaleConfiguratorZ.AutoLabels = true;
NMeshSurfaceSeries surface = null;
if (chart.Series.Count == 0)
{
surface = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface);
}
else
{
surface = (NMeshSurfaceSeries)chart.Series[0];
}
if (m_map_original_content != null)
{
btnToggleOverlay.Visible = true;
NMeshSurfaceSeries surface2 = null;
if (chart.Series.Count == 1)
{
surface2 = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface);
}
else
{
surface2 = (NMeshSurfaceSeries)chart.Series[1];
}
surface2.PositionValue = 10.0;
surface2.Name = "Surface2";
if (m_issixteenbit)
{
surface2.Data.SetGridSize((m_map_content.Length / 2) / m_TableWidth, m_TableWidth);
}
else
{
surface2.Data.SetGridSize(m_map_content.Length / m_TableWidth, m_TableWidth);
}
surface2.ValueFormatter.FormatSpecifier = "0.00";
surface2.FillMode = SurfaceFillMode.Zone;
surface2.FillStyle.SetTransparencyPercent(50);
surface2.SmoothPalette = true;
surface2.FrameColorMode = SurfaceFrameColorMode.Zone;//Uniform;
surface2.FrameMode = SurfaceFrameMode.MeshContour;
NMeshSurfaceSeries surface3 = null;
if (chart.Series.Count == 2)
{
surface3 = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface);
}
else
{
surface3 = (NMeshSurfaceSeries)chart.Series[2];
}
surface3.PositionValue = 10.0;
surface3.Name = "Surface3";
if (m_issixteenbit)
{
surface3.Data.SetGridSize((m_map_content.Length / 2) / m_TableWidth, m_TableWidth);
}
else
{
surface3.Data.SetGridSize(m_map_content.Length / m_TableWidth, m_TableWidth);
}
surface3.ValueFormatter.FormatSpecifier = "0.00";
surface3.FillMode = SurfaceFillMode.Zone;
surface3.FillStyle.SetTransparencyPercent(50);
surface3.SmoothPalette = true;
surface3.FrameColorMode = SurfaceFrameColorMode.Zone;
surface3.FrameMode = SurfaceFrameMode.MeshContour;
}
chart.Wall(ChartWallType.Back).Visible = false;
chart.Wall(ChartWallType.Left).Visible = false;
chart.Wall(ChartWallType.Right).Visible = false;
chart.Wall(ChartWallType.Floor).Visible = false;
surface.Name = "Surface";
//surface.Legend.Mode = SeriesLegendMode.SeriesLogic;
surface.PositionValue = 10.0;
// always 256 * 256 ?
if (m_issixteenbit)
{
surface.Data.SetGridSize((m_map_content.Length / 2) / m_TableWidth, m_TableWidth);
}
else
{
surface.Data.SetGridSize(m_map_content.Length / m_TableWidth, m_TableWidth);
}
//surface.SyncPaletteWithAxisScale = true;
//surface.PaletteSteps = 16;
surface.ValueFormatter.FormatSpecifier = "0.00";
//surface.FillStyle = new NColorFillStyle(Color.Green);
surface.FillMode = SurfaceFillMode.Zone; // <GS-08032010>
surface.SmoothPalette = true;
surface.FrameColorMode = SurfaceFrameColorMode.Uniform;
surface.FillStyle.SetTransparencyPercent(25);
surface.FrameMode = SurfaceFrameMode.MeshContour;
RefreshMeshGraph();
//byte[] bts = GetDataFromGridView(false);
//UpdateChartControlSlice(bts);
/*
x = "MAP";
y = "RPM";
z = "Degrees";
*/
}
else if (m_TableWidth == 1)
{
xtraTabControl1.SelectedTabPage = xtraTabPage2;
SetViewTypeParams(m_vs);
trackBarControl1.Properties.Minimum = 0;
trackBarControl1.Properties.Maximum = x_axisvalues.Length - 1;
labelControl8.Text = X_axis_name + " values";
/*** end test ***/
trackBarControl1.Properties.Minimum = 0;
trackBarControl1.Properties.Maximum = 0;
trackBarControl1.Enabled = false;
labelControl8.Text = X_axis_name;
DataTable chartdt = new DataTable();
chartdt.Columns.Add("X", Type.GetType("System.Double"));
chartdt.Columns.Add("Y", Type.GetType("System.Double"));
double valcount = 0;
if (m_issixteenbit)
{
for (int t = 0; t < m_map_length; t += 2)
{
double yval = valcount;
double value = Convert.ToDouble(m_map_content.GetValue(t)) * 256;
value += Convert.ToDouble(m_map_content.GetValue(t + 1));
if (y_axisvalues.Length > valcount) yval = Convert.ToDouble((int)y_axisvalues.GetValue((int)valcount));
chartdt.Rows.Add(yval, value);
valcount++;
}
}
else
{
for (int t = 0; t < m_map_length; t++)
{
double yval = valcount;
double value = Convert.ToDouble(m_map_content.GetValue(t));
if (y_axisvalues.Length > valcount) yval = Convert.ToDouble((int)y_axisvalues.GetValue((int)valcount));
chartdt.Rows.Add(yval, value);
valcount++;
}
}
//chartControl1.Series[0].Label.Text = m_map_name;
/*chartControl1.Series[0].LegendText = m_map_name;
chartControl1.DataSource = chartdt;
string[] datamembers = new string[1];
chartControl1.Series[0].ValueDataMembers.Clear();
datamembers.SetValue("Y", 0);
chartControl1.Series[0].ValueDataMembers.AddRange(datamembers);
chartControl1.Series[0].ArgumentDataMember = "X";
chartControl1.Visible = true;*/
}
Init2dChart();
m_trackbarBlocked = false;
if (this.m_map_address >= 0xF00000 || (m_isOpenSoftware && m_isRAMViewer))
{
//this.m_isRAMViewer = true;
//this.OnlineMode = true;
if (_autoUpdateIfSRAM)
{
timer5.Interval = _autoUpdateInterval * 1000;
timer5.Enabled = true;
}
}
}