private void fillTree(String fullPath, DirItem parent) { try { String[] dirs = Directory.GetDirectories(fullPath); foreach (String dir in dirs) { if (new DirectoryInfo(dir).Attributes.HasFlag(FileAttributes.Hidden) != true) { DirItem DI = new DirItem(System.IO.Path.GetFileName(dir), dir); try { if (Directory.GetDirectories(dir).Length > 0) { DI.Nodes.Add(new DirItem("1")); } } catch { DI.Nodes.Add(new DirItem("1")); } parent.Nodes.Add(DI); } else { continue; } } } catch { } }
private void treeView_Expanded(object sender, RoutedEventArgs e) { TreeViewItem tmp = (TreeViewItem)e.OriginalSource; DirItem DI = (DirItem)tmp.Header; DI.Nodes.Clear(); this.fillTree(DI.fullPath, DI); }
public MainWindow() { InitializeComponent(); String[] drives = Directory.GetLogicalDrives(); foreach (String drive in drives) { DirItem DI = new DirItem(drive, drive); DI.Nodes.Add(new DirItem("1")); this.treeView.Items.Add(DI); } }
private void listView_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { ListView temp = sender as ListView; if (temp.SelectedIndex == -1) { return; } DirItem di = (DirItem)temp.Items[temp.SelectedIndex]; mainImage.Source = BitmapFrame.Create(new Uri(@di.fullPath)); }
private void buttonForward_Click(object sender, RoutedEventArgs e) { if (treeView.SelectedItem == null) { MessageBox.Show("Невозможно выполнить действие. Папка не выбрана", " Ошибка выполнения", MessageBoxButton.OK, MessageBoxImage.Error); return; } else { if (sender == button1Forward) { try { DirItem DI = (DirItem)treeView.SelectedItem; String[] files = Directory.GetFiles(DI.fullPath); List <DirItem> temp = new List <DirItem>(); foreach (String file in files) { String extension = Path.GetExtension(file); if (extension == ".png" || extension == ".bmp" || extension == ".jpg" || extension == ".svg") { DirItem adding = new DirItem(Path.GetFileName(file), file); listView3.Items.Add(adding); temp.Add(adding); } } if (temp.Count != 0) { listView2.Items.Add(new LoadedFile(DI.fileName, temp)); } } catch { } } if (sender == button2Forward) { System.Collections.IList dir = (System.Collections.IList)listView1.SelectedItems; String tempName = ""; List <DirItem> temp = new List <DirItem>(); foreach (object obj in dir) { DirItem diItem = obj as DirItem; tempName += diItem.fileName + " "; temp.Add(diItem); listView3.Items.Add(diItem); } if (temp.Count != 0) { listView2.Items.Add(new LoadedFile(tempName, temp)); } } } }
private void treeView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { DirItem DI = (DirItem)treeView.SelectedItem; if (DI == null) { return; } foreach (DirItem di in listView1.Items) { listView2.Items.Add(di); } } }
private void listView_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { if (sender == listView1) { DirItem di = (DirItem)listView1.SelectedItem; listView2.Items.Add(di); } if (sender == listView2) { DirItem di = (DirItem)listView2.SelectedItem; listView2.Items.Remove(di); } } }
private void treeView_Selected(object sender, RoutedEventArgs e) { mainImage.Source = null; try { TreeViewItem tmp = (TreeViewItem)e.OriginalSource; DirItem DI = (DirItem)tmp.Header; listView1.Items.Clear(); String[] files = Directory.GetFiles(DI.fullPath); foreach (String file in files) { String extension = Path.GetExtension(file).ToLower(); if (extension == ".png" || extension == ".bmp" || extension == ".jpg") { listView1.Items.Add(new DirItem(System.IO.Path.GetFileName(file), file)); } } } catch { } }
private void buttonForward_Click(object sender, RoutedEventArgs e) { try { DirItem DI = (DirItem)treeView.SelectedItem; String[] files = Directory.GetFiles(DI.fullPath); List <DirItem> temp = new List <DirItem>(); foreach (String file in files) { String extension = Path.GetExtension(file).ToLower(); if (extension == ".png" || extension == ".bmp" || extension == ".jpg") { DirItem adding = new DirItem(Path.GetFileName(file), file); listView2.Items.Add(adding); temp.Add(adding); } } } catch { } }