Esempio n. 1
0
    //---- end of spin_exhibition_group stuff
    private void on_button_exhibition_select_clicked(object o, EventArgs args)
    {
        //select session
        string newSessionName = string.Format("{0}-{1}", spin_exhibition_school.Value, spin_exhibition_group.Value);

        if (currentSession == null || currentSession.Name != newSessionName)
        {
            currentSession = SqliteSession.SelectByName(newSessionName);
            on_load_session_accepted();
            sensitiveGuiYesSession();
        }

        //select person
        int rowToSelect = myTreeViewPersons.FindRow(Convert.ToInt32(spin_exhibition_id.Value));

        if (rowToSelect != -1)
        {
            selectRowTreeView_persons(treeview_persons, rowToSelect);
            sensitiveGuiYesPerson();
        }
    }
Esempio n. 2
0
    private void configInit()
    {
        //trying new Config class
        Config config = new Config();

        config.Read();
        LogB.Information("Config:\n" + config.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 (config.Maximized)
        {
            app1.Maximize();
        }
        if (config.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
            //88 then buttons will be the same height than button_encoder_select. The 8 extra is for the vertical space
            button_encoder_capture.SetSizeRequest(125, 88);
            //button_encoder_capture.HeightRequest = 88;

            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 (!config.UseVideo)
        {
            useVideo = false;
            alignment_video_encoder.Visible = false;
        }

        //Auto-detect stuff
        configAutodetectPort = config.AutodetectPort;

        autodetectSignalEnabled = false;         //do not raise signals that could rewrite the config file (loop)

        if (configAutodetectPort == Config.AutodetectPortEnum.ACTIVE)
        {
            radio_autodetect_active.Active = true;
        }
        else if (configAutodetectPort == Config.AutodetectPortEnum.INACTIVE)
        {
            radio_autodetect_inactive.Active = true;
        }
        else         // (configAutodetectPort == Config.AutodetectPortEnum.DISCARDFIRST)
        {
            radio_autodetect_discard_first.Active = true;
        }

        autodetectSignalEnabled = true;         //activate signals again


        //show only power
        if (config.OnlyEncoderGravitatory)
        {
            select_menuitem_mode_toggled(menuitem_modes.POWERGRAVITATORY);
        }
        else if (config.OnlyEncoderInertial)
        {
            select_menuitem_mode_toggled(menuitem_modes.POWERINERTIAL);
        }

        if (config.EncoderCaptureShowOnlyBars)
        {
            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 = config.EncoderUpdateTreeViewWhileCapturing;

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

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

        if (config.Econf != null)
        {
            encoderConfigurationDefinedFromFile = true;
            encoderConfigurationCurrent         = config.Econf;
            encoderConfigurationGUIUpdate();
            //TODO: allow to see full data, but don't allow to change it (Open window content as unsensitive)
        }

        if (config.SessionMode == Config.SessionModeEnum.UNIQUE)
        {
            main_menu.Visible = false;
            button_preferences_not_menu.Visible = true;

            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");
            }

            on_load_session_accepted();
        }

        //TODO
        //RunScriptOnExit

        /*
         * if(linuxType == linuxTypeEnum.NETWORKS) {
         *      //mostrar directament el power
         *      select_menuitem_mode_toggled(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;
         * }
         */
    }
Esempio n. 3
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);
    }