Skip to content

Commit 7e9a086

Browse files
Merge pull request #1 from tfslabs/new-version
[PR 1/3] Discrete Device Assignment Phase
2 parents 36052d8 + 50a9576 commit 7e9a086

40 files changed

+3038
-115
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/workflows/codeql.yml

Lines changed: 0 additions & 96 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,6 @@ FodyWeavers.xsd
398398

399399
# JetBrains Rider
400400
*.sln.iml
401+
402+
# Visual Studio Code
403+
.vscode/*

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule ".wiki"]
2+
path = .wiki
3+
url = https://github.com/tfslabs/dda-gui.wiki.git

.wiki

Submodule .wiki added at c571e69

About.xaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Window x:Class="TheFlightSims.HyperVDPD.About"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:TheFlightSims.HyperVDPD"
7+
mc:Ignorable="d"
8+
Title="About"
9+
Height="150"
10+
Width="400"
11+
SizeToContent="WidthAndHeight"
12+
ResizeMode="NoResize">
13+
<Grid Width="400">
14+
<TextBlock Name="TextBoxDescription" TextWrapping="Wrap" Margin="5,5,5,5">
15+
Hyper-V Device Passthrough and Paravirtualization Devices. Currently under support.
16+
<LineBreak />
17+
<LineBreak />
18+
Copyright (C) 2025 TheFlightSims
19+
<LineBreak />
20+
<LineBreak />
21+
This tool is the alternative tool for deployment on PowerShell. All comamnds are implemented in WMI.
22+
<LineBreak />
23+
<LineBreak />
24+
</TextBlock>
25+
</Grid>
26+
</Window>

About.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Windows;
2+
3+
namespace TheFlightSims.HyperVDPD
4+
{
5+
public partial class About : Window
6+
{
7+
public About()
8+
{
9+
InitializeComponent();
10+
}
11+
}
12+
}

AddDevice.xaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<Window x:Class="TheFlightSims.HyperVDPD.AddDevice"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:TheFlightSims.HyperVDPD"
7+
mc:Ignorable="d"
8+
Title="Add Device"
9+
ResizeMode="NoResize"
10+
SizeToContent="WidthAndHeight"
11+
Height="320"
12+
Width="440">
13+
<Grid>
14+
<Grid.Margin>
15+
<Thickness Top="10" Bottom="10" Left="10" Right="10"></Thickness>
16+
</Grid.Margin>
17+
<Grid.RowDefinitions>
18+
<RowDefinition Height="25*" MinHeight="100" MaxHeight="300"></RowDefinition>
19+
<RowDefinition Height="3*"></RowDefinition>
20+
</Grid.RowDefinitions>
21+
<ListView x:Name="DeviceList" Grid.Row="0">
22+
<ListView.View>
23+
<GridView>
24+
<GridViewColumn Header="Status" DisplayMemberBinding="{Binding DeviceStatus}" Width="50"/>
25+
<GridViewColumn Header="Type" DisplayMemberBinding="{Binding DeviceType}" Width="100"/>
26+
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding DeviceName}" Width="160"/>
27+
<GridViewColumn Header="ID" DisplayMemberBinding="{Binding DeviceId}" Width="80"/>
28+
</GridView>
29+
</ListView.View>
30+
</ListView>
31+
<Grid Grid.Row="1">
32+
<Grid.ColumnDefinitions>
33+
<ColumnDefinition/>
34+
<ColumnDefinition Width="Auto"/>
35+
<ColumnDefinition Width="Auto"/>
36+
</Grid.ColumnDefinitions>
37+
<Grid.Margin>
38+
<Thickness Top="5" Bottom="5"></Thickness>
39+
</Grid.Margin>
40+
<Button Grid.Column="1" Content="Add Device" VerticalAlignment="Center" Click="AddDeviceButton_Click" Margin="5,0,5,0" Padding="5,0,5,0"/>
41+
<Button Grid.Column="2" Content="Close" VerticalAlignment="Center" Click="AddDeviceCloseButton_Click" Margin="5,0,0,0" Padding="5,0,5,0"/>
42+
</Grid>
43+
</Grid>
44+
</Window>

AddDevice.xaml.cs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using System;
2+
using System.Linq;
3+
using System.Management;
4+
using System.Windows;
5+
using TheFlightSims.HyperVDPD.WMIProperties;
6+
7+
namespace TheFlightSims.HyperVDPD
8+
{
9+
public partial class AddDevice : Window
10+
{
11+
protected string deviceId;
12+
protected MachineMethods machine;
13+
14+
public AddDevice(MachineMethods machine)
15+
{
16+
this.machine = machine;
17+
machine.Connect("root\\cimv2");
18+
InitializeComponent();
19+
}
20+
21+
/*
22+
* Button and UI methods behaviour....
23+
*/
24+
25+
private void AddDeviceButton_Click(object sender, RoutedEventArgs e)
26+
{
27+
if (DeviceList.SelectedItem != null)
28+
{
29+
deviceId = DeviceList.SelectedItem.GetType().GetProperty("DeviceId").GetValue(DeviceList.SelectedItem, null).ToString();
30+
DialogResult = true;
31+
}
32+
else
33+
{
34+
MessageBox.Show(
35+
"Please select a device to add.",
36+
"Warning",
37+
MessageBoxButton.OK,
38+
MessageBoxImage.Warning
39+
);
40+
}
41+
}
42+
43+
private void AddDeviceCloseButton_Click(object sender, RoutedEventArgs e)
44+
{
45+
Close();
46+
}
47+
48+
/*
49+
* Non-button methods
50+
*/
51+
52+
public string GetDeviceId()
53+
{
54+
UpdateDevices();
55+
ShowDialog();
56+
57+
return deviceId;
58+
}
59+
60+
private void UpdateDevices()
61+
{
62+
DeviceList.Items.Clear();
63+
64+
try
65+
{
66+
foreach (ManagementObject device in machine.GetObjects("Win32_PnPEntity", "Status, PNPClass, Name, DeviceID").Cast<ManagementObject>())
67+
{
68+
string deviceStatus = device["Status"]?.ToString() ?? "Unknown";
69+
string deviceType = device["PNPClass"]?.ToString() ?? "Unknown";
70+
string deviceName = device["Name"]?.ToString() ?? "Unknown";
71+
string deviceId = device["DeviceID"]?.ToString() ?? "Unknown";
72+
73+
if (!deviceId.StartsWith("PCI"))
74+
{
75+
continue;
76+
}
77+
78+
DeviceList.Items.Add(new
79+
{
80+
DeviceStatus = deviceStatus,
81+
DeviceType = deviceType,
82+
DeviceName = deviceName,
83+
DeviceId = deviceId
84+
});
85+
}
86+
}
87+
catch (Exception ex)
88+
{
89+
WMIDefaultValues.HandleException(ex, machine.GetComputerName());
90+
}
91+
}
92+
}
93+
}

0 commit comments

Comments
 (0)