Beispiel #1
0
 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 { }
 }
Beispiel #2
0
        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);
        }
Beispiel #3
0
 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);
     }
 }
Beispiel #4
0
        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));
        }
Beispiel #5
0
 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));
             }
         }
     }
 }
Beispiel #6
0
 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);
         }
     }
 }
Beispiel #7
0
 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);
         }
     }
 }
Beispiel #8
0
 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 { }
 }
Beispiel #9
0
 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 { }
 }