コード例 #1
0
ファイル: MainForm.cs プロジェクト: dalinhuang/janalyzer-nap
        /// <summary>
        /// Refresh the form inputs with the specified application configuration
        /// </summary>
        /// <param name="appConfig">the application configuration entity</param>
        private void updateForm(ApplicationConfig appConfig)
        {
            if (appConfig != null)
            {
                this.txtFile.Text = appConfig.NmapFile;
                this.txtExportFolder.Text = appConfig.ExportFolder;

                if (this.txtFile.Text.Trim() != "")
                {
                    string fileName = Path.GetFileNameWithoutExtension(this.txtFile.Text.Trim());
                    if (ApplicationConfig.AppConfig.FilterNames.ContainsKey("rule_" + fileName))
                    {
                        this.txtAllowedItemPatterns.Text = ApplicationConfig.AppConfig.FilterNames["rule_" + fileName];
                    }
                }

            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: dalinhuang/janalyzer-nap
        /// <summary>
        /// Loads the configuration from the config.ini file.
        /// </summary>
        /// <returns>the application configuration entity</returns>
        private ApplicationConfig loadConfig()
        {
            if (FileHelper.isFileExisted(ApplicationConfig.APP_CONFIG_FILE))
            {
                ApplicationConfig config = new ApplicationConfig();

                config.NmapFile = ApplicationConfig.IniHelper.ReadValue(ApplicationConfig.SECTION_GENERAL, "nmapFile");
                config.ExportFolder = ApplicationConfig.IniHelper.ReadValue(ApplicationConfig.SECTION_GENERAL, "exportFolder");

                StringCollection collections = ApplicationConfig.IniHelper.ReadSection(ApplicationConfig.SECTION_GENERAL);
                foreach (string key in collections)
                {
                    if (key.StartsWith("rule_"))
                    {
                        config.FilterNames.Add(key, ApplicationConfig.IniHelper.ReadValue(ApplicationConfig.SECTION_GENERAL, key));
                    }
                }

                return config;
            }

            return null;
        }