public void ShowSymbolCollection(SymbolCollection sc) { DataTable dt = new DataTable(); dt.Columns.Add("SYMBOLNAME"); dt.Columns.Add("DESCRIPTION"); dt.Columns.Add("XAXIS"); dt.Columns.Add("XAXISDESCRIPTION"); dt.Columns.Add("YAXIS"); dt.Columns.Add("YAXISDESCRIPTION"); SymbolAxesTranslator sat = new SymbolAxesTranslator(); SymbolTranslator symtrans = new SymbolTranslator(); string helptext = string.Empty; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory subcat = XDFSubCategory.Undocumented; string xaxis = string.Empty; string yaxis = string.Empty; string xaxisdescr = ""; string yaxisdescr = ""; string zaxisdescr = ""; foreach (SymbolHelper sh in sc) { string name = sh.Varname; if (sh.Userdescription != "" && sh.Userdescription != String.Format("Symbolnumber {0}", sh.Symbol_number)) { name = sh.Userdescription; } sat.GetAxisSymbols(name, out xaxis, out yaxis, out xaxisdescr, out yaxisdescr, out zaxisdescr); string symboldescr = symtrans.TranslateSymbolToHelpText(name, out helptext, out cat, out subcat, m_ApplicationLanguage); if (xaxis != "") { xaxisdescr = symtrans.TranslateSymbolToHelpText(xaxis, out helptext, out cat, out subcat, m_ApplicationLanguage); } if (yaxis != "") { yaxisdescr = symtrans.TranslateSymbolToHelpText(yaxis, out helptext, out cat, out subcat, m_ApplicationLanguage); } if (xaxis != "" || yaxis != "") { dt.Rows.Add(name, symboldescr, xaxis, xaxisdescr, yaxis, yaxisdescr); } } gridControl1.DataSource = dt; }
private int[] GetYaxisValues(string filename, SymbolCollection curSymbols, string symbolname) { int[] retval = new int[GetSymbolLength(curSymbols, symbolname)]; //retval.SetValue(0, 0); int yaxisaddress = 0; int yaxislength = 0; bool issixteenbit = true; double multiplier = 1; SymbolAxesTranslator axistranslator = new SymbolAxesTranslator(); string x_axis = string.Empty; string y_axis = string.Empty; string x_axis_descr = string.Empty; string y_axis_descr = string.Empty; string z_axis_descr = string.Empty; if (axistranslator.GetAxisSymbols(symbolname, out x_axis, out y_axis, out x_axis_descr, out y_axis_descr, out z_axis_descr)) { if (y_axis != "") { yaxislength = GetSymbolLength(curSymbols, y_axis); yaxisaddress = (int)GetSymbolAddress(curSymbols, y_axis); } } multiplier = GetMapCorrectionFactor(y_axis); if (symbolname == "TorqueCal.M_ManGearLim" || symbolname == "TorqueCal.M_CabGearLim") { retval = new int[6]; retval.SetValue(-1, 0); retval.SetValue(1, 1); retval.SetValue(2, 2); retval.SetValue(3, 3); retval.SetValue(4, 4); retval.SetValue(5, 5); return retval; } if (symbolname == "GearCal.Ratio" || symbolname == "GearCal") { retval = new int[5]; retval.SetValue(1, 0); retval.SetValue(2, 1); retval.SetValue(3, 2); retval.SetValue(4, 3); retval.SetValue(5, 4); return retval; } if (symbolname == "BstMetCal.BoostMeter") { retval = new int[6]; retval.SetValue(0, 0); retval.SetValue(1, 1); retval.SetValue(2, 2); retval.SetValue(3, 3); retval.SetValue(4, 4); retval.SetValue(5, 5); return retval; } int number = yaxislength; if (yaxislength > 0) { byte[] axisdata = readdatafromfile(filename, yaxisaddress, yaxislength); if (issixteenbit) number /= 2; retval = new int[number]; int offset = 0; for (int i = 0; i < yaxislength; i++) { if (issixteenbit) { byte val1 = (byte)axisdata.GetValue(i); byte val2 = (byte)axisdata.GetValue(++i); int ival1 = Convert.ToInt32(val1); int ival2 = Convert.ToInt32(val2); int value = (ival1 * 256) + ival2; double valtot = (double)value * multiplier; value = (int)valtot; if (value > 0x8000) { value = 0x10000 - value; value = -value; } retval.SetValue(value, offset++); } else { byte val1 = (byte)axisdata.GetValue(i); int ival1 = Convert.ToInt32(val1); double valtot = (double)ival1 * multiplier; ival1 = (int)valtot; retval.SetValue(ival1, offset++); } } } return retval; }
private int[] GetXaxisValues(string filename, SymbolCollection curSymbols, string symbolname) { int[] retval = new int[1]; retval.SetValue(0, 0); int xaxisaddress = 0; int xaxislength = 0; bool issixteenbit = true; double multiplier = 1; SymbolAxesTranslator axistranslator = new SymbolAxesTranslator(); string x_axis = string.Empty; string y_axis = string.Empty; string x_axis_descr = string.Empty; string y_axis_descr = string.Empty; string z_axis_descr = string.Empty; if (axistranslator.GetAxisSymbols(symbolname, out x_axis, out y_axis, out x_axis_descr, out y_axis_descr, out z_axis_descr)) { if (x_axis != "") { xaxislength = GetSymbolLength(curSymbols, x_axis); xaxisaddress = (int)GetSymbolAddress(curSymbols, x_axis); } } multiplier = GetMapCorrectionFactor(x_axis); int number = xaxislength; if (xaxislength > 0) { byte[] axisdata = readdatafromfile(filename,xaxisaddress, xaxislength); if (issixteenbit) number /= 2; retval = new int[number]; int offset = 0; for (int i = 0; i < xaxislength; i++) { if (issixteenbit) { byte val1 = (byte)axisdata.GetValue(i); byte val2 = (byte)axisdata.GetValue(++i); int ival1 = Convert.ToInt32(val1); int ival2 = Convert.ToInt32(val2); int value = (ival1 * 256) + ival2; if (symbolname == "BstKnkCal.MaxAirmass" || symbolname == "BstKnkCal.MaxAirmassAu") { if (value > 32000) value = -(65536 - value); // negatief maken } double valtot = (double)value * multiplier; value = (int)valtot; retval.SetValue(value, offset++); } else { byte val1 = (byte)axisdata.GetValue(i); int ival1 = Convert.ToInt32(val1); double valtot = (double)ival1 * multiplier; ival1 = (int)valtot; retval.SetValue(ival1, offset++); } } } return retval; }
private void ExportToExcel(string mapname, int address, int length, byte[] mapdata, int cols, int rows, bool isSixteenbit, int[] xaxisvalues, int[] yaxisvalues) { //en-US CultureInfo tci = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = tci; try { bool isupsidedown = GetMapUpsideDown(mapname); try { if (xla == null) { xla = new Microsoft.Office.Interop.Excel.Application(); } } catch (Exception xlaE) { frmInfoBox info = new frmInfoBox("Failed to create office application interface"); logger.Debug("Failed to create office application interface: " + xlaE.Message); } // turn mapdata upside down if (isupsidedown) { mapdata = TurnMapUpsideDown(mapdata, cols, rows, isSixteenbit); } xla.Visible = true; Microsoft.Office.Interop.Excel.Workbook wb = xla.Workbooks.Add(XlSheetType.xlWorksheet); Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)xla.ActiveSheet; ws.Name = "symboldata"; // Now create the chart. ChartObjects chartObjs = (ChartObjects)ws.ChartObjects(Type.Missing); ChartObject chartObj = chartObjs.Add(100, 400, 400, 300); Microsoft.Office.Interop.Excel.Chart xlChart = chartObj.Chart; int nRows = rows; if (isSixteenbit) nRows /= 2; int nColumns = cols; string upperLeftCell = "B3"; int endRowNumber = System.Int32.Parse(upperLeftCell.Substring(1)) + nRows - 1; char endColumnLetter = System.Convert.ToChar(Convert.ToInt32(upperLeftCell[0]) + nColumns - 1); string upperRightCell = System.String.Format("{0}{1}", endColumnLetter, System.Int32.Parse(upperLeftCell.Substring(1))); string lowerRightCell = System.String.Format("{0}{1}", endColumnLetter, endRowNumber); // Send single dimensional array to Excel: Range rg1 = ws.get_Range("B2", "Z2"); double[] xarray = new double[nColumns]; double[] yarray = new double[nRows]; ws.Cells[1, 1] = "Data for " + mapname; for (int i = 0; i < xarray.Length; i++) { if (xaxisvalues.Length > i) { xarray[i] = (int)xaxisvalues.GetValue(i); } else { xarray[i] = i; } //ws.Cells[i + 3, 1] = xarray[i]; ws.Cells[2, 2 + i] = xarray[i]; } for (int i = 0; i < yarray.Length; i++) { if (yaxisvalues.Length > i) { if (isupsidedown) { yarray[i] = (int)yaxisvalues.GetValue((yarray.Length - 1) - i); } else { yarray[i] = (int)yaxisvalues.GetValue(i); } } else { yarray[i] = i; } ws.Cells[i + 3, 1] = yarray[i]; //ws.Cells[2, 2 + i] = yarray[i]; } string xaxisdescr = "x-axis"; string yaxisdescr = "y-axis"; string zaxisdescr = "z-axis"; //GetAxisDescriptions(m_currentfile, m_symbols, mapname, out xaxisdescr, out yaxisdescr, out zaxisdescr); SymbolAxesTranslator axestrans = new SymbolAxesTranslator(); string x_axis = string.Empty; string y_axis = string.Empty; axestrans.GetAxisSymbols(mapname, out x_axis, out y_axis, out xaxisdescr, out yaxisdescr, out zaxisdescr); Range rg = ws.get_Range(upperLeftCell, lowerRightCell); rg.Value2 = AddData(nRows, nColumns, mapdata, isSixteenbit); Range chartRange = ws.get_Range("A2", lowerRightCell); xlChart.SetSourceData(chartRange, Type.Missing); if (yarray.Length > 1) { xlChart.ChartType = XlChartType.xlSurface; } // Customize axes: Axis xAxis = (Axis)xlChart.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary); xAxis.HasTitle = true; xAxis.AxisTitle.Text = yaxisdescr; try { Axis yAxis = (Axis)xlChart.Axes(XlAxisType.xlSeriesAxis, XlAxisGroup.xlPrimary); yAxis.HasTitle = true; yAxis.AxisTitle.Text = xaxisdescr; } catch (Exception E) { logger.Debug("Failed to set y axis: " + E.Message); } Axis zAxis = (Axis)xlChart.Axes(XlAxisType.xlValue, XlAxisGroup.xlPrimary); zAxis.HasTitle = true; zAxis.AxisTitle.Text = zaxisdescr; // Add title: xlChart.HasTitle = true; xlChart.ChartTitle.Text = TranslateSymbolName(mapname); // Remove legend: xlChart.HasLegend = false; // add 3d shade xlChart.SurfaceGroup.Has3DShading = true; /*if (File.Exists(m_currentfile + "~" + mapname + ".xls")) { }*/ try { wb.SaveAs(m_currentfile + "~" + mapname + ".xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, null, null, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, false, null, null, null, null); } catch (Exception sE) { logger.Debug("Failed to save workbook: " + sE.Message); } /* This following code is used to create Excel default color indices: for (int i = 0; i < 14; i++) { string cellString = "A" + (i + 1).ToString(); ws.get_Range(cellString, cellString).Interior.ColorIndex = i + 1; ws.get_Range(cellString, cellString).Value2 = i + 1; cellString = "B" + (i + 1).ToString(); ws.get_Range(cellString, cellString).Interior.ColorIndex = 14 + i + 1; ws.get_Range(cellString, cellString).Value2 = 14 + i + 1; cellString = "C" + (i + 1).ToString(); ws.get_Range(cellString, cellString).Interior.ColorIndex = 2 * 14 + i + 1; ws.get_Range(cellString, cellString).Value2 = 2 * 14 + i + 1; cellString = "D" + (i + 1).ToString(); ws.get_Range(cellString, cellString).Interior.ColorIndex = 3 * 14 + i + 1; ws.get_Range(cellString, cellString).Value2 = 3 * 14 + i + 1; }*/ } catch (Exception E) { logger.Debug("Failed to export to excel: " + E.Message); } tci = new CultureInfo("nl-NL"); Thread.CurrentThread.CurrentCulture = tci; }
private void StartTableViewerFromTuningPackage(string symbolname, byte[] data, string filename) { if (!File.Exists(filename)) return; DockPanel dockPanel; bool pnlfound = false; foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text == "Tuning package symbol: " + symbolname + " [" + Path.GetFileName(filename) + "]") { dockPanel = pnl; pnlfound = true; dockPanel.Show(); } } if (!pnlfound) { dockManager1.BeginUpdate(); try { dockPanel = dockManager1.AddPanel(DockingStyle.Right); dockPanel.Tag = filename; IMapViewer tabdet;//= new MapViewer(); if (m_appSettings.UseNewMapViewer) { tabdet = new MapViewerEx(); } else { tabdet = new MapViewer(); } tabdet.AutoUpdateIfSRAM = false;// m_appSettings.AutoUpdateSRAMViewers; tabdet.SetViewSize(m_appSettings.DefaultViewSize); tabdet.Filename = filename; tabdet.Viewtype = m_appSettings.DefaultViewType; tabdet.GraphVisible = m_appSettings.ShowGraphs; if (m_appSettings.Viewinhex) { tabdet.Viewtype = ViewType.Hexadecimal; } tabdet.DisableColors = m_appSettings.DisableMapviewerColors; tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows; tabdet.IsRedWhite = m_appSettings.ShowRedWhite; tabdet.Map_name = symbolname; tabdet.Map_descr = TranslateSymbolName(tabdet.Map_name); tabdet.Map_cat = XDFCategories.Undocumented; tabdet.X_axisvalues = GetXaxisValues(m_currentfile, m_symbols, tabdet.Map_name); tabdet.Y_axisvalues = GetYaxisValues(m_currentfile, m_symbols, tabdet.Map_name); /** new 12/11/2008 **/ if (!m_appSettings.NewPanelsFloating) { // dockPanel = dockManager1.AddPanel(DevExpress.XtraBars.Docking.DockingStyle.Right); if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { int dw = 650; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 400) dw = 400; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 900); } else { dockPanel.FloatSize = new Size(dw, 500); } } else if (m_appSettings.DefaultViewSize == ViewSize.SmallView) { int dw = 550; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 380) dw = 380; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 850); } else { dockPanel.FloatSize = new Size(dw, 450); } } else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView) { int dw = 450; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 30); } if (dw < 380) dw = 380; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 700); } else { dockPanel.FloatSize = new Size(dw, 450); } } } SymbolAxesTranslator axestrans = new SymbolAxesTranslator(); string x_axis = string.Empty; string y_axis = string.Empty; string x_axis_descr = string.Empty; string y_axis_descr = string.Empty; string z_axis_descr = string.Empty; axestrans.GetAxisSymbols(tabdet.Map_name, out x_axis, out y_axis, out x_axis_descr, out y_axis_descr, out z_axis_descr); tabdet.X_axis_name = x_axis_descr; tabdet.Y_axis_name = y_axis_descr; tabdet.Z_axis_name = z_axis_descr; int columns = 8; int rows = 8; int tablewidth = GetTableMatrixWitdhByName(m_currentfile, m_symbols, tabdet.Map_name, out columns, out rows); int address = (int)GetSymbolAddress(m_symbols, symbolname); //int sramaddress = sramaddress; // while (address > m_currentfile_size) address -= m_currentfile_size; tabdet.Map_address = address; tabdet.Map_sramaddress = (int)GetSymbolAddressSRAM(m_symbols, symbolname); tabdet.Map_length = data.Length; byte[] mapdata = data; tabdet.Map_content = mapdata; tabdet.Correction_factor = GetMapCorrectionFactor(tabdet.Map_name); tabdet.Correction_offset = GetMapCorrectionOffset(tabdet.Map_name); tabdet.IsUpsideDown = GetMapUpsideDown(tabdet.Map_name); tabdet.ShowTable(columns, isSixteenBitTable(tabdet.Map_name)); TryToAddOpenLoopTables(tabdet); tabdet.IsRAMViewer = true; tabdet.OnlineMode = true; tabdet.Dock = DockStyle.Fill; //tabdet.onSymbolSave += new MapViewer.NotifySaveSymbol(tabdet_onSymbolSave); tabdet.onSymbolSave += new IMapViewer.NotifySaveSymbol(tuningpackage_onSymbolSave); tabdet.onClose += new IMapViewer.ViewerClose(tabdet_onClose); //tabdet.onReadFromSRAM += new IMapViewer.ReadDataFromSRAM(tabdet_onReadFromSRAM); //tabdet.onWriteToSRAM += new IMapViewer.WriteDataToSRAM(tabdet_onWriteToSRAM); tabdet.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged); tabdet.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx); tabdet.onSurfaceGraphViewChanged += new IMapViewer.SurfaceGraphViewChanged(mv_onSurfaceGraphViewChanged); //dockPanel.DockAsTab(dockPanel1); dockPanel.Text = "Tuning package symbol: " + tabdet.Map_name + " [" + Path.GetFileName(filename) + "]"; bool isDocked = false; if (m_appSettings.AutoDockSameSymbol) { foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text.Contains(tabdet.Map_name) && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); isDocked = true; break; } } } if (!isDocked) { dockPanel.DockTo(dockManager1, DockingStyle.Right, 0); if (m_appSettings.AutoSizeNewWindows) { if (tabdet.X_axisvalues.Length > 0) { dockPanel.Width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } } if (dockPanel.Width < 400) dockPanel.Width = 400; } dockPanel.Controls.Add(tabdet); } catch (Exception newdockE) { logger.Debug(newdockE.Message); } dockManager1.EndUpdate(); } }
private void StartTableViewer(ECUMode mode) { if (gridViewSymbols.SelectedRowsCount > 0) { int[] selrows = gridViewSymbols.GetSelectedRows(); if (selrows.Length > 0) { int row = (int)selrows.GetValue(0); if (row >= 0) { SymbolHelper sh = (SymbolHelper)gridViewSymbols.GetRow((int)selrows.GetValue(0)); if (sh.Flash_start_address == 0 && sh.Start_address == 0) return; string varname = sh.Varname; if (varname.StartsWith("Symbol") && sh.Userdescription != "") { varname = sh.Userdescription; } //DataRowView dr = (DataRowView)gridViewSymbols.GetRow((int)selrows.GetValue(0)); if (sh == null) return; /*if (sh.Flash_start_address > m_currentfile_size) { MessageBox.Show("Symbol outside of flash boundary, probably SRAM only symbol"); return; }*/ DockPanel dockPanel; DockPanel sramdockPanel; bool pnlfound = false; //bool srampnlfound = false; try { foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text == "Symbol: " + varname + " [" + Path.GetFileName(m_currentfile) + "]") { if (pnl.Tag.ToString() == m_currentfile) // <GS-11052011> { dockPanel = pnl; pnlfound = true; dockPanel.Show(); } } /* if (pnl.Text == "SRAM Symbol: " + varname + " [" + Path.GetFileName(m_currentfile) + "]") { sramdockPanel = pnl; srampnlfound = true; //sramdockPanel.Show(); // nog data verversen? }*/ } } catch (Exception E) { logger.Debug(E.Message); } if (!pnlfound) { //dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); logger.Debug("Begin update"); dockManager1.BeginUpdate(); try { IMapViewer tabdet;//= new MapViewer(); if (m_appSettings.UseNewMapViewer) { tabdet = new MapViewerEx(); } else { tabdet = new MapViewer(); } tabdet.AutoUpdateIfSRAM = m_appSettings.AutoUpdateSRAMViewers; tabdet.AutoUpdateInterval = m_appSettings.AutoUpdateInterval; tabdet.SetViewSize(m_appSettings.DefaultViewSize); tabdet.Visible = false; tabdet.Filename = m_currentfile; tabdet.GraphVisible = m_appSettings.ShowGraphs; tabdet.Viewtype = m_appSettings.DefaultViewType;//ViewType.Easy; tabdet.DisableColors = m_appSettings.DisableMapviewerColors; tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows; tabdet.IsRedWhite = m_appSettings.ShowRedWhite; tabdet.Map_name = varname; tabdet.Map_descr = TranslateSymbolName(tabdet.Map_name); tabdet.Map_cat = XDFCategories.Undocumented; //TranslateSymbolNameToCategory(tabdet.Map_name); SymbolAxesTranslator axestrans = new SymbolAxesTranslator(); string x_axis = string.Empty; string y_axis = string.Empty; string x_axis_descr = string.Empty; string y_axis_descr = string.Empty; string z_axis_descr = string.Empty; axestrans.GetAxisSymbols(varname, out x_axis, out y_axis, out x_axis_descr, out y_axis_descr, out z_axis_descr); tabdet.X_axis_name = x_axis_descr; tabdet.Y_axis_name = y_axis_descr; tabdet.Z_axis_name = z_axis_descr; tabdet.X_axisvalues = GetXaxisValues(m_currentfile, m_symbols, tabdet.Map_name); tabdet.Y_axisvalues = GetYaxisValues(m_currentfile, m_symbols, tabdet.Map_name); //tabdet.Yaxiscorrectionfactor = GetMapCorrectionFactor(y_axis); //tabdet.Xaxiscorrectionfactor = GetMapCorrectionFactor(x_axis); //tabdet.close // z, y and z axis to do if (!m_appSettings.NewPanelsFloating) { dockPanel = dockManager1.AddPanel(DockingStyle.Right); if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { int dw = 650; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 400) dw = 400; if (dw > 800) dw = 800; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 900); } else { dockPanel.FloatSize = new Size(dw, 500); } } else if (m_appSettings.DefaultViewSize == ViewSize.SmallView) { int dw = 550; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 380) dw = 380; if (dw > 600) dw = 600; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 850); } else { dockPanel.FloatSize = new Size(dw, 450); } } else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView) { int dw = 450; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 30); } if (dw < 380) dw = 380; if (dw > 400) dw = 400; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 700); } else { dockPanel.FloatSize = new Size(dw, 450); } } } else { System.Drawing.Point floatpoint = this.PointToClient(new System.Drawing.Point(dockSymbols.Location.X + dockSymbols.Width + 30, dockSymbols.Location.Y + 30)); dockPanel = dockManager1.AddPanel(floatpoint); if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { int dw = 650; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 400) dw = 400; if (dw > 800) dw = 800; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 900); tabdet.SetSplitter(0, 0, 280, false, false); } else { dockPanel.FloatSize = new Size(dw, 500); } } else if (m_appSettings.DefaultViewSize == ViewSize.SmallView) { int dw = 550; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 380) dw = 380; if (dw > 600) dw = 600; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 850); tabdet.SetSplitter(0, 0, 250, false, false); //tabdet.SetSurfaceGraphZoom(0.4); } else { dockPanel.FloatSize = new Size(dw, 450); //dockPanel.FloatSize = new Size(550, 450); } } else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView) { int dw = 450; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 30); } if (dw < 380) dw = 380; if (dw > 400) dw = 400; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 700); tabdet.SetSplitter(0, 0, 320, false, false); // tabdet.SetSurfaceGraphZoom(0.5); } else { // dockPanel.FloatSize = new Size(450, 450); dockPanel.FloatSize = new Size(dw, 450); } } floatpoint = new System.Drawing.Point(Screen.PrimaryScreen.WorkingArea.Size.Width / 2 - dockPanel.FloatSize.Width / 2, Screen.PrimaryScreen.WorkingArea.Size.Height / 2 - dockPanel.FloatSize.Height / 2); while ((floatpoint.X < (dockSymbols.Width + 20)) && ((floatpoint.X + dockSymbols.Width) < Screen.PrimaryScreen.WorkingArea.Size.Width)) floatpoint.X++; dockPanel.FloatLocation = floatpoint; } dockPanel.Tag = m_currentfile; dockPanel.ClosedPanel += new DockPanelEventHandler(dockPanel_ClosedPanel); /*string xdescr = string.Empty; string ydescr = string.Empty; string zdescr = string.Empty; GetAxisDescriptions(m_currentfile, m_symbols, tabdet.Map_name, out xdescr, out ydescr, out zdescr); tabdet.X_axis_name = xdescr; tabdet.Y_axis_name = ydescr; tabdet.Z_axis_name = zdescr;*/ int columns = 8; int rows = 8; int tablewidth = GetTableMatrixWitdhByName(m_currentfile, m_symbols, tabdet.Map_name, out columns, out rows); int address = Convert.ToInt32(sh.Flash_start_address); int sramaddress = 0;// Convert.ToInt32(dr.Row["SRAMADDRESS"].ToString()); if (address != 0) { logger.Debug("address: " + address.ToString("X8")); //while (address > m_currentfile_size) address -= m_currentfile_size; tabdet.Map_address = address; tabdet.Map_sramaddress = sramaddress; int length = Convert.ToInt32(sh.Length); tabdet.Map_length = length; byte[] mapdata = new byte[sh.Length]; mapdata.Initialize(); if (address < 0x0F00000) { logger.Debug("read data from file"); mapdata = readdatafromfile(m_currentfile, address, length); } else { if (IsSoftwareOpen()/*length > 0x10*/) { address = address - GetOpenFileOffset();// 0xEFFC34; // this should autodetect!!! tabdet.Map_address = address; tabdet.IsOpenSoftware = _softwareIsOpen; mapdata = readdatafromfile(m_currentfile, address, length); } } logger.Debug("mapdata len: " + mapdata.Length.ToString("X4")); tabdet.Map_content = mapdata; tabdet.Correction_factor = GetMapCorrectionFactor(tabdet.Map_name); tabdet.Correction_offset = GetMapCorrectionOffset(tabdet.Map_name); tabdet.IsUpsideDown = GetMapUpsideDown(tabdet.Map_name); // m_connectedToECU = true; //<GS-07102010> if (mode == ECUMode.Auto || mode == ECUMode.Online) { if ((m_connectedToECU && !m_appSettings.UseNewMapViewer)) { tabdet.IsRAMViewer = true; } else { tabdet.IsRAMViewer = false; } } //<GS-07102010> if (mode == ECUMode.Auto || mode == ECUMode.Online) { if ((m_connectedToECU && m_appSettings.UseNewMapViewer) /*|| m_appSettings.DebugMode*/) { tabdet.OnlineMode = true; tabdet.IsRAMViewer = true; } else { tabdet.IsRAMViewer = false; } } tabdet.ShowTable(columns, isSixteenBitTable(tabdet.Map_name)); TryToAddOpenLoopTables(tabdet); tabdet.Dock = DockStyle.Fill; tabdet.onSymbolSave += new IMapViewer.NotifySaveSymbol(tabdet_onSymbolSave); tabdet.onSymbolRead += new IMapViewer.NotifyReadSymbol(tabdet_onSymbolRead); tabdet.onClose += new IMapViewer.ViewerClose(tabdet_onClose); //tabdet.onAxisLock += new MapViewer.NotifyAxisLock(tabdet_onAxisLock); //tabdet.onSliderMove += new MapViewer.NotifySliderMove(tabdet_onSliderMove); //tabdet.onSelectionChanged += new MapViewer.SelectionChanged(tabdet_onSelectionChanged); //tabdet.onSplitterMoved += new MapViewer.SplitterMoved(tabdet_onSplitterMoved); //tabdet.onSurfaceGraphViewChanged += new MapViewer.SurfaceGraphViewChanged(tabdet_onSurfaceGraphViewChanged); //tabdet.onGraphSelectionChanged += new MapViewer.GraphSelectionChanged(tabdet_onGraphSelectionChanged); //tabdet.onViewTypeChanged += new MapViewer.ViewTypeChanged(tabdet_onViewTypeChanged); //tabdet.onAxisEditorRequested += new MapViewer.AxisEditorRequested(tabdet_onAxisEditorRequested); tabdet.onWriteToSRAM += new IMapViewer.WriteDataToSRAM(tabdet_onWriteToSRAM); tabdet.onReadFromSRAM += new IMapViewer.ReadDataFromSRAM(tabdet_onReadFromSRAM); tabdet.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged); tabdet.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx); tabdet.onSurfaceGraphViewChanged += new IMapViewer.SurfaceGraphViewChanged(mv_onSurfaceGraphViewChanged); //dockPanel.DockAsTab(dockPanel1); dockPanel.Text = "Symbol: " + tabdet.Map_name + " [" + Path.GetFileName(m_currentfile) + "]"; // autodock same symbolname!!! bool isDocked = false; if (m_appSettings.AutoDockSameSymbol) { foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text.StartsWith("Symbol: " + tabdet.Map_name) && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); isDocked = true; break; } } } if (!isDocked) { if (m_appSettings.AutoDockSameFile) { foreach (DockPanel pnl in dockManager1.Panels) { if ((string)pnl.Tag == m_currentfile && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); isDocked = true; break; } } } } if (!isDocked) { int width = 400; if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { width = 500; } if (m_appSettings.AutoSizeNewWindows) { if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { if (tabdet.X_axisvalues.Length > 0) { width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } else { //width = this.Width - dockSymbols.Width - 10; } if (width < 500) width = 500; if (width > 800) width = 800; } else if (m_appSettings.DefaultViewSize == ViewSize.SmallView) { if (tabdet.X_axisvalues.Length > 0) { width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } else { //width = this.Width - dockSymbols.Width - 10; } if (width < 450) width = 450; if (width > 600) width = 600; } else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView) { if (tabdet.X_axisvalues.Length > 0) { width = 30 + ((tabdet.X_axisvalues.Length + 1) * 30); } else { //width = this.Width - dockSymbols.Width - 10; } if (width < 400) width = 400; if (width > 600) width = 600; } } dockPanel.Width = width; } dockPanel.Controls.Add(tabdet); } else { byte[] mapdata = new byte[sh.Length]; mapdata.Initialize(); } tabdet.Visible = true; } catch (Exception newdockE) { logger.Debug(newdockE.Message); } logger.Debug("End update"); dockManager1.EndUpdate(); } /*if (!srampnlfound) { // ook openen // show sram equivalent for the current symbol if (m_currentsramfile != string.Empty) { try { int sramaddress = (int)sh.Start_address; int length = sh.Length; if (sramaddress != 0) { StartSRAMTableViewer(); } } catch (Exception E) { logger.Debug(E.Message); } } }*/ } System.Windows.Forms.Application.DoEvents(); } } }
private void StartSRAMToFlashCompareDifferenceViewer(string SymbolName, string SRAMFilename, string FlashFilename, int SymbolLength, int SymbolAddressSRAM, int SymbolAddress) { DockPanel dockPanel; bool pnlfound = false; foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text == "Symbol difference: " + SymbolName + " [" + Path.GetFileName(SRAMFilename) + "]") { dockPanel = pnl; pnlfound = true; dockPanel.Show(); } } if (!pnlfound) { dockManager1.BeginUpdate(); try { dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); dockPanel.Tag = SRAMFilename; IMapViewer tabdet;//= new MapViewer(); if (m_appSettings.UseNewMapViewer) { tabdet = new MapViewerEx(); } else { tabdet = new MapViewer(); } tabdet.AutoUpdateIfSRAM = false;// m_appSettings.AutoUpdateSRAMViewers; tabdet.AutoUpdateInterval = m_appSettings.AutoUpdateInterval; //tabdet.IsHexMode = true; // always in hexmode! tabdet.Viewtype = m_appSettings.DefaultViewType; tabdet.DisableColors = m_appSettings.DisableMapviewerColors; tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows; tabdet.GraphVisible = m_appSettings.ShowGraphs; tabdet.IsRedWhite = m_appSettings.ShowRedWhite; tabdet.SetViewSize(m_appSettings.DefaultViewSize); tabdet.Filename = SRAMFilename; tabdet.Map_name = SymbolName; //tabdet.Map_descr = TranslateSymbolName(tabdet.Map_name); //tabdet.Map_cat = TranslateSymbolNameToCategory(tabdet.Map_name); tabdet.X_axisvalues = GetXaxisValues(m_currentfile, m_symbols, tabdet.Map_name); tabdet.Y_axisvalues = GetYaxisValues(m_currentfile, m_symbols, tabdet.Map_name); /*string xdescr = string.Empty; string ydescr = string.Empty; string zdescr = string.Empty; GetAxisDescriptions(m_currentfile, m_symbols, tabdet.Map_name, out xdescr, out ydescr, out zdescr); tabdet.X_axis_name = xdescr; tabdet.Y_axis_name = ydescr; tabdet.Z_axis_name = zdescr;*/ SymbolAxesTranslator axestrans = new SymbolAxesTranslator(); string x_axis = string.Empty; string y_axis = string.Empty; string x_axis_descr = string.Empty; string y_axis_descr = string.Empty; string z_axis_descr = string.Empty; axestrans.GetAxisSymbols(tabdet.Map_name, out x_axis, out y_axis, out x_axis_descr, out y_axis_descr, out z_axis_descr); tabdet.X_axis_name = x_axis_descr; tabdet.Y_axis_name = y_axis_descr; tabdet.Z_axis_name = z_axis_descr; //tabdet.Map_sramaddress = GetSymbolAddressSRAM(SymbolName); int columns = 8; int rows = 8; int tablewidth = GetTableMatrixWitdhByName(m_currentfile, m_symbols, tabdet.Map_name, out columns, out rows); int address = Convert.ToInt32(SymbolAddress); if (address != 0) { while (address > m_currentfile_size) address -= m_currentfile_size; tabdet.Map_address = address; int length = SymbolLength; tabdet.Map_length = length; byte[] mapdata = readdatafromSRAMfile(SRAMFilename, SymbolAddressSRAM, length); byte[] mapdataorig = readdatafromSRAMfile(SRAMFilename, SymbolAddressSRAM, length); byte[] mapdata2 = readdatafromfile(m_currentfile, (int)GetSymbolAddress(m_symbols, SymbolName), GetSymbolLength(m_symbols, SymbolName)); tabdet.Map_original_content = mapdataorig; tabdet.Map_compare_content = mapdata2; if (mapdata.Length == mapdata2.Length) { if (isSixteenBitTable(SymbolName)) { for (int bt = 0; bt < mapdata2.Length; bt += 2) { int value1 = Convert.ToInt16(mapdata.GetValue(bt)) * 256 + Convert.ToInt16(mapdata.GetValue(bt + 1)); int value2 = Convert.ToInt16(mapdata2.GetValue(bt)) * 256 + Convert.ToInt16(mapdata2.GetValue(bt + 1)); value1 = Math.Abs((int)value1 - (int)value2); byte v1 = (byte)(value1 / 256); byte v2 = (byte)(value1 - (int)v1 * 256); mapdata.SetValue(v1, bt); mapdata.SetValue(v2, bt + 1); } } else { for (int bt = 0; bt < mapdata2.Length; bt++) { logger.Debug("Byte diff: " + mapdata.GetValue(bt).ToString() + " - " + mapdata2.GetValue(bt).ToString() + " = " + (byte)Math.Abs(((byte)mapdata.GetValue(bt) - (byte)mapdata2.GetValue(bt)))); mapdata.SetValue((byte)Math.Abs(((byte)mapdata.GetValue(bt) - (byte)mapdata2.GetValue(bt))), bt); } } tabdet.Map_content = mapdata; tabdet.UseNewCompare = true; tabdet.Correction_factor = GetMapCorrectionFactor(tabdet.Map_name); tabdet.Correction_offset = GetMapCorrectionOffset(tabdet.Map_name); tabdet.IsUpsideDown = GetMapUpsideDown(tabdet.Map_name); tabdet.ShowTable(columns, isSixteenBitTable(SymbolName)); TryToAddOpenLoopTables(tabdet); tabdet.Dock = DockStyle.Fill; tabdet.onSymbolSave += new IMapViewer.NotifySaveSymbol(tabdet_onSymbolSave); tabdet.onSymbolRead += new IMapViewer.NotifyReadSymbol(tabdet_onSymbolRead); tabdet.onClose += new IMapViewer.ViewerClose(tabdet_onClose); tabdet.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged); tabdet.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx); tabdet.onSurfaceGraphViewChanged += new IMapViewer.SurfaceGraphViewChanged(mv_onSurfaceGraphViewChanged); //tabdet.onAxisLock += new MapViewer.NotifyAxisLock(tabdet_onAxisLock); //tabdet.onSliderMove += new MapViewer.NotifySliderMove(tabdet_onSliderMove); //tabdet.onSelectionChanged += new MapViewer.SelectionChanged(tabdet_onSelectionChanged); //tabdet.onSplitterMoved += new MapViewer.SplitterMoved(tabdet_onSplitterMoved); //tabdet.onSurfaceGraphViewChanged += new MapViewer.SurfaceGraphViewChanged(tabdet_onSurfaceGraphViewChanged); //tabdet.onGraphSelectionChanged += new MapViewer.GraphSelectionChanged(tabdet_onGraphSelectionChanged); //tabdet.onViewTypeChanged += new MapViewer.ViewTypeChanged(tabdet_onViewTypeChanged); //dockPanel.DockAsTab(dockPanel1); dockPanel.Text = "Symbol difference: " + SymbolName + " [" + Path.GetFileName(SRAMFilename) + "]"; bool isDocked = false; if (m_appSettings.AutoDockSameSymbol) { foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text.StartsWith("Symbol difference: " + SymbolName) && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); isDocked = true; break; } } } if (!isDocked) { if (m_appSettings.AutoDockSameFile) { foreach (DockPanel pnl in dockManager1.Panels) { if ((string)pnl.Tag == m_currentfile && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); isDocked = true; break; } } } } if (!isDocked) { dockPanel.DockTo(dockManager1, DockingStyle.Right, 0); if (m_appSettings.AutoSizeNewWindows) { if (tabdet.X_axisvalues.Length > 0) { dockPanel.Width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } else { //dockPanel.Width = this.Width - dockSymbols.Width - 10; } } if (dockPanel.Width < 400) dockPanel.Width = 400; // dockPanel.Width = 400; } dockPanel.Controls.Add(tabdet); } else { frmInfoBox info = new frmInfoBox("Map lengths don't match..."); } } } catch (Exception E) { logger.Debug(E.Message); } dockManager1.EndUpdate(); } }
private void StartSRAMTableViewer() { if (gridViewSymbols.SelectedRowsCount > 0) { int[] selrows = gridViewSymbols.GetSelectedRows(); if (selrows.Length > 0) { SymbolHelper sh = (SymbolHelper)gridViewSymbols.GetRow((int)selrows.GetValue(0)); DockPanel dockPanel; bool pnlfound = false; foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text == "SRAM Symbol: " + sh.Varname + " [" + Path.GetFileName(m_currentsramfile) + "]") { dockPanel = pnl; pnlfound = true; dockPanel.Show(); } } if (!pnlfound) { dockManager1.BeginUpdate(); try { dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(650, 700); } else { dockPanel.FloatSize = new Size(650, 450); } dockPanel.Tag = m_currentsramfile; IMapViewer tabdet;//= new MapViewer(); if (m_appSettings.UseNewMapViewer) { tabdet = new MapViewerEx(); } else { tabdet = new MapViewer(); } tabdet.AutoUpdateIfSRAM = false;// m_appSettings.AutoUpdateSRAMViewers; tabdet.AutoUpdateInterval = m_appSettings.AutoUpdateInterval; tabdet.SetViewSize(m_appSettings.DefaultViewSize); tabdet.Filename = m_currentsramfile; tabdet.GraphVisible = m_appSettings.ShowGraphs; //tabdet.IsHexMode = barViewInHex.Checked; tabdet.Viewtype = m_appSettings.DefaultViewType;//ViewType.Easy; if (m_appSettings.Viewinhex) { tabdet.Viewtype = ViewType.Hexadecimal; } tabdet.DisableColors = m_appSettings.DisableMapviewerColors; tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows; tabdet.IsRedWhite = m_appSettings.ShowRedWhite; tabdet.Map_name = sh.Varname; tabdet.Map_descr = TranslateSymbolName(tabdet.Map_name); tabdet.Map_cat = XDFCategories.Undocumented; tabdet.X_axisvalues = GetXaxisValues(m_currentfile, m_symbols, tabdet.Map_name); tabdet.Y_axisvalues = GetYaxisValues(m_currentfile, m_symbols, tabdet.Map_name); /** NEW 12/11/2008 **/ if (!m_appSettings.NewPanelsFloating) { dockPanel = dockManager1.AddPanel(DockingStyle.Right); if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { int dw = 650; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 400) dw = 400; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 900); } else { dockPanel.FloatSize = new Size(dw, 500); } } else if (m_appSettings.DefaultViewSize == ViewSize.SmallView) { int dw = 550; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 380) dw = 380; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 850); } else { dockPanel.FloatSize = new Size(dw, 450); } } else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView) { int dw = 450; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 30); } if (dw < 380) dw = 380; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 700); } else { dockPanel.FloatSize = new Size(dw, 450); } } } else { System.Drawing.Point floatpoint = this.PointToClient(new System.Drawing.Point(dockSymbols.Location.X + dockSymbols.Width + 30, dockSymbols.Location.Y + 30)); dockPanel = dockManager1.AddPanel(floatpoint); if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { int dw = 650; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 400) dw = 400; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 900); tabdet.SetSplitter(0, 0, 280, false, false); } else { dockPanel.FloatSize = new Size(dw, 500); } } else if (m_appSettings.DefaultViewSize == ViewSize.SmallView) { int dw = 550; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 380) dw = 380; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 850); tabdet.SetSplitter(0, 0, 250, false, false); //tabdet.SetSurfaceGraphZoom(0.4); } else { dockPanel.FloatSize = new Size(dw, 450); //dockPanel.FloatSize = new Size(550, 450); } } else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView) { int dw = 450; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 30); } if (dw < 380) dw = 380; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 700); tabdet.SetSplitter(0, 0, 320, false, false); // tabdet.SetSurfaceGraphZoom(0.5); } else { // dockPanel.FloatSize = new Size(450, 450); dockPanel.FloatSize = new Size(dw, 450); } } floatpoint = new System.Drawing.Point(Screen.PrimaryScreen.WorkingArea.Size.Width / 2 - dockPanel.FloatSize.Width / 2, Screen.PrimaryScreen.WorkingArea.Size.Height / 2 - dockPanel.FloatSize.Height / 2); while ((floatpoint.X < (dockSymbols.Width + 20)) && ((floatpoint.X + dockSymbols.Width) < Screen.PrimaryScreen.WorkingArea.Size.Width)) floatpoint.X++; dockPanel.FloatLocation = floatpoint; } /** end NEW 12/11/2008 */ // z, y and z axis to do /*string xdescr = string.Empty; string ydescr = string.Empty; string zdescr = string.Empty; GetAxisDescriptions(m_currentfile, m_symbols, tabdet.Map_name, out xdescr, out ydescr, out zdescr); tabdet.X_axis_name = xdescr; tabdet.Y_axis_name = ydescr; tabdet.Z_axis_name = zdescr;*/ SymbolAxesTranslator axestrans = new SymbolAxesTranslator(); string x_axis = string.Empty; string y_axis = string.Empty; string x_axis_descr = string.Empty; string y_axis_descr = string.Empty; string z_axis_descr = string.Empty; axestrans.GetAxisSymbols(tabdet.Map_name, out x_axis, out y_axis, out x_axis_descr, out y_axis_descr, out z_axis_descr); tabdet.X_axis_name = x_axis_descr; tabdet.Y_axis_name = y_axis_descr; tabdet.Z_axis_name = z_axis_descr; int columns = 8; int rows = 8; int tablewidth = GetTableMatrixWitdhByName(m_currentfile, m_symbols, tabdet.Map_name, out columns, out rows); int address = (int)sh.Flash_start_address; int sramaddress = (int)sh.Start_address; if (sramaddress != 0) { //while (address > m_currentfile_size) address -= m_currentfile_size; tabdet.Map_address = address; tabdet.Map_sramaddress = sramaddress; int length = sh.Length; tabdet.Map_length = length; byte[] mapdata = readdatafromSRAMfile(m_currentsramfile, sramaddress, length); tabdet.Map_content = mapdata; tabdet.Correction_factor = GetMapCorrectionFactor(tabdet.Map_name); tabdet.Correction_offset = GetMapCorrectionOffset(tabdet.Map_name); tabdet.IsUpsideDown = GetMapUpsideDown(tabdet.Map_name); tabdet.ShowTable(columns, isSixteenBitTable(tabdet.Map_name)); TryToAddOpenLoopTables(tabdet); tabdet.IsRAMViewer = true; tabdet.Dock = DockStyle.Fill; //tabdet.onSymbolSave += new MapViewer.NotifySaveSymbol(tabdet_onSymbolSave); tabdet.onClose += new IMapViewer.ViewerClose(tabdet_onClose); //tabdet.onAxisLock += new MapViewer.NotifyAxisLock(tabdet_onAxisLock); //tabdet.onSliderMove += new MapViewer.NotifySliderMove(tabdet_onSliderMove); //tabdet.onSelectionChanged += new MapViewer.SelectionChanged(tabdet_onSelectionChanged); //tabdet.onSplitterMoved += new MapViewer.SplitterMoved(tabdet_onSplitterMoved); //tabdet.onSurfaceGraphViewChanged += new MapViewer.SurfaceGraphViewChanged(tabdet_onSurfaceGraphViewChanged); //tabdet.onGraphSelectionChanged += new MapViewer.GraphSelectionChanged(tabdet_onGraphSelectionChanged); //tabdet.onViewTypeChanged += new MapViewer.ViewTypeChanged(tabdet_onViewTypeChanged); tabdet.onReadFromSRAM += new IMapViewer.ReadDataFromSRAM(tabdet_onReadFromSRAM); tabdet.onWriteToSRAM += new IMapViewer.WriteDataToSRAM(tabdet_onWriteToSRAM); tabdet.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged); tabdet.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx); tabdet.onSurfaceGraphViewChanged += new IMapViewer.SurfaceGraphViewChanged(mv_onSurfaceGraphViewChanged); //dockPanel.DockAsTab(dockPanel1); dockPanel.Text = "SRAM Symbol: " + tabdet.Map_name + " [" + Path.GetFileName(m_currentsramfile) + "]"; bool isDocked = false; if (m_appSettings.AutoDockSameSymbol) { foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text.StartsWith("SRAM Symbol: " + tabdet.Map_name) && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); isDocked = true; break; } } } if (!isDocked) { if (m_appSettings.AutoDockSameFile) { foreach (DockPanel pnl in dockManager1.Panels) { if ((string)pnl.Tag == m_currentsramfile && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); isDocked = true; break; } } } } if (!isDocked) { dockPanel.DockTo(dockManager1, DockingStyle.Right, 0); if (m_appSettings.AutoSizeNewWindows) { if (tabdet.X_axisvalues.Length > 0) { dockPanel.Width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } else { //dockPanel.Width = this.Width - dockSymbols.Width - 10; } } if (dockPanel.Width < 400) dockPanel.Width = 400; } dockPanel.Controls.Add(tabdet); } } catch (Exception newdockE) { logger.Debug(newdockE.Message); } dockManager1.EndUpdate(); } } } }
private void StartSRAMCompareDifferenceViewer(string symbolname, string filename1, string filename2, int length, int sramaddress, string symbolDescription) { DockPanel dockPanel; bool pnlfound = false; foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text == "SRAM symbol difference: " + symbolname + " [" + Path.GetFileName(filename1) + " vs " + Path.GetFileName(filename2) + "]") { dockPanel = pnl; pnlfound = true; dockPanel.Show(); } } if (!pnlfound) { dockManager1.BeginUpdate(); try { dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); dockPanel.Tag = filename1; //IMapViewer tabdet = new MapViewerEx(); IMapViewer tabdet; if (m_appSettings.UseNewMapViewer) { tabdet = new MapViewerEx(); } else { tabdet = new MapViewer(); } tabdet.GraphVisible = m_appSettings.ShowGraphs; tabdet.IsCompareViewer = true; tabdet.DisableColors = m_appSettings.DisableMapviewerColors; tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows; tabdet.GraphVisible = m_appSettings.ShowGraphs; tabdet.IsRedWhite = m_appSettings.ShowRedWhite; tabdet.Filename = filename1; tabdet.Map_name = symbolname; tabdet.Map_descr = symbolDescription; ///tabdet.Map_cat = m_trionicFileInformation.GetSymbolCategory(tabdet.Map_name); tabdet.X_axisvalues = GetXaxisValues(m_currentfile, m_symbols, symbolname); tabdet.Y_axisvalues = GetYaxisValues(m_currentfile, m_symbols, symbolname); string xdescr = string.Empty; string ydescr = string.Empty; string zdescr = string.Empty; SymbolAxesTranslator axestrans = new SymbolAxesTranslator(); string x_axis = string.Empty; string y_axis = string.Empty; axestrans.GetAxisSymbols(symbolname, out x_axis, out y_axis, out xdescr, out ydescr, out zdescr); tabdet.X_axis_name = xdescr; tabdet.Y_axis_name = ydescr; tabdet.Z_axis_name = zdescr; //tabdet.Map_sramaddress = GetSymbolAddressSRAM(SymbolName); int columns = 8; int rows = 8; GetTableMatrixWitdhByName(m_currentfile, m_symbols, symbolname, out columns, out rows); int tablewidth = columns; int address = sramaddress; if (address != 0) { //while (address > m_trionicFileInformation.Filelength) address -= m_trionicFileInformation.Filelength; tabdet.Map_address = address; tabdet.Map_length = length; byte[] mapdata = readdatafromSRAMfile(filename1, sramaddress, length); byte[] mapdata2 = readdatafromSRAMfile(filename2, sramaddress, length); if (mapdata.Length == mapdata2.Length) { if (isSixteenBitTable(symbolname)) { for (int bt = 0; bt < mapdata2.Length; bt += 2) { int value1 = Convert.ToInt16(mapdata.GetValue(bt)) * 256 + Convert.ToInt16(mapdata.GetValue(bt + 1)); int value2 = Convert.ToInt16(mapdata2.GetValue(bt)) * 256 + Convert.ToInt16(mapdata2.GetValue(bt + 1)); value1 = (int)Math.Abs(value1 - value2); byte v1 = (byte)(value1 / 256); byte v2 = (byte)(value1 - (int)v1 * 256); mapdata.SetValue(v1, bt); mapdata.SetValue(v2, bt + 1); } } else { for (int bt = 0; bt < mapdata2.Length; bt++) { //logger.Debug("Byte diff: " + mapdata.GetValue(bt).ToString() + " - " + mapdata2.GetValue(bt).ToString() + " = " + (byte)Math.Abs(((byte)mapdata.GetValue(bt) - (byte)mapdata2.GetValue(bt)))); mapdata.SetValue((byte)Math.Abs(((byte)mapdata.GetValue(bt) - (byte)mapdata2.GetValue(bt))), bt); } } tabdet.Map_content = mapdata; tabdet.Correction_factor = GetMapCorrectionFactor(tabdet.Map_name); tabdet.Correction_offset = GetMapCorrectionOffset(tabdet.Map_name); tabdet.Viewtype = ViewType.Easy; tabdet.IsUpsideDown = true;//GetMapUpsideDown(tabdet.Map_name); tabdet.ShowTable(columns, isSixteenBitTable(tabdet.Map_name)); tabdet.Dock = DockStyle.Fill; tabdet.onClose += new IMapViewer.ViewerClose(tabdet_onClose); tabdet.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged); tabdet.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx); dockPanel.Text = "SRAM symbol difference: " + symbolname + " [" + Path.GetFileName(filename1) + " vs " + Path.GetFileName(filename2) + "]"; bool isDocked = false; if (m_appSettings.AutoDockSameSymbol) { foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text.StartsWith("SRAM symbol difference: " + symbolname) && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); pnl.Options.ShowCloseButton = false; isDocked = true; break; } } } if (!isDocked) { if (m_appSettings.AutoDockSameFile) { foreach (DockPanel pnl in dockManager1.Panels) { if ((string)pnl.Tag == m_currentfile && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); pnl.Options.ShowCloseButton = false; isDocked = true; break; } } } } if (!isDocked) { dockPanel.DockTo(dockManager1, DockingStyle.Right, 0); if (m_appSettings.AutoSizeNewWindows) { if (tabdet.X_axisvalues.Length > 0) { dockPanel.Width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } else { //dockPanel.Width = this.Width - dockSymbols.Width - 10; } } if (dockPanel.Width < 400) dockPanel.Width = 400; // dockPanel.Width = 400; } dockPanel.Controls.Add(tabdet); } else { frmInfoBox info = new frmInfoBox("Map lengths don't match..."); } if (dockPanel != null) { dockPanel.Options.ShowCloseButton = false; } } } catch (Exception E) { logger.Debug(E.Message); } dockManager1.EndUpdate(); } }
private void StartCompareMapViewer(string SymbolName, string Filename, int SymbolAddress, int SymbolLength, SymbolCollection curSymbols, int symbolnumber) { try { // TEST SYMBOLNUMBERS if (symbolnumber > 0 && SymbolName.StartsWith("Symbol")) { foreach (SymbolHelper h in curSymbols) { if (h.Symbol_number == symbolnumber) { SymbolName = h.Varname; } } } DockPanel dockPanel; bool pnlfound = false; foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text == "Symbol: " + SymbolName + " [" + Path.GetFileName(Filename) + "]") { if (pnl.Tag.ToString() == Filename) // <GS-10052011> { dockPanel = pnl; pnlfound = true; dockPanel.Show(); } } } if (!pnlfound) { dockManager1.BeginUpdate(); try { dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); dockPanel.Tag = Filename;// m_currentfile; changed 24/01/2008 IMapViewer tabdet;//= new MapViewer(); if (m_appSettings.UseNewMapViewer) { tabdet = new MapViewerEx(); } else { tabdet = new MapViewer(); } tabdet.AutoUpdateIfSRAM = false;// m_appSettings.AutoUpdateSRAMViewers; tabdet.AutoUpdateInterval = m_appSettings.AutoUpdateInterval; tabdet.SetViewSize(m_appSettings.DefaultViewSize); //tabdet.IsHexMode = barViewInHex.Checked; tabdet.Viewtype = m_appSettings.DefaultViewType; tabdet.DisableColors = m_appSettings.DisableMapviewerColors; tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows; tabdet.GraphVisible = m_appSettings.ShowGraphs; tabdet.IsRedWhite = m_appSettings.ShowRedWhite; tabdet.Filename = Filename; tabdet.Map_name = SymbolName; tabdet.Map_descr = TranslateSymbolName(tabdet.Map_name); tabdet.Map_cat = XDFCategories.Undocumented; tabdet.X_axisvalues = GetXaxisValues(Filename, curSymbols, tabdet.Map_name); tabdet.Y_axisvalues = GetYaxisValues(Filename, curSymbols, tabdet.Map_name); SymbolAxesTranslator axestrans = new SymbolAxesTranslator(); string x_axis = string.Empty; string y_axis = string.Empty; string x_axis_descr = string.Empty; string y_axis_descr = string.Empty; string z_axis_descr = string.Empty; axestrans.GetAxisSymbols(tabdet.Map_name, out x_axis, out y_axis, out x_axis_descr, out y_axis_descr, out z_axis_descr); tabdet.X_axis_name = x_axis_descr; tabdet.Y_axis_name = y_axis_descr; tabdet.Z_axis_name = z_axis_descr; /*string xdescr = string.Empty; string ydescr = string.Empty; string zdescr = string.Empty; GetAxisDescriptions(Filename, curSymbols, tabdet.Map_name, out xdescr, out ydescr, out zdescr); tabdet.X_axis_name = xdescr; tabdet.Y_axis_name = ydescr; tabdet.Z_axis_name = zdescr;*/ //tabdet.Map_sramaddress = GetSymbolAddressSRAM(SymbolName); int columns = 8; int rows = 8; int tablewidth = GetTableMatrixWitdhByName(Filename, curSymbols, tabdet.Map_name, out columns, out rows); int address = Convert.ToInt32(SymbolAddress); if (address != 0) { while (address > m_currentfile_size) address -= m_currentfile_size; tabdet.Map_address = address; int length = SymbolLength; tabdet.Map_length = length; byte[] mapdata = readdatafromfile(Filename, address, length); tabdet.Map_content = mapdata; tabdet.Correction_factor = GetMapCorrectionFactor(tabdet.Map_name); tabdet.Correction_offset = GetMapCorrectionOffset(tabdet.Map_name); tabdet.IsUpsideDown = GetMapUpsideDown(tabdet.Map_name); tabdet.ShowTable(columns, isSixteenBitTable(SymbolName)); TryToAddOpenLoopTables(tabdet); tabdet.Dock = DockStyle.Fill; tabdet.onSymbolSave += new IMapViewer.NotifySaveSymbol(tabdet_onSymbolSave); tabdet.onSymbolRead += new IMapViewer.NotifyReadSymbol(tabdet_onSymbolRead); tabdet.onClose += new IMapViewer.ViewerClose(tabdet_onClose); tabdet.onSelectionChanged += new IMapViewer.SelectionChanged(tabdet_onSelectionChanged); tabdet.onSurfaceGraphViewChangedEx += new IMapViewer.SurfaceGraphViewChangedEx(mv_onSurfaceGraphViewChangedEx); tabdet.onSurfaceGraphViewChanged += new IMapViewer.SurfaceGraphViewChanged(mv_onSurfaceGraphViewChanged); //dockPanel.DockAsTab(dockPanel1); dockPanel.Text = "Symbol: " + SymbolName + " [" + Path.GetFileName(Filename) + "]"; bool isDocked = false; if (m_appSettings.AutoDockSameSymbol) { foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text.StartsWith("Symbol: " + SymbolName) && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); isDocked = true; break; } } } if (!isDocked) { if (m_appSettings.AutoDockSameFile) { foreach (DockPanel pnl in dockManager1.Panels) { if ((string)pnl.Tag == Filename && pnl != dockPanel && (pnl.Visibility == DockVisibility.Visible)) { dockPanel.DockAsTab(pnl, 0); isDocked = true; break; } } } } if (!isDocked) { dockPanel.DockTo(dockManager1, DockingStyle.Right, 0); if (m_appSettings.AutoSizeNewWindows) { if (tabdet.X_axisvalues.Length > 0) { dockPanel.Width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } else { //dockPanel.Width = this.Width - dockSymbols.Width - 10; } } if (dockPanel.Width < 400) dockPanel.Width = 400; // dockPanel.Width = 400; } dockPanel.Controls.Add(tabdet); /*dockPanel.DockTo(dockManager1, DevExpress.XtraBars.Docking.DockingStyle.Right, 0); if (tabdet.X_axisvalues.Length > 0) { dockPanel.Width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } else { //dockPanel.Width = this.Width - dockSymbols.Width - 10; } if (dockPanel.Width < 400) dockPanel.Width = 400; // dockPanel.Width = 400; dockPanel.Controls.Add(tabdet);*/ } } catch (Exception E) { logger.Debug(E.Message); } dockManager1.EndUpdate(); } } catch (Exception startnewcompareE) { logger.Debug(startnewcompareE.Message); } }
private void ShowAfrMAP(string mapname, string filename) { // show seperate mapviewer for AFR target map DockPanel dockPanel; bool pnlfound = false; string symbolname = mapname; try { foreach (DockPanel pnl in dockManager1.Panels) { if (pnl.Text == "Symbol: " + symbolname + " [" + Path.GetFileName(m_currentfile) + "]") { dockPanel = pnl; pnlfound = true; dockPanel.Show(); } } } catch (Exception E) { logger.Debug(E.Message); } if (!pnlfound) { //dockPanel = dockManager1.AddPanel(new System.Drawing.Point(-500, -500)); dockManager1.BeginUpdate(); try { IMapViewer tabdet;//= new MapViewer(); if (m_appSettings.UseNewMapViewer) { tabdet = new MapViewerEx(); } else { tabdet = new MapViewer(); } tabdet.SetViewSize(m_appSettings.DefaultViewSize); tabdet.Visible = false; tabdet.Filename = m_currentfile; tabdet.GraphVisible = m_appSettings.ShowGraphs; tabdet.Viewtype = m_appSettings.DefaultViewType;//ViewType.Easy; if (m_appSettings.Viewinhex) { tabdet.Viewtype = ViewType.Hexadecimal; } tabdet.DisableColors = m_appSettings.DisableMapviewerColors; tabdet.AutoSizeColumns = m_appSettings.AutoSizeColumnsInWindows; tabdet.IsRedWhite = m_appSettings.ShowRedWhite; tabdet.Map_name = symbolname; tabdet.Map_descr = "Target AFR map for use with wideband lambda sensor"; if (mapname == "FeedbackAFR") tabdet.Map_descr = "Feedback AFR map from wideband lambda sensor"; //if (mapname == "FeedbackvsTargetAFR") tabdet.Map_descr = "Feedback AFR minus target AFR map from wideband lambda sensor"; tabdet.Map_cat = XDFCategories.Sensor; tabdet.X_axisvalues = GetXaxisValues(m_currentfile, m_symbols, "BFuelCal.Map"); tabdet.Y_axisvalues = GetYaxisValues(m_currentfile, m_symbols, "BFuelCal.Map"); // z, y and z axis to do if (!m_appSettings.NewPanelsFloating) { dockPanel = dockManager1.AddPanel(DockingStyle.Right); if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { int dw = 650; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 400) dw = 400; if (dw > 800) dw = 800; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 900); } else { dockPanel.FloatSize = new Size(dw, 500); } } else if (m_appSettings.DefaultViewSize == ViewSize.SmallView) { int dw = 550; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 380) dw = 380; if (dw > 600) dw = 600; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 850); } else { dockPanel.FloatSize = new Size(dw, 450); } } else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView) { int dw = 450; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 30); } if (dw < 380) dw = 380; if (dw > 400) dw = 400; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 700); } else { dockPanel.FloatSize = new Size(dw, 450); } } } else { System.Drawing.Point floatpoint = this.PointToClient(new System.Drawing.Point(dockSymbols.Location.X + dockSymbols.Width + 30, dockSymbols.Location.Y + 30)); dockPanel = dockManager1.AddPanel(floatpoint); if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { int dw = 650; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 400) dw = 400; if (dw > 800) dw = 800; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 900); tabdet.SetSplitter(0, 0, 280, false, false); } else { dockPanel.FloatSize = new Size(dw, 500); } } else if (m_appSettings.DefaultViewSize == ViewSize.SmallView) { int dw = 550; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 380) dw = 380; if (dw > 600) dw = 600; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 850); tabdet.SetSplitter(0, 0, 250, false, false); //tabdet.SetSurfaceGraphZoom(0.4); } else { dockPanel.FloatSize = new Size(dw, 450); //dockPanel.FloatSize = new Size(550, 450); } } else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView) { int dw = 450; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 30); } if (dw < 380) dw = 380; if (dw > 400) dw = 400; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 700); tabdet.SetSplitter(0, 0, 320, false, false); // tabdet.SetSurfaceGraphZoom(0.5); } else { // dockPanel.FloatSize = new Size(450, 450); dockPanel.FloatSize = new Size(dw, 450); } } floatpoint = new System.Drawing.Point(Screen.PrimaryScreen.WorkingArea.Size.Width / 2 - dockPanel.FloatSize.Width / 2, Screen.PrimaryScreen.WorkingArea.Size.Height / 2 - dockPanel.FloatSize.Height / 2); while ((floatpoint.X < (dockSymbols.Width + 20)) && ((floatpoint.X + dockSymbols.Width) < Screen.PrimaryScreen.WorkingArea.Size.Width)) floatpoint.X++; dockPanel.FloatLocation = floatpoint; } // OUD /* System.Drawing.Point floatpoint = this.PointToClient(new System.Drawing.Point(dockSymbols.Location.X + dockSymbols.Width + 30, dockSymbols.Location.Y + 30)); dockPanel = dockManager1.AddPanel(floatpoint); if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { int dw = 650; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 400) dw = 400; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 900); tabdet.SetSplitter(0, 0, 280, false, false); } else { dockPanel.FloatSize = new Size(dw, 500); } } else if (m_appSettings.DefaultViewSize == ViewSize.SmallView) { int dw = 550; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } if (dw < 380) dw = 380; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 850); tabdet.SetSplitter(0, 0, 250, false, false); //tabdet.SetSurfaceGraphZoom(0.4); } else { dockPanel.FloatSize = new Size(dw, 450); //dockPanel.FloatSize = new Size(550, 450); } } else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView) { int dw = 450; if (tabdet.X_axisvalues.Length > 0) { dw = 30 + ((tabdet.X_axisvalues.Length + 1) * 30); } if (dw < 380) dw = 380; if (m_appSettings.ShowGraphs) { dockPanel.FloatSize = new Size(dw, 700); tabdet.SetSplitter(0, 0, 320, false, false); // tabdet.SetSurfaceGraphZoom(0.5); } else { // dockPanel.FloatSize = new Size(450, 450); dockPanel.FloatSize = new Size(dw, 450); } } floatpoint = new System.Drawing.Point(Screen.PrimaryScreen.WorkingArea.Size.Width / 2 - dockPanel.FloatSize.Width / 2, Screen.PrimaryScreen.WorkingArea.Size.Height / 2 - dockPanel.FloatSize.Height / 2); while ((floatpoint.X < (dockSymbols.Width + 20)) && ((floatpoint.X + dockSymbols.Width) < Screen.PrimaryScreen.WorkingArea.Size.Width)) floatpoint.X++; dockPanel.FloatLocation = floatpoint;*/ dockPanel.Tag = m_currentfile; /*string xdescr = string.Empty; string ydescr = string.Empty; string zdescr = string.Empty; GetAxisDescriptions(m_currentfile, m_symbols, "BFuelCal.Map", out xdescr, out ydescr, out zdescr); tabdet.X_axis_name = xdescr; tabdet.Y_axis_name = ydescr; tabdet.Z_axis_name = zdescr;*/ SymbolAxesTranslator axestrans = new SymbolAxesTranslator(); string x_axis = string.Empty; string y_axis = string.Empty; string x_axis_descr = string.Empty; string y_axis_descr = string.Empty; string z_axis_descr = string.Empty; axestrans.GetAxisSymbols("BFuelCal.Map", out x_axis, out y_axis, out x_axis_descr, out y_axis_descr, out z_axis_descr); tabdet.X_axis_name = x_axis_descr; tabdet.Y_axis_name = y_axis_descr; tabdet.Z_axis_name = z_axis_descr; int columns = 8; int rows = 8; int tablewidth = GetTableMatrixWitdhByName(m_currentfile, m_symbols, "BFuelCal.Map", out columns, out rows); tabdet.Map_address = 0; tabdet.Map_sramaddress = 0; int length = GetSymbolLength(m_symbols, "BFuelCal.Map"); tabdet.Map_length = length * 2; if (mapname == "FeedbackAFR") { byte[] mapdata = m_AFRMap.GetFeedbackMapInBytes(length);//LoadTargetAFRMapInBytes(filename);//TODO: ??? tabdet.Map_content = mapdata; tabdet.Afr_counter = m_AFRMap.GetAFRCountermap(); tabdet.Correction_factor = 0.1; tabdet.Correction_offset = 0; } if (mapname == "FeedbackCounter") { byte[] mapdata = m_AFRMap.GetFeedbackCounterMapInBytes(length);//LoadTargetAFRMapInBytes(filename);//TODO: ??? tabdet.Map_content = mapdata; tabdet.Correction_factor = 1; tabdet.Correction_offset = 0; } if (mapname == "TargetAFR") { byte[] mapdata = m_AFRMap.GetTargetAFRMapinBytes(length, m_currentfile);//LoadTargetAFRMapInBytes(filename);//TODO: ??? tabdet.Map_content = mapdata; tabdet.Correction_factor = 0.1; tabdet.Correction_offset = 0; } tabdet.IsUpsideDown = true; tabdet.ShowTable(columns, true); TryToAddOpenLoopTables(tabdet); tabdet.Dock = DockStyle.Fill; tabdet.onSymbolSave += new IMapViewer.NotifySaveSymbol(onTargetAFRMapSave); tabdet.onClose += new IMapViewer.ViewerClose(tabdet_onClose); dockPanel.Text = "Symbol: " + tabdet.Map_name + " [" + Path.GetFileName(m_currentfile) + "]"; bool isDocked = false; if (!isDocked) { int width = 400; if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { width = 500; } if (m_appSettings.AutoSizeNewWindows) { if (m_appSettings.DefaultViewSize == ViewSize.NormalView) { if (tabdet.X_axisvalues.Length > 0) { width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } else { //width = this.Width - dockSymbols.Width - 10; } if (width < 500) width = 500; } else if (m_appSettings.DefaultViewSize == ViewSize.SmallView) { if (tabdet.X_axisvalues.Length > 0) { width = 30 + ((tabdet.X_axisvalues.Length + 1) * 35); } else { //width = this.Width - dockSymbols.Width - 10; } if (width < 450) width = 450; } else if (m_appSettings.DefaultViewSize == ViewSize.ExtraSmallView) { if (tabdet.X_axisvalues.Length > 0) { width = 30 + ((tabdet.X_axisvalues.Length + 1) * 30); } if (width < 400) width = 400; } } dockPanel.Width = width; } dockPanel.Controls.Add(tabdet); tabdet.Visible = true; //tabdet.MaxValueInTable = 350; } catch (Exception newdockE) { logger.Debug(newdockE.Message); } dockManager1.EndUpdate(); } System.Windows.Forms.Application.DoEvents(); }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { SymbolAxesTranslator sat = new SymbolAxesTranslator(); string x = sat.GetXaxisSymbol(m_map_name); string y = sat.GetYaxisSymbol(m_map_name); if (x != string.Empty) { editXaxisSymbolToolStripMenuItem.Enabled = true; editXaxisSymbolToolStripMenuItem.Text = "Edit x-axis (" + x + ")"; } else { editXaxisSymbolToolStripMenuItem.Enabled = false; editXaxisSymbolToolStripMenuItem.Text = "Edit x-axis"; } if (y != string.Empty) { editYaxisSymbolToolStripMenuItem.Enabled = true; editYaxisSymbolToolStripMenuItem.Text = "Edit y-axis (" + y + ")"; } else { editYaxisSymbolToolStripMenuItem.Enabled = false; editYaxisSymbolToolStripMenuItem.Text = "Edit y-axis"; } }