private Trionic7File TryToOpenFileUsingClass(string filename, out SymbolCollection symbol_collection, int filename_size, bool isWorkingFile) { Trionic7File retval = new Trionic7File(); retval.onProgress += retval_onProgress; SymbolTranslator translator = new SymbolTranslator(); string help = string.Empty; _softwareIsOpen = false; _softwareIsOpenDetermined = false; m_currentsramfile = string.Empty; // geen sramfile erbij barStaticItem1.Caption = ""; barFilenameText.Caption = ""; FileInfo fi = new FileInfo(filename); try { fi.IsReadOnly = false; btnReadOnly.Caption = "File access OK"; } catch (Exception E) { logger.Debug("Failed to remove read only flag: " + E.Message); btnReadOnly.Caption = "File is READ ONLY"; } try { if (isWorkingFile) { T7FileHeader t7InfoHeader = new T7FileHeader(); if (t7InfoHeader.init(filename, m_appSettings.AutoFixFooter)) { m_current_softwareversion = t7InfoHeader.getSoftwareVersion(); m_currentSramOffsett = ReverseInt(t7InfoHeader.Unknown_9cvalue); } else { m_current_softwareversion = ""; } } } catch (Exception E2) { logger.Debug(E2.Message); } AddFileToMRUList(filename); symbol_collection = retval.ExtractFile(filename, m_appSettings.ApplicationLanguage, m_current_softwareversion); SetProgressPercentage(60); SetProgress("Examining file"); System.Windows.Forms.Application.DoEvents(); if (isWorkingFile) { if (m_currentSramOffsett == 0) { m_currentSramOffsett = retval.SramOffsetForOpenFile; logger.Debug("Overrules m_currentSramOffsett with value from t7file: " + m_currentSramOffsett.ToString("X8")); } // <GS-27042010> now we need to check if there is a symbol information XML file present. try { IsSoftwareOpen(); // fill in the rest of the parameters barFilenameText.Caption = Path.GetFileNameWithoutExtension(filename); } catch (Exception E3) { logger.Debug(E3.Message); } } if (IsBinaryBiopower()) { foreach (SymbolHelper sh in symbol_collection) { if (sh.Varname == "BFuelCal.StartMap") { sh.Varname = "BFuelCal.E85Map"; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory sub = XDFSubCategory.Undocumented; sh.Description = translator.TranslateSymbolToHelpText(sh.Varname, out help, out cat, out sub, m_appSettings.ApplicationLanguage); } if (sh.Userdescription == "BFuelCal.StartMap") { sh.Userdescription = "BFuelCal.E85Map"; XDFCategories cat = XDFCategories.Undocumented; XDFSubCategory sub = XDFSubCategory.Undocumented; sh.Description = translator.TranslateSymbolToHelpText(sh.Userdescription, out help, out cat, out sub, m_appSettings.ApplicationLanguage); } } } return retval; }
private void simpleButton3_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Binary files|*.bin"; if (ofd.ShowDialog() == DialogResult.OK) { m_current_comparefilename = ofd.FileName; SymbolTranslator translator = new SymbolTranslator(); string help = string.Empty; FileInfo fi = new FileInfo(m_current_comparefilename); fi.IsReadOnly = false; try { T7FileHeader t7InfoHeader = new T7FileHeader(); if (t7InfoHeader.init(m_current_comparefilename, false)) { m_current_softwareversion = t7InfoHeader.getSoftwareVersion(); } else { m_current_softwareversion = ""; } } catch (Exception E2) { logger.Debug(E2.Message); } Trionic7File t7file = new Trionic7File(); Compare_symbol_collection = t7file.ExtractFile(m_current_comparefilename, 44, m_current_softwareversion); // so... now determine the max values for the compare file // show the dynograph xtraTabControl1.SelectedTabPage = xtraTabPage2; LoadGraphWithDetails(); // initial values from original bin //DataTable dt = CalculateDataTable(m_current_comparefilename, Compare_symbol_collection); //LoadExtraGraphFromCompareBin(dt, m_current_comparefilename); } }