private void DownLoadImg_Load(object sender, EventArgs e) { this.initHotKey(); string dir = AppCfg.getItem(AppCfg.localImgDir); if (dir != null) { this.localDirTextBox.Text = dir; } }
public static EnumGenType genType = EnumGenType.All; // 生成的类型 public static void init() { // 生成的类型 string genType = AppCfg.getItem(AppCfg.genType); if (genType == null) { AppData.genType = EnumGenType.All; } else { AppData.genType = (EnumGenType)int.Parse(genType); } }
private void FormMain_Load(object sender, EventArgs e) { //更新标题: 工具的目录 this.Text += " - exe: " + AppData.exePath; this.rootDirComboBox.Items.Add("-- 文件夹列表 --"); AppData.init(); //初始化文件夹下边的 数据 this.InitDirectory(); this.initGenTypeCombox(); // listDir 处理 if (this.rootListDir.Count > 0) { for (int i = 0; i < this.rootListDir.Count; i++) { this.rootDirComboBox.Items.Add(this.rootListDir[i]); } // 加载上次保存的selectIndex string indexStr = AppCfg.getItem(AppCfg.selectIndex); int index = 0; if (indexStr != null) { index = int.Parse(indexStr); } if (index > this.rootDirComboBox.Items.Count - 1) { index = 0; } this.rootDirComboBox.SelectedIndex = index; } // bat 文件配置 string cfgBatName = AppCfg.getItem(AppCfg.batFilePath); if (cfgBatName != null) { this.batPathTextBox.Text = cfgBatName; } // 隐藏窗口的定时器 this.hideWinTimer.Start(); //this.Top = 0; }
// 选择bat文件 private void selectBatBtn_Click(object sender, EventArgs e) { OpenFileDialog fileDlg = new OpenFileDialog(); fileDlg.Title = "请选择bat文件"; fileDlg.Filter = "bat文件|*.bat|所有文件|*.*"; string cfgBatPath = AppCfg.getItem("batPath"); if (cfgBatPath == null)// 目录为空 { // 去json目录找 string path = AppData.exePath; int selectIndex = this.rootDirComboBox.SelectedIndex; if (selectIndex > 0) { // 选中了目录文件 string dir = this.rootListDir[selectIndex - 1]; path = AppData.exePath + "\\" + dir + "\\json"; } fileDlg.InitialDirectory = path; } else { fileDlg.InitialDirectory = cfgBatPath; } fileDlg.Multiselect = false; DialogResult result = fileDlg.ShowDialog(); if (result == DialogResult.OK) { string filename = System.IO.Path.GetFileName(fileDlg.FileName); //得到文件名 string filepach = System.IO.Path.GetDirectoryName(fileDlg.FileName); //得到路径 this.batPathTextBox.Text = fileDlg.FileName; AppCfg.setItem("batFile", fileDlg.FileName); AppCfg.setItem("batPath", filepach); } }