private void ReLoadDirectory() { if (isDirectory) { string[] IGNORE_FILENAME = new string[] { ".", ".." }; SftpFile[] files; files = WindowMain.current?.enableConnect?.sshManager?.PullListInDirectory(Path); if (files == null) { Icon = "/CofileUI;component/Resources/directory_deny.png"; return; } Icon = "/CofileUI;component/Resources/directory.png"; if (Children.Count > 0) { return; } Children.Clear(); int count_have_directory = 0; foreach (var file in files) { int i; for (i = 0; i < IGNORE_FILENAME.Length; i++) { if (file.Name == IGNORE_FILENAME[i]) { break; } } if (i != IGNORE_FILENAME.Length) { continue; } LinuxFileModel lfm_child; if (file.IsDirectory) { lfm_child = new LinuxFileModel(viewModel) { Path = file.FullName, FileInfo = file, IsDirectory = true, FileName = file.Name }; Children.Insert(count_have_directory++, lfm_child); } else { lfm_child = new LinuxFileModel(viewModel) { Path = file.FullName, FileInfo = file, IsDirectory = false, FileName = file.Name }; Children.Add(lfm_child); } } } }
public LinuxFileViewModel(UserControl _view) { view = _view; LinuxFileModel root = new LinuxFileModel(this) { Path = "/", IsDirectory = true, FileName = "/" }; LinuxFileTree.Add(root); }
private int SetConfigInfo(string path, string config_info) { if (path == null || path.Length <= 0 || path[0] != '/') { return(-1); } string[] path_names = path.Split('/'); if (path != null) { LinuxFileModel lt_cur = LinuxFileTree[0]; for (int i = 0; i < path_names.Length; i++) { if (lt_cur != null && path_names[i].Length > 0) { ObservableCollection <LinuxFileModel> children = lt_cur.Children; lt_cur = null; if (children != null) { int j; for (j = 0; j < children.Count; j++) { if (children[j].FileName == path_names[i]) { lt_cur = children[j]; if (i == path_names.Length - 1) { children[j].BackGroundColor = Brushes.LightGreen; children[j].ConfigIndex = config_info; } else { children[j].BackGroundColor = Brushes.LightCyan; } break; } } if (j == children.Count) { return(-2); } } } } } return(0); }
public int RefreshLinuxFileTree(string path) { if (LinuxFileTree.Count == 0) { return(0); } LinuxFileModel lfm_cur = LinuxFileTree[0]; if (lfm_cur != null) { lfm_cur.IsExpanded = true; } string[] names = path.Split('/'); if (names != null) { for (int i = 0; i < names.Length; i++) { if (names[i] == null || names[i].Length == 0) { continue; } for (int j = 0; j < lfm_cur.Children.Count; j++) { if (names[i] == lfm_cur.Children[j]?.FileName) { lfm_cur = lfm_cur.Children[j]; lfm_cur.IsExpanded = true; break; } } } } RefreshConfigInfo(); return(0); }