private void btStartClick(object sender, EventArgs e) { nDone = 0; nChecked = 0; nJumped = 0; for (int i = 0; i < 5; i++) { fBestUtility[i] = 0; } Cursor = Cursors.WaitCursor; tStart = DateTime.Now; btStart.Enabled = false; TimerRefresh.Enabled = true; Optimize(0); //HINT: FileMode.Create does the same as ofstream with trunc mode, because ofstream creates the file in every mode if it does not exist. fDbg = new FStreamWrapper("Debug.txt", FileMode.Create, FileAccess.Write); for (int i = 0; i < nCombinations; i++) { for (int j = 0; j < 4; j++) { fDbg = fDbg + arCombinations[i].group[j] + '\t' + arCombinations[i].value[j] + '\t'; } fDbg = fDbg + arCombinations[i].count + '\n'; } fDbg.Dispose(); TimerRefreshTimer(null, EventArgs.Empty); Cursor = Cursors.Default; TimerRefresh.Enabled = false; btStart.Enabled = true; if (BestCombination >= 0) { btAccept.Enabled = true; } }
// und den Tag mit dieser Funktion wieder schliessen public bool CloseTag() { if (arOpenTags.Count > 0) { foXml += "</" + arOpenTags[arOpenTags.Count - 1] + ">\n"; arOpenTags.RemoveAt(arOpenTags.Count - 1); return true; } return false; }
//Funktionen für das Schreiben // Mit dieser Funktion einen Tag schreiben // Variable Argumentenliste ist hier Blödsinn, macht zu viel Arbeit public bool OpenTag(String Tag, String Content, String Attribute) { arOpenTags.Add(Tag); foXml += "<" + Tag; // Jetzt die attribute wenn wir welche haben if (Attribute.Length > 0) foXml += ' ' + Attribute; foXml += ">" + Content; if (Content == "") foXml += "\n"; return true; }
public void CloseXml() { if (fiXml != null) { if (bInFile) { ((IFStreamWrapper)fiXml).Close(); } } fiXml = null; if (foXml != null) { ((FStreamWrapper)foXml).Close(); } foXml = null; }
// Öffnet die xml-Datei für Schreibzugriff und schreibe die Header-Zeile // Mit OpenTag und CloseTag die tags schreiben public bool OpenSaveXml(string Filename) { CloseXml(); strFileName = FileName; bool fail = false; try { //HINT: FileMode.Create does the same as ofstream with trunc mode, because ofstream creates the file in every mode if it does not exist. foXml = new FStreamWrapper(Filename, FileMode.Create, FileAccess.Write); } catch { fail = true; } arOpenTags.Clear(); if (fail) return false; foXml += "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n"; return true; }
//--------------------------------------------------------------------------- public CXml() { fiXml = null; foXml = null; arOpenTags = new List<string>(); }
// Schreibe einen leeren Tag in den Stream public bool EmptyTag(String Tag) { foXml += "<" + Tag + "/>\n"; return true; }