Skip to content
This repository was archived by the owner on Aug 23, 2025. It is now read-only.

Commit 38fafd3

Browse files
authored
Merge pull request #69 from 86Box/master
Port .NET Core 3.0 changes to vNext
2 parents 67057e0 + 08dbc08 commit 38fafd3

File tree

8 files changed

+109
-5
lines changed

8 files changed

+109
-5
lines changed

86BoxManager.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28010.2036
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "86BoxManager", "86boxManager\86BoxManager.csproj", "{559F81B9-D1A5-45FC-AA69-E98F3B3926BB}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "86BoxManagerCore", "86BoxManagerCore\86BoxManagerCore.csproj", "{508DDE75-0405-47E9-9876-D3DF2D7047B3}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,14 @@ Global
2123
{559F81B9-D1A5-45FC-AA69-E98F3B3926BB}.Release|Any CPU.Build.0 = Release|x86
2224
{559F81B9-D1A5-45FC-AA69-E98F3B3926BB}.Release|x86.ActiveCfg = Release|x86
2325
{559F81B9-D1A5-45FC-AA69-E98F3B3926BB}.Release|x86.Build.0 = Release|x86
26+
{508DDE75-0405-47E9-9876-D3DF2D7047B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{508DDE75-0405-47E9-9876-D3DF2D7047B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{508DDE75-0405-47E9-9876-D3DF2D7047B3}.Debug|x86.ActiveCfg = Debug|Any CPU
29+
{508DDE75-0405-47E9-9876-D3DF2D7047B3}.Debug|x86.Build.0 = Debug|Any CPU
30+
{508DDE75-0405-47E9-9876-D3DF2D7047B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
31+
{508DDE75-0405-47E9-9876-D3DF2D7047B3}.Release|Any CPU.Build.0 = Release|Any CPU
32+
{508DDE75-0405-47E9-9876-D3DF2D7047B3}.Release|x86.ActiveCfg = Release|Any CPU
33+
{508DDE75-0405-47E9-9876-D3DF2D7047B3}.Release|x86.Build.0 = Release|Any CPU
2434
EndGlobalSection
2535
GlobalSection(SolutionProperties) = preSolution
2636
HideSolutionNode = FALSE

86BoxManager/FolderSelectDialog.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
#if !NETCOREAPP // Not required for .NET Core builds
2+
using System;
23
using System.Reflection;
34
using System.Windows.Forms;
45

@@ -50,7 +51,7 @@ private static class VistaDialog
5051
private readonly static Assembly s_windowsFormsAssembly = typeof(FileDialog).Assembly;
5152
private readonly static Type s_iFileDialogType = s_windowsFormsAssembly.GetType("System.Windows.Forms.FileDialogNative+IFileDialog");
5253
private readonly static MethodInfo s_createVistaDialogMethodInfo = typeof(OpenFileDialog).GetMethod("CreateVistaDialog", c_flags);
53-
private readonly static MethodInfo s_onBeforeVistaDialogMethodInfo = typeof(OpenFileDialog).GetMethod("OnBeforeVistaDialog", c_flags);
54+
private readonly static MethodInfo s_onBeforeVistaDialogMethodInfo = typeof(FileDialog).GetMethod("OnBeforeVistaDialog", c_flags);
5455
private readonly static MethodInfo s_getOptionsMethodInfo = typeof(FileDialog).GetMethod("GetOptions", c_flags);
5556
private readonly static MethodInfo s_setOptionsMethodInfo = s_iFileDialogType.GetMethod("SetOptions", c_flags);
5657
private readonly static uint s_fosPickFoldersBitFlag = (uint)s_windowsFormsAssembly
@@ -107,4 +108,5 @@ private class WindowWrapper : IWin32Window
107108
public IntPtr Handle { get { return _handle; } }
108109
}
109110
}
110-
}
111+
}
112+
#endif

86BoxManager/dlgAbout.Designer.cs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

86BoxManager/dlgAddVM.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,25 @@ private void txtName_TextChanged(object sender, EventArgs e)
7474
}
7575
}
7676

77+
// .NET Core implements the better Vista-style folder browse dialog in the stock FolderBrowserDialog
78+
#if NETCOREAPP
79+
private void btnBrowse_Click(object sender, EventArgs e)
80+
{
81+
FolderBrowserDialog dialog = new FolderBrowserDialog
82+
{
83+
RootFolder = Environment.SpecialFolder.MyComputer,
84+
Description = "Select a folder where your virtual machines (configs, nvr folders, etc.) will be located",
85+
UseDescriptionForTitle = true
86+
};
87+
88+
if (dialog.ShowDialog() == DialogResult.OK)
89+
{
90+
txtImportPath.Text = dialog.SelectedPath;
91+
txtName.Text = Path.GetFileName(dialog.SelectedPath);
92+
}
93+
}
94+
// A custom class is required for Vista-style folder dialogs under the original .NET Framework
95+
#else
7796
private void btnBrowse_Click(object sender, EventArgs e)
7897
{
7998
FolderSelectDialog dialog = new FolderSelectDialog
@@ -88,6 +107,7 @@ private void btnBrowse_Click(object sender, EventArgs e)
88107
txtName.Text = Path.GetFileName(dialog.FileName);
89108
}
90109
}
110+
#endif
91111

92112
private void cbxImport_CheckedChanged(object sender, EventArgs e)
93113
{

86BoxManager/dlgSettings.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,47 @@ private void LoadSettings()
235235
}
236236
}
237237

238+
// .NET Core implements the better Vista-style folder browse dialog in the stock FolderBrowserDialog
239+
#if NETCOREAPP
240+
private void btnBrowse1_Click(object sender, EventArgs e)
241+
{
242+
FolderBrowserDialog dialog = new FolderBrowserDialog
243+
{
244+
RootFolder = Environment.SpecialFolder.MyComputer,
245+
Description = "Select a folder where 86Box program files and the roms folder are located",
246+
UseDescriptionForTitle = true
247+
};
248+
249+
if (dialog.ShowDialog() == DialogResult.OK)
250+
{
251+
txtEXEdir.Text = dialog.SelectedPath;
252+
if (!txtEXEdir.Text.EndsWith(@"\")) //Just in case
253+
{
254+
txtEXEdir.Text += @"\";
255+
}
256+
}
257+
}
258+
259+
private void btnBrowse2_Click(object sender, EventArgs e)
260+
{
261+
FolderBrowserDialog dialog = new FolderBrowserDialog
262+
{
263+
RootFolder = Environment.SpecialFolder.MyComputer,
264+
Description = "Select a folder where your virtual machines (configs, nvr folders, etc.) will be located",
265+
UseDescriptionForTitle = true
266+
};
267+
268+
if (dialog.ShowDialog() == DialogResult.OK)
269+
{
270+
txtCFGdir.Text = dialog.SelectedPath;
271+
if (!txtCFGdir.Text.EndsWith(@"\")) //Just in case
272+
{
273+
txtCFGdir.Text += @"\";
274+
}
275+
}
276+
}
277+
// A custom class is required for Vista-style folder dialogs under the original .NET Framework
278+
#else
238279
private void btnBrowse1_Click(object sender, EventArgs e)
239280
{
240281
FolderSelectDialog dialog = new FolderSelectDialog
@@ -270,6 +311,7 @@ private void btnBrowse2_Click(object sender, EventArgs e)
270311
}
271312
}
272313
}
314+
#endif
273315

274316
private void btnDefaults_Click(object sender, EventArgs e)
275317
{

86BoxManager/frmMain.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using IWshRuntimeLibrary;
1+
#if !NETCOREAPP // COM references require .NET framework for now
2+
using IWshRuntimeLibrary;
3+
#endif
24
using Microsoft.Win32;
35
using System;
46
using System.ComponentModel;
@@ -49,6 +51,10 @@ public frmMain()
4951
InitializeComponent();
5052
LoadSettings();
5153
LoadVMs();
54+
55+
#if NETCOREAPP
56+
createADesktopShortcutToolStripMenuItem.Enabled = false; // Requires the original .NET framework
57+
#endif
5258
}
5359

5460
private void frmMain_Load(object sender, EventArgs e)
@@ -1130,6 +1136,7 @@ private void VMOpenFolder()
11301136

11311137
private void createADesktopShortcutToolStripMenuItem_Click(object sender, EventArgs e)
11321138
{
1139+
#if !NETCOREAPP // Requires the original .NET Framework
11331140
VM vm = (VM)lstVMs.SelectedItems[0].Tag;
11341141
WshShell shell = new WshShell();
11351142
string shortcutAddress = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\" + vm.Name + ".lnk";
@@ -1141,6 +1148,7 @@ private void createADesktopShortcutToolStripMenuItem_Click(object sender, EventA
11411148
shortcut.Save();
11421149

11431150
MessageBox.Show("A desktop shortcut for this virtual machine was successfully created.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
1151+
#endif
11441152
}
11451153

11461154
//Starts/stops selected VM when enter is pressed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>netcoreapp3.0</TargetFramework>
6+
<RootNamespace>_86BoxManager</RootNamespace>
7+
<UseWindowsForms>true</UseWindowsForms>
8+
9+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
10+
<AssemblyName>86Manager</AssemblyName>
11+
12+
<ApplicationIcon>..\86BoxManager\Resources\86Box.ico</ApplicationIcon>
13+
</PropertyGroup>
14+
15+
<ItemGroup>
16+
<Compile Include="..\86BoxManager\**\*.cs" />
17+
<EmbeddedResource Include="..\86BoxManager\**\*.resx" />
18+
</ItemGroup>
19+
20+
</Project>

AUTHORS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ The following individuals or organizations have contributed at least some code t
22

33
David Simunič (@daviunic)
44
David Lee (@DL444)
5-
FolderSelectDialog class by ErikE from stackOverflow
5+
FolderSelectDialog class by ErikE from stackOverflow
6+
David Hrdlička (@dhrdlicka)

0 commit comments

Comments
 (0)