Ejemplo n.º 1
0
    private void configInit()
    {
        //trying new Config class
        configChronojump = new Config();
        configChronojump.Read();
        LogB.Information("Config:\n" + configChronojump.ToString());

        /*
         * TODO: do an else to any option
         * is good to do the else here because user can import a configuration at any time
         * and things need to be restored to default position in glade
         *
         * But note this has to be executed only if it has changed!!
         */

        if (configChronojump.Maximized)
        {
            app1.Maximize();
        }
        if (configChronojump.CustomButtons)
        {
            //---- capture tab ----

            hbox_encoder_capture_extra_mass_no_raspberry.Visible = false;
            hbox_encoder_capture_extra_mass_raspberry.Visible    = true;

            button_encoder_select.HeightRequest = 40;
            //this will make all encoder capture controls taller
            button_encoder_capture.SetSizeRequest(125, 60);

            spin_encoder_im_weights_n.Visible = false;
            hbox_encoder_im_weights_n.Visible = true;

            //---- analyze tab ----

            hbox_encoder_analyze_signal_or_curves.HeightRequest = 40;
            button_encoder_analyze.SetSizeRequest(120, 40);
        }
        if (!configChronojump.UseVideo)
        {
            alignment_video_encoder.Visible = false;
        }

        //show only power
        if (configChronojump.OnlyEncoderGravitatory)
        {
            select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERGRAVITATORY);
        }
        else if (configChronojump.OnlyEncoderInertial)
        {
            select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERINERTIAL);
        }

        if (configChronojump.EncoderCaptureShowOnlyBars)
        {
            //attention: this makes encoder_capture_signal_drawingarea == null
            vpaned_encoder_capture_video_and_set_graph.Visible = false;

            vpaned_encoder_main.Remove(alignment_treeview_encoder_capture_curves);
            vbox_treeview_encoder_at_second_page.PackStart(alignment_treeview_encoder_capture_curves);
            notebook_encoder_capture_main.ShowTabs = true;
        }
        else
        {
            /*
             * is good to do the else here because user can import a configuration at any time
             * and things need to be restored to default position in glade
             *
             * But note this has to be executed only if it has changed!!
             */
            /*
             * notebook_encoder_capture_main.ShowTabs = false;
             * vbox_treeview_encoder_at_second_page.Remove(alignment_treeview_encoder_capture_curves);
             * vpaned_encoder_main.PackStart(alignment_treeview_encoder_capture_curves);
             */
        }

        encoderUpdateTreeViewWhileCapturing = configChronojump.EncoderUpdateTreeViewWhileCapturing;

        if (configChronojump.PersonWinHide)
        {
            //vbox_persons.Visible = false;
            notebook_session_person.Visible = false;
            hbox_encoder_person.Visible     = true;
        }

        if (configChronojump.EncoderAnalyzeHide)
        {
            hbox_encoder_sup_capture_analyze_two_buttons.Visible = false;
        }

        if (configChronojump.SessionMode == Config.SessionModeEnum.UNIQUE || configChronojump.SessionMode == Config.SessionModeEnum.MONTHLY)
        {
            main_menu.Visible = false;
            app1.Decorated    = false;
            hbox_menu_and_preferences_outside_menu.Visible = true;

            if (configChronojump.SessionMode == Config.SessionModeEnum.UNIQUE)
            {
                if (!Sqlite.Exists(false, Constants.SessionTable, "session"))
                {
                    //this creates the session and inserts at DB
                    currentSession = new Session(
                        "session", "", DateTime.Today,                                  //name, place, dateTime
                        Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID,
                        "", Constants.ServerUndefinedID);                               //comments, serverID
                }
                else
                {
                    currentSession = SqliteSession.SelectByName("session");
                }
            }
            else
            {
                //configChronojump.SessionMode == Config.SessionModeEnum.MONTHLY

                string yearMonthStr = UtilDate.GetCurrentYearMonthStr();
                LogB.Information("yearMonthStr: " + yearMonthStr);
                if (!Sqlite.Exists(false, Constants.SessionTable, yearMonthStr))
                {
                    //this creates the session and inserts at DB
                    currentSession = new Session(
                        yearMonthStr, "", DateTime.Today,                                 //name, place, dateTime
                        Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, Constants.LevelUndefinedID,
                        "", Constants.ServerUndefinedID);                                 //comments, serverID

                    //insert personSessions from last month
                    string yearLastMonthStr = UtilDate.GetCurrentYearLastMonthStr();
                    if (Sqlite.Exists(false, Constants.SessionTable, yearLastMonthStr))
                    {
                        Session s = SqliteSession.SelectByName(yearLastMonthStr);

                        //import all persons from last session
                        List <PersonSession> personSessions = SqlitePersonSession.SelectPersonSessionList(s.UniqueID);

                        //convert all personSessions to currentSession
                        //and nullify UniqueID in order to be inserted incrementally by SQL
                        foreach (PersonSession ps in personSessions)
                        {
                            ps.UniqueID  = -1;
                            ps.SessionID = currentSession.UniqueID;
                        }


                        //insert personSessions using a transaction
                        new SqlitePersonSessionTransaction(personSessions);
                    }
                }
                else
                {
                    currentSession = SqliteSession.SelectByName(yearMonthStr);
                }
            }

            on_load_session_accepted();
        }

        //TODO
        //RunScriptOnExit

        /*
         * if(linuxType == linuxTypeEnum.NETWORKS) {
         *      //mostrar directament el power
         *      select_menuitem_mode_toggled(Constants.Menuitem_modes.POWER);
         *
         *      //no mostrar menu
         *      main_menu.Visible = false;
         *
         *      //no mostrar persones
         *      //vbox_persons.Visible = false;
         *      //TODO: rfid can be here, also machine, maybe weight, other features
         *      //time, gym, ...
         *
         *      //show rfid
         *      hbox_rfid.Visible = true;
         *
         *      //to test display, just make sensitive the top controls, but beware there's no session yet and no person
         *      notebook_sup.Sensitive = true;
         *      hbox_encoder_sup_capture_analyze.Sensitive = true;
         *      notebook_encoder_sup.Sensitive = false;
         * }
         */

        hbox_rfid.Visible = (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.LINUX);
    }