Ejemplo n.º 1
0
    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);
        }
    }
    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();
    }
Ejemplo n.º 3
0
    private void fillTreeView(List <EncoderConfigurationSQLObject> list, EncoderConfigurationSQLObject currentSO)
    {
        foreach (EncoderConfigurationSQLObject econfSO in list)
        {
            store.AppendValues(new string[] { econfSO.name, econfSO.description });
        }

        UtilGtk.TreeviewSelectRowWithName(treeview_select, store, colName, currentSO.name, true);
    }