Esempio n. 1
0
        /// <summary>
        /// Loads the configuration parameters from the config file
        /// </summary>
        public void LoadConfiguration()
        {
            string value = string.Empty;

            // Check for folder at startup
            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.user], MainOptionSText[(int)ToolConfOptions.skip_remote_folder], userconf_filepath).ToLower();
            if (value.Contains("true"))
            {
                options.skip_remote_folder_check = true;
            }


            // check for Tools
            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.user], MainOptionSText[(int)ToolConfOptions.skip_remote_tool_folder], userconf_filepath).ToLower();
            if (value.Contains("true"))
            {
                options.skip_remote_folder_tools = true;
            }

            // Set to auto flash
            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.user], MainOptionSText[(int)ToolConfOptions.always_flash], userconf_filepath).ToLower();
            if (value.Contains("true"))
            {
                options.always_auto_flash = true;
            }

            // Sets to ask to save always or not
            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.user], MainOptionSText[(int)ToolConfOptions.always_ask_to_save], userconf_filepath).ToLower();
            if (value.Contains("true"))
            {
                options.always_ask_save = true;
            }

            // Set the default save dir
            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.user], MainOptionSText[(int)ToolConfOptions.default_save_folder], userconf_filepath).ToLower();
            if (value != string.Empty || value != null)
            {
                options.default_save_folder_path = value;
            }

            // Set the default work folder
            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.user], MainOptionSText[(int)ToolConfOptions.default_working_folder], userconf_filepath).ToLower();
            if (value != string.Empty || value != null)
            {
                options.default_working_folder_path = value;
            }

            // Get the active dir
            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.user], MainOptionSText[(int)ToolConfOptions.active_working_folder], userconf_filepath).ToLower();
            if (value != string.Empty || value != null)
            {
                options.active_working_folder_path = value;
            }

            // Get active save dir
            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.user], MainOptionSText[(int)ToolConfOptions.active_save_folder], userconf_filepath).ToLower();
            if (value != string.Empty || value != null)
            {
                options.active_save_folder_path = value;
            }

            // Get the Flashing tool to use always
            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.user], MainOptionSText[(int)ToolConfOptions.default_flash_tool], userconf_filepath).ToLower();
            for (int i = 0; i < flash_tool_names.Length; i++)
            {
                if (value.Contains(flash_tool_names[i].ToLower()))
                {
                    options.default_flash_tool = i;
                }
            }

            // Tool : default remote paths
            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.tool], MainOptionSText[(int)ToolConfOptions.default_flashfolders_path], userconf_filepath).ToLower();
            if (value != string.Empty || value != null)
            {
                options.default_srv_flash_path = value;
            }

            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.tool], MainOptionSText[(int)ToolConfOptions.default_common_tool_path], userconf_filepath).ToLower();
            if (value != string.Empty || value != null)
            {
                options.default_srv_tool_path = value;
            }

            value = IniFileHelper.ReadValue(ConfigSectionsText[(int)ConfigSections.tool], MainOptionSText[(int)ToolConfOptions.default_ssf_path], userconf_filepath).ToLower();
            if (value != string.Empty || value != null)
            {
                options.default_srv_ssf_path = value;
            }


            OptMeessage = "Load Configuration from file";
        }