private void btnfresh_Click(object sender, EventArgs e) { _mTreeExpand.Clear();//清空扩展信息 // 记录树结构 Point pos = tvFiles.AutoScrollOffset; foreach (TreeNode n in tvFiles.Nodes) { ForeachTree(n, "", 4); } 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); // 恢复树结构 foreach (TreeNode n in tvFiles.Nodes) { ForeachTree(n, "", 5); } tvFiles.AutoScrollOffset = pos; }
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 cmbDirs_SelectedIndexChanged(object sender, EventArgs e) { if (cmbDirs.Text != "") { 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); lbx_linux_dirs.Items.Clear(); _dbFile.LoadDir(lbx_linux_dirs); } }
// 刷新界面所有的数据 private void RefushAll() { 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); }
private void btnSelectDir_Click(object sender, EventArgs e) { this.cmbDirs.Text = _dbFile.GetWindowRootPath(); this.folderBrowserDialog1.SelectedPath = this.cmbDirs.Text; if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK) { this.cmbDirs.Text = this.folderBrowserDialog1.SelectedPath; 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.LoadDir(lbx_linux_dirs); LoadComBox(); } }