private void LoadLocalData(string localDirPath) { try { List <LocalEntry> UpdateLocalEntries = new List <LocalEntry>(); if (localDirPath != pathTextBox.Text) { DirectoryInfo di = new DirectoryInfo(localDirPath); LocalEntry de = new LocalEntry("...", di.Parent.FullName, null, null, EntryType.Cartella, new Uri("pack://application:,,,/images/OpenFolder.png")); UpdateLocalEntries.Add(de); } foreach (string d in Directory.GetDirectories(localDirPath)) { DirectoryInfo di = new DirectoryInfo(d); LocalEntry de = new LocalEntry(di.Name, di.FullName, null, di.LastWriteTime.ToString(), EntryType.Cartella, new Uri("pack://application:,,,/images/Folder.png")); UpdateLocalEntries.Add(de); } foreach (string f in Directory.GetFiles(localDirPath)) { FileInfo fi = new FileInfo(f); LocalEntry de = new LocalEntry(fi.Name, fi.FullName, (fi.Length >> 10).ToString(), fi.LastWriteTime.ToString(), EntryType.File, new Uri("pack://application:,,,/images/File.png")); UpdateLocalEntries.Add(de); } localDir.Tag = localDirPath; // Update current directory of Local Data Grid localEntries = UpdateLocalEntries; localDir.ItemsSource = localEntries; } catch (Exception err) { // rivedere gestione eccezioni e log file eventLogConsole.AppendText(new LogMessage("Source: " + err.Source + " Msg: " + err.Message, DateTime.Now).ToString()); eventLogConsole.ScrollToEnd(); } }
private void Row_MouseDoubleClick(object sender, MouseButtonEventArgs e) { DataGridRow row = sender as DataGridRow; LocalEntry entry = row.DataContext as LocalEntry; if (entry.Type == EntryType.Cartella) { if (Directory.Exists(entry.Fullpath)) { LoadLocalData(entry.Fullpath); } else { MessageBox.Show("Impossibile accedere alla cartella selezionata."); LoadLocalData(localDir.Tag.ToString()); // ricarica la UI nel caso in cui una cartella non esiste piĆ¹ } } }