public TreeStore GetListFrameDataFor(int day, int veranstaltungs_id, int instanz_id, string sprache) { // Populates a treeStore with the data from @programm[day] // Check if data is already cached if (cached_ProgrammQuery == null || (veranstaltungs_id != cached_veranstaltungs_id || instanz_id != cached_instanz_id || sprache != null || !sprache.Equals(cached_sprache))) { CacheProgrammData(veranstaltungs_id, instanz_id, sprache); } // No more data will be needed if (day >= cached_ProgrammQuery.Length) { cached_ProgrammQuery = null; // Free cached_programm return(null); } TreeStore treeStore = new TreeStore(typeof(string), typeof(string), typeof(string)); ProgramQuery[] dayList = cached_ProgrammQuery[day]; for (uint i = 0; i < dayList.Length;) { var currItem = dayList[i]; var iter = treeStore.AppendValues( "" + currItem.termin_Uhrzeit, "" + currItem.termin_Titel, "" + API_Contract.ProgrammTerminTypHR[currItem.termin_Typ]); if (currItem.beschreibung_Text != null) { // While has childs do { treeStore.AppendValues(iter, "└──", "" + API_Contract.ConvertDatabaseToTreeChild(dayList[i].beschreibung_Text), "" + API_Contract.ProgrammDescrTypHR[currItem.beschreibung_Typ]); i++; } while (i < dayList.Length && currItem.termin_Uhrzeit.Equals(dayList[i].termin_Uhrzeit) && currItem.termin_Tag == dayList[i].termin_Tag); continue; // No need to count up } i++; } return(treeStore); }
protected override bool HookOnSave() { // Assert data integrity if (!timeBox.ValidateTime()) { return(false); } // Mutable values string validTime; string textString = CurrText; string origTime = timeBox.OrigTime; string typString = GtkHelper.ComboBoxActiveString(cbTyp); int typ = cbTyp.Active; // Save on Database DatabaseTable orig, newElem; if (IsCurrParent) { validTime = timeBox.Time; orig = new Table_Termin(day, origTime, OrigText, origTyp); newElem = new Table_Termin(day, validTime, textString, typ); } else { validTime = origTime; // Parent time, we got on EditTreeRow() textString = API_Contract.ConvertEditViewToDatabase(textString); orig = new Table_Beschreibung(day, origTime, OrigText, origTyp); newElem = new Table_Beschreibung(day, validTime, textString, typ); } orig.Update(newElem); // Save on UI if (IsCurrParent) // Only Parent time can change { currTreeStore.SetValue(currTreeIter, (int)ProgrammColumnID.Uhrzeit, validTime); } currTreeStore.SetValue(currTreeIter, (int)ProgrammColumnID.Typ, typString); // Set UI text value and sort in if (IsCurrParent) { // Sort by time, and clear conflicts currTreeStore.SetValue(currTreeIter, (int)ProgrammColumnID.Text, textString); var iter = GtkHelper.SortInByColumn(currTreeStore, (int)ProgrammColumnID.Uhrzeit, currTreeIter); validTime = API_Contract.ClearTimeConflicts(currTreeStore, iter); } else { // Sort by text currTreeStore.SetValue(currTreeIter, (int)ProgrammColumnID.Text, API_Contract.ConvertDatabaseToTreeChild(textString)); GtkHelper.SortInByColumn(currTreeStore, (int)ProgrammColumnID.Text, currTreeIter); } // Save on this timeBox.Time = validTime; origTyp = cbTyp.Active; return(true); }