35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
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();
|
||
}
|
||
}
|
||
} |