예제 #1
0
        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();
                    }
                }
            }
        }