1. Iteration of the Copy Function

2. Settings Tap
3. XML TAB
This commit is contained in:
Black_Betty committed 2026-10-04 20:29:33 +02:00
1 parent 33153f9448
commit abab3612f2
5 files changed
+499 -10

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
using System;
using System.IO;
using System.Windows.Controls;
using System.Windows;
namespace TapeCatalog.Methods
{
// Reusable helper methods for copy-related UI functionality
public static class CopyMethods
{
public static void PopulateTree(TreeView tree, string path)
{
if (tree == null) return;
tree.Items.Clear();
if (string.IsNullOrWhiteSpace(path) || !Directory.Exists(path)) return;
var rootDir = new DirectoryInfo(path);
var rootItem = CreateDirectoryNode(rootDir);
rootItem.IsExpanded = true;
tree.Items.Add(rootItem);
}
public static TreeViewItem CreateDirectoryNode(DirectoryInfo dir)
{
var item = new TreeViewItem { Header = dir.Name, Tag = dir.FullName };
try
{
foreach (var sub in dir.GetDirectories())
{
item.Items.Add(CreateDirectoryNode(sub));
}
foreach (var f in dir.GetFiles())
{
var fileItem = new TreeViewItem { Tag = f.FullName };
var sp = new StackPanel { Orientation = Orientation.Horizontal };
var cb = new CheckBox { VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 0, 4, 0) };
var tb = new TextBlock { Text = f.Name, VerticalAlignment = VerticalAlignment.Center };
sp.Children.Add(cb);
sp.Children.Add(tb);
fileItem.Header = sp;
item.Items.Add(fileItem);
}
}
catch
{
// ignore access exceptions
}
return item;
}
}
}