private void rightListFiles_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { MyViewItem item = (MyViewItem)rightListFiles.SelectedItem; itemActivate(item, rightListFiles, RIGHT); } }
private void leftListFiles_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { MyViewItem item = (MyViewItem)leftListFiles.SelectedItem; itemActivate(item, leftListFiles, LEFT); } }
private void itemActivate(MyViewItem item, ListView listFiles, string side) { string path = side == LEFT ? leftPath : rightPath; if (item != null & item.Name == ". . .") { int ind = path.LastIndexOf("\\"); if (path.Length > 4 & ind > -1 & path[path.Length - 1] != '\\') { path = path.Substring(0, ind); } if (path.Length < 3) { path += SLASHES; } changePath(path, side); BuildList(path, listFiles); return; } if (item != null) { DirectoryInfo DirInfo = new DirectoryInfo(path); if (DirInfo.Root.ToString() != DirInfo.FullName.ToString()) { path += SLASHES; } string filePath = path + item.Name; if (isFile(filePath)) { try { System.Diagnostics.Process.Start(filePath); } catch (Exception ex) { MessageBox.Show(ex.StackTrace); } } else { path += item.Name; changePath(path, side); BuildList(path, listFiles); } } }
private void rightListFiles_MouseDoubleClick(object sender, MouseButtonEventArgs e) { MyViewItem item = (MyViewItem)rightListFiles.SelectedItem; itemActivate(item, rightListFiles, RIGHT); }
private void leftListFiles_MouseDoubleClick(object sender, MouseButtonEventArgs e) { MyViewItem item = (MyViewItem)leftListFiles.SelectedItem; itemActivate(item, leftListFiles, LEFT); }
private void BuildList(string path, ListView listFiles) { listFiles.ItemsSource = null; listFiles.Items.Clear(); var list = new System.Collections.Generic.List <MyViewItem>(); foreach (DirectoryInfo dir in MyFile.GetFolders(path)) { if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } listFiles.View = MyGridView.CreateGridView(); list.Add(new MyViewItem { MyIcon = getIcon(dir.FullName), Name = dir.Name, Type = "<DIR>", Size = " ", Date = dir.LastAccessTime.ToShortDateString() + " " + dir.LastAccessTime.ToShortTimeString() }); } foreach (FileInfo file in MyFile.GetFiles(path)) { if ((file.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } listFiles.View = MyGridView.CreateGridView(); list.Add(new MyViewItem { MyIcon = getIcon(file.FullName), Name = file.Name, Type = file.Extension.Replace(".", ""), Size = Math.Round((file.Length / 1024f)).ToString() + " Kb", Date = file.LastAccessTime.ToShortDateString() + " " + file.LastAccessTime.ToShortTimeString() }); } string pathTmp; if (listFiles.Name == "leftListFiles") { pathTmp = leftPath; } else { pathTmp = rightPath; } DirectoryInfo DirInfo = new DirectoryInfo(pathTmp); MyViewItem noRootItem = new MyViewItem { MyIcon = null, Name = ". . .", Type = "", Size = "", Date = "" }; if (DirInfo.Root.ToString() != DirInfo.FullName.ToString()) { listFiles.View = MyGridView.CreateGridView(); list.Insert(0, noRootItem); } listFiles.ItemsSource = list; listFiles.SelectedIndex = 0; }