public override void AddParentEntry() // Add a Termin { TimeBox timeBox = new TimeBox(true); timeBox.posEntry.Text = "0"; // Default pos Entry textEntry = new Entry(); ComboBox cbType = new ComboBox(API_Contract.ProgrammTerminTypVal); cbType.Active = 1; // Default is 'Programm' GetUserArgs[] args = new GetUserArgs[] { new GetUserArgs(new Label("Text"), textEntry), new GetUserArgs(new Label("Sichtbarkeit"), cbType), }; var diag = new GetUserDataDialog(args, timeBox, "Speichern", 0, "Abbruch", 1); if (diag.Run() == 0) { bool validated; while (!(validated = timeBox.ValidateTime())) { if (diag.Run() == 1) { validated = false; break; } } if (validated) // There is valid user data { var treeContent = CurrTreeStore; string finalTime; string tmpTime = timeBox.Time; string text = textEntry.Text; string typString = GtkHelper.ComboBoxActiveString(cbType); int typ = cbType.Active; // Save on UI TreeIter insertIter; insertIter = treeContent.AppendValues(tmpTime, text, typString); GtkHelper.SortInByColumn(treeContent, (int)ProgrammColumnID.Uhrzeit, insertIter); finalTime = API_Contract.ClearTimeConflicts(treeContent, insertIter); // Save on Database var insert = new Table_Termin(CurrTabIndex, finalTime, text, typ); dbAdapter.InsertEntry(insert); } } // Free Memory diag.Destroy(); foreach (var arg in args) // Free args { arg.Dispose(); } }
public override void AddChildEntry() { var parIter = editFrameAdapter.ActiveParentTreeIter; if (parIter.Equals(TreeIter.Zero)) { return; } // Get User data EventTimeBox timeBox = new EventTimeBox(false); GetUserArgs[] args = { }; var diag = new GetUserDataDialog(args, timeBox, "Speichern", 0, "Abbruch", 1); if (diag.Run() == 0) { bool validated; while (!(validated = timeBox.ValidateTime())) { if (diag.Run() == 1) { validated = false; break; } } if (validated) // There is valid user data { var treeContent = CurrTreeStore; string time = timeBox.Time; int vId = int.Parse((string)treeContent.GetValue(parIter, (int)EventColumnId.ID)); int iId = treeContent.IterNChildren(parIter) + 1; if (iId != 1) // XXX: Start counting with 1 here (beta) { iId++; } // Save on UI treeContent.AppendValues(parIter, iId, "", "", "", time); // Save on Database var elem = new Table_Instanz(vId, iId, time); dbAdapter.InsertEntry(elem); } } diag.Destroy(); foreach (var arg in args) { arg.Dispose(); } }
public override void AddChildEntry() { Entry nameEntry = new Entry(); GetUserArgs[] args = { new GetUserArgs(new Label("Name"), nameEntry), }; var diag = new GetUserDataDialog(args, null, "Ok", 0, "Abbruch", 1); if (diag.Run() == 0) { var kategorie = new Table_Kategorie(nameEntry.Text); dbAdapter.InsertEntry(kategorie); CurrTreeStore.AppendValues(nameEntry.Text); // TODO: //FrameManager.GetInstance().Toolbar.Refresh(); } diag.Destroy(); foreach (var arg in args) { arg.Dispose(); } }
public override void AddChildEntry() { TreeIter parentIter = editFrameAdapter.ActiveParentTreeIter; if (CurrTabIndex == -1 || parentIter.Equals(TreeIter.Zero)) { return; } ComboBox cbTyp = new ComboBox(API_Contract.CategorieTextTypChildVal); cbTyp.Active = 0; // Text is default Entry textEntry = new Entry(); GetUserArgs[] args = { new GetUserArgs(new Label("Typ"), cbTyp), new GetUserArgs(new Label("Text"), textEntry), }; var diag = new GetUserDataDialog(args, null, "Ok", 0, "Abburch", 1); if (diag.Run() == 0 && AssertNotEmpty(diag, textEntry)) { var treeContent = CurrTreeStore; string text = textEntry.Text; string typString = GtkHelper.ComboBoxActiveString(cbTyp); int typ = API_Contract.CategorieTextChildTypCR[typString]; int row; TreeIter firstIt; // Get row if (treeContent.IterChildren(out firstIt, parentIter)) { var lastIt = GtkHelper.GetLastIter(treeContent, firstIt); row = int.Parse((string)treeContent.GetValue(lastIt, (int)CategorieColumnID.Rang)); row += 1; } else { row = 0; } // Save on UI treeContent.AppendValues(parentIter, row, typString, text); // Save on Database var titelName = (string)treeContent.GetValue(parentIter, (int)CategorieColumnID.Text); var insert = new Table_Kategorie_Tab_Text(tabNames[CurrTabIndex], titelName, text, typ, row); dbAdapter.InsertEntry(insert); } // Free memory diag.Destroy(); foreach (var arg in args) { arg.Dispose(); } }
private static bool AssertNotEmpty(GetUserDataDialog diag, Entry textEntry) { while ((textEntry.Text.Length == 0)) // Invalid input { textEntry.OverrideColor(0, API_Contract.invalidColor); // Show problem if (diag.Run() == 1) // User aborts { return(false); } } return(true); }
public override void AddParentEntry() { if (CurrTabIndex == -1) { return; } Entry nameEntry = new Entry(); var cbTyp = new ComboBox(API_Contract.CategorieTextTypParentVal); cbTyp.Active = 0; GetUserArgs[] args = { new GetUserArgs(new Label("Titel"), nameEntry), new GetUserArgs(new Label("Typ"), cbTyp), }; var diag = new GetUserDataDialog(args, null, "Speichern", 0, "Abbrechen", 1); if (diag.Run() == 0 && AssertNotEmpty(diag, nameEntry)) { var treeContent = CurrTreeStore; string text = nameEntry.Text; string typString = GtkHelper.ComboBoxActiveString(cbTyp); int typ = API_Contract.CategorieTextParentTypCR[typString]; int row; TreeIter firstIt; if (treeContent.GetIterFirst(out firstIt)) // Has childs { var lastIt = GtkHelper.GetLastIter(treeContent, firstIt); row = int.Parse((string)treeContent.GetValue(lastIt, (int)CategorieColumnID.Rang)); row += 1; } else // Is empty { row = 0; } // Save on UI treeContent.AppendValues(row, typString, text); // Save in Database var insert = new Table_Kategorie_Tab_Titel(tabNames[CurrTabIndex], text, typ, row); dbAdapter.InsertEntry(insert); } // Free memory diag.Destroy(); foreach (var arg in args) { arg.Dispose(); } }
public override void AddChildEntry() // Add a Beschreibung { // Is there a active parent? TreeIter parentIter = editFrameAdapter.ActiveParentTreeIter; if (parentIter.Equals(TreeIter.Zero)) { var error = new SafeCallDialog("Kein Element ausgewählt", "Ok", 0, null, 1); error.Run(); error.Destroy(); return; } ComboBox cbTyp = new ComboBox(API_Contract.ProgrammDescrTypVal); cbTyp.Active = 2; // Default is 'All' Entry textEntry = new Entry(); var args = new GetUserArgs[] { new GetUserArgs(new Label("Text"), textEntry), new GetUserArgs(new Label("Typ"), cbTyp), }; var diag = new GetUserDataDialog(args, null, "Ok", 0, "Abbruch", 1); if (diag.Run() == 0) { var treeContent = CurrTreeStore; string text = textEntry.Text; string typString = GtkHelper.ComboBoxActiveString(cbTyp); int typ = cbTyp.Active; // Save on UI TreeIter insertIter, firstIter; insertIter = treeContent.AppendValues(parentIter, "└──", "\t" + text, typString); treeContent.IterNthChild(out firstIter, parentIter, 0); GtkHelper.SortInByColumn(treeContent, (int)ProgrammColumnID.Text, insertIter); // XXX: Save on Database string time = (string)treeContent.GetValue(parentIter, (int)ProgrammColumnID.Uhrzeit); var insert = new Table_Beschreibung(CurrTabIndex, time, text, typ); dbAdapter.InsertEntry(insert); } // Free Memory diag.Destroy(); foreach (var arg in args) { arg.Dispose(); } }
public override void AddTab() { Label nameLabel = new Label("Titel"); Entry nameEntry = new Entry(); GetUserArgs[] args = { new GetUserArgs(nameLabel, nameEntry), }; var diag = new GetUserDataDialog(args, null, "Speichern", 0, "Abbrechen", 1); if (diag.Run() == 0 && AssertNotEmpty(diag, nameEntry)) { string text = nameEntry.Text; // Save on UI var treeStore = new TreeStore(typeof(int), typeof(string), typeof(string)); var tabContent = GenerateTabContent(treeStore); AddTab(tabContent, text); // Save on Database dbAdapter.InsertEntry(new Table_Kategorie_Tab(text, tabs)); } diag.Destroy(); }
public override void AddParentEntry() { var parIter = editFrameAdapter.ActiveParentTreeIter; var treeContent = CurrTreeStore; EventTimeBox timeBox = new EventTimeBox(true); ComboBox cbKrz = new ComboBox(API_Contract.SupportedKrzl); Entry krzlEntry = new Entry(); krzlEntry.Changed += delegate { krzlEntry.Text = krzlEntry.Text.Trim(); if (krzlEntry.Text.Length != 0) // New Krzl { cbKrz.Active = -1; cbKrz.Sensitive = false; } else // Existing KRZL { cbKrz.Sensitive = true; } }; ComboBox cbLang = new ComboBox(API_Contract.SupportedLanguages); Entry textEntry = new Entry(); GetUserArgs[] args = { new GetUserArgs(new Label("Sprache"), cbLang), new GetUserArgs(new Label("Kürzel"), cbKrz), new GetUserArgs(new Label("Neues Kürzel"), krzlEntry), new GetUserArgs(new Label("Name"), textEntry), }; var diag = new GetUserDataDialog(args, timeBox, "Speichern", 0, "Abbruch", 1); if (diag.Run() == 0) { bool validated; // While the Input is invalid while (!(validated = timeBox.ValidateTime() && ValidateKrzl(args[3]))) { if (diag.Run() == 1) // User cancels { validated = false; break; } } if (validated) // There is valid user data { string text = textEntry.Text; string time = timeBox.Time; string lang = API_Contract.SupportedLanguages[cbLang.Active]; string krzl; int id = treeContent.IterNChildren(parIter) + 1; if (id != 1) // XXX: Start counting with 1 here (beta) { id++; } if (cbKrz.Active > 0) // No new Krzl { krzl = API_Contract.SupportedLanguages[cbKrz.Active]; } else { krzl = krzlEntry.Text; } // Save on UI treeContent.AppendValues(parIter, id, text, krzl, lang, time); // Save on Database var elem = new Table_Veranstaltung(id, text, krzl, lang, int.Parse(time)); dbAdapter.InsertEntry(elem); } } // Free memory diag.Destroy(); foreach (var arg in args) { arg.Dispose(); } }