Exemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //初始化变量
            selectSourcePath        = "";
            selectTargetPath        = "";
            subDirectoryList        = new List <string>();
            copyFilePathMap         = new HashSet <string>();
            fileTypeMap             = new HashSet <string>();
            selectedSubDirectoryMap = new HashSet <string>();
            selectedFileTypeMap     = new HashSet <string>();
            subDirectoryIndexList   = new List <int>();
            filePathList            = new List <List <string> >();
            fileNameList            = new List <List <string> >();

            //创建配置文件
            ca = new ConfigAccess("config.ini");
            selectSourcePath = ca.GetString("selectSourcePath");
            selectTargetPath = ca.GetString("selectTargetPath");
            this.IncludeKeywordTextBox.Text = ca.GetString("HsKeyword");

            //初始化界面
            this.SelectSourcePathTextBox.Text = selectSourcePath;
            this.SelectTargetPathTextBox.Text = selectTargetPath;
            if (!selectSourcePath.Trim().Equals(""))
            {
                UpdatesubDirectoryListBox();
            }
            //初始化文件类型勾选
            if (fileTypeMap.Count > 0)
            {
                String fileTypeStr = ca.GetString("HsFileTpye").Trim();
                if (!fileTypeStr.Equals(""))
                {
                    string[] fileTypeArr = fileTypeStr.Split(new char[] { '|' });
                    for (int i = 0; i < FileTypeListBox.Items.Count; i++)
                    {
                        String itemStr = FileTypeListBox.GetItemText(FileTypeListBox.Items[i]);
                        foreach (var fileType in fileTypeArr)
                        {
                            if (itemStr.Equals(fileType))
                            {
                                FileTypeListBox.SetItemChecked(i, true);
                                break;
                            }
                        }
                    }
                    updateSelectFileTypeList();
                }
            }
            //初始化子目录勾选
            if (subDirectoryList.Count > 0)
            {
                String subDirectoryStr = ca.GetString("HsSubDirectory").Trim();
                if (!subDirectoryStr.Equals(""))
                {
                    string[] subDirectoryArr = subDirectoryStr.Split(new char[] { '|' });
                    for (int i = 0; i < SubDirectoryListBox.Items.Count; i++)
                    {
                        String itemStr = SubDirectoryListBox.GetItemText(SubDirectoryListBox.Items[i]);
                        foreach (var subDirectory in subDirectoryArr)
                        {
                            if (itemStr.Equals(subDirectory))
                            {
                                SubDirectoryListBox.SetItemChecked(i, true);
                                break;
                            }
                        }
                    }
                    updateSelectSubDirectoryList();
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="key"></param>
 /// <param name="section"></param>
 /// <returns></returns>
 public static string ReadValue(string key, string section = "Others")
 {
     return(ca.GetString(section, key));
 }