void on_button_new_clicked(object o, EventArgs args) { string selectedName = getSelectedName(); if (selectedName == "") { return; } List <EncoderConfigurationSQLObject> list = SqliteEncoderConfiguration.Select(false, encoderGI, selectedName); if (list != null && list.Count == 1) { EncoderConfigurationSQLObject econfSO = list[0]; econfSO.uniqueID = -1; //to be entered as null and not repeat the uniqueID //add a suffix econfSO.name += "_" + Catalog.GetString("copy"); //add more suffixes until name is unique econfSO.name = SqliteEncoderConfiguration.IfNameExistsAddSuffix(econfSO.name, Catalog.GetString("copy")); SqliteEncoderConfiguration.MarkAllAsUnactive(false, encoderGI); econfSO.active = true; SqliteEncoderConfiguration.Insert(false, econfSO); store.AppendValues(new string[] { econfSO.name, econfSO.description }); UtilGtk.TreeviewSelectRowWithName(treeview_select, store, colName, econfSO.name, true); } }
static public EncoderConfigurationWindow View( Constants.EncoderGI encoderGI, EncoderConfigurationSQLObject econfSO, string anchorage_str, int extraWeightN) { if (EncoderConfigurationWindowBox == null) { EncoderConfigurationWindowBox = new EncoderConfigurationWindow(); } EncoderConfigurationWindowBox.encoderGI = encoderGI; EncoderConfigurationWindowBox.updateGUIFromEncoderConfiguration(econfSO.encoderConfiguration); EncoderConfigurationWindowBox.main_gui_anchorage_str = anchorage_str; EncoderConfigurationWindowBox.main_gui_extraWeightN = extraWeightN; EncoderConfigurationWindowBox.createTreeView(); EncoderConfigurationWindowBox.fillTreeView( SqliteEncoderConfiguration.Select(false, encoderGI, ""), //all econfSO); //A) side is hidden at start to ensure scr_treeview_select is scrolled and displays correctly the last row EncoderConfigurationWindowBox.notebook_side.Visible = false; EncoderConfigurationWindowBox.encoder_configuration.Show(); //B) side is shown now, after showing the window in order to be displayed correctly (see A) EncoderConfigurationWindowBox.notebook_side.Visible = (EncoderConfigurationWindowBox.sideMode != sideModes.HIDDEN); return(EncoderConfigurationWindowBox); }
private void onTVSelectionChanged(object o, EventArgs args) { string selectedName = getSelectedName(); if (selectedName == "") { return; } List <EncoderConfigurationSQLObject> list = SqliteEncoderConfiguration.Select(false, encoderGI, selectedName); if (list != null && list.Count == 1) { EncoderConfigurationSQLObject econfSO = list[0]; entry_save_name.Text = econfSO.name; entry_save_description.Text = econfSO.description; //mark all as unactive SqliteEncoderConfiguration.MarkAllAsUnactive(false, encoderGI); econfSO.active = true; //mark this as active SqliteEncoderConfiguration.Update(false, encoderGI, selectedName, econfSO); EncoderConfigurationWindowBox.updateGUIFromEncoderConfiguration(econfSO.encoderConfiguration); } }
void on_button_import_clicked(object o, EventArgs args) { Gtk.FileChooserDialog fc = new Gtk.FileChooserDialog(Catalog.GetString("Select file to import"), encoder_configuration, FileChooserAction.Open, Catalog.GetString("Cancel"), ResponseType.Cancel, Catalog.GetString("Accept"), ResponseType.Accept ); fc.Filter = new FileFilter(); fc.Filter.AddPattern("*.txt"); if (fc.Run() == (int)ResponseType.Accept) { try { string contents = Util.ReadFile(fc.Filename, false); if (contents != null && contents != "") { EncoderConfigurationSQLObject econfSO = new EncoderConfigurationSQLObject(contents); if (econfSO.encoderGI != encoderGI) { if (encoderGI == Constants.EncoderGI.GRAVITATORY) { new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Chronojump is currently in gravitory mode.") + "\n" + Catalog.GetString("Selected configuration is inertial.") + "\n\n" + Catalog.GetString("If you still want to import it, change to inertial mode.")); } else if (encoderGI == Constants.EncoderGI.INERTIAL) { new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Chronojump is currently in inertial mode.") + "\n" + Catalog.GetString("Selected configuration is gravitatory.") + "\n\n" + Catalog.GetString("If you still want to import it, change to gravitatory mode.")); } } else if (econfSO.name != null && econfSO.name != "") { //add more suffixes until name is unique econfSO.name = SqliteEncoderConfiguration.IfNameExistsAddSuffix(econfSO.name, "_" + Catalog.GetString("copy")); SqliteEncoderConfiguration.MarkAllAsUnactive(false, encoderGI); econfSO.active = true; SqliteEncoderConfiguration.Insert(false, econfSO); store.AppendValues(new string[] { econfSO.name, econfSO.description }); UtilGtk.TreeviewSelectRowWithName(treeview_select, store, colName, econfSO.name, true); } } } catch { LogB.Warning("Catched! Configuration cannot be imported"); new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error importing data.")); } } //Don't forget to call Destroy() or the FileChooserDialog window won't get closed. fc.Destroy(); }
private void apply(bool updateGUI) { //useful fo update SQL string selectedOldName = getSelectedName(); if (selectedOldName == "") { return; } string newName = entry_save_name.Text; if (newName != selectedOldName) { /* * if name has changed, then check if newname already exists on database * if exists add _copy recursively */ newName = SqliteEncoderConfiguration.IfNameExistsAddSuffix(newName, Catalog.GetString("copy")); } //update entry_save_name if needed if (newName != entry_save_name.Text) { entry_save_name.Text = newName; } //update SQL EncoderConfiguration econfOnGUI = GetAcceptedValues(); EncoderConfigurationSQLObject econfSO = new EncoderConfigurationSQLObject(-1, encoderGI, true, newName, econfOnGUI, entry_save_description.Text.ToString()); SqliteEncoderConfiguration.Update(false, encoderGI, selectedOldName, econfSO); if (updateGUI) { TreeModel model; TreeIter iter = new TreeIter(); treeview_select.Selection.GetSelected(out model, out iter); store.SetValue(iter, colName, newName); store.SetValue(iter, colDescription, entry_save_description.Text); } }