GetHrzWpf/SelectUsbWindow.xaml.cs
2025-12-25 13:47:13 +05:00

35 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
using System.IO;
using System.Windows;
namespace GetHrzWPF
{
public partial class SelectUsbWindow : Window
{
public DriveInfo SelectedDrive { get; private set; }
public SelectUsbWindow()
{
InitializeComponent();
}
public SelectUsbWindow(List<DriveInfo> usbDrives) : this()
{
DriveCombo.ItemsSource = usbDrives;
// Чтобы ComboBox показывал "E:\ (Label)" — проще всего положить строки,
// но можно и DriveInfo + DisplayMemberPath.
// Оставим DriveInfo, а отображение зададим через ToString().
if (usbDrives.Count > 0)
DriveCombo.SelectedIndex = 0;
}
private void OnConfirmClick(object sender, RoutedEventArgs e)
{
SelectedDrive = DriveCombo.SelectedItem as DriveInfo;
DialogResult = SelectedDrive != null;
Close();
}
}
}