public void LoadSynDirectory() { string value = _appConfig.GetValue("syn_directory"); if (!string.IsNullOrEmpty(value)) { _synDirectory = JsonHelper.DeserializeJsonToObject <CSynDirectory>(value); } }
private void Main_Form_Load(object sender, EventArgs e) { _synFiles = new CSynFiles(this, _dbFile); // 同步文件的类 Random ran = new Random((int)DateTime.Now.Ticks); this.lbx_linux_dirs.HorizontalScrollbar = true; // 连接服务器 //Connnet(); // 初试话listView ColumnHeader ch = new ColumnHeader(); ch.Text = "文件名称"; //设置列标题 ch.Width = 400; //设置列宽度 ch.TextAlign = HorizontalAlignment.Left; //设置列的对齐方式 this.lvTask.Columns.Add(ch); //将列头添加到ListView控件。 this.lvTask.Columns.Add("linux目录", 500, HorizontalAlignment.Left); LoadComBox(); // 加载任务 // _dbFile.LoadTask(this.lvTask); _dbFile.LoadDir(this.lbx_linux_dirs); // 初始化树形目录 this.cmbDirs.Text = _dbFile.GetWindowRootPath(); TreeNode root = new TreeNode(); //根目录名称 root.Text = "目录"; //根目录路径 SynCommon.GetFiles(this.cmbDirs.Text, root, lvTask); tvFiles.Nodes.Clear(); foreach (TreeNode n in root.Nodes) { tvFiles.Nodes.Add(n); } _dbFile.SetWindowRootPath(this.cmbDirs.Text); // 加载当前同步目录 _dbFile.LoadSynDirectory(); CSynDirectory synDir = _dbFile._synDirectory; // 目录同步 foreach (CSynDirectoryItem item in synDir.lsItems) { CFileWatcher fileWatch = new CFileWatcher(this, item.win_dir, item.linux_dir); fileWatch._allFileWatch = _lsFileWatches; _lsFileWatches.Add(fileWatch); } }
private void FManaDirectory_FormClosed(object sender, FormClosedEventArgs e) { // 保存数据 CSynDirectory synDir = new CSynDirectory(); foreach (ListViewItem li in lvDir.Items) { CSynDirectoryItem item = new CSynDirectoryItem(); item.win_dir = li.Text; item.linux_dir = li.SubItems[1].Text; synDir.lsItems.Add(item); } _dbFile._synDirectory = synDir; _dbFile.SaveSynDirectory(); // 把结果保存到同步目录当中 List <CFileWatcher> lsFileWatches = _mainForm._lsFileWatches; foreach (CFileWatcher sss in lsFileWatches) { sss.Stop(); } lsFileWatches.Clear(); int i = 1; foreach (CSynDirectoryItem item in synDir.lsItems) { CFileWatcher fileWather = new CFileWatcher(_mainForm, item.win_dir, item.linux_dir); fileWather._allFileWatch = lsFileWatches; fileWather.id = i++; if (!IsIn(lsFileWatches, fileWather)) // 添加不在同步集合里面的 { lsFileWatches.Add(fileWather); if (_mainForm._isSyn) { fileWather.Start(); } } } }
private void FManaDirectory_Load(object sender, EventArgs e) { ColumnHeader ch = new ColumnHeader(); ch.Text = "winRoot目录"; //设置列标题 ch.Width = 400; //设置列宽度 ch.TextAlign = HorizontalAlignment.Left; //设置列的对齐方式 this.lvDir.Columns.Add(ch); //将列头添加到ListView控件。 this.lvDir.Columns.Add("linux目录", 500, HorizontalAlignment.Left); _dbFile.LoadSynDirectory(); lvDir.BeginUpdate(); //数据更新,UI暂时挂起,直到EndUpdate绘制控件,可以有效避免闪烁并大大提高加载速度 CSynDirectory synDir = _dbFile._synDirectory; // 目录同步 foreach (CSynDirectoryItem item in synDir.lsItems) { ListViewItem lvi = new ListViewItem(); lvi.Text = item.win_dir; lvi.SubItems.Add(item.linux_dir); lvDir.Items.Add(lvi); } lvDir.EndUpdate(); //结束数据处理,UI界面一次性绘制。 }