mirror of
https://github.com/SabreTools/MPF.git
synced 2026-02-04 05:35:52 +00:00
Compare commits
171 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a833e926f3 | ||
|
|
950be07bf0 | ||
|
|
4c5c1417e9 | ||
|
|
6fdc3412e0 | ||
|
|
807b0c5f9e | ||
|
|
9e0b64a1d1 | ||
|
|
8cfbf2d9f1 | ||
|
|
0064737130 | ||
|
|
292e3999c5 | ||
|
|
5ed1e94d84 | ||
|
|
5b094f57cb | ||
|
|
8066b5541e | ||
|
|
921d0207c2 | ||
|
|
4374ff7f74 | ||
|
|
0be5825b5e | ||
|
|
14c630bea7 | ||
|
|
9a66c685fd | ||
|
|
5e0fa1ad47 | ||
|
|
79065dcc69 | ||
|
|
3d7355aee1 | ||
|
|
6e9a6724c3 | ||
|
|
be35acfb48 | ||
|
|
f1a46c2e82 | ||
|
|
872959c889 | ||
|
|
b848a401f8 | ||
|
|
ee4762f8b3 | ||
|
|
d68bcfb96a | ||
|
|
d2433e4749 | ||
|
|
56ec0e7057 | ||
|
|
26e5d33d17 | ||
|
|
8b8b51ace4 | ||
|
|
f350904441 | ||
|
|
8e8e3368d0 | ||
|
|
4d8153dba1 | ||
|
|
e4e4b5ecde | ||
|
|
8373a6b8f5 | ||
|
|
45c51ebc80 | ||
|
|
af27085cc1 | ||
|
|
82e3707dce | ||
|
|
85192e8d3e | ||
|
|
6f784a352e | ||
|
|
ee707cf1af | ||
|
|
a14c998b3b | ||
|
|
004208df6a | ||
|
|
2f765146d1 | ||
|
|
a7d548f7ce | ||
|
|
fbdb9875f3 | ||
|
|
39a524e3cc | ||
|
|
9740ca3a7a | ||
|
|
f8d81972bf | ||
|
|
fe9302a553 | ||
|
|
c0ed7a7a0e | ||
|
|
b0b48743ac | ||
|
|
47e79dab31 | ||
|
|
90edc42fdf | ||
|
|
45db365705 | ||
|
|
952828dddd | ||
|
|
4a1e953ffd | ||
|
|
25740c2936 | ||
|
|
3696257940 | ||
|
|
4d46b7db5c | ||
|
|
21f5f29ac0 | ||
|
|
436e198826 | ||
|
|
91eb8c96c3 | ||
|
|
edf0bcb4fe | ||
|
|
1526714ab9 | ||
|
|
767e0bb05b | ||
|
|
52e781329c | ||
|
|
0c1395d3ec | ||
|
|
791d9cdb7b | ||
|
|
7d7dc4ee4e | ||
|
|
97fd04b13a | ||
|
|
899db4c8c0 | ||
|
|
bba204cbfe | ||
|
|
145660e9f9 | ||
|
|
24de14aea5 | ||
|
|
d57161e4d1 | ||
|
|
a066a5234a | ||
|
|
229db5dda2 | ||
|
|
4f2a8d354a | ||
|
|
b886471d72 | ||
|
|
2bab266ae2 | ||
|
|
6c5fd9bac8 | ||
|
|
08e93d7f13 | ||
|
|
7a510e084b | ||
|
|
da46d20ffc | ||
|
|
234c0bfbab | ||
|
|
82d60dbf4a | ||
|
|
6dffb80609 | ||
|
|
267c0e3184 | ||
|
|
033ccbbe67 | ||
|
|
c31b3f5894 | ||
|
|
9b1a303fea | ||
|
|
80a0f6da35 | ||
|
|
0c30eb7a60 | ||
|
|
7a8125bb71 | ||
|
|
c4beffd845 | ||
|
|
f97c112a53 | ||
|
|
5ef43ab6be | ||
|
|
2c399f99bf | ||
|
|
42e9eb0b96 | ||
|
|
e67d65f908 | ||
|
|
4ec8954b14 | ||
|
|
1a6abb039c | ||
|
|
bb5d1e5ac8 | ||
|
|
03c4c475eb | ||
|
|
04d7817d28 | ||
|
|
7cd100bc53 | ||
|
|
019924232a | ||
|
|
b5fc9f0275 | ||
|
|
44509b72ed | ||
|
|
d532a63dbd | ||
|
|
227785b079 | ||
|
|
0e364be998 | ||
|
|
7ae1f64ee3 | ||
|
|
92463a103d | ||
|
|
101cdb7b34 | ||
|
|
e924299f85 | ||
|
|
b983f7eb4a | ||
|
|
33b4be8b24 | ||
|
|
71a4edc8ba | ||
|
|
ceb305eb54 | ||
|
|
0b0d13dcf3 | ||
|
|
9f02368622 | ||
|
|
152010ee14 | ||
|
|
c6d5f0aea5 | ||
|
|
8c2ad64bb8 | ||
|
|
fa54d694b6 | ||
|
|
dc35b08624 | ||
|
|
4429515ba2 | ||
|
|
fdbc7b34e5 | ||
|
|
a1ab442cf0 | ||
|
|
9ed5c297f6 | ||
|
|
4ce9b214b0 | ||
|
|
7dcdadda75 | ||
|
|
f87a4d9fe2 | ||
|
|
e4e5d173f0 | ||
|
|
115b242d59 | ||
|
|
706bf8a431 | ||
|
|
87ecf1aa99 | ||
|
|
b5cf274333 | ||
|
|
4f4b6879b6 | ||
|
|
3b19463913 | ||
|
|
37386cd182 | ||
|
|
e04bdad16c | ||
|
|
e37f12705d | ||
|
|
5c8dc2c23a | ||
|
|
e9121f3b03 | ||
|
|
d68175db4e | ||
|
|
9d8181b0e2 | ||
|
|
6d657f268a | ||
|
|
3b3c5f823d | ||
|
|
09fc313492 | ||
|
|
316d0f6e54 | ||
|
|
a0033238bd | ||
|
|
5b1c6a7f46 | ||
|
|
8c0dff6552 | ||
|
|
43b230c84a | ||
|
|
f1b657011d | ||
|
|
e4d8ac8e1c | ||
|
|
08f44173dd | ||
|
|
54765c71fd | ||
|
|
01f8b49214 | ||
|
|
e8b0b3efaa | ||
|
|
f637938858 | ||
|
|
ae326c1d2f | ||
|
|
a4a1e6bf0a | ||
|
|
ecee44966e | ||
|
|
83437977ba | ||
|
|
8fcac1d425 | ||
|
|
705b5f1049 |
4
.editorconfig
Normal file
4
.editorconfig
Normal file
@@ -0,0 +1,4 @@
|
||||
[*.cs]
|
||||
|
||||
# SYSLIB1045: Convert to 'GeneratedRegexAttribute'.
|
||||
dotnet_diagnostic.SYSLIB1045.severity = silent
|
||||
4
.github/ISSUE_TEMPLATE/feature-request.md
vendored
4
.github/ISSUE_TEMPLATE/feature-request.md
vendored
@@ -8,9 +8,9 @@ assignees: mnadareski
|
||||
---
|
||||
|
||||
**Before You Submit**
|
||||
|
||||
- Remember to try the [latest WIP build](https://ci.appveyor.com/project/mnadareski/mpf/build/artifacts) to see if the feature already exists.
|
||||
- Is it copy protection related? If so, report the issue [here](https://github.com/mnadareski/BurnOutSharp/issues) instead.
|
||||
- .NET 6.0 has known limitations, so make sure that what you're asking for isn't already in another build.
|
||||
- Is it copy protection related? If so, report the issue [here](hhttps://github.com/SabreTools/BinaryObjectScanner/issues) instead.
|
||||
- Check [previous issues](https://github.com/SabreTools/MPF/issues) to see if any of those are related to what you're about to ask for.
|
||||
|
||||
If none of those apply, then continue...
|
||||
|
||||
6
.github/ISSUE_TEMPLATE/informational.md
vendored
6
.github/ISSUE_TEMPLATE/informational.md
vendored
@@ -8,9 +8,9 @@ assignees: mnadareski
|
||||
---
|
||||
|
||||
**Before You Submit**
|
||||
|
||||
- Remember to try the [latest WIP build](https://ci.appveyor.com/project/mnadareski/mpf/build/artifacts) to see if the feature already exists.
|
||||
- Is it copy protection related? If so, report the issue [here](https://github.com/mnadareski/BurnOutSharp/issues) instead.
|
||||
- .NET 6.0 has known limitations, so make sure that what you're giving information on isn't already in another build.
|
||||
- Is it copy protection related? If so, report the issue [here](hhttps://github.com/SabreTools/BinaryObjectScanner/issues) instead.
|
||||
- Check [previous issues](https://github.com/SabreTools/MPF/issues) to see if any of those are related to what you're about to ask for.
|
||||
|
||||
If none of those apply, then continue...
|
||||
@@ -19,4 +19,4 @@ If none of those apply, then continue...
|
||||
A clear and concise description of what the information is. Ex. With the latest build of DumpingProgram, it [...]
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the information here.
|
||||
Add any other context or screenshots about the information here.
|
||||
|
||||
9
.github/ISSUE_TEMPLATE/issue-report.md
vendored
9
.github/ISSUE_TEMPLATE/issue-report.md
vendored
@@ -8,16 +8,16 @@ assignees: mnadareski
|
||||
---
|
||||
|
||||
**Before You Submit**
|
||||
|
||||
- Remember to try the [latest WIP build](https://ci.appveyor.com/project/mnadareski/mpf/build/artifacts) to see if the issue has already been addressed.
|
||||
- Is it copy protection related? If so, report the issue [here](https://github.com/mnadareski/BurnOutSharp/issues) instead.
|
||||
- .NET 6.0 has known issues, please try using another build to reproduce the error
|
||||
- Is it copy protection related? If so, report the issue [here](hhttps://github.com/SabreTools/BinaryObjectScanner/issues) instead.
|
||||
- Check multiple discs to help narrow down the issue
|
||||
- Check the Options to see if changing any of those affects your issue.
|
||||
|
||||
If all of those fail, then continue...
|
||||
|
||||
**Version**
|
||||
What version are you using?
|
||||
What version are you using?
|
||||
|
||||
- [ ] Stable release (version here)
|
||||
- [ ] WIP release (version here)
|
||||
@@ -25,14 +25,15 @@ What version are you using?
|
||||
**Build**
|
||||
What runtime version are you using?
|
||||
|
||||
- [ ] .NET Framework 4.8 running on (Operating System)
|
||||
- [ ] .NET 6.0 running on (Operating System)
|
||||
- [ ] .NET 8.0 running on (Operating System)
|
||||
|
||||
**Describe the issue**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
|
||||
172
CHANGELIST.md
172
CHANGELIST.md
@@ -1,3 +1,175 @@
|
||||
### 3.0.3 (2023-12-04)
|
||||
|
||||
- Fix broken tests
|
||||
- Fix using SHA-1 for track checks
|
||||
- Fix build warning for NRE
|
||||
- Remove .NET Framework 3.5 from build script
|
||||
- Handle or suppress some messages
|
||||
|
||||
### 3.0.2 (2023-12-01)
|
||||
|
||||
- Read CSS for some copy protections
|
||||
- Add Disc ID and Key fields in info window
|
||||
- Replace build script with Powershell
|
||||
- Fix Powershell build script
|
||||
- Fix cross-framework UI rendering
|
||||
- Fix most .NET Framework 3.5 issues
|
||||
- Fix cross-framework UI styles
|
||||
- Update Redumper to build 271
|
||||
- Update USE_ALL in Powershell script
|
||||
- Import WinFX for .NET Framework 3.5
|
||||
- Reference .NET Framework 3.0 for 3.5
|
||||
- Handle most VS and dotnet differences
|
||||
|
||||
### 3.0.1 (2023-11-30)
|
||||
|
||||
- Add Bandai Pippin detection
|
||||
- Zip manufacturer files for Redumper
|
||||
- Fix BE flag logic bug in DIC
|
||||
- Support ancient .NET in Core
|
||||
- Support ancient .NET in UI Core
|
||||
- Support C# 12 syntax
|
||||
- Support ancient .NET in Check
|
||||
- Support ancient .NET in UI
|
||||
- Fix TLS for older .NET
|
||||
- Perform more ancient .NET support work
|
||||
- Prepare XAML for ancient .NET support
|
||||
- Suppress deprecation warnings
|
||||
- Fix reversed ringcode test
|
||||
- Add C#12 syntax to tests
|
||||
- Trim PS3 serial and add unrelated notes
|
||||
- Update RedumpLib and use moved methods
|
||||
- Perform some post-move cleanup
|
||||
- More C# 12 cleanup in Core
|
||||
- Update to BinaryObjectScanner 3.0.1
|
||||
- Update Xunit packages
|
||||
- Get Core building with Framework 4.0
|
||||
- Get UI.Core building with Framework 4.0
|
||||
- Get Check building with Framework 4.0
|
||||
- Use TryGetValue on dictionaries
|
||||
- Support proper async in .NET Framework 4.0
|
||||
- Temporarily remove .NET Framework 4.0
|
||||
- Update to BinaryObjectScanner 3.0.2
|
||||
- Re-enable .NET Framework 4.0 building in Core
|
||||
- Re-enable .NET Framework 4.0 building in UI.Core
|
||||
- Re-enable .NET Framework 4.0 building in Check
|
||||
- Support .NET Framework 3.5
|
||||
- Update compatibility libraries
|
||||
- Support .NET Framework 2.0
|
||||
- Support .NET Framework 3.5 in UI.Core
|
||||
- Get UI building with Framework 4.0
|
||||
- Temporarily remove .NET Framework 4.0 from UI
|
||||
- Get UI building with Framework 4.0 again
|
||||
- Support .NET Framework 3.5 in UI
|
||||
- Update Redumper to build 268
|
||||
|
||||
### 3.0.0 (2023-11-14)
|
||||
|
||||
- Remove .NET Framework 4.8 from build
|
||||
- Remove .NET Framework 4.8 from projects
|
||||
- Remove .NET Framework 4.8 gated code
|
||||
- Address lingering modern .NET syntax
|
||||
- Update README for Legacy
|
||||
- Remove redundant information
|
||||
- Remove 4.8 note from build script
|
||||
- Even more README cleanup
|
||||
- Consolidate build script information
|
||||
- Remove lingering script reference
|
||||
- Make releases less verbose
|
||||
- Remove .NET Framework 4.8 from issue report
|
||||
- Remove Unshield reference
|
||||
- Update documentation for BOS change
|
||||
- Bump library versions
|
||||
- Update to .NET 8
|
||||
|
||||
### 2.7.5 (2023-11-06)
|
||||
|
||||
- Remove psxt001z Pkg Ref in MPF.Test (Deterous)
|
||||
- Update Redumper to build 247
|
||||
- Focus main window after child window closes (Deterous)
|
||||
- Try to get PS3 data from SFB
|
||||
- Fix PS3 version finding
|
||||
- Pull PS3 Firmware Version (Deterous)
|
||||
- Fix default layerbreak output
|
||||
- Enable browsing for Redumper path (Deterous)
|
||||
- Update to MMI 3.0.0 (Deterous)
|
||||
|
||||
### 2.7.4 (2023-10-31)
|
||||
|
||||
- Move Hash enum and simplify
|
||||
- Add other non-cryptographic hashes
|
||||
- Avoid unncessary allocation in hashing
|
||||
- Make Hasher more consistent
|
||||
- Move all hashing to Hasher
|
||||
- Separate out static hashing
|
||||
- Remove unncessary summary
|
||||
- Version-gate new switch statement
|
||||
- Ignore empty protection results
|
||||
- Remove and Sort Usings
|
||||
- Update Redumper to build 244
|
||||
- Enable Bluray dumping with Redumper
|
||||
- Add Bluray layerbreak support for Redumper
|
||||
- Remove now-obsolete notes
|
||||
- Compile most regex statements
|
||||
- Handle a couple of messages
|
||||
- Remove .manufacturer for Bluray
|
||||
- Fix typo that disables DIC during media check (Deterous)
|
||||
- Fix build
|
||||
- Remove duplicate check
|
||||
- Add PIC output for Redumper
|
||||
- Update Redumper to build 246
|
||||
- Enable HD-DVD for Redumper in UI
|
||||
- Attempt to fix window owner issue
|
||||
|
||||
### 2.7.3 (2023-10-26)
|
||||
|
||||
- Split InfoTool into 2 classes
|
||||
- Add path variants for PlayStation info
|
||||
- Convert Drive to use paths internally
|
||||
- Create skeleton for first-run
|
||||
- Show options window on first run
|
||||
- Fix drive letter issue in UI
|
||||
- Add first-run Options title, fix saving bug
|
||||
- Fix multiple handler invocation
|
||||
- Create method for applying theme
|
||||
- Fix drive letter check
|
||||
- Simply theme application
|
||||
- Add framework for deleteable files
|
||||
- Add deleteable file lists for Redumper and DIC
|
||||
- Add optional file deletion
|
||||
- Rearrange OptionsWindow to be easier to navigate
|
||||
- Fix up DumpEnvironment a bit
|
||||
- Add filename suffix setting (nw)
|
||||
- Wire through filename suffix
|
||||
- Expose suffix setting
|
||||
- Set UDF CD threshold at 800MB (Deterous)
|
||||
- Update package versions
|
||||
- Attempt to parse out PS5 params.json
|
||||
- Fix CRC32 hashing
|
||||
- Update XUnit packages
|
||||
- Update to BurnOutSharp 2.9.0
|
||||
- Update to MMI 3.0.0-preview.4
|
||||
- Fix two small nullability issues
|
||||
- Use Array.Empty in hasher
|
||||
- Always use relative path internally (Deterous)
|
||||
|
||||
### 2.7.2 (2023-10-17)
|
||||
|
||||
- Fix options loading for Check
|
||||
- Cleanup and gated code
|
||||
- Gate some switch expressions
|
||||
- Suppress some unnecessary messages
|
||||
- Disable dumping button when Redumper selected with unsupported media type (Deterous)
|
||||
- Improve check for which program supports which media (Deterous)
|
||||
- Remove code for getting Universal Hash from DIC logs (Deterous)
|
||||
- Fix Redumper retry count not showing
|
||||
- Enable parameters checkbox by default
|
||||
- Update Redumper to build 230
|
||||
- Fix GetPVD in dic (fuzz6001)
|
||||
- Get SecuROM data from Redumper
|
||||
- Clean up issue templates
|
||||
- Support Redumper 231 outputs
|
||||
|
||||
### 2.7.1 (2023-10-11)
|
||||
|
||||
- Add pull-all flag for Check
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net48;net6.0;net7.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
|
||||
<!-- Assembly Properties -->
|
||||
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Title>MPF Check</Title>
|
||||
<Description>Validator for various dumping programs</Description>
|
||||
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
|
||||
<Copyright>Copyright (c)2019-2023</Copyright>
|
||||
<VersionPrefix>2.7.1</VersionPrefix>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<VersionPrefix>3.0.3</VersionPrefix>
|
||||
|
||||
<!-- Package Properties -->
|
||||
<Title>MPF Check</Title>
|
||||
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
|
||||
<Description>Validator for various dumping programs</Description>
|
||||
<Copyright>Copyright (c) Matt Nadareski 2019-2023</Copyright>
|
||||
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/SabreTools/MPF</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -24,14 +31,14 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BurnOutSharp" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="2.8.0" GeneratePathProperty="true">
|
||||
<PackageReference Include="BinaryObjectScanner" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="3.0.2" GeneratePathProperty="true">
|
||||
<IncludeAssets>runtime; compile; build; native; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.1.1" />
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="$(PkgBurnOutSharp)\content\**" PackagePath="contentFiles\any\any;content" CopyToOutputDirectory="Always" PackageCopyToOutput="true" />
|
||||
<Content Include="$(PkgBinaryObjectScanner)\content\**" PackagePath="contentFiles\any\any;content" CopyToOutputDirectory="Always" PackageCopyToOutput="true" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using BurnOutSharp;
|
||||
using BinaryObjectScanner;
|
||||
using MPF.Core;
|
||||
using MPF.Core.Data;
|
||||
using MPF.Core.Utilities;
|
||||
@@ -45,12 +45,12 @@ namespace MPF.Check
|
||||
protectionProgress.ProgressChanged += ConsoleLogger.ProgressUpdated;
|
||||
|
||||
// Validate the supplied credentials
|
||||
#if NET48
|
||||
(bool? _, string message) = RedumpWebClient.ValidateCredentials(options?.RedumpUsername, options?.RedumpPassword);
|
||||
#if NETFRAMEWORK
|
||||
(bool? _, string? message) = RedumpWebClient.ValidateCredentials(options.RedumpUsername ?? string.Empty, options.RedumpPassword ?? string.Empty);
|
||||
#else
|
||||
(bool? _, string? message) = RedumpHttpClient.ValidateCredentials(options.RedumpUsername ?? string.Empty, options.RedumpPassword ?? string.Empty).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
#endif
|
||||
if (!string.IsNullOrWhiteSpace(message))
|
||||
if (!string.IsNullOrEmpty(message))
|
||||
Console.WriteLine(message);
|
||||
|
||||
// Loop through all the rest of the args
|
||||
@@ -67,18 +67,20 @@ namespace MPF.Check
|
||||
string filepath = Path.GetFullPath(args[i].Trim('"'));
|
||||
|
||||
// Now populate an environment
|
||||
#if NET48
|
||||
Drive drive = null;
|
||||
#else
|
||||
Drive? drive = null;
|
||||
#endif
|
||||
if (!string.IsNullOrWhiteSpace(path))
|
||||
drive = Drive.Create(null, path);
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
drive = Drive.Create(null, path!);
|
||||
|
||||
var env = new DumpEnvironment(options, filepath, drive, knownSystem, mediaType, internalProgram: null, parameters: null);
|
||||
|
||||
// Finally, attempt to do the output dance
|
||||
#if NET40
|
||||
var resultTask = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress);
|
||||
resultTask.Wait();
|
||||
var result = resultTask.Result;
|
||||
#else
|
||||
var result = env.VerifyAndSaveDumpOutput(resultProgress, protectionProgress).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
#endif
|
||||
Console.WriteLine(result.Message);
|
||||
}
|
||||
}
|
||||
@@ -87,11 +89,7 @@ namespace MPF.Check
|
||||
/// Display help for MPF.Check
|
||||
/// </summary>
|
||||
/// <param name="error">Error string to prefix the help text with</param>
|
||||
#if NET48
|
||||
private static void DisplayHelp(string error = null)
|
||||
#else
|
||||
private static void DisplayHelp(string? error = null)
|
||||
#endif
|
||||
{
|
||||
if (error != null)
|
||||
Console.WriteLine(error);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using BurnOutSharp;
|
||||
using BinaryObjectScanner;
|
||||
using MPF.Core.Data;
|
||||
|
||||
namespace MPF.Core
|
||||
@@ -9,11 +9,7 @@ namespace MPF.Core
|
||||
/// <summary>
|
||||
/// Simple process counter to write to console
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static void ProgressUpdated(object sender, Result value)
|
||||
#else
|
||||
public static void ProgressUpdated(object? sender, Result value)
|
||||
#endif
|
||||
{
|
||||
Console.WriteLine(value.Message);
|
||||
}
|
||||
@@ -21,11 +17,7 @@ namespace MPF.Core
|
||||
/// <summary>
|
||||
/// Simple process counter to write to console
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static void ProgressUpdated(object sender, ProtectionProgress value)
|
||||
#else
|
||||
public static void ProgressUpdated(object? sender, ProtectionProgress value)
|
||||
#endif
|
||||
{
|
||||
Console.WriteLine($"{value.Percentage * 100:N2}%: {value.Filename} - {value.Protection}");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
using System;
|
||||
#if NET20 || NET35
|
||||
using System.Collections.Generic;
|
||||
#else
|
||||
using System.Collections.Concurrent;
|
||||
#endif
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using MPF.Core.Data;
|
||||
@@ -18,17 +22,13 @@ namespace MPF.Core.Converters
|
||||
/// <returns>InternalDriveType, if possible, null on error</returns>
|
||||
public static InternalDriveType? ToInternalDriveType(this DriveType driveType)
|
||||
{
|
||||
switch (driveType)
|
||||
return driveType switch
|
||||
{
|
||||
case DriveType.CDRom:
|
||||
return InternalDriveType.Optical;
|
||||
case DriveType.Fixed:
|
||||
return InternalDriveType.HardDisk;
|
||||
case DriveType.Removable:
|
||||
return InternalDriveType.Removable;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
DriveType.CDRom => (InternalDriveType?)InternalDriveType.Optical,
|
||||
DriveType.Fixed => (InternalDriveType?)InternalDriveType.HardDisk,
|
||||
DriveType.Removable => (InternalDriveType?)InternalDriveType.Removable,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -38,10 +38,10 @@ namespace MPF.Core.Converters
|
||||
/// <summary>
|
||||
/// Long name method cache
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private static readonly ConcurrentDictionary<Type, MethodInfo> LongNameMethods = new ConcurrentDictionary<Type, MethodInfo>();
|
||||
#if NET20 || NET35
|
||||
private static readonly Dictionary<Type, MethodInfo?> LongNameMethods = [];
|
||||
#else
|
||||
private static readonly ConcurrentDictionary<Type, MethodInfo?> LongNameMethods = new ConcurrentDictionary<Type, MethodInfo?>();
|
||||
private static readonly ConcurrentDictionary<Type, MethodInfo?> LongNameMethods = [];
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
@@ -58,11 +58,14 @@ namespace MPF.Core.Converters
|
||||
|
||||
if (!LongNameMethods.TryGetValue(sourceType, out var method))
|
||||
{
|
||||
method = typeof(Extensions).GetMethod("LongName", new[] { typeof(Nullable<>).MakeGenericType(sourceType) });
|
||||
if (method == null)
|
||||
method = typeof(EnumConverter).GetMethod("LongName", new[] { typeof(Nullable<>).MakeGenericType(sourceType) });
|
||||
method = typeof(Extensions).GetMethod("LongName", [typeof(Nullable<>).MakeGenericType(sourceType)]);
|
||||
method ??= typeof(EnumConverter).GetMethod("LongName", [typeof(Nullable<>).MakeGenericType(sourceType)]);
|
||||
|
||||
#if NET20 || NET35
|
||||
LongNameMethods[sourceType] = method;
|
||||
#else
|
||||
LongNameMethods.TryAdd(sourceType, method);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (method != null)
|
||||
@@ -84,36 +87,27 @@ namespace MPF.Core.Converters
|
||||
/// <returns>String representing the value, if possible</returns>
|
||||
public static string LongName(this InternalProgram? prog)
|
||||
{
|
||||
switch (prog)
|
||||
return (prog) switch
|
||||
{
|
||||
#region Dumping support
|
||||
|
||||
case InternalProgram.Aaru:
|
||||
return "Aaru";
|
||||
case InternalProgram.DiscImageCreator:
|
||||
return "DiscImageCreator";
|
||||
case InternalProgram.Redumper:
|
||||
return "redumper";
|
||||
InternalProgram.Aaru => "Aaru",
|
||||
InternalProgram.DiscImageCreator => "DiscImageCreator",
|
||||
InternalProgram.Redumper => "Redumper",
|
||||
|
||||
#endregion
|
||||
|
||||
#region Verification support only
|
||||
|
||||
case InternalProgram.CleanRip:
|
||||
return "CleanRip";
|
||||
|
||||
case InternalProgram.DCDumper:
|
||||
return "DCDumper";
|
||||
|
||||
case InternalProgram.UmdImageCreator:
|
||||
return "UmdImageCreator";
|
||||
InternalProgram.CleanRip => "CleanRip",
|
||||
InternalProgram.DCDumper => "DCDumper",
|
||||
InternalProgram.UmdImageCreator => "UmdImageCreator",
|
||||
|
||||
#endregion
|
||||
|
||||
case InternalProgram.NONE:
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
InternalProgram.NONE => "Unknown",
|
||||
_ => "Unknown",
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -125,46 +119,35 @@ namespace MPF.Core.Converters
|
||||
/// </summary>
|
||||
/// <param name="internalProgram">String value to convert</param>
|
||||
/// <returns>InternalProgram represented by the string, if possible</returns>
|
||||
#if NET48
|
||||
public static InternalProgram ToInternalProgram(string internalProgram)
|
||||
#else
|
||||
public static InternalProgram ToInternalProgram(string? internalProgram)
|
||||
#endif
|
||||
{
|
||||
switch (internalProgram?.ToLowerInvariant())
|
||||
return (internalProgram?.ToLowerInvariant()) switch
|
||||
{
|
||||
// Dumping support
|
||||
case "aaru":
|
||||
case "chef":
|
||||
case "dichef":
|
||||
case "discimagechef":
|
||||
return InternalProgram.Aaru;
|
||||
case "creator":
|
||||
case "dic":
|
||||
case "dicreator":
|
||||
case "discimagecreator":
|
||||
return InternalProgram.DiscImageCreator;
|
||||
case "rd":
|
||||
case "redumper":
|
||||
return InternalProgram.Redumper;
|
||||
"aaru"
|
||||
or "chef"
|
||||
or "dichef"
|
||||
or "discimagechef" => InternalProgram.Aaru,
|
||||
"creator"
|
||||
or "dic"
|
||||
or "dicreator"
|
||||
or "discimagecreator" => InternalProgram.DiscImageCreator,
|
||||
"rd"
|
||||
or "redumper" => InternalProgram.Redumper,
|
||||
|
||||
// Verification support only
|
||||
case "cleanrip":
|
||||
case "cr":
|
||||
return InternalProgram.CleanRip;
|
||||
case "dc":
|
||||
case "dcd":
|
||||
case "dcdumper":
|
||||
return InternalProgram.DCDumper;
|
||||
case "uic":
|
||||
case "umd":
|
||||
case "umdcreator":
|
||||
case "umdimagecreator":
|
||||
return InternalProgram.UmdImageCreator;
|
||||
"cleanrip"
|
||||
or "cr" => InternalProgram.CleanRip,
|
||||
"dc"
|
||||
or "dcd"
|
||||
or "dcdumper" => InternalProgram.DCDumper,
|
||||
"uic"
|
||||
or "umd"
|
||||
or "umdcreator"
|
||||
or "umdimagecreator" => InternalProgram.UmdImageCreator,
|
||||
|
||||
default:
|
||||
return InternalProgram.NONE;
|
||||
}
|
||||
_ => InternalProgram.NONE,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -174,170 +157,140 @@ namespace MPF.Core.Converters
|
||||
/// <returns>MediaType represented by the string, if possible</returns>
|
||||
public static MediaType ToMediaType(string type)
|
||||
{
|
||||
switch (type.ToLowerInvariant())
|
||||
return (type.ToLowerInvariant()) switch
|
||||
{
|
||||
#region Punched Media
|
||||
|
||||
case "aperture":
|
||||
case "aperturecard":
|
||||
case "aperture card":
|
||||
return MediaType.ApertureCard;
|
||||
case "jacquardloom":
|
||||
case "jacquardloomcard":
|
||||
case "jacquard loom card":
|
||||
return MediaType.JacquardLoomCard;
|
||||
case "magneticstripe":
|
||||
case "magneticstripecard":
|
||||
case "magnetic stripe card":
|
||||
return MediaType.MagneticStripeCard;
|
||||
case "opticalphone":
|
||||
case "opticalphonecard":
|
||||
case "optical phonecard":
|
||||
return MediaType.OpticalPhonecard;
|
||||
case "punchcard":
|
||||
case "punchedcard":
|
||||
case "punched card":
|
||||
return MediaType.PunchedCard;
|
||||
case "punchtape":
|
||||
case "punchedtape":
|
||||
case "punched tape":
|
||||
return MediaType.PunchedTape;
|
||||
"aperture"
|
||||
or "aperturecard"
|
||||
or "aperture card" => MediaType.ApertureCard,
|
||||
"jacquardloom"
|
||||
or "jacquardloomcard"
|
||||
or "jacquard loom card" => MediaType.JacquardLoomCard,
|
||||
"magneticstripe"
|
||||
or "magneticstripecard"
|
||||
or "magnetic stripe card" => MediaType.MagneticStripeCard,
|
||||
"opticalphone"
|
||||
or "opticalphonecard"
|
||||
or "optical phonecard" => MediaType.OpticalPhonecard,
|
||||
"punchcard"
|
||||
or "punchedcard"
|
||||
or "punched card" => MediaType.PunchedCard,
|
||||
"punchtape"
|
||||
or "punchedtape"
|
||||
or "punched tape" => MediaType.PunchedTape,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tape
|
||||
|
||||
case "openreel":
|
||||
case "openreeltape":
|
||||
case "open reel tape":
|
||||
return MediaType.OpenReel;
|
||||
case "datacart":
|
||||
case "datacartridge":
|
||||
case "datatapecartridge":
|
||||
case "data tape cartridge":
|
||||
return MediaType.DataCartridge;
|
||||
case "cassette":
|
||||
case "cassettetape":
|
||||
case "cassette tape":
|
||||
return MediaType.Cassette;
|
||||
"openreel"
|
||||
or "openreeltape"
|
||||
or "open reel tape" => MediaType.OpenReel,
|
||||
"datacart"
|
||||
or "datacartridge"
|
||||
or "datatapecartridge"
|
||||
or "data tape cartridge" => MediaType.DataCartridge,
|
||||
"cassette"
|
||||
or "cassettetape"
|
||||
or "cassette tape" => MediaType.Cassette,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Disc / Disc
|
||||
|
||||
case "bd":
|
||||
case "bdrom":
|
||||
case "bd-rom":
|
||||
case "bluray":
|
||||
return MediaType.BluRay;
|
||||
case "cd":
|
||||
case "cdrom":
|
||||
case "cd-rom":
|
||||
return MediaType.CDROM;
|
||||
case "dvd":
|
||||
case "dvd5":
|
||||
case "dvd-5":
|
||||
case "dvd9":
|
||||
case "dvd-9":
|
||||
case "dvdrom":
|
||||
case "dvd-rom":
|
||||
return MediaType.DVD;
|
||||
case "fd":
|
||||
case "floppy":
|
||||
case "floppydisk":
|
||||
case "floppy disk":
|
||||
case "floppy diskette":
|
||||
return MediaType.FloppyDisk;
|
||||
case "floptical":
|
||||
return MediaType.Floptical;
|
||||
case "gd":
|
||||
case "gdrom":
|
||||
case "gd-rom":
|
||||
return MediaType.GDROM;
|
||||
case "hddvd":
|
||||
case "hd-dvd":
|
||||
case "hddvdrom":
|
||||
case "hd-dvd-rom":
|
||||
return MediaType.HDDVD;
|
||||
case "hdd":
|
||||
case "harddisk":
|
||||
case "hard disk":
|
||||
return MediaType.HardDisk;
|
||||
case "bernoullidisk":
|
||||
case "iomegabernoullidisk":
|
||||
case "bernoulli disk":
|
||||
case "iomega bernoulli disk":
|
||||
return MediaType.IomegaBernoulliDisk;
|
||||
case "jaz":
|
||||
case "iomegajaz":
|
||||
case "iomega jaz":
|
||||
return MediaType.IomegaJaz;
|
||||
case "zip":
|
||||
case "zipdisk":
|
||||
case "iomegazip":
|
||||
case "iomega zip":
|
||||
return MediaType.IomegaZip;
|
||||
case "ldrom":
|
||||
case "lvrom":
|
||||
case "ld-rom":
|
||||
case "lv-rom":
|
||||
case "laserdisc":
|
||||
case "laservision":
|
||||
case "ld-rom / lv-rom":
|
||||
return MediaType.LaserDisc;
|
||||
case "64dd":
|
||||
case "n64dd":
|
||||
case "64dddisk":
|
||||
case "n64dddisk":
|
||||
case "64dd disk":
|
||||
case "n64dd disk":
|
||||
return MediaType.Nintendo64DD;
|
||||
case "fds":
|
||||
case "famicom":
|
||||
case "nfds":
|
||||
case "nintendofamicom":
|
||||
case "famicomdisksystem":
|
||||
case "famicom disk system":
|
||||
case "famicom disk system disk":
|
||||
return MediaType.NintendoFamicomDiskSystem;
|
||||
case "gc":
|
||||
case "gamecube":
|
||||
case "nintendogamecube":
|
||||
case "nintendo gamecube":
|
||||
case "gamecube disc":
|
||||
case "gamecube game disc":
|
||||
return MediaType.NintendoGameCubeGameDisc;
|
||||
case "wii":
|
||||
case "nintendowii":
|
||||
case "nintendo wii":
|
||||
case "nintendo wii disc":
|
||||
case "wii optical disc":
|
||||
return MediaType.NintendoWiiOpticalDisc;
|
||||
case "wiiu":
|
||||
case "nintendowiiu":
|
||||
case "nintendo wiiu":
|
||||
case "nintendo wiiu disc":
|
||||
case "wiiu optical disc":
|
||||
case "wii u optical disc":
|
||||
return MediaType.NintendoWiiUOpticalDisc;
|
||||
case "umd":
|
||||
return MediaType.UMD;
|
||||
"bd"
|
||||
or "bdrom"
|
||||
or "bd-rom"
|
||||
or "bluray" => MediaType.BluRay,
|
||||
"cd"
|
||||
or "cdrom"
|
||||
or "cd-rom" => MediaType.CDROM,
|
||||
"dvd"
|
||||
or "dvd5"
|
||||
or "dvd-5"
|
||||
or "dvd9"
|
||||
or "dvd-9"
|
||||
or "dvdrom"
|
||||
or "dvd-rom" => MediaType.DVD,
|
||||
"fd"
|
||||
or "floppy"
|
||||
or "floppydisk"
|
||||
or "floppy disk"
|
||||
or "floppy diskette" => MediaType.FloppyDisk,
|
||||
"floptical" => MediaType.Floptical,
|
||||
"gd"
|
||||
or "gdrom"
|
||||
or "gd-rom" => MediaType.GDROM,
|
||||
"hddvd"
|
||||
or "hd-dvd"
|
||||
or "hddvdrom"
|
||||
or "hd-dvd-rom" => MediaType.HDDVD,
|
||||
"hdd"
|
||||
or "harddisk"
|
||||
or "hard disk" => MediaType.HardDisk,
|
||||
"bernoullidisk"
|
||||
or "iomegabernoullidisk"
|
||||
or "bernoulli disk"
|
||||
or "iomega bernoulli disk" => MediaType.IomegaBernoulliDisk,
|
||||
"jaz"
|
||||
or "iomegajaz"
|
||||
or "iomega jaz" => MediaType.IomegaJaz,
|
||||
"zip"
|
||||
or "zipdisk"
|
||||
or "iomegazip"
|
||||
or "iomega zip" => MediaType.IomegaZip,
|
||||
"ldrom"
|
||||
or "lvrom"
|
||||
or "ld-rom"
|
||||
or "lv-rom"
|
||||
or "laserdisc"
|
||||
or "laservision"
|
||||
or "ld-rom / lv-rom" => MediaType.LaserDisc,
|
||||
"64dd"
|
||||
or "n64dd"
|
||||
or "64dddisk"
|
||||
or "n64dddisk"
|
||||
or "64dd disk"
|
||||
or "n64dd disk" => MediaType.Nintendo64DD,
|
||||
"fds"
|
||||
or "famicom"
|
||||
or "nfds"
|
||||
or "nintendofamicom"
|
||||
or "famicomdisksystem"
|
||||
or "famicom disk system"
|
||||
or "famicom disk system disk" => MediaType.NintendoFamicomDiskSystem,
|
||||
"gc"
|
||||
or "gamecube"
|
||||
or "nintendogamecube"
|
||||
or "nintendo gamecube"
|
||||
or "gamecube disc"
|
||||
or "gamecube game disc" => MediaType.NintendoGameCubeGameDisc,
|
||||
"wii"
|
||||
or "nintendowii"
|
||||
or "nintendo wii"
|
||||
or "nintendo wii disc"
|
||||
or "wii optical disc" => MediaType.NintendoWiiOpticalDisc,
|
||||
"wiiu"
|
||||
or "nintendowiiu"
|
||||
or "nintendo wiiu"
|
||||
or "nintendo wiiu disc"
|
||||
or "wiiu optical disc"
|
||||
or "wii u optical disc" => MediaType.NintendoWiiUOpticalDisc,
|
||||
"umd" => MediaType.UMD,
|
||||
|
||||
#endregion
|
||||
|
||||
// Unsorted Formats
|
||||
case "cartridge":
|
||||
return MediaType.Cartridge;
|
||||
case "ced":
|
||||
case "rcaced":
|
||||
case "rca ced":
|
||||
case "videodisc":
|
||||
case "rca videodisc":
|
||||
return MediaType.CED;
|
||||
"cartridge" => MediaType.Cartridge,
|
||||
"ced"
|
||||
or "rcaced"
|
||||
or "rca ced"
|
||||
or "videodisc"
|
||||
or "rca videodisc" => MediaType.CED,
|
||||
|
||||
default:
|
||||
return MediaType.NONE;
|
||||
}
|
||||
_ => MediaType.NONE,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -14,38 +14,45 @@ namespace MPF.Core.Data
|
||||
public const string StopDumping = "Stop Dumping";
|
||||
|
||||
// Byte arrays for signatures
|
||||
public static readonly byte[] SaturnSectorZeroStart = new byte[] { 0x53, 0x45, 0x47, 0x41, 0x20, 0x53, 0x45, 0x47, 0x41, 0x53, 0x41, 0x54, 0x55, 0x52, 0x4E, 0x20 };
|
||||
public static readonly byte[] SaturnSectorZeroStart = [0x53, 0x45, 0x47, 0x41, 0x20, 0x53, 0x45, 0x47, 0x41, 0x53, 0x41, 0x54, 0x55, 0x52, 0x4E, 0x20];
|
||||
|
||||
// Lists of known drive speed ranges
|
||||
#if NET20 || NET35 || NET40
|
||||
public static IList<int> CD { get; } = new List<int> { 1, 2, 3, 4, 6, 8, 12, 16, 20, 24, 32, 40, 44, 48, 52, 56, 72 };
|
||||
public static IList<int> DVD { get; } = CD.Where(s => s <= 24).ToList();
|
||||
public static IList<int> HDDVD { get; } = CD.Where(s => s <= 24).ToList();
|
||||
public static IList<int> BD { get; } = CD.Where(s => s <= 16).ToList();
|
||||
public static IList<int> Unknown { get; } = new List<int> { 1 };
|
||||
#else
|
||||
public static IReadOnlyList<int> CD { get; } = new List<int> { 1, 2, 3, 4, 6, 8, 12, 16, 20, 24, 32, 40, 44, 48, 52, 56, 72 };
|
||||
public static IReadOnlyList<int> DVD { get; } = CD.Where(s => s <= 24).ToList();
|
||||
public static IReadOnlyList<int> HDDVD { get; } = CD.Where(s => s <= 24).ToList();
|
||||
public static IReadOnlyList<int> BD { get; } = CD.Where(s => s <= 16).ToList();
|
||||
public static IReadOnlyList<int> Unknown { get; } = new List<int> { 1 };
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get list of all drive speeds for a given MediaType
|
||||
/// </summary>
|
||||
/// <param name="type">MediaType? that represents the current item</param>
|
||||
/// <returns>Read-only list of drive speeds</returns>
|
||||
#if NET20 || NET35 || NET40
|
||||
public static IList<int> GetSpeedsForMediaType(MediaType? type)
|
||||
#else
|
||||
public static IReadOnlyList<int> GetSpeedsForMediaType(MediaType? type)
|
||||
#endif
|
||||
{
|
||||
switch (type)
|
||||
return type switch
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
case MediaType.GDROM:
|
||||
return CD;
|
||||
case MediaType.DVD:
|
||||
case MediaType.NintendoGameCubeGameDisc:
|
||||
case MediaType.NintendoWiiOpticalDisc:
|
||||
return DVD;
|
||||
case MediaType.HDDVD:
|
||||
return HDDVD;
|
||||
case MediaType.BluRay:
|
||||
return BD;
|
||||
default:
|
||||
return Unknown;
|
||||
}
|
||||
MediaType.CDROM
|
||||
or MediaType.GDROM => CD,
|
||||
MediaType.DVD
|
||||
or MediaType.NintendoGameCubeGameDisc
|
||||
or MediaType.NintendoWiiOpticalDisc => DVD,
|
||||
MediaType.HDDVD => HDDVD,
|
||||
MediaType.BluRay => BD,
|
||||
_ => Unknown,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,65 +61,6 @@ namespace MPF.Core.Data
|
||||
/// </summary>
|
||||
public static class Template
|
||||
{
|
||||
// Manual information
|
||||
|
||||
public const string TitleField = "Title";
|
||||
public const string ForeignTitleField = "Foreign Title (Non-latin)";
|
||||
public const string DiscNumberField = "Disc Number / Letter";
|
||||
public const string DiscTitleField = "Disc Title";
|
||||
public const string SystemField = "System";
|
||||
public const string MediaTypeField = "Media Type";
|
||||
public const string CategoryField = "Category";
|
||||
public const string RegionField = "Region";
|
||||
public const string LanguagesField = "Languages";
|
||||
public const string PlaystationLanguageSelectionViaField = "Language Selection Via";
|
||||
public const string DiscSerialField = "Disc Serial";
|
||||
public const string BarcodeField = "Barcode";
|
||||
public const string CommentsField = "Comments";
|
||||
public const string ContentsField = "Contents";
|
||||
public const string VersionField = "Version";
|
||||
public const string EditionField = "Edition/Release";
|
||||
public const string PlayStation3WiiDiscKeyField = "Disc Key";
|
||||
public const string PlayStation3DiscIDField = "Disc ID";
|
||||
public const string GameCubeWiiBCAField = "BCA";
|
||||
public const string CopyProtectionField = "Copy Protection";
|
||||
public const string MasteringRingField = "Mastering Code (laser branded/etched)";
|
||||
public const string MasteringSIDField = "Mastering SID Code";
|
||||
public const string MouldSIDField = "Mould SID Code";
|
||||
public const string AdditionalMouldField = "Additional Mould";
|
||||
public const string ToolstampField = "Toolstamp or Mastering Code (engraved/stamped)";
|
||||
|
||||
// Automatic Information
|
||||
|
||||
public const string DumpingProgramField = "Dumping Program";
|
||||
public const string DumpingDateField = "Date";
|
||||
public const string DumpingDriveManufacturer = "Manufacturer";
|
||||
public const string DumpingDriveModel = "Model";
|
||||
public const string DumpingDriveFirmware = "Firmware";
|
||||
public const string ReportedDiscType = "Reported Disc Type";
|
||||
public const string PVDField = "Primary Volume Descriptor (PVD)";
|
||||
public const string DATField = "DAT";
|
||||
public const string SizeField = "Size";
|
||||
public const string CRC32Field = "CRC32";
|
||||
public const string MD5Field = "MD5";
|
||||
public const string SHA1Field = "SHA1";
|
||||
public const string FullyMatchingIDField = "Fully Matching ID";
|
||||
public const string PartiallyMatchingIDsField = "Partially Matching IDs";
|
||||
public const string ErrorCountField = "Error Count";
|
||||
public const string CuesheetField = "Cuesheet";
|
||||
public const string SubIntentionField = "SubIntention Data (SecuROM/LibCrypt)";
|
||||
public const string WriteOffsetField = "Write Offset";
|
||||
public const string LayerbreakField = "Layerbreak";
|
||||
public const string EXEDateBuildDate = "EXE/Build Date";
|
||||
public const string HeaderField = "Header";
|
||||
public const string PICField = "Permanent Information & Control (PIC)";
|
||||
public const string PlayStationEDCField = "EDC";
|
||||
public const string PlayStationAntiModchipField = "Anti-modchip";
|
||||
public const string PlayStationLibCryptField = "LibCrypt";
|
||||
public const string XBOXSSRanges = "Security Sector Ranges";
|
||||
|
||||
// Default values
|
||||
|
||||
public const string RequiredValue = "(REQUIRED)";
|
||||
public const string RequiredIfExistsValue = "(REQUIRED, IF EXISTS)";
|
||||
public const string OptionalValue = "(OPTIONAL)";
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
using Microsoft.Management.Infrastructure;
|
||||
using Microsoft.Management.Infrastructure.Generic;
|
||||
#endif
|
||||
using MPF.Core.Converters;
|
||||
using MPF.Core.Utilities;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
namespace MPF.Core.Data
|
||||
@@ -14,7 +15,6 @@ namespace MPF.Core.Data
|
||||
/// Represents information for a single drive
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// TODO: This needs to be less Windows-centric. Devices do not always have a single letter that can be used.
|
||||
/// TODO: Can the Aaru models be used instead of the ones I've created here?
|
||||
/// </remarks>
|
||||
public class Drive
|
||||
@@ -29,20 +29,12 @@ namespace MPF.Core.Data
|
||||
/// <summary>
|
||||
/// Drive partition format
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string DriveFormat { get; private set; } = null;
|
||||
#else
|
||||
public string? DriveFormat { get; private set; } = null;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Windows drive path
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string Name { get; private set; } = null;
|
||||
#else
|
||||
public string? Name { get; private set; } = null;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Represents if Windows has marked the drive as active
|
||||
@@ -58,11 +50,7 @@ namespace MPF.Core.Data
|
||||
/// Media label as read by Windows
|
||||
/// </summary>
|
||||
/// <remarks>The try/catch is needed because Windows will throw an exception if the drive is not marked as active</remarks>
|
||||
#if NET48
|
||||
public string VolumeLabel { get; private set; } = null;
|
||||
#else
|
||||
public string? VolumeLabel { get; private set; } = null;
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -71,34 +59,31 @@ namespace MPF.Core.Data
|
||||
/// <summary>
|
||||
/// Media label as read by Windows, formatted to avoid odd outputs
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string FormattedVolumeLabel
|
||||
#else
|
||||
public string? FormattedVolumeLabel
|
||||
#endif
|
||||
{
|
||||
get
|
||||
{
|
||||
string volumeLabel = Template.DiscNotDetected;
|
||||
string? volumeLabel = Template.DiscNotDetected;
|
||||
if (this.MarkedActive)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(this.VolumeLabel))
|
||||
if (string.IsNullOrEmpty(this.VolumeLabel))
|
||||
volumeLabel = "track";
|
||||
else
|
||||
volumeLabel = this.VolumeLabel;
|
||||
}
|
||||
|
||||
foreach (char c in Path.GetInvalidFileNameChars())
|
||||
volumeLabel = volumeLabel.Replace(c, '_');
|
||||
volumeLabel = volumeLabel?.Replace(c, '_');
|
||||
|
||||
return volumeLabel;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Windows drive letter
|
||||
/// Read-only access to the drive letter
|
||||
/// </summary>
|
||||
public char Letter => this.Name == null || this.Name.Length == 0 ? '\0' : this.Name[0];
|
||||
/// <remarks>Should only be used in UI applications</remarks>
|
||||
public char? Letter => this.Name?[0] ?? '\0';
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -112,11 +97,7 @@ namespace MPF.Core.Data
|
||||
/// </summary>
|
||||
/// <param name="driveType">InternalDriveType value representing the drive type</param>
|
||||
/// <param name="devicePath">Path to the device according to the local machine</param>
|
||||
#if NET48
|
||||
public static Drive Create(InternalDriveType? driveType, string devicePath)
|
||||
#else
|
||||
public static Drive? Create(InternalDriveType? driveType, string devicePath)
|
||||
#endif
|
||||
{
|
||||
// Create a new, empty drive object
|
||||
var drive = new Drive()
|
||||
@@ -125,16 +106,12 @@ namespace MPF.Core.Data
|
||||
};
|
||||
|
||||
// If we have an invalid device path, return null
|
||||
if (string.IsNullOrWhiteSpace(devicePath))
|
||||
if (string.IsNullOrEmpty(devicePath))
|
||||
return null;
|
||||
|
||||
// Sanitize a Windows-formatted long device path
|
||||
if (devicePath.StartsWith("\\\\.\\"))
|
||||
#if NET48
|
||||
devicePath = devicePath.Substring("\\\\.\\".Length);
|
||||
#else
|
||||
devicePath = devicePath["\\\\.\\".Length..];
|
||||
#endif
|
||||
|
||||
// Create and validate the drive info object
|
||||
var driveInfo = new DriveInfo(devicePath);
|
||||
@@ -151,11 +128,7 @@ namespace MPF.Core.Data
|
||||
/// Populate all fields from a DriveInfo object
|
||||
/// </summary>
|
||||
/// <param name="driveInfo">DriveInfo object to populate from</param>
|
||||
#if NET48
|
||||
private void PopulateFromDriveInfo(DriveInfo driveInfo)
|
||||
#else
|
||||
private void PopulateFromDriveInfo(DriveInfo? driveInfo)
|
||||
#endif
|
||||
{
|
||||
// If we have an invalid DriveInfo, just return
|
||||
if (driveInfo == null || driveInfo == default)
|
||||
@@ -188,7 +161,7 @@ namespace MPF.Core.Data
|
||||
public static List<Drive> CreateListOfDrives(bool ignoreFixedDrives)
|
||||
{
|
||||
var drives = GetDriveList(ignoreFixedDrives);
|
||||
drives = drives.OrderBy(i => i == null ? '\0' : i.Letter).ToList();
|
||||
drives = [.. drives.OrderBy(i => i == null ? "\0" : i.Name)];
|
||||
return drives;
|
||||
}
|
||||
|
||||
@@ -197,11 +170,7 @@ namespace MPF.Core.Data
|
||||
/// </summary>
|
||||
/// <param name="system"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
public (MediaType?, string) GetMediaType(RedumpSystem? system)
|
||||
#else
|
||||
public (MediaType?, string?) GetMediaType(RedumpSystem? system)
|
||||
#endif
|
||||
{
|
||||
// Take care of the non-optical stuff first
|
||||
switch (this.InternalDriveType)
|
||||
@@ -264,13 +233,9 @@ namespace MPF.Core.Data
|
||||
}
|
||||
|
||||
// Handle optical media by size and filesystem
|
||||
if (this.TotalSize >= 0 && this.TotalSize < 800_000_000 && this.DriveFormat == "CDFS")
|
||||
if (this.TotalSize >= 0 && this.TotalSize <= 800_000_000 && (this.DriveFormat == "CDFS" || this.DriveFormat == "UDF"))
|
||||
return (MediaType.CDROM, null);
|
||||
else if (this.TotalSize >= 0 && this.TotalSize < 400_000_000 && this.DriveFormat == "UDF")
|
||||
return (MediaType.CDROM, null);
|
||||
else if (this.TotalSize >= 800_000_000 && this.TotalSize <= 8_540_000_000 && this.DriveFormat == "CDFS")
|
||||
return (MediaType.DVD, null);
|
||||
else if (this.TotalSize >= 400_000_000 && this.TotalSize <= 8_540_000_000 && this.DriveFormat == "UDF")
|
||||
else if (this.TotalSize > 800_000_000 && this.TotalSize <= 8_540_000_000 && (this.DriveFormat == "CDFS" || this.DriveFormat == "UDF"))
|
||||
return (MediaType.DVD, null);
|
||||
else if (this.TotalSize > 8_540_000_000)
|
||||
return (MediaType.BluRay, null);
|
||||
@@ -285,14 +250,11 @@ namespace MPF.Core.Data
|
||||
/// <returns></returns>
|
||||
public RedumpSystem? GetRedumpSystem(RedumpSystem? defaultValue)
|
||||
{
|
||||
string drivePath = $"{this.Letter}:\\";
|
||||
|
||||
// If we can't read the media in that drive, we can't do anything
|
||||
if (!Directory.Exists(drivePath))
|
||||
if (string.IsNullOrEmpty(this.Name) || !Directory.Exists(this.Name))
|
||||
return defaultValue;
|
||||
|
||||
// We're going to assume for floppies, HDDs, and removable drives
|
||||
// TODO: Try to be smarter about this
|
||||
if (this.InternalDriveType != Data.InternalDriveType.Optical)
|
||||
return RedumpSystem.IBMPCcompatible;
|
||||
|
||||
@@ -307,7 +269,11 @@ namespace MPF.Core.Data
|
||||
// Bandai Playdia Quick Interactive System
|
||||
try
|
||||
{
|
||||
List<string> files = Directory.EnumerateFiles(drivePath, "*", SearchOption.TopDirectoryOnly).ToList();
|
||||
#if NET20 || NET35
|
||||
List<string> files = [.. Directory.GetFiles(this.Name, "*", SearchOption.TopDirectoryOnly)];
|
||||
#else
|
||||
List<string> files = Directory.EnumerateFiles(this.Name, "*", SearchOption.TopDirectoryOnly).ToList();
|
||||
#endif
|
||||
|
||||
if (files.Any(f => f.EndsWith(".AJS", StringComparison.OrdinalIgnoreCase))
|
||||
&& files.Any(f => f.EndsWith(".GLB", StringComparison.OrdinalIgnoreCase)))
|
||||
@@ -317,8 +283,18 @@ namespace MPF.Core.Data
|
||||
}
|
||||
catch { }
|
||||
|
||||
// Bandai Pippin
|
||||
if (File.Exists(Path.Combine(this.Name, "PippinAuthenticationFile")))
|
||||
{
|
||||
return RedumpSystem.BandaiPippin;
|
||||
}
|
||||
|
||||
// Mattel Fisher-Price iXL
|
||||
if (File.Exists(Path.Combine(drivePath, "iXL", "iXLUpdater.exe")))
|
||||
#if NET20 || NET35
|
||||
if (File.Exists(Path.Combine(Path.Combine(this.Name, "iXL"), "iXLUpdater.exe")))
|
||||
#else
|
||||
if (File.Exists(Path.Combine(this.Name, "iXL", "iXLUpdater.exe")))
|
||||
#endif
|
||||
{
|
||||
return RedumpSystem.MattelFisherPriceiXL;
|
||||
}
|
||||
@@ -326,8 +302,12 @@ namespace MPF.Core.Data
|
||||
// Microsoft Xbox 360
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(drivePath, "$SystemUpdate"))
|
||||
&& Directory.EnumerateFiles(Path.Combine(drivePath, "$SystemUpdate")).Any()
|
||||
if (Directory.Exists(Path.Combine(this.Name, "$SystemUpdate"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(this.Name, "$SystemUpdate")).Any()
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(this.Name, "$SystemUpdate")).Any()
|
||||
#endif
|
||||
&& this.TotalSize <= 500_000_000)
|
||||
{
|
||||
return RedumpSystem.MicrosoftXbox360;
|
||||
@@ -338,8 +318,12 @@ namespace MPF.Core.Data
|
||||
// Microsoft Xbox One
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(drivePath, "MSXC"))
|
||||
&& Directory.EnumerateFiles(Path.Combine(drivePath, "MSXC")).Any())
|
||||
if (Directory.Exists(Path.Combine(this.Name, "MSXC"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(this.Name, "MSXC")).Any())
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(this.Name, "MSXC")).Any())
|
||||
#endif
|
||||
{
|
||||
return RedumpSystem.MicrosoftXboxOne;
|
||||
}
|
||||
@@ -347,35 +331,30 @@ namespace MPF.Core.Data
|
||||
catch { }
|
||||
|
||||
// Sega Dreamcast
|
||||
if (File.Exists(Path.Combine(drivePath, "IP.BIN")))
|
||||
if (File.Exists(Path.Combine(this.Name, "IP.BIN")))
|
||||
{
|
||||
return RedumpSystem.SegaDreamcast;
|
||||
}
|
||||
|
||||
// Sega Mega-CD / Sega-CD
|
||||
if (File.Exists(Path.Combine(drivePath, "_BOOT", "IP.BIN"))
|
||||
|| File.Exists(Path.Combine(drivePath, "_BOOT", "SP.BIN"))
|
||||
|| File.Exists(Path.Combine(drivePath, "_BOOT", "SP_AS.BIN"))
|
||||
|| File.Exists(Path.Combine(drivePath, "FILESYSTEM.BIN")))
|
||||
#if NET20 || NET35
|
||||
if (File.Exists(Path.Combine(Path.Combine(this.Name, "_BOOT"), "IP.BIN"))
|
||||
|| File.Exists(Path.Combine(Path.Combine(this.Name, "_BOOT"), "SP.BIN"))
|
||||
|| File.Exists(Path.Combine(Path.Combine(this.Name, "_BOOT"), "SP_AS.BIN"))
|
||||
|| File.Exists(Path.Combine(this.Name, "FILESYSTEM.BIN")))
|
||||
#else
|
||||
if (File.Exists(Path.Combine(this.Name, "_BOOT", "IP.BIN"))
|
||||
|| File.Exists(Path.Combine(this.Name, "_BOOT", "SP.BIN"))
|
||||
|| File.Exists(Path.Combine(this.Name, "_BOOT", "SP_AS.BIN"))
|
||||
|| File.Exists(Path.Combine(this.Name, "FILESYSTEM.BIN")))
|
||||
#endif
|
||||
{
|
||||
return RedumpSystem.SegaMegaCDSegaCD;
|
||||
}
|
||||
|
||||
// Sega Saturn
|
||||
try
|
||||
{
|
||||
var sector = ReadSector(0);
|
||||
if (sector != null)
|
||||
{
|
||||
if (sector.StartsWith(Interface.SaturnSectorZeroStart))
|
||||
return RedumpSystem.SegaSaturn;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
// Sony PlayStation and Sony PlayStation 2
|
||||
string psxExePath = Path.Combine(drivePath, "PSX.EXE");
|
||||
string systemCnfPath = Path.Combine(drivePath, "SYSTEM.CNF");
|
||||
string psxExePath = Path.Combine(this.Name, "PSX.EXE");
|
||||
string systemCnfPath = Path.Combine(this.Name, "SYSTEM.CNF");
|
||||
if (File.Exists(systemCnfPath))
|
||||
{
|
||||
// Check for either BOOT or BOOT2
|
||||
@@ -393,9 +372,9 @@ namespace MPF.Core.Data
|
||||
// Sony PlayStation 3
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(drivePath, "PS3_GAME"))
|
||||
|| Directory.Exists(Path.Combine(drivePath, "PS3_UPDATE"))
|
||||
|| File.Exists(Path.Combine(drivePath, "PS3_DISC.SFB")))
|
||||
if (Directory.Exists(Path.Combine(this.Name, "PS3_GAME"))
|
||||
|| Directory.Exists(Path.Combine(this.Name, "PS3_UPDATE"))
|
||||
|| File.Exists(Path.Combine(this.Name, "PS3_DISC.SFB")))
|
||||
{
|
||||
return RedumpSystem.SonyPlayStation3;
|
||||
}
|
||||
@@ -414,23 +393,27 @@ namespace MPF.Core.Data
|
||||
// Is used as an on-disc update for the base game app without needing to get update from the internet.
|
||||
// "/addcont/GAME_SERIAL/CONTENT_ID/ac.pkg" can be found in Redump entry 97619.
|
||||
// Originally on disc as "/addcont/CUSA00288/FFXIVEXPS400001A/ac.pkg".
|
||||
if (File.Exists(Path.Combine(drivePath, "PS4", "UPDATE", "PS4UPDATE.PUP")))
|
||||
#if NET20 || NET35
|
||||
if (File.Exists(Path.Combine(Path.Combine(Path.Combine(this.Name, "PS4"), "UPDATE"), "PS4UPDATE.PUP")))
|
||||
#else
|
||||
if (File.Exists(Path.Combine(this.Name, "PS4", "UPDATE", "PS4UPDATE.PUP")))
|
||||
#endif
|
||||
{
|
||||
return RedumpSystem.SonyPlayStation4;
|
||||
}
|
||||
|
||||
// V.Tech V.Flash / V.Smile Pro
|
||||
if (File.Exists(Path.Combine(drivePath, "0SYSTEM")))
|
||||
if (File.Exists(Path.Combine(this.Name, "0SYSTEM")))
|
||||
{
|
||||
return RedumpSystem.VTechVFlashVSmilePro;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Computers
|
||||
|
||||
// Sharp X68000
|
||||
if (File.Exists(Path.Combine(drivePath, "COMMAND.X")))
|
||||
if (File.Exists(Path.Combine(this.Name, "COMMAND.X")))
|
||||
{
|
||||
return RedumpSystem.SharpX68000;
|
||||
}
|
||||
@@ -440,7 +423,7 @@ namespace MPF.Core.Data
|
||||
#region Video Formats
|
||||
|
||||
// BD-Video
|
||||
if (Directory.Exists(Path.Combine(drivePath, "BDMV")))
|
||||
if (Directory.Exists(Path.Combine(this.Name, "BDMV")))
|
||||
{
|
||||
// Technically BD-Audio has this as well, but it's hard to split that out right now
|
||||
return RedumpSystem.BDVideo;
|
||||
@@ -449,14 +432,22 @@ namespace MPF.Core.Data
|
||||
// DVD-Audio and DVD-Video
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(drivePath, "AUDIO_TS"))
|
||||
&& Directory.EnumerateFiles(Path.Combine(drivePath, "AUDIO_TS")).Any())
|
||||
if (Directory.Exists(Path.Combine(this.Name, "AUDIO_TS"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(this.Name, "AUDIO_TS")).Any())
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(this.Name, "AUDIO_TS")).Any())
|
||||
#endif
|
||||
{
|
||||
return RedumpSystem.DVDAudio;
|
||||
}
|
||||
|
||||
else if (Directory.Exists(Path.Combine(drivePath, "VIDEO_TS"))
|
||||
&& Directory.EnumerateFiles(Path.Combine(drivePath, "VIDEO_TS")).Any())
|
||||
else if (Directory.Exists(Path.Combine(this.Name, "VIDEO_TS"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(this.Name, "VIDEO_TS")).Any())
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(this.Name, "VIDEO_TS")).Any())
|
||||
#endif
|
||||
{
|
||||
return RedumpSystem.DVDVideo;
|
||||
}
|
||||
@@ -466,8 +457,12 @@ namespace MPF.Core.Data
|
||||
// HD-DVD-Video
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(drivePath, "HVDVD_TS"))
|
||||
&& Directory.EnumerateFiles(Path.Combine(drivePath, "HVDVD_TS")).Any())
|
||||
if (Directory.Exists(Path.Combine(this.Name, "HVDVD_TS"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(this.Name, "HVDVD_TS")).Any())
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(this.Name, "HVDVD_TS")).Any())
|
||||
#endif
|
||||
{
|
||||
return RedumpSystem.HDDVDVideo;
|
||||
}
|
||||
@@ -477,15 +472,19 @@ namespace MPF.Core.Data
|
||||
// VCD
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(drivePath, "VCD"))
|
||||
&& Directory.EnumerateFiles(Path.Combine(drivePath, "VCD")).Any())
|
||||
if (Directory.Exists(Path.Combine(this.Name, "VCD"))
|
||||
#if NET20 || NET35
|
||||
&& Directory.GetFiles(Path.Combine(this.Name, "VCD")).Any())
|
||||
#else
|
||||
&& Directory.EnumerateFiles(Path.Combine(this.Name, "VCD")).Any())
|
||||
#endif
|
||||
{
|
||||
return RedumpSystem.VideoCD;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// Default return
|
||||
return defaultValue;
|
||||
@@ -498,11 +497,11 @@ namespace MPF.Core.Data
|
||||
public RedumpSystem? GetRedumpSystemFromVolumeLabel()
|
||||
{
|
||||
// If the volume label is empty, we can't do anything
|
||||
if (string.IsNullOrWhiteSpace(this.VolumeLabel))
|
||||
if (string.IsNullOrEmpty(this.VolumeLabel))
|
||||
return null;
|
||||
|
||||
// Audio CD
|
||||
if (this.VolumeLabel.Equals("Audio CD", StringComparison.OrdinalIgnoreCase))
|
||||
if (this.VolumeLabel!.Equals("Audio CD", StringComparison.OrdinalIgnoreCase))
|
||||
return RedumpSystem.AudioCD;
|
||||
|
||||
// Microsoft Xbox
|
||||
@@ -542,56 +541,6 @@ namespace MPF.Core.Data
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a sector with a specified size from the drive
|
||||
/// </summary>
|
||||
/// <param name="num">Sector number, non-negative</param>
|
||||
/// <param name="size">Size of a sector in bytes</param>
|
||||
/// <returns>Byte array representing the sector, null on error</returns>
|
||||
#if NET48
|
||||
public byte[] ReadSector(long num, int size = 2048)
|
||||
#else
|
||||
public byte[]? ReadSector(long num, int size = 2048)
|
||||
#endif
|
||||
{
|
||||
// Missing drive leter is not supported
|
||||
if (string.IsNullOrEmpty(this.Name))
|
||||
return null;
|
||||
|
||||
// We don't support negative sectors
|
||||
if (num < 0)
|
||||
return null;
|
||||
|
||||
// Wrap the following in case of device access errors
|
||||
#if NET48
|
||||
Stream fs = null;
|
||||
#else
|
||||
Stream? fs = null;
|
||||
#endif
|
||||
try
|
||||
{
|
||||
// Open the drive as a device
|
||||
fs = File.OpenRead($"\\\\?\\{this.Letter}:");
|
||||
|
||||
// Seek to the start of the sector, if possible
|
||||
long start = num * size;
|
||||
fs.Seek(start, SeekOrigin.Begin);
|
||||
|
||||
// Read and return the sector
|
||||
byte[] buffer = new byte[size];
|
||||
fs.Read(buffer, 0, size);
|
||||
return buffer;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
fs?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh the current drive information based on path
|
||||
/// </summary>
|
||||
@@ -601,7 +550,7 @@ namespace MPF.Core.Data
|
||||
this.PopulateFromDriveInfo(driveInfo);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
|
||||
@@ -643,6 +592,7 @@ namespace MPF.Core.Data
|
||||
}
|
||||
|
||||
// Find and update all floppy drives
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
try
|
||||
{
|
||||
CimSession session = CimSession.Create(null);
|
||||
@@ -655,7 +605,7 @@ namespace MPF.Core.Data
|
||||
if (mediaType != null && ((mediaType > 0 && mediaType < 11) || (mediaType > 12 && mediaType < 22)))
|
||||
{
|
||||
char devId = (properties["Caption"].Value as string ?? string.Empty)[0];
|
||||
drives.ForEach(d => { if (d?.Letter == devId) { d.InternalDriveType = Data.InternalDriveType.Floppy; } });
|
||||
drives.ForEach(d => { if (d?.Name != null && d.Name[0] == devId) { d.InternalDriveType = Data.InternalDriveType.Floppy; } });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -663,6 +613,7 @@ namespace MPF.Core.Data
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
#endif
|
||||
|
||||
return drives;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
namespace MPF.Core.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Available hashing types
|
||||
/// </summary>
|
||||
public enum Hash
|
||||
{
|
||||
CRC32,
|
||||
#if NET6_0_OR_GREATER
|
||||
CRC64,
|
||||
#endif
|
||||
MD5,
|
||||
SHA1,
|
||||
SHA256,
|
||||
SHA384,
|
||||
SHA512,
|
||||
#if NET6_0_OR_GREATER
|
||||
XxHash32,
|
||||
XxHash64,
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Drive type for dumping
|
||||
/// </summary>
|
||||
|
||||
@@ -8,25 +8,23 @@ namespace MPF.Core.Data
|
||||
{
|
||||
public class IniFile : IDictionary<string, string>
|
||||
{
|
||||
private Dictionary<string, string> _keyValuePairs = new Dictionary<string, string>();
|
||||
private Dictionary<string, string> _keyValuePairs = [];
|
||||
|
||||
public string this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_keyValuePairs == null)
|
||||
_keyValuePairs = new Dictionary<string, string>();
|
||||
_keyValuePairs ??= [];
|
||||
|
||||
key = key.ToLowerInvariant();
|
||||
if (_keyValuePairs.ContainsKey(key))
|
||||
return _keyValuePairs[key];
|
||||
if (_keyValuePairs.TryGetValue(key, out string? val))
|
||||
return val;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_keyValuePairs == null)
|
||||
_keyValuePairs = new Dictionary<string, string>();
|
||||
_keyValuePairs ??= [];
|
||||
|
||||
key = key.ToLowerInvariant();
|
||||
_keyValuePairs[key] = value;
|
||||
@@ -81,10 +79,8 @@ namespace MPF.Core.Data
|
||||
if (!File.Exists(path))
|
||||
return false;
|
||||
|
||||
using (var fileStream = File.OpenRead(path))
|
||||
{
|
||||
return Parse(fileStream);
|
||||
}
|
||||
using var fileStream = File.OpenRead(path);
|
||||
return Parse(fileStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,51 +95,49 @@ namespace MPF.Core.Data
|
||||
// Keys are case-insensitive by default
|
||||
try
|
||||
{
|
||||
using (StreamReader sr = new StreamReader(stream))
|
||||
using var sr = new StreamReader(stream);
|
||||
string section = string.Empty;
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
string section = string.Empty;
|
||||
while (!sr.EndOfStream)
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
|
||||
// Empty lines are skipped
|
||||
if (string.IsNullOrEmpty(line))
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
|
||||
// Empty lines are skipped
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
// No-op, we don't process empty lines
|
||||
}
|
||||
|
||||
// Comments start with ';'
|
||||
else if (line.StartsWith(";"))
|
||||
{
|
||||
// No-op, we don't process comments
|
||||
}
|
||||
|
||||
// Section titles are surrounded by square brackets
|
||||
else if (line.StartsWith("["))
|
||||
{
|
||||
section = line.TrimStart('[').TrimEnd(']');
|
||||
}
|
||||
|
||||
// Valid INI lines are in the format key=value
|
||||
else if (line.Contains("="))
|
||||
{
|
||||
// Split the line by '=' for key-value pairs
|
||||
string[] data = line.Split('=');
|
||||
|
||||
// If the value field contains an '=', we need to put them back in
|
||||
string key = data[0].Trim();
|
||||
string value = string.Join("=", data.Skip(1)).Trim();
|
||||
|
||||
// Section names are prepended to the key with a '.' separating
|
||||
if (!string.IsNullOrEmpty(section))
|
||||
key = $"{section}.{key}";
|
||||
|
||||
// Set or overwrite keys in the returned dictionary
|
||||
_keyValuePairs[key.ToLowerInvariant()] = value;
|
||||
}
|
||||
|
||||
// All other lines are ignored
|
||||
// No-op, we don't process empty lines
|
||||
}
|
||||
|
||||
// Comments start with ';'
|
||||
else if (line!.StartsWith(";"))
|
||||
{
|
||||
// No-op, we don't process comments
|
||||
}
|
||||
|
||||
// Section titles are surrounded by square brackets
|
||||
else if (line.StartsWith("["))
|
||||
{
|
||||
section = line.TrimStart('[').TrimEnd(']');
|
||||
}
|
||||
|
||||
// Valid INI lines are in the format key=value
|
||||
else if (line.Contains('='))
|
||||
{
|
||||
// Split the line by '=' for key-value pairs
|
||||
string[] data = line.Split('=');
|
||||
|
||||
// If the value field contains an '=', we need to put them back in
|
||||
string key = data[0].Trim();
|
||||
string value = string.Join("=", data.Skip(1).ToArray()).Trim();
|
||||
|
||||
// Section names are prepended to the key with a '.' separating
|
||||
if (!string.IsNullOrEmpty(section))
|
||||
key = $"{section}.{key}";
|
||||
|
||||
// Set or overwrite keys in the returned dictionary
|
||||
_keyValuePairs[key.ToLowerInvariant()] = value;
|
||||
}
|
||||
|
||||
// All other lines are ignored
|
||||
}
|
||||
}
|
||||
catch
|
||||
@@ -164,10 +158,8 @@ namespace MPF.Core.Data
|
||||
if (_keyValuePairs == null || _keyValuePairs.Count == 0)
|
||||
return false;
|
||||
|
||||
using (var fileStream = File.OpenWrite(path))
|
||||
{
|
||||
return Write(fileStream);
|
||||
}
|
||||
using var fileStream = File.OpenWrite(path);
|
||||
return Write(fileStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -185,39 +177,37 @@ namespace MPF.Core.Data
|
||||
|
||||
try
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(stream))
|
||||
// Order the dictionary by keys to link sections together
|
||||
using var sw = new StreamWriter(stream);
|
||||
var orderedKeyValuePairs = _keyValuePairs.OrderBy(kvp => kvp.Key);
|
||||
|
||||
string section = string.Empty;
|
||||
foreach (var keyValuePair in orderedKeyValuePairs)
|
||||
{
|
||||
// Order the dictionary by keys to link sections together
|
||||
var orderedKeyValuePairs = _keyValuePairs.OrderBy(kvp => kvp.Key);
|
||||
// Extract the key and value
|
||||
string key = keyValuePair.Key;
|
||||
string value = keyValuePair.Value;
|
||||
|
||||
string section = string.Empty;
|
||||
foreach (var keyValuePair in orderedKeyValuePairs)
|
||||
// We assume '.' is a section name separator
|
||||
if (key.Contains('.'))
|
||||
{
|
||||
// Extract the key and value
|
||||
string key = keyValuePair.Key;
|
||||
string value = keyValuePair.Value;
|
||||
// Split the key by '.'
|
||||
string[] data = keyValuePair.Key.Split('.');
|
||||
|
||||
// We assume '.' is a section name separator
|
||||
if (key.Contains('.'))
|
||||
// If the key contains an '.', we need to put them back in
|
||||
string newSection = data[0].Trim();
|
||||
key = string.Join(".", data.Skip(1).ToArray()).Trim();
|
||||
|
||||
// If we have a new section, write it out
|
||||
if (!string.Equals(newSection, section, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Split the key by '.'
|
||||
string[] data = keyValuePair.Key.Split('.');
|
||||
|
||||
// If the key contains an '.', we need to put them back in
|
||||
string newSection = data[0].Trim();
|
||||
key = string.Join(".", data.Skip(1)).Trim();
|
||||
|
||||
// If we have a new section, write it out
|
||||
if (!string.Equals(newSection, section, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
sw.WriteLine($"[{newSection}]");
|
||||
section = newSection;
|
||||
}
|
||||
sw.WriteLine($"[{newSection}]");
|
||||
section = newSection;
|
||||
}
|
||||
|
||||
// Now write out the key and value in a standardized way
|
||||
sw.WriteLine($"{key}={value}");
|
||||
}
|
||||
|
||||
// Now write out the key and value in a standardized way
|
||||
sw.WriteLine($"{key}={value}");
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -9,22 +9,23 @@ namespace MPF.Core.Data
|
||||
/// <summary>
|
||||
/// All settings in the form of a dictionary
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Dictionary<string, string> Settings { get; private set; }
|
||||
#else
|
||||
public Dictionary<string, string?> Settings { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Indicate if the program is being run with a clean configuration
|
||||
/// </summary>
|
||||
public bool FirstRun
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "FirstRun", true); }
|
||||
set { Settings["FirstRun"] = value.ToString(); }
|
||||
}
|
||||
|
||||
#region Internal Program
|
||||
|
||||
/// <summary>
|
||||
/// Path to Aaru
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string AaruPath
|
||||
#else
|
||||
public string? AaruPath
|
||||
#endif
|
||||
{
|
||||
get { return GetStringSetting(Settings, "AaruPath", "Programs\\Aaru\\Aaru.exe"); }
|
||||
set { Settings["AaruPath"] = value; }
|
||||
@@ -33,11 +34,7 @@ namespace MPF.Core.Data
|
||||
/// <summary>
|
||||
/// Path to DiscImageCreator
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string DiscImageCreatorPath
|
||||
#else
|
||||
public string? DiscImageCreatorPath
|
||||
#endif
|
||||
{
|
||||
get { return GetStringSetting(Settings, "DiscImageCreatorPath", "Programs\\Creator\\DiscImageCreator.exe"); }
|
||||
set { Settings["DiscImageCreatorPath"] = value; }
|
||||
@@ -46,11 +43,7 @@ namespace MPF.Core.Data
|
||||
/// <summary>
|
||||
/// Path to Redumper
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string RedumperPath
|
||||
#else
|
||||
public string? RedumperPath
|
||||
#endif
|
||||
{
|
||||
get { return GetStringSetting(Settings, "RedumperPath", "Programs\\Redumper\\redumper.exe"); }
|
||||
set { Settings["RedumperPath"] = value; }
|
||||
@@ -107,11 +100,7 @@ namespace MPF.Core.Data
|
||||
/// <summary>
|
||||
/// Default output path for dumps
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string DefaultOutputPath
|
||||
#else
|
||||
public string? DefaultOutputPath
|
||||
#endif
|
||||
{
|
||||
get { return GetStringSetting(Settings, "DefaultOutputPath", "ISO"); }
|
||||
set { Settings["DefaultOutputPath"] = value; }
|
||||
@@ -466,6 +455,15 @@ namespace MPF.Core.Data
|
||||
set { Settings["ToolsInSeparateWindow"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the dump filename as a suffix to the auto-generated files
|
||||
/// </summary>
|
||||
public bool AddFilenameSuffix
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "AddFilenameSuffix", false); }
|
||||
set { Settings["AddFilenameSuffix"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Output the compressed JSON version of the submission info
|
||||
/// </summary>
|
||||
@@ -493,6 +491,15 @@ namespace MPF.Core.Data
|
||||
set { Settings["CompressLogFiles"] = value.ToString(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete unnecessary files to reduce space
|
||||
/// </summary>
|
||||
public bool DeleteUnnecessaryFiles
|
||||
{
|
||||
get { return GetBooleanSetting(Settings, "DeleteUnnecessaryFiles", false); }
|
||||
set { Settings["DeleteUnnecessaryFiles"] = value.ToString(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Skip Options
|
||||
@@ -572,22 +579,14 @@ namespace MPF.Core.Data
|
||||
|
||||
#region Redump Login Information
|
||||
|
||||
#if NET48
|
||||
public string RedumpUsername
|
||||
#else
|
||||
public string? RedumpUsername
|
||||
#endif
|
||||
{
|
||||
get { return GetStringSetting(Settings, "RedumpUsername", ""); }
|
||||
set { Settings["RedumpUsername"] = value; }
|
||||
}
|
||||
|
||||
// TODO: Figure out a way to keep this encrypted in some way, BASE64 to start?
|
||||
#if NET48
|
||||
public string RedumpPassword
|
||||
#else
|
||||
public string? RedumpPassword
|
||||
#endif
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -599,7 +598,7 @@ namespace MPF.Core.Data
|
||||
/// <summary>
|
||||
/// Determine if a complete set of Redump credentials might exist
|
||||
/// </summary>
|
||||
public bool HasRedumpLogin { get => !string.IsNullOrWhiteSpace(RedumpUsername) && !string.IsNullOrWhiteSpace(RedumpPassword); }
|
||||
public bool HasRedumpLogin { get => !string.IsNullOrEmpty(RedumpUsername) && !string.IsNullOrEmpty(RedumpPassword); }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -607,44 +606,24 @@ namespace MPF.Core.Data
|
||||
/// Constructor taking a dictionary for settings
|
||||
/// </summary>
|
||||
/// <param name="settings"></param>
|
||||
#if NET48
|
||||
public Options(Dictionary<string, string> settings = null)
|
||||
#else
|
||||
public Options(Dictionary<string, string?>? settings = null)
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
this.Settings = settings ?? new Dictionary<string, string>();
|
||||
#else
|
||||
this.Settings = settings ?? new Dictionary<string, string?>();
|
||||
#endif
|
||||
this.Settings = settings ?? [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor taking an existing Options object
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
#if NET48
|
||||
public Options(Options source)
|
||||
#else
|
||||
public Options(Options? source)
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
Settings = new Dictionary<string, string>(source?.Settings ?? new Dictionary<string, string>());
|
||||
#else
|
||||
Settings = new Dictionary<string, string?>(source?.Settings ?? new Dictionary<string, string?>());
|
||||
#endif
|
||||
Settings = new Dictionary<string, string?>(source?.Settings ?? []);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accessor for the internal dictionary
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string this[string key]
|
||||
#else
|
||||
public string? this[string key]
|
||||
#endif
|
||||
{
|
||||
get => this.Settings[key];
|
||||
set => this.Settings[key] = value;
|
||||
@@ -659,11 +638,7 @@ namespace MPF.Core.Data
|
||||
/// <param name="key">Setting key to get a value for</param>
|
||||
/// <param name="defaultValue">Default value to return if no value is found</param>
|
||||
/// <returns>Setting value if possible, default value otherwise</returns>
|
||||
#if NET48
|
||||
private static bool GetBooleanSetting(Dictionary<string, string> settings, string key, bool defaultValue)
|
||||
#else
|
||||
private static bool GetBooleanSetting(Dictionary<string, string?> settings, string key, bool defaultValue)
|
||||
#endif
|
||||
{
|
||||
if (settings.ContainsKey(key))
|
||||
{
|
||||
@@ -685,11 +660,7 @@ namespace MPF.Core.Data
|
||||
/// <param name="key">Setting key to get a value for</param>
|
||||
/// <param name="defaultValue">Default value to return if no value is found</param>
|
||||
/// <returns>Setting value if possible, default value otherwise</returns>
|
||||
#if NET48
|
||||
private static int GetInt32Setting(Dictionary<string, string> settings, string key, int defaultValue)
|
||||
#else
|
||||
private static int GetInt32Setting(Dictionary<string, string?> settings, string key, int defaultValue)
|
||||
#endif
|
||||
{
|
||||
if (settings.ContainsKey(key))
|
||||
{
|
||||
@@ -711,11 +682,7 @@ namespace MPF.Core.Data
|
||||
/// <param name="key">Setting key to get a value for</param>
|
||||
/// <param name="defaultValue">Default value to return if no value is found</param>
|
||||
/// <returns>Setting value if possible, default value otherwise</returns>
|
||||
#if NET48
|
||||
private static string GetStringSetting(Dictionary<string, string> settings, string key, string defaultValue)
|
||||
#else
|
||||
private static string? GetStringSetting(Dictionary<string, string?> settings, string key, string? defaultValue)
|
||||
#endif
|
||||
{
|
||||
if (settings.ContainsKey(key))
|
||||
return settings[key];
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
using System;
|
||||
#if NET20 || NET35
|
||||
using System.Collections.Generic;
|
||||
#else
|
||||
using System.Collections.Concurrent;
|
||||
#endif
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MPF.Core.Data
|
||||
{
|
||||
public class ProcessingQueue<T> : IDisposable
|
||||
public sealed class ProcessingQueue<T> : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Internal queue to hold data to process
|
||||
/// </summary>
|
||||
#if NET20 || NET35
|
||||
private readonly Queue<T> InternalQueue;
|
||||
#else
|
||||
private readonly ConcurrentQueue<T> InternalQueue;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Custom processing step for dequeued data
|
||||
@@ -24,10 +32,20 @@ namespace MPF.Core.Data
|
||||
|
||||
public ProcessingQueue(Action<T> customProcessing)
|
||||
{
|
||||
#if NET20 || NET35
|
||||
this.InternalQueue = new Queue<T>();
|
||||
#else
|
||||
this.InternalQueue = new ConcurrentQueue<T>();
|
||||
#endif
|
||||
this.CustomProcessing = customProcessing;
|
||||
this.TokenSource = new CancellationTokenSource();
|
||||
#if NET20 || NET35
|
||||
Task.Run(() => ProcessQueue());
|
||||
#elif NET40
|
||||
Task.Factory.StartNew(() => ProcessQueue());
|
||||
#else
|
||||
Task.Run(() => ProcessQueue(), this.TokenSource.Token);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -39,7 +57,7 @@ namespace MPF.Core.Data
|
||||
/// Enqueue a new item for processing
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public void Enqueue(T item)
|
||||
public void Enqueue(T? item)
|
||||
{
|
||||
// Only accept new data when not cancelled
|
||||
if (item != null && !this.TokenSource.IsCancellationRequested)
|
||||
@@ -54,7 +72,11 @@ namespace MPF.Core.Data
|
||||
while (true)
|
||||
{
|
||||
// Nothing in the queue means we get to idle
|
||||
if (this.InternalQueue.Count == 0)
|
||||
#if NET20 || NET35
|
||||
if (InternalQueue.Count == 0)
|
||||
#else
|
||||
if (InternalQueue.IsEmpty)
|
||||
#endif
|
||||
{
|
||||
if (this.TokenSource.IsCancellationRequested)
|
||||
break;
|
||||
@@ -63,12 +85,17 @@ namespace MPF.Core.Data
|
||||
continue;
|
||||
}
|
||||
|
||||
#if NET20 || NET35
|
||||
// Get the next item from the queue and invoke the lambda, if possible
|
||||
this.CustomProcessing?.Invoke(this.InternalQueue.Dequeue());
|
||||
#else
|
||||
// Get the next item from the queue
|
||||
if (!this.InternalQueue.TryDequeue(out var nextItem))
|
||||
continue;
|
||||
|
||||
// Invoke the lambda, if possible
|
||||
this.CustomProcessing?.Invoke(nextItem);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
namespace MPF.Core.Data
|
||||
using System;
|
||||
|
||||
namespace MPF.Core.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Generic success/failure result object, with optional message
|
||||
/// </summary>
|
||||
public class Result
|
||||
public class Result : System.EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Internal representation of success
|
||||
@@ -24,33 +26,30 @@
|
||||
/// <summary>
|
||||
/// Create a default success result with no message
|
||||
/// </summary>
|
||||
public static Result Success() => new Result(true, "");
|
||||
public static Result Success() => new(true, "");
|
||||
|
||||
/// <summary>
|
||||
/// Create a success result with a custom message
|
||||
/// </summary>
|
||||
/// <param name="message">String to add as a message</param>
|
||||
#if NET48
|
||||
public static Result Success(string message) => new Result(true, message);
|
||||
#else
|
||||
public static Result Success(string? message) => new Result(true, message ?? string.Empty);
|
||||
#endif
|
||||
public static Result Success(string? message) => new(true, message ?? string.Empty);
|
||||
|
||||
/// <summary>
|
||||
/// Create a default failure result with no message
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Result Failure() => new Result(false, "");
|
||||
public static Result Failure() => new(false, "");
|
||||
|
||||
/// <summary>
|
||||
/// Create a failure result with a custom message
|
||||
/// </summary>
|
||||
/// <param name="message">String to add as a message</param>
|
||||
#if NET48
|
||||
public static Result Failure(string message) => new Result(false, message);
|
||||
#else
|
||||
public static Result Failure(string? message) => new Result(false, message ?? string.Empty);
|
||||
#endif
|
||||
public static Result Failure(string? message) => new(false, message ?? string.Empty);
|
||||
|
||||
internal static Result Success(object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Results can be compared to boolean values based on the success value
|
||||
|
||||
@@ -1,200 +0,0 @@
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
namespace MPF.Core.Data
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information specific to an XGD disc
|
||||
/// </summary>
|
||||
public class XgdInfo
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the information in this object is fully instantiated or not
|
||||
/// </summary>
|
||||
public bool Initialized { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Raw XMID/XeMID string that all other information is derived from
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string RawXMID { get; private set; }
|
||||
#else
|
||||
public string? RawXMID { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// XGD1 XMID
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public SabreTools.Models.Xbox.XMID XMID { get; private set; }
|
||||
#else
|
||||
public SabreTools.Models.Xbox.XMID? XMID { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// XGD2/3 XeMID
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public SabreTools.Models.Xbox.XeMID XeMID { get; private set; }
|
||||
#else
|
||||
public SabreTools.Models.Xbox.XeMID? XeMID { get; private set; }
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Populate a set of XGD information from a Master ID (XMID/XeMID) string
|
||||
/// </summary>
|
||||
/// <param name="xmid">XMID/XeMID string representing the DMI information</param>
|
||||
public XgdInfo(string xmid)
|
||||
{
|
||||
this.Initialized = false;
|
||||
if (string.IsNullOrWhiteSpace(xmid))
|
||||
return;
|
||||
|
||||
this.RawXMID = xmid.TrimEnd('\0');
|
||||
if (string.IsNullOrWhiteSpace(this.RawXMID))
|
||||
return;
|
||||
|
||||
// XGD1 information is 8 characters
|
||||
if (this.RawXMID.Length == 8)
|
||||
this.Initialized = ParseXGD1XMID(this.RawXMID);
|
||||
|
||||
// XGD2/3 information is semi-variable length
|
||||
else if (this.RawXMID.Length == 13 || this.RawXMID.Length == 14 || this.RawXMID.Length == 21 || this.RawXMID.Length == 22)
|
||||
this.Initialized = ParseXGD23XeMID(this.RawXMID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the human-readable serial string
|
||||
/// </summary>
|
||||
/// <returns>Formatted serial string, null on error</returns>
|
||||
#if NET48
|
||||
public string GetSerial()
|
||||
#else
|
||||
public string? GetSerial()
|
||||
#endif
|
||||
{
|
||||
if (!this.Initialized)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
// XGD1 doesn't use PlatformIdentifier
|
||||
if (XMID != null)
|
||||
return $"{XMID.PublisherIdentifier}-{XMID.GameID}";
|
||||
|
||||
// XGD2/3 uses a specific identifier
|
||||
else if (XeMID?.PlatformIdentifier == '2')
|
||||
return $"{XeMID.PublisherIdentifier}-{XeMID.PlatformIdentifier}{XeMID.GameID}";
|
||||
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the human-readable version string
|
||||
/// </summary>
|
||||
/// <returns>Formatted version string, null on error</returns>
|
||||
/// <remarks>This may differ for XGD2/3 in the future</remarks>
|
||||
#if NET48
|
||||
public string GetVersion()
|
||||
#else
|
||||
public string? GetVersion()
|
||||
#endif
|
||||
{
|
||||
if (!this.Initialized)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
// XGD1 doesn't use PlatformIdentifier
|
||||
if (XMID != null)
|
||||
return $"1.{XMID.VersionNumber}";
|
||||
|
||||
// XGD2/3 uses a specific identifier
|
||||
else if (XeMID?.PlatformIdentifier == '2')
|
||||
return $"1.{XeMID.SKU}";
|
||||
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse an XGD1 XMID string
|
||||
/// </summary>
|
||||
/// <param name="rawXmid">XMID string to attempt to parse</param>
|
||||
/// <returns>True if the XMID could be parsed, false otherwise</returns>
|
||||
private bool ParseXGD1XMID(string rawXmid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var xmid = new SabreTools.Serialization.Files.XMID().Deserialize(rawXmid);
|
||||
if (xmid == null)
|
||||
return false;
|
||||
|
||||
this.XMID = xmid;
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse an XGD2/3 XeMID string
|
||||
/// </summary>
|
||||
/// <param name="rawXemid">XeMID string to attempt to parse</param>
|
||||
/// <returns>True if the XeMID could be parsed, false otherwise</returns>
|
||||
private bool ParseXGD23XeMID(string rawXemid)
|
||||
{
|
||||
try
|
||||
{
|
||||
var xemid = new SabreTools.Serialization.Files.XeMID().Deserialize(rawXemid);
|
||||
if (xemid == null)
|
||||
return false;
|
||||
|
||||
this.XeMID = xemid;
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#region Helpers
|
||||
|
||||
/// <summary>
|
||||
/// Determine the region based on the XGD serial character
|
||||
/// </summary>
|
||||
/// <param name="region">Character denoting the region</param>
|
||||
/// <returns>Region, if possible</returns>
|
||||
public static Region? GetRegion(char? region)
|
||||
{
|
||||
switch (region)
|
||||
{
|
||||
case 'W': return Region.World;
|
||||
case 'A': return Region.UnitedStatesOfAmerica;
|
||||
case 'J': return Region.JapanAsia;
|
||||
case 'E': return Region.Europe;
|
||||
case 'K': return Region.USAJapan;
|
||||
case 'L': return Region.USAEurope;
|
||||
case 'H': return Region.JapanEurope;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BurnOutSharp;
|
||||
using MPF.Core.Data;
|
||||
using MPF.Core.Utilities;
|
||||
using MPF.Core.Modules;
|
||||
using MPF.Core.Utilities;
|
||||
using SabreTools.RedumpLib;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
namespace MPF.Core
|
||||
@@ -30,11 +31,7 @@ namespace MPF.Core
|
||||
/// <summary>
|
||||
/// Drive object representing the current drive
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Drive Drive { get; private set; }
|
||||
#else
|
||||
public Drive? Drive { get; private set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Currently selected system
|
||||
@@ -59,21 +56,17 @@ namespace MPF.Core
|
||||
/// <summary>
|
||||
/// Parameters object representing what to send to the internal program
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public BaseParameters Parameters { get; private set; }
|
||||
#else
|
||||
public BaseParameters? Parameters { get; private set; }
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
/// <summary>
|
||||
/// Generic way of reporting a message
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public EventHandler<string> ReportStatus;
|
||||
#if NET20 || NET35 || NET40
|
||||
public EventHandler<BaseParameters.StringEventArgs>? ReportStatus;
|
||||
#else
|
||||
public EventHandler<string>? ReportStatus;
|
||||
#endif
|
||||
@@ -81,17 +74,13 @@ namespace MPF.Core
|
||||
/// <summary>
|
||||
/// Queue of items that need to be logged
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private ProcessingQueue<string> outputQueue;
|
||||
#else
|
||||
private ProcessingQueue<string>? outputQueue;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for data returned from a process
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private void OutputToLog(object proc, string args) => outputQueue?.Enqueue(args);
|
||||
#if NET20 || NET35 || NET40
|
||||
private void OutputToLog(object? proc, BaseParameters.StringEventArgs args) => outputQueue?.Enqueue(args.Value);
|
||||
#else
|
||||
private void OutputToLog(object? proc, string args) => outputQueue?.Enqueue(args);
|
||||
#endif
|
||||
@@ -99,7 +88,11 @@ namespace MPF.Core
|
||||
/// <summary>
|
||||
/// Process the outputs in the queue
|
||||
/// </summary>
|
||||
#if NET20 || NET35 || NET40
|
||||
private void ProcessOutputs(string nextOutput) => ReportStatus?.Invoke(this, new BaseParameters.StringEventArgs { Value = nextOutput });
|
||||
#else
|
||||
private void ProcessOutputs(string nextOutput) => ReportStatus?.Invoke(this, nextOutput);
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -115,31 +108,23 @@ namespace MPF.Core
|
||||
/// <param name="parameters"></param>
|
||||
public DumpEnvironment(Data.Options options,
|
||||
string outputPath,
|
||||
#if NET48
|
||||
Drive drive,
|
||||
#else
|
||||
Drive? drive,
|
||||
#endif
|
||||
RedumpSystem? system,
|
||||
MediaType? type,
|
||||
InternalProgram? internalProgram,
|
||||
#if NET48
|
||||
string parameters)
|
||||
#else
|
||||
string? parameters)
|
||||
#endif
|
||||
{
|
||||
// Set options object
|
||||
this.Options = options;
|
||||
Options = options;
|
||||
|
||||
// Output paths
|
||||
this.OutputPath = InfoTool.NormalizeOutputPaths(outputPath, true);
|
||||
OutputPath = InfoTool.NormalizeOutputPaths(outputPath, false);
|
||||
|
||||
// UI information
|
||||
this.Drive = drive;
|
||||
this.System = system ?? options.DefaultSystem;
|
||||
this.Type = type ?? MediaType.NONE;
|
||||
this.InternalProgram = internalProgram ?? options.InternalProgram;
|
||||
Drive = drive;
|
||||
System = system ?? options.DefaultSystem;
|
||||
Type = type ?? MediaType.NONE;
|
||||
InternalProgram = internalProgram ?? options.InternalProgram;
|
||||
|
||||
// Dumping program
|
||||
SetParameters(parameters);
|
||||
@@ -147,102 +132,33 @@ namespace MPF.Core
|
||||
|
||||
#region Public Functionality
|
||||
|
||||
/// <summary>
|
||||
/// Adjust output paths if we're using DiscImageCreator
|
||||
/// </summary>
|
||||
public void AdjustPathsForDiscImageCreator()
|
||||
{
|
||||
// Only DiscImageCreator has issues with paths
|
||||
if (this.Parameters?.InternalProgram != InternalProgram.DiscImageCreator)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// Normalize the output path
|
||||
string outputPath = InfoTool.NormalizeOutputPaths(this.OutputPath, true);
|
||||
|
||||
// Replace all instances in the output directory
|
||||
var outputDirectory = Path.GetDirectoryName(outputPath);
|
||||
outputDirectory = outputDirectory?.Replace(".", "_");
|
||||
|
||||
// Replace all instances in the output filename
|
||||
string outputFilename = Path.GetFileNameWithoutExtension(outputPath);
|
||||
outputFilename = outputFilename.Replace(".", "_");
|
||||
|
||||
// Get the extension for recreating the path
|
||||
string outputExtension = Path.GetExtension(outputPath).TrimStart('.');
|
||||
|
||||
// Rebuild the output path
|
||||
if (string.IsNullOrWhiteSpace(outputDirectory))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(outputExtension))
|
||||
this.OutputPath = outputFilename;
|
||||
else
|
||||
this.OutputPath = $"{outputFilename}.{outputExtension}";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(outputExtension))
|
||||
this.OutputPath = Path.Combine(outputDirectory, outputFilename);
|
||||
else
|
||||
this.OutputPath = Path.Combine(outputDirectory, $"{outputFilename}.{outputExtension}");
|
||||
}
|
||||
|
||||
// Assign the path to the filename as well for dumping
|
||||
((Modules.DiscImageCreator.Parameters)this.Parameters).Filename = this.OutputPath;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the parameters object based on the internal program and parameters string
|
||||
/// </summary>
|
||||
/// <param name="parameters">String representation of the parameters</param>
|
||||
#if NET48
|
||||
public void SetParameters(string parameters)
|
||||
#else
|
||||
public void SetParameters(string? parameters)
|
||||
#endif
|
||||
{
|
||||
switch (this.InternalProgram)
|
||||
Parameters = InternalProgram switch
|
||||
{
|
||||
// Dumping support
|
||||
case InternalProgram.Aaru:
|
||||
this.Parameters = new Modules.Aaru.Parameters(parameters) { ExecutablePath = Options.AaruPath };
|
||||
break;
|
||||
|
||||
case InternalProgram.DiscImageCreator:
|
||||
this.Parameters = new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath };
|
||||
break;
|
||||
|
||||
case InternalProgram.Redumper:
|
||||
this.Parameters = new Modules.Redumper.Parameters(parameters) { ExecutablePath = Options.RedumperPath };
|
||||
break;
|
||||
InternalProgram.Aaru => new Modules.Aaru.Parameters(parameters) { ExecutablePath = Options.AaruPath },
|
||||
InternalProgram.DiscImageCreator => new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath },
|
||||
InternalProgram.Redumper => new Modules.Redumper.Parameters(parameters) { ExecutablePath = Options.RedumperPath },
|
||||
|
||||
// Verification support only
|
||||
case InternalProgram.CleanRip:
|
||||
this.Parameters = new Modules.CleanRip.Parameters(parameters) { ExecutablePath = null };
|
||||
break;
|
||||
|
||||
case InternalProgram.DCDumper:
|
||||
this.Parameters = null; // TODO: Create correct parameter type when supported
|
||||
break;
|
||||
|
||||
case InternalProgram.UmdImageCreator:
|
||||
this.Parameters = new Modules.UmdImageCreator.Parameters(parameters) { ExecutablePath = null };
|
||||
break;
|
||||
InternalProgram.CleanRip => new Modules.CleanRip.Parameters(parameters) { ExecutablePath = null },
|
||||
InternalProgram.DCDumper => null, // TODO: Create correct parameter type when supported
|
||||
InternalProgram.UmdImageCreator => new Modules.UmdImageCreator.Parameters(parameters) { ExecutablePath = null },
|
||||
|
||||
// This should never happen, but it needs a fallback
|
||||
default:
|
||||
this.Parameters = new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath };
|
||||
break;
|
||||
}
|
||||
_ => new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath },
|
||||
};
|
||||
|
||||
// Set system and type
|
||||
if (this.Parameters != null)
|
||||
if (Parameters != null)
|
||||
{
|
||||
this.Parameters.System = this.System;
|
||||
this.Parameters.Type = this.Type;
|
||||
Parameters.System = System;
|
||||
Parameters.Type = Type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,11 +167,7 @@ namespace MPF.Core
|
||||
/// </summary>
|
||||
/// <param name="driveSpeed">Nullable int representing the drive speed</param>
|
||||
/// <returns>String representing the params, null on error</returns>
|
||||
#if NET48
|
||||
public string GetFullParameters(int? driveSpeed)
|
||||
#else
|
||||
public string? GetFullParameters(int? driveSpeed)
|
||||
#endif
|
||||
{
|
||||
// Populate with the correct params for inputs (if we're not on the default option)
|
||||
if (System != null && Type != MediaType.NONE)
|
||||
@@ -265,25 +177,15 @@ namespace MPF.Core
|
||||
return null;
|
||||
|
||||
// Set the proper parameters
|
||||
switch (this.InternalProgram)
|
||||
Parameters = InternalProgram switch
|
||||
{
|
||||
case InternalProgram.Aaru:
|
||||
Parameters = new Modules.Aaru.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options);
|
||||
break;
|
||||
|
||||
case InternalProgram.DiscImageCreator:
|
||||
Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options);
|
||||
break;
|
||||
|
||||
case InternalProgram.Redumper:
|
||||
Parameters = new Modules.Redumper.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options);
|
||||
break;
|
||||
InternalProgram.Aaru => new Modules.Aaru.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options),
|
||||
InternalProgram.DiscImageCreator => new Modules.DiscImageCreator.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options),
|
||||
InternalProgram.Redumper => new Modules.Redumper.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options),
|
||||
|
||||
// This should never happen, but it needs a fallback
|
||||
default:
|
||||
Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, this.OutputPath, driveSpeed, Options);
|
||||
break;
|
||||
}
|
||||
_ => new Modules.DiscImageCreator.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options),
|
||||
};
|
||||
|
||||
// Generate and return the param string
|
||||
return Parameters.GenerateParameters();
|
||||
@@ -292,7 +194,7 @@ namespace MPF.Core
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Dumping
|
||||
|
||||
@@ -304,35 +206,27 @@ namespace MPF.Core
|
||||
/// <summary>
|
||||
/// Eject the disc using DiscImageCreator
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public async Task<string> EjectDisc() =>
|
||||
#else
|
||||
public async Task<string?> EjectDisc() =>
|
||||
#endif
|
||||
await RunStandaloneDiscImageCreatorCommand(Modules.DiscImageCreator.CommandStrings.Eject);
|
||||
await RunStandaloneDiscImageCreatorCommand(Modules.DiscImageCreator.CommandStrings.Eject);
|
||||
|
||||
/// <summary>
|
||||
/// Reset the current drive using DiscImageCreator
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public async Task<string> ResetDrive() =>
|
||||
#else
|
||||
public async Task<string?> ResetDrive() =>
|
||||
#endif
|
||||
await RunStandaloneDiscImageCreatorCommand(Modules.DiscImageCreator.CommandStrings.Reset);
|
||||
|
||||
/// <summary>
|
||||
/// Execute the initial invocation of the dumping programs
|
||||
/// </summary>
|
||||
/// <param name="progress">Optional result progress callback</param>
|
||||
#if NET48
|
||||
public async Task<Result> Run(IProgress<Result> progress = null)
|
||||
#if NET40
|
||||
public Result Run(IProgress<Result>? progress = null)
|
||||
#else
|
||||
public async Task<Result> Run(IProgress<Result>? progress = null)
|
||||
#endif
|
||||
{
|
||||
// If we don't have parameters
|
||||
if (this.Parameters == null)
|
||||
if (Parameters == null)
|
||||
return Result.Failure("Error! Current configuration is not supported!");
|
||||
|
||||
// Check that we have the basics for dumping
|
||||
@@ -349,19 +243,19 @@ namespace MPF.Core
|
||||
}
|
||||
|
||||
// Execute internal tool
|
||||
progress?.Report(Result.Success($"Executing {this.InternalProgram}... {(Options.ToolsInSeparateWindow ? "please wait!" : "see log for output!")}"));
|
||||
progress?.Report(Result.Success($"Executing {InternalProgram}... {(Options.ToolsInSeparateWindow ? "please wait!" : "see log for output!")}"));
|
||||
|
||||
var directoryName = Path.GetDirectoryName(this.OutputPath);
|
||||
if (!string.IsNullOrWhiteSpace(directoryName))
|
||||
var directoryName = Path.GetDirectoryName(OutputPath);
|
||||
if (!string.IsNullOrEmpty(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
#if NET40
|
||||
var executeTask = Task.Factory.StartNew(() => Parameters.ExecuteInternalProgram(Options.ToolsInSeparateWindow));
|
||||
executeTask.Wait();
|
||||
#else
|
||||
await Task.Run(() => Parameters.ExecuteInternalProgram(Options.ToolsInSeparateWindow));
|
||||
progress?.Report(Result.Success($"{this.InternalProgram} has finished!"));
|
||||
|
||||
// Execute additional tools
|
||||
progress?.Report(Result.Success("Running any additional tools... see log for output!"));
|
||||
result = await Task.Run(() => ExecuteAdditionalTools());
|
||||
progress?.Report(result);
|
||||
#endif
|
||||
progress?.Report(Result.Success($"{InternalProgram} has finished!"));
|
||||
|
||||
// Remove event handler if needed
|
||||
if (!Options.ToolsInSeparateWindow)
|
||||
@@ -382,41 +276,34 @@ namespace MPF.Core
|
||||
/// <param name="seedInfo">A seed SubmissionInfo object that contains user data</param>
|
||||
/// <returns>Result instance with the outcome</returns>
|
||||
public async Task<Result> VerifyAndSaveDumpOutput(
|
||||
#if NET48
|
||||
IProgress<Result> resultProgress = null,
|
||||
IProgress<ProtectionProgress> protectionProgress = null,
|
||||
Func<SubmissionInfo, (bool?, SubmissionInfo)> processUserInfo = null,
|
||||
SubmissionInfo seedInfo = null)
|
||||
#else
|
||||
IProgress<Result>? resultProgress = null,
|
||||
IProgress<ProtectionProgress>? protectionProgress = null,
|
||||
IProgress<BinaryObjectScanner.ProtectionProgress>? protectionProgress = null,
|
||||
Func<SubmissionInfo?, (bool?, SubmissionInfo?)>? processUserInfo = null,
|
||||
SubmissionInfo? seedInfo = null)
|
||||
#endif
|
||||
{
|
||||
resultProgress?.Report(Result.Success("Gathering submission information... please wait!"));
|
||||
|
||||
// Get the output directory and filename separately
|
||||
var outputDirectory = Path.GetDirectoryName(this.OutputPath);
|
||||
var outputFilename = Path.GetFileName(this.OutputPath);
|
||||
var outputDirectory = Path.GetDirectoryName(OutputPath);
|
||||
var outputFilename = Path.GetFileName(OutputPath);
|
||||
|
||||
// Check to make sure that the output had all the correct files
|
||||
(bool foundFiles, List<string> missingFiles) = InfoTool.FoundAllFiles(outputDirectory, outputFilename, this.Parameters, false);
|
||||
(bool foundFiles, List<string> missingFiles) = Parameters.FoundAllFiles(outputDirectory, outputFilename, false);
|
||||
if (!foundFiles)
|
||||
{
|
||||
resultProgress?.Report(Result.Failure($"There were files missing from the output:\n{string.Join("\n", missingFiles)}"));
|
||||
resultProgress?.Report(Result.Failure($"There were files missing from the output:\n{string.Join("\n", [.. missingFiles])}"));
|
||||
return Result.Failure("Error! Please check output directory as dump may be incomplete!");
|
||||
}
|
||||
|
||||
// Extract the information from the output files
|
||||
resultProgress?.Report(Result.Success("Extracting output information from output files..."));
|
||||
var submissionInfo = await InfoTool.ExtractOutputInformation(
|
||||
this.OutputPath,
|
||||
this.Drive,
|
||||
this.System,
|
||||
this.Type,
|
||||
this.Options,
|
||||
this.Parameters,
|
||||
var submissionInfo = await SubmissionInfoTool.ExtractOutputInformation(
|
||||
OutputPath,
|
||||
Drive,
|
||||
System,
|
||||
Type,
|
||||
Options,
|
||||
Parameters,
|
||||
resultProgress,
|
||||
protectionProgress);
|
||||
resultProgress?.Report(Result.Success("Extracting information complete!"));
|
||||
@@ -425,21 +312,21 @@ namespace MPF.Core
|
||||
if (seedInfo != null)
|
||||
{
|
||||
resultProgress?.Report(Result.Success("Injecting user-supplied information..."));
|
||||
InjectSubmissionInformation(submissionInfo, seedInfo);
|
||||
Builder.InjectSubmissionInformation(submissionInfo, seedInfo);
|
||||
resultProgress?.Report(Result.Success("Information injection complete!"));
|
||||
}
|
||||
|
||||
// Eject the disc automatically if configured to
|
||||
if (Options.EjectAfterDump == true)
|
||||
{
|
||||
resultProgress?.Report(Result.Success($"Ejecting disc in drive {Drive?.Letter}"));
|
||||
resultProgress?.Report(Result.Success($"Ejecting disc in drive {Drive?.Name}"));
|
||||
await EjectDisc();
|
||||
}
|
||||
|
||||
// Reset the drive automatically if configured to
|
||||
if (this.InternalProgram == InternalProgram.DiscImageCreator && Options.DICResetDriveAfterDump)
|
||||
if (InternalProgram == InternalProgram.DiscImageCreator && Options.DICResetDriveAfterDump)
|
||||
{
|
||||
resultProgress?.Report(Result.Success($"Resetting drive {Drive?.Letter}"));
|
||||
resultProgress?.Report(Result.Success($"Resetting drive {Drive?.Name}"));
|
||||
await ResetDrive();
|
||||
}
|
||||
|
||||
@@ -459,41 +346,47 @@ namespace MPF.Core
|
||||
|
||||
// Process special fields for site codes
|
||||
resultProgress?.Report(Result.Success("Processing site codes..."));
|
||||
InfoTool.ProcessSpecialFields(submissionInfo);
|
||||
Formatter.ProcessSpecialFields(submissionInfo);
|
||||
resultProgress?.Report(Result.Success("Processing complete!"));
|
||||
|
||||
// Format the information for the text output
|
||||
resultProgress?.Report(Result.Success("Formatting information..."));
|
||||
(var formattedValues, var formatResult) = InfoTool.FormatOutputData(submissionInfo, this.Options);
|
||||
(var formattedValues, var formatResult) = Formatter.FormatOutputData(submissionInfo, Options.EnableRedumpCompatibility);
|
||||
if (formattedValues == null)
|
||||
resultProgress?.Report(Result.Success(formatResult));
|
||||
else
|
||||
resultProgress?.Report(Result.Failure(formatResult));
|
||||
|
||||
// Get the filename suffix for auto-generated files
|
||||
var filenameSuffix = Options.AddFilenameSuffix ? Path.GetFileNameWithoutExtension(outputFilename) : null;
|
||||
|
||||
// Write the text output
|
||||
resultProgress?.Report(Result.Success("Writing information to !submissionInfo.txt..."));
|
||||
(bool txtSuccess, string txtResult) = InfoTool.WriteOutputData(outputDirectory, formattedValues);
|
||||
(bool txtSuccess, string txtResult) = InfoTool.WriteOutputData(outputDirectory, filenameSuffix, formattedValues);
|
||||
if (txtSuccess)
|
||||
resultProgress?.Report(Result.Success(txtResult));
|
||||
else
|
||||
resultProgress?.Report(Result.Failure(txtResult));
|
||||
|
||||
// Write the copy protection output
|
||||
if (Options.ScanForProtection && Options.OutputSeparateProtectionFile)
|
||||
if (submissionInfo?.CopyProtection?.FullProtections != null && submissionInfo.CopyProtection.FullProtections.Any())
|
||||
{
|
||||
resultProgress?.Report(Result.Success("Writing protection to !protectionInfo.txt..."));
|
||||
bool scanSuccess = InfoTool.WriteProtectionData(outputDirectory, submissionInfo);
|
||||
if (scanSuccess)
|
||||
resultProgress?.Report(Result.Success("Writing complete!"));
|
||||
else
|
||||
resultProgress?.Report(Result.Failure("Writing could not complete!"));
|
||||
if (Options.ScanForProtection && Options.OutputSeparateProtectionFile)
|
||||
{
|
||||
resultProgress?.Report(Result.Success("Writing protection to !protectionInfo.txt..."));
|
||||
bool scanSuccess = InfoTool.WriteProtectionData(outputDirectory, filenameSuffix, submissionInfo);
|
||||
if (scanSuccess)
|
||||
resultProgress?.Report(Result.Success("Writing complete!"));
|
||||
else
|
||||
resultProgress?.Report(Result.Failure("Writing could not complete!"));
|
||||
}
|
||||
}
|
||||
|
||||
// Write the JSON output, if required
|
||||
if (Options.OutputSubmissionJSON)
|
||||
{
|
||||
resultProgress?.Report(Result.Success($"Writing information to !submissionInfo.json{(Options.IncludeArtifacts ? ".gz" : string.Empty)}..."));
|
||||
bool jsonSuccess = InfoTool.WriteOutputData(outputDirectory, submissionInfo, Options.IncludeArtifacts);
|
||||
bool jsonSuccess = InfoTool.WriteOutputData(outputDirectory, filenameSuffix, submissionInfo, Options.IncludeArtifacts);
|
||||
if (jsonSuccess)
|
||||
resultProgress?.Report(Result.Success("Writing complete!"));
|
||||
else
|
||||
@@ -504,13 +397,24 @@ namespace MPF.Core
|
||||
if (Options.CompressLogFiles)
|
||||
{
|
||||
resultProgress?.Report(Result.Success("Compressing log files..."));
|
||||
(bool compressSuccess, string compressResult) = InfoTool.CompressLogFiles(outputDirectory, outputFilename, this.Parameters);
|
||||
(bool compressSuccess, string compressResult) = InfoTool.CompressLogFiles(outputDirectory, filenameSuffix, outputFilename, Parameters);
|
||||
if (compressSuccess)
|
||||
resultProgress?.Report(Result.Success(compressResult));
|
||||
else
|
||||
resultProgress?.Report(Result.Failure(compressResult));
|
||||
}
|
||||
|
||||
// Delete unnecessary files, if required
|
||||
if (Options.DeleteUnnecessaryFiles)
|
||||
{
|
||||
resultProgress?.Report(Result.Success("Deleting unnecessary files..."));
|
||||
(bool deleteSuccess, string deleteResult) = InfoTool.DeleteUnnecessaryFiles(outputDirectory, outputFilename, Parameters);
|
||||
if (deleteSuccess)
|
||||
resultProgress?.Report(Result.Success(deleteResult));
|
||||
else
|
||||
resultProgress?.Report(Result.Failure(deleteResult));
|
||||
}
|
||||
|
||||
resultProgress?.Report(Result.Success("Submission information process complete!"));
|
||||
return Result.Success();
|
||||
}
|
||||
@@ -535,28 +439,26 @@ namespace MPF.Core
|
||||
return parametersValid && floppyValid && removableDiskValid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run any additional tools given a DumpEnvironment
|
||||
/// </summary>
|
||||
/// <returns>Result instance with the outcome</returns>
|
||||
private Result ExecuteAdditionalTools() => Result.Success("No external tools needed!");
|
||||
|
||||
/// <summary>
|
||||
/// Run internal program async with an input set of parameters
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns>Standard output from commandline window</returns>
|
||||
private async Task<string> ExecuteInternalProgram(BaseParameters parameters)
|
||||
private static async Task<string> ExecuteInternalProgram(BaseParameters parameters)
|
||||
{
|
||||
Process childProcess;
|
||||
#if NET40
|
||||
string output = await Task.Factory.StartNew(() =>
|
||||
#else
|
||||
string output = await Task.Run(() =>
|
||||
#endif
|
||||
{
|
||||
childProcess = new Process()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
FileName = parameters.ExecutablePath,
|
||||
Arguments = parameters.GenerateParameters(),
|
||||
FileName = parameters.ExecutablePath!,
|
||||
Arguments = parameters.GenerateParameters()!,
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = false,
|
||||
RedirectStandardInput = true,
|
||||
@@ -578,82 +480,6 @@ namespace MPF.Core
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inject information from a seed SubmissionInfo into the existing one
|
||||
/// </summary>
|
||||
/// <param name="info">Existing submission information</param>
|
||||
/// <param name="seed">User-supplied submission information</param>
|
||||
#if NET48
|
||||
private void InjectSubmissionInformation(SubmissionInfo info, SubmissionInfo seed)
|
||||
#else
|
||||
private void InjectSubmissionInformation(SubmissionInfo? info, SubmissionInfo? seed)
|
||||
#endif
|
||||
{
|
||||
// If we have any invalid info
|
||||
if (info == null || seed == null)
|
||||
return;
|
||||
|
||||
// Otherwise, inject information as necessary
|
||||
if (seed.CommonDiscInfo != null)
|
||||
{
|
||||
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
|
||||
|
||||
// Info that only overwrites if supplied
|
||||
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Title)) info.CommonDiscInfo.Title = seed.CommonDiscInfo.Title;
|
||||
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.ForeignTitleNonLatin)) info.CommonDiscInfo.ForeignTitleNonLatin = seed.CommonDiscInfo.ForeignTitleNonLatin;
|
||||
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.DiscNumberLetter)) info.CommonDiscInfo.DiscNumberLetter = seed.CommonDiscInfo.DiscNumberLetter;
|
||||
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.DiscTitle)) info.CommonDiscInfo.DiscTitle = seed.CommonDiscInfo.DiscTitle;
|
||||
if (seed.CommonDiscInfo.Category != null) info.CommonDiscInfo.Category = seed.CommonDiscInfo.Category;
|
||||
if (seed.CommonDiscInfo.Region != null) info.CommonDiscInfo.Region = seed.CommonDiscInfo.Region;
|
||||
if (seed.CommonDiscInfo.Languages != null) info.CommonDiscInfo.Languages = seed.CommonDiscInfo.Languages;
|
||||
if (seed.CommonDiscInfo.LanguageSelection != null) info.CommonDiscInfo.LanguageSelection = seed.CommonDiscInfo.LanguageSelection;
|
||||
if (seed.CommonDiscInfo.Serial != null) info.CommonDiscInfo.Serial = seed.CommonDiscInfo.Serial;
|
||||
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Barcode)) info.CommonDiscInfo.Barcode = seed.CommonDiscInfo.Barcode;
|
||||
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Comments)) info.CommonDiscInfo.Comments = seed.CommonDiscInfo.Comments;
|
||||
if (seed.CommonDiscInfo.CommentsSpecialFields != null) info.CommonDiscInfo.CommentsSpecialFields = seed.CommonDiscInfo.CommentsSpecialFields;
|
||||
if (!string.IsNullOrWhiteSpace(seed.CommonDiscInfo.Contents)) info.CommonDiscInfo.Contents = seed.CommonDiscInfo.Contents;
|
||||
if (seed.CommonDiscInfo.ContentsSpecialFields != null) info.CommonDiscInfo.ContentsSpecialFields = seed.CommonDiscInfo.ContentsSpecialFields;
|
||||
|
||||
// Info that always overwrites
|
||||
info.CommonDiscInfo.Layer0MasteringRing = seed.CommonDiscInfo.Layer0MasteringRing;
|
||||
info.CommonDiscInfo.Layer0MasteringSID = seed.CommonDiscInfo.Layer0MasteringSID;
|
||||
info.CommonDiscInfo.Layer0ToolstampMasteringCode = seed.CommonDiscInfo.Layer0ToolstampMasteringCode;
|
||||
info.CommonDiscInfo.Layer0MouldSID = seed.CommonDiscInfo.Layer0MouldSID;
|
||||
info.CommonDiscInfo.Layer0AdditionalMould = seed.CommonDiscInfo.Layer0AdditionalMould;
|
||||
|
||||
info.CommonDiscInfo.Layer1MasteringRing = seed.CommonDiscInfo.Layer1MasteringRing;
|
||||
info.CommonDiscInfo.Layer1MasteringSID = seed.CommonDiscInfo.Layer1MasteringSID;
|
||||
info.CommonDiscInfo.Layer1ToolstampMasteringCode = seed.CommonDiscInfo.Layer1ToolstampMasteringCode;
|
||||
info.CommonDiscInfo.Layer1MouldSID = seed.CommonDiscInfo.Layer1MouldSID;
|
||||
info.CommonDiscInfo.Layer1AdditionalMould = seed.CommonDiscInfo.Layer1AdditionalMould;
|
||||
|
||||
info.CommonDiscInfo.Layer2MasteringRing = seed.CommonDiscInfo.Layer2MasteringRing;
|
||||
info.CommonDiscInfo.Layer2MasteringSID = seed.CommonDiscInfo.Layer2MasteringSID;
|
||||
info.CommonDiscInfo.Layer2ToolstampMasteringCode = seed.CommonDiscInfo.Layer2ToolstampMasteringCode;
|
||||
|
||||
info.CommonDiscInfo.Layer3MasteringRing = seed.CommonDiscInfo.Layer3MasteringRing;
|
||||
info.CommonDiscInfo.Layer3MasteringSID = seed.CommonDiscInfo.Layer3MasteringSID;
|
||||
info.CommonDiscInfo.Layer3ToolstampMasteringCode = seed.CommonDiscInfo.Layer3ToolstampMasteringCode;
|
||||
}
|
||||
|
||||
if (seed.VersionAndEditions != null)
|
||||
{
|
||||
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
|
||||
|
||||
// Info that only overwrites if supplied
|
||||
if (!string.IsNullOrWhiteSpace(seed.VersionAndEditions.Version)) info.VersionAndEditions.Version = seed.VersionAndEditions.Version;
|
||||
if (!string.IsNullOrWhiteSpace(seed.VersionAndEditions.OtherEditions)) info.VersionAndEditions.OtherEditions = seed.VersionAndEditions.OtherEditions;
|
||||
}
|
||||
|
||||
if (seed.CopyProtection != null)
|
||||
{
|
||||
if (info.CopyProtection == null) info.CopyProtection = new CopyProtectionSection();
|
||||
|
||||
// Info that only overwrites if supplied
|
||||
if (!string.IsNullOrWhiteSpace(seed.CopyProtection.Protection)) info.CopyProtection.Protection = seed.CopyProtection.Protection;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validate the current environment is ready for a dump
|
||||
/// </summary>
|
||||
@@ -661,14 +487,14 @@ namespace MPF.Core
|
||||
private Result IsValidForDump()
|
||||
{
|
||||
// Validate that everything is good
|
||||
if (this.Parameters == null || !ParametersValid())
|
||||
if (Parameters == null || !ParametersValid())
|
||||
return Result.Failure("Error! Current configuration is not supported!");
|
||||
|
||||
// Fix the output paths, just in case
|
||||
this.OutputPath = InfoTool.NormalizeOutputPaths(this.OutputPath, true);
|
||||
OutputPath = InfoTool.NormalizeOutputPaths(OutputPath, false);
|
||||
|
||||
// Validate that the output path isn't on the dumping drive
|
||||
if (Drive != null && this.OutputPath[0] == Drive.Letter)
|
||||
if (Drive?.Name != null && OutputPath.StartsWith(Drive.Name))
|
||||
return Result.Failure("Error! Cannot output to same drive that is being dumped!");
|
||||
|
||||
// Validate that the required program exists
|
||||
@@ -676,8 +502,8 @@ namespace MPF.Core
|
||||
return Result.Failure($"Error! {Parameters.ExecutablePath} does not exist!");
|
||||
|
||||
// Validate that the dumping drive doesn't contain the executable
|
||||
string fullExecutablePath = Path.GetFullPath(Parameters.ExecutablePath);
|
||||
if (Drive != null && fullExecutablePath[0] == Drive.Letter)
|
||||
string fullExecutablePath = Path.GetFullPath(Parameters.ExecutablePath!);
|
||||
if (Drive?.Name != null && fullExecutablePath.StartsWith(Drive.Name))
|
||||
return Result.Failure("Error! Cannot dump same drive that executable resides on!");
|
||||
|
||||
// Validate that the current configuration is supported
|
||||
@@ -691,7 +517,7 @@ namespace MPF.Core
|
||||
private bool RequiredProgramsExist()
|
||||
{
|
||||
// Validate that the path is configured
|
||||
if (string.IsNullOrWhiteSpace(Options.DiscImageCreatorPath))
|
||||
if (string.IsNullOrEmpty(Options.DiscImageCreatorPath))
|
||||
return false;
|
||||
|
||||
// Validate that the required program exists
|
||||
@@ -706,11 +532,7 @@ namespace MPF.Core
|
||||
/// </summary>
|
||||
/// <param name="command">Command string to run</param>
|
||||
/// <returns>The output of the command on success, null on error</returns>
|
||||
#if NET48
|
||||
private async Task<string> RunStandaloneDiscImageCreatorCommand(string command)
|
||||
#else
|
||||
private async Task<string?> RunStandaloneDiscImageCreatorCommand(string command)
|
||||
#endif
|
||||
{
|
||||
// Validate that DiscImageCreator is all set
|
||||
if (!RequiredProgramsExist())
|
||||
@@ -725,13 +547,13 @@ namespace MPF.Core
|
||||
var parameters = new Modules.DiscImageCreator.Parameters(string.Empty)
|
||||
{
|
||||
BaseCommand = command,
|
||||
DriveLetter = Drive.Letter.ToString(),
|
||||
DrivePath = Drive.Name,
|
||||
ExecutablePath = Options.DiscImageCreatorPath,
|
||||
};
|
||||
|
||||
return await ExecuteInternalProgram(parameters);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.IO.Hashing;
|
||||
#endif
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading.Tasks;
|
||||
using MPF.Core.Data;
|
||||
|
||||
namespace MPF.Core.Hashing
|
||||
{
|
||||
/// <summary>
|
||||
/// Available hashing types
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum Hash
|
||||
public sealed class Hasher : IDisposable
|
||||
{
|
||||
CRC32 = 1 << 0,
|
||||
MD5 = 1 << 1,
|
||||
SHA1 = 1 << 2,
|
||||
SHA256 = 1 << 3,
|
||||
SHA384 = 1 << 4,
|
||||
SHA512 = 1 << 5,
|
||||
#region Properties
|
||||
|
||||
// Special combinations
|
||||
Standard = CRC32 | MD5 | SHA1,
|
||||
All = CRC32 | MD5 | SHA1 | SHA256 | SHA384 | SHA512,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Async hashing class wraper
|
||||
/// </summary>
|
||||
public class Hasher
|
||||
{
|
||||
/// <summary>
|
||||
/// Hash type associated with the current state
|
||||
/// </summary>
|
||||
#if NETFRAMEWORK || NETCOREAPP3_1
|
||||
public Hash HashType { get; private set; }
|
||||
|
||||
#if NET48
|
||||
private object _hasher;
|
||||
#else
|
||||
private object? _hasher;
|
||||
public Hash HashType { get; init; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Current hash in bytes
|
||||
/// </summary>
|
||||
public byte[]? CurrentHashBytes
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_hasher) switch
|
||||
{
|
||||
HashAlgorithm ha => ha.Hash,
|
||||
NonCryptographicHashAlgorithm ncha => ncha.GetCurrentHash().Reverse().ToArray(),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current hash as a string
|
||||
/// </summary>
|
||||
public string? CurrentHashString => ByteArrayToString(CurrentHashBytes);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Internal hasher being used for processing
|
||||
/// </summary>
|
||||
/// <remarks>May be either a HashAlgorithm or NonCryptographicHashAlgorithm</remarks>
|
||||
private object? _hasher;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="hashType">Hash type to instantiate</param>
|
||||
public Hasher(Hash hashType)
|
||||
{
|
||||
this.HashType = hashType;
|
||||
@@ -47,57 +74,231 @@ namespace MPF.Core.Hashing
|
||||
/// </summary>
|
||||
private void GetHasher()
|
||||
{
|
||||
switch (HashType)
|
||||
_hasher = HashType switch
|
||||
{
|
||||
case Hash.CRC32:
|
||||
_hasher = new Crc32();
|
||||
break;
|
||||
|
||||
case Hash.MD5:
|
||||
_hasher = MD5.Create();
|
||||
break;
|
||||
|
||||
case Hash.SHA1:
|
||||
_hasher = SHA1.Create();
|
||||
break;
|
||||
|
||||
case Hash.SHA256:
|
||||
_hasher = SHA256.Create();
|
||||
break;
|
||||
|
||||
case Hash.SHA384:
|
||||
_hasher = SHA384.Create();
|
||||
break;
|
||||
|
||||
case Hash.SHA512:
|
||||
_hasher = SHA512.Create();
|
||||
break;
|
||||
}
|
||||
Hash.CRC32 => new Crc32(),
|
||||
#if NET6_0_OR_GREATER
|
||||
Hash.CRC64 => new Crc64(),
|
||||
#endif
|
||||
Hash.MD5 => MD5.Create(),
|
||||
Hash.SHA1 => SHA1.Create(),
|
||||
Hash.SHA256 => SHA256.Create(),
|
||||
Hash.SHA384 => SHA384.Create(),
|
||||
Hash.SHA512 => SHA512.Create(),
|
||||
#if NET6_0_OR_GREATER
|
||||
Hash.XxHash32 => new XxHash32(),
|
||||
Hash.XxHash64 => new XxHash64(),
|
||||
#endif
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_hasher is IDisposable disposable)
|
||||
disposable.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Static Hashing
|
||||
|
||||
/// <summary>
|
||||
/// Get hashes from an input file path
|
||||
/// </summary>
|
||||
/// <param name="filename">Path to the input file</param>
|
||||
/// <returns>True if hashing was successful, false otherwise</returns>
|
||||
public static bool GetFileHashes(string filename, out long size, out string? crc32, out string? md5, out string? sha1)
|
||||
{
|
||||
// Set all initial values
|
||||
crc32 = null; md5 = null; sha1 = null;
|
||||
|
||||
// Get all file hashes
|
||||
var fileHashes = GetFileHashes(filename, out size);
|
||||
if (fileHashes == null)
|
||||
return false;
|
||||
|
||||
// Assign the file hashes and return
|
||||
crc32 = fileHashes[Hash.CRC32];
|
||||
md5 = fileHashes[Hash.MD5];
|
||||
sha1 = fileHashes[Hash.SHA1];
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get hashes from an input file path
|
||||
/// </summary>
|
||||
/// <param name="filename">Path to the input file</param>
|
||||
/// <returns>Dictionary containing hashes on success, null on error</returns>
|
||||
public static Dictionary<Hash, string?>? GetFileHashes(string filename, out long size)
|
||||
{
|
||||
// If the file doesn't exist, we can't do anything
|
||||
if (!File.Exists(filename))
|
||||
{
|
||||
size = -1;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set the file size
|
||||
size = new FileInfo(filename).Length;
|
||||
|
||||
// Open the input file
|
||||
var input = File.OpenRead(filename);
|
||||
|
||||
// Return the hashes from the stream
|
||||
return GetStreamHashes(input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get hashes from an input Stream
|
||||
/// </summary>
|
||||
/// <param name="input">Stream to hash</param>
|
||||
/// <returns>Dictionary containing hashes on success, null on error</returns>
|
||||
public static Dictionary<Hash, string?>? GetStreamHashes(Stream input)
|
||||
{
|
||||
// Create the output dictionary
|
||||
var hashDict = new Dictionary<Hash, string?>();
|
||||
|
||||
try
|
||||
{
|
||||
// Get a list of hashers to run over the buffer
|
||||
var hashers = new Dictionary<Hash, Hasher>
|
||||
{
|
||||
{ Hash.CRC32, new Hasher(Hash.CRC32) },
|
||||
#if NET6_0_OR_GREATER
|
||||
{ Hash.CRC64, new Hasher(Hash.CRC64) },
|
||||
#endif
|
||||
{ Hash.MD5, new Hasher(Hash.MD5) },
|
||||
{ Hash.SHA1, new Hasher(Hash.SHA1) },
|
||||
{ Hash.SHA256, new Hasher(Hash.SHA256) },
|
||||
{ Hash.SHA384, new Hasher(Hash.SHA384) },
|
||||
{ Hash.SHA512, new Hasher(Hash.SHA512) },
|
||||
#if NET6_0_OR_GREATER
|
||||
{ Hash.XxHash32, new Hasher(Hash.XxHash32) },
|
||||
{ Hash.XxHash64, new Hasher(Hash.XxHash64) },
|
||||
#endif
|
||||
};
|
||||
|
||||
// Initialize the hashing helpers
|
||||
var loadBuffer = new ThreadLoadBuffer(input);
|
||||
int buffersize = 3 * 1024 * 1024;
|
||||
byte[] buffer0 = new byte[buffersize];
|
||||
byte[] buffer1 = new byte[buffersize];
|
||||
|
||||
/*
|
||||
Please note that some of the following code is adapted from
|
||||
RomVault. This is a modified version of how RomVault does
|
||||
threaded hashing. As such, some of the terminology and code
|
||||
is the same, though variable names and comments may have
|
||||
been tweaked to better fit this code base.
|
||||
*/
|
||||
|
||||
// Pre load the first buffer
|
||||
long refsize = input.Length;
|
||||
int next = refsize > buffersize ? buffersize : (int)refsize;
|
||||
input.Read(buffer0, 0, next);
|
||||
int current = next;
|
||||
refsize -= next;
|
||||
bool bufferSelect = true;
|
||||
|
||||
while (current > 0)
|
||||
{
|
||||
// Trigger the buffer load on the second buffer
|
||||
next = refsize > buffersize ? buffersize : (int)refsize;
|
||||
if (next > 0)
|
||||
loadBuffer.Trigger(bufferSelect ? buffer1 : buffer0, next);
|
||||
|
||||
byte[] buffer = bufferSelect ? buffer0 : buffer1;
|
||||
|
||||
#if NET20 || NET35
|
||||
// Run hashers sequentially on each chunk
|
||||
foreach (var h in hashers)
|
||||
{
|
||||
h.Value.Process(buffer, current);
|
||||
}
|
||||
#else
|
||||
// Run hashers in parallel on each chunk
|
||||
Parallel.ForEach(hashers, h => h.Value.Process(buffer, current));
|
||||
#endif
|
||||
|
||||
// Wait for the load buffer worker, if needed
|
||||
if (next > 0)
|
||||
loadBuffer.Wait();
|
||||
|
||||
// Setup for the next hashing step
|
||||
current = next;
|
||||
refsize -= next;
|
||||
bufferSelect = !bufferSelect;
|
||||
}
|
||||
|
||||
// Finalize all hashing helpers
|
||||
loadBuffer.Finish();
|
||||
#if NET20 || NET35
|
||||
foreach (var h in hashers)
|
||||
{
|
||||
h.Value.Terminate();
|
||||
}
|
||||
#else
|
||||
Parallel.ForEach(hashers, h => h.Value.Terminate());
|
||||
#endif
|
||||
|
||||
// Get the results
|
||||
hashDict[Hash.CRC32] = hashers[Hash.CRC32].CurrentHashString;
|
||||
#if NET6_0_OR_GREATER
|
||||
hashDict[Hash.CRC64] = hashers[Hash.CRC64].CurrentHashString;
|
||||
#endif
|
||||
hashDict[Hash.MD5] = hashers[Hash.MD5].CurrentHashString;
|
||||
hashDict[Hash.SHA1] = hashers[Hash.SHA1].CurrentHashString;
|
||||
hashDict[Hash.SHA256] = hashers[Hash.SHA256].CurrentHashString;
|
||||
hashDict[Hash.SHA384] = hashers[Hash.SHA384].CurrentHashString;
|
||||
hashDict[Hash.SHA512] = hashers[Hash.SHA512].CurrentHashString;
|
||||
#if NET6_0_OR_GREATER
|
||||
hashDict[Hash.XxHash32] = hashers[Hash.XxHash32].CurrentHashString;
|
||||
hashDict[Hash.XxHash64] = hashers[Hash.XxHash64].CurrentHashString;
|
||||
#endif
|
||||
|
||||
// Dispose of the hashers
|
||||
loadBuffer.Dispose();
|
||||
foreach (var hasher in hashers.Values)
|
||||
{
|
||||
hasher.Dispose();
|
||||
}
|
||||
|
||||
return hashDict;
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
input.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hashing
|
||||
|
||||
/// <summary>
|
||||
/// Process a buffer of some length with the internal hash algorithm
|
||||
/// </summary>
|
||||
public void Process(byte[] buffer, int size)
|
||||
{
|
||||
switch (HashType)
|
||||
switch (_hasher)
|
||||
{
|
||||
case Hash.CRC32:
|
||||
(_hasher as NonCryptographicHashAlgorithm)?.Append(buffer);
|
||||
case HashAlgorithm ha:
|
||||
ha.TransformBlock(buffer, 0, size, null, 0);
|
||||
break;
|
||||
|
||||
case Hash.MD5:
|
||||
case Hash.SHA1:
|
||||
case Hash.SHA256:
|
||||
case Hash.SHA384:
|
||||
case Hash.SHA512:
|
||||
(_hasher as HashAlgorithm)?.TransformBlock(buffer, 0, size, null, 0);
|
||||
case NonCryptographicHashAlgorithm ncha:
|
||||
#if NET20 || NET35 || NET40
|
||||
byte[] bufferSpan = new byte[size];
|
||||
Array.Copy(buffer, bufferSpan, size);
|
||||
#else
|
||||
var bufferSpan = new ReadOnlySpan<byte>(buffer, 0, size);
|
||||
#endif
|
||||
ncha.Append(bufferSpan);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -105,68 +306,21 @@ namespace MPF.Core.Hashing
|
||||
/// <summary>
|
||||
/// Finalize the internal hash algorigthm
|
||||
/// </summary>
|
||||
/// <remarks>NonCryptographicHashAlgorithm implementations do not need finalization</remarks>
|
||||
public void Terminate()
|
||||
{
|
||||
byte[] emptyBuffer = new byte[0];
|
||||
switch (HashType)
|
||||
byte[] emptyBuffer = [];
|
||||
switch (_hasher)
|
||||
{
|
||||
case Hash.CRC32:
|
||||
(_hasher as NonCryptographicHashAlgorithm)?.Append(emptyBuffer);
|
||||
break;
|
||||
|
||||
case Hash.MD5:
|
||||
case Hash.SHA1:
|
||||
case Hash.SHA256:
|
||||
case Hash.SHA384:
|
||||
case Hash.SHA512:
|
||||
(_hasher as HashAlgorithm)?.TransformFinalBlock(emptyBuffer, 0, 0);
|
||||
case HashAlgorithm ha:
|
||||
ha.TransformFinalBlock(emptyBuffer, 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get internal hash as a byte array
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public byte[] GetHash()
|
||||
#else
|
||||
public byte[]? GetHash()
|
||||
#endif
|
||||
{
|
||||
if (_hasher == null)
|
||||
return null;
|
||||
#endregion
|
||||
|
||||
switch (HashType)
|
||||
{
|
||||
case Hash.CRC32:
|
||||
return (_hasher as NonCryptographicHashAlgorithm)?.GetCurrentHash();
|
||||
|
||||
case Hash.MD5:
|
||||
case Hash.SHA1:
|
||||
case Hash.SHA256:
|
||||
case Hash.SHA384:
|
||||
case Hash.SHA512:
|
||||
return (_hasher as HashAlgorithm)?.Hash;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get internal hash as a string
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public string GetHashString()
|
||||
#else
|
||||
public string? GetHashString()
|
||||
#endif
|
||||
{
|
||||
var hash = GetHash();
|
||||
if (hash == null)
|
||||
return null;
|
||||
|
||||
return ByteArrayToString(hash);
|
||||
}
|
||||
#region Helpers
|
||||
|
||||
/// <summary>
|
||||
/// Convert a byte array to a hex string
|
||||
@@ -174,11 +328,7 @@ namespace MPF.Core.Hashing
|
||||
/// <param name="bytes">Byte array to convert</param>
|
||||
/// <returns>Hex string representing the byte array</returns>
|
||||
/// <link>http://stackoverflow.com/questions/311165/how-do-you-convert-byte-array-to-hexadecimal-string-and-vice-versa</link>
|
||||
#if NET48
|
||||
private static string ByteArrayToString(byte[] bytes)
|
||||
#else
|
||||
private static string? ByteArrayToString(byte[]? bytes)
|
||||
#endif
|
||||
{
|
||||
// If we get null in, we send null out
|
||||
if (bytes == null)
|
||||
@@ -194,5 +344,7 @@ namespace MPF.Core.Hashing
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
184
MPF.Core/Hashing/OptimizedCRC.cs
Normal file
184
MPF.Core/Hashing/OptimizedCRC.cs
Normal file
@@ -0,0 +1,184 @@
|
||||
#if NETFRAMEWORK || NETCOREAPP3_1 || NET5_0
|
||||
|
||||
/*
|
||||
|
||||
Copyright (c) 2012-2015 Eugene Larchenko (spct@mail.ru)
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
//namespace OptimizedCRC
|
||||
namespace MPF.Core.Hashing
|
||||
{
|
||||
/// <summary>
|
||||
/// Shell class to trick older versions into using CRC-32 properly
|
||||
/// </summary>
|
||||
internal abstract class NonCryptographicHashAlgorithm
|
||||
{
|
||||
#if NET20 || NET35 || NET40
|
||||
/// <summary>
|
||||
/// When overridden in a derived class, appends the contents of source to
|
||||
/// the data already processed for the current hash computation.
|
||||
/// </summary>
|
||||
/// <param name="source">The data to process.</param>
|
||||
public abstract void Append(byte[] source);
|
||||
#else
|
||||
/// <summary>
|
||||
/// When overridden in a derived class, appends the contents of source to
|
||||
/// the data already processed for the current hash computation.
|
||||
/// </summary>
|
||||
/// <param name="source">The data to process.</param>
|
||||
public abstract void Append(ReadOnlySpan<byte> source);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current computed hash value without modifying accumulated state.
|
||||
/// </summary>
|
||||
/// <returns>The hash value for the data already provided.</returns>
|
||||
public abstract byte[] GetCurrentHash();
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// Some changes have been made to this code to make it more similar to the System.IO.Hashing implementations
|
||||
/// </remarks>
|
||||
internal class Crc32 : NonCryptographicHashAlgorithm, IDisposable
|
||||
{
|
||||
private const uint kCrcPoly = 0xEDB88320;
|
||||
private const uint kInitial = 0xFFFFFFFF;
|
||||
private const int CRC_NUM_TABLES = 8;
|
||||
private static readonly uint[] Table;
|
||||
|
||||
static Crc32()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
Table = new uint[256 * CRC_NUM_TABLES];
|
||||
int i;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
uint r = (uint)i;
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1));
|
||||
}
|
||||
Table[i] = r;
|
||||
}
|
||||
for (; i < 256 * CRC_NUM_TABLES; i++)
|
||||
{
|
||||
uint r = Table[i - 256];
|
||||
Table[i] = Table[r & 0xFF] ^ (r >> 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public uint UnsignedValue;
|
||||
|
||||
public Crc32()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset CRC
|
||||
/// </summary>
|
||||
public void Init()
|
||||
{
|
||||
UnsignedValue = kInitial;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override byte[] GetCurrentHash()
|
||||
{
|
||||
return BitConverter.GetBytes(~UnsignedValue);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET20 || NET35 || NET40
|
||||
public override void Append(byte[] source)
|
||||
{
|
||||
Update(source, 0, source.Length);
|
||||
}
|
||||
#else
|
||||
public override void Append(ReadOnlySpan<byte> source)
|
||||
{
|
||||
byte[] sourceBytes = source.ToArray();
|
||||
Update(sourceBytes, 0, sourceBytes.Length);
|
||||
}
|
||||
#endif
|
||||
|
||||
private void Update(byte[] data, int offset, int count)
|
||||
{
|
||||
_ = new ArraySegment<byte>(data, offset, count); // check arguments
|
||||
if (count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var table = Table;
|
||||
|
||||
uint crc = UnsignedValue;
|
||||
|
||||
for (; (offset & 7) != 0 && count != 0; count--)
|
||||
{
|
||||
crc = (crc >> 8) ^ table[(byte)crc ^ data[offset++]];
|
||||
}
|
||||
|
||||
if (count >= 8)
|
||||
{
|
||||
/*
|
||||
* Idea from 7-zip project sources (http://7-zip.org/sdk.html)
|
||||
*/
|
||||
|
||||
int end = (count - 8) & ~7;
|
||||
count -= end;
|
||||
end += offset;
|
||||
|
||||
while (offset != end)
|
||||
{
|
||||
crc ^= (uint)(data[offset] + (data[offset + 1] << 8) + (data[offset + 2] << 16) + (data[offset + 3] << 24));
|
||||
uint high = (uint)(data[offset + 4] + (data[offset + 5] << 8) + (data[offset + 6] << 16) + (data[offset + 7] << 24));
|
||||
offset += 8;
|
||||
|
||||
crc = table[(byte)crc + 0x700]
|
||||
^ table[(byte)(crc >>= 8) + 0x600]
|
||||
^ table[(byte)(crc >>= 8) + 0x500]
|
||||
^ table[/*(byte)*/(crc >> 8) + 0x400]
|
||||
^ table[(byte)(high) + 0x300]
|
||||
^ table[(byte)(high >>= 8) + 0x200]
|
||||
^ table[(byte)(high >>= 8) + 0x100]
|
||||
^ table[/*(byte)*/(high >> 8) + 0x000];
|
||||
}
|
||||
}
|
||||
|
||||
while (count-- != 0)
|
||||
{
|
||||
crc = (crc >> 8) ^ table[(byte)crc ^ data[offset++]];
|
||||
}
|
||||
|
||||
UnsignedValue = crc;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UnsignedValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -5,17 +5,13 @@ using System.Threading;
|
||||
//namespace Compress.ThreadReaders
|
||||
namespace MPF.Core.Hashing
|
||||
{
|
||||
public class ThreadLoadBuffer : IDisposable
|
||||
public sealed class ThreadLoadBuffer : IDisposable
|
||||
{
|
||||
private readonly AutoResetEvent _waitEvent;
|
||||
private readonly AutoResetEvent _outEvent;
|
||||
private readonly Thread _tWorker;
|
||||
|
||||
#if NET48
|
||||
private byte[] _buffer;
|
||||
#else
|
||||
private byte[]? _buffer;
|
||||
#endif
|
||||
private int _size;
|
||||
private readonly Stream _ds;
|
||||
private bool _finished;
|
||||
|
||||
3463
MPF.Core/InfoTool.cs
3463
MPF.Core/InfoTool.cs
File diff suppressed because it is too large
Load Diff
@@ -1,34 +1,63 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net48;net6.0;net7.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
|
||||
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
|
||||
<Copyright>Copyright (c)2019-2023</Copyright>
|
||||
<VersionPrefix>2.7.1</VersionPrefix>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">
|
||||
<!-- Assembly Properties -->
|
||||
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<VersionPrefix>3.0.3</VersionPrefix>
|
||||
|
||||
<!-- Package Properties -->
|
||||
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
|
||||
<Description>Common code for all MPF implementations</Description>
|
||||
<Copyright>Copyright (c) Matt Nadareski 2019-2023</Copyright>
|
||||
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/SabreTools/MPF</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="MPF.Test" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Support for old .NET versions -->
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net40`))">
|
||||
<PackageReference Include="MinAsyncBridge" Version="0.12.4" />
|
||||
<PackageReference Include="MinTasksExtensionsBridge" Version="0.3.4" />
|
||||
<PackageReference Include="MinThreadingBridge" Version="0.11.4" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`))">
|
||||
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net4`)) AND !$(TargetFramework.StartsWith(`net40`))">
|
||||
<PackageReference Include="IndexRange" Version="1.0.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net452`))">
|
||||
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))">
|
||||
<PackageReference Include="Microsoft.Management.Infrastructure" Version="3.0.0" />
|
||||
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`))">
|
||||
<PackageReference Include="System.IO.Hashing" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BurnOutSharp" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="2.8.0" GeneratePathProperty="true">
|
||||
<PackageReference Include="BinaryObjectScanner" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="3.0.2" GeneratePathProperty="true">
|
||||
<IncludeAssets>runtime; compile; build; native; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Management.Infrastructure" Version="3.0.0-preview.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.1.4" />
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.1.1" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.1.6" />
|
||||
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
|
||||
<PackageReference Include="System.IO.Compression.ZipFile" Version="4.3.0" />
|
||||
<PackageReference Include="System.IO.Hashing" Version="7.0.0" />
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
|
||||
<PackageReference Include="psxt001z.Library" Version="0.21.0-beta3" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.3.0" />
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.3.1" />
|
||||
<PackageReference Include="SabreTools.Serialization" Version="1.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using MPF.Core.Converters;
|
||||
using MPF.Core.Data;
|
||||
using SabreTools.RedumpLib;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
namespace MPF.Core.Modules.CleanRip
|
||||
@@ -22,15 +22,11 @@ namespace MPF.Core.Modules.CleanRip
|
||||
#endregion
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Parameters(string parameters) : base(parameters) { }
|
||||
#else
|
||||
public Parameters(string? parameters) : base(parameters) { }
|
||||
#endif
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options)
|
||||
: base(system, type, driveLetter, filename, driveSpeed, options)
|
||||
public Parameters(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Options options)
|
||||
: base(system, type, drivePath, filename, driveSpeed, options)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -39,7 +35,7 @@ namespace MPF.Core.Modules.CleanRip
|
||||
/// <inheritdoc/>
|
||||
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
|
||||
{
|
||||
List<string> missingFiles = new List<string>();
|
||||
var missingFiles = new List<string>();
|
||||
switch (this.Type)
|
||||
{
|
||||
case MediaType.DVD: // Only added here to help users; not strictly correct
|
||||
@@ -64,24 +60,21 @@ namespace MPF.Core.Modules.CleanRip
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, Options options, string basePath, Drive drive, bool includeArtifacts)
|
||||
#else
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, Options options, string basePath, Drive? drive, bool includeArtifacts)
|
||||
#endif
|
||||
{
|
||||
// Ensure that required sections exist
|
||||
info = Builder.EnsureAllSections(info);
|
||||
|
||||
// TODO: Determine if there's a CleanRip version anywhere
|
||||
if (info.DumpingInfo == null) info.DumpingInfo = new DumpingInfoSection();
|
||||
info.DumpingInfo.DumpingProgram = EnumConverter.LongName(this.InternalProgram);
|
||||
info.DumpingInfo.DumpingDate = GetFileModifiedDate(basePath + "-dumpinfo.txt")?.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
info.DumpingInfo!.DumpingProgram = EnumConverter.LongName(this.InternalProgram);
|
||||
info.DumpingInfo.DumpingDate = InfoTool.GetFileModifiedDate(basePath + "-dumpinfo.txt")?.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
var datafile = GenerateCleanripDatafile(basePath + ".iso", basePath + "-dumpinfo.txt");
|
||||
|
||||
// Get the individual hash data, as per internal
|
||||
if (GetISOHashValues(datafile, out long size, out var crc32, out var md5, out var sha1))
|
||||
if (InfoTool.GetISOHashValues(datafile, out long size, out var crc32, out var md5, out var sha1))
|
||||
{
|
||||
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
|
||||
info.SizeAndChecksums.Size = size;
|
||||
info.SizeAndChecksums!.Size = size;
|
||||
info.SizeAndChecksums.CRC32 = crc32;
|
||||
info.SizeAndChecksums.MD5 = md5;
|
||||
info.SizeAndChecksums.SHA1 = sha1;
|
||||
@@ -98,23 +91,13 @@ namespace MPF.Core.Modules.CleanRip
|
||||
case MediaType.NintendoGameCubeGameDisc:
|
||||
case MediaType.NintendoWiiOpticalDisc:
|
||||
if (File.Exists(basePath + ".bca"))
|
||||
{
|
||||
if (info.Extras == null) info.Extras = new ExtrasSection();
|
||||
info.Extras.BCA = GetBCA(basePath + ".bca");
|
||||
}
|
||||
info.Extras!.BCA = GetBCA(basePath + ".bca");
|
||||
|
||||
if (GetGameCubeWiiInformation(basePath + "-dumpinfo.txt", out Region? gcRegion, out var gcVersion, out var gcName))
|
||||
{
|
||||
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
|
||||
info.CommonDiscInfo.Region = gcRegion ?? info.CommonDiscInfo.Region;
|
||||
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
|
||||
info.VersionAndEditions.Version = gcVersion ?? info.VersionAndEditions.Version;
|
||||
#if NET48
|
||||
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode?, string>();
|
||||
#else
|
||||
if (info.CommonDiscInfo.CommentsSpecialFields == null) info.CommonDiscInfo.CommentsSpecialFields = new Dictionary<SiteCode, string>();
|
||||
#endif
|
||||
info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalName] = gcName ?? string.Empty;
|
||||
info.CommonDiscInfo!.Region = gcRegion ?? info.CommonDiscInfo.Region;
|
||||
info.VersionAndEditions!.Version = gcVersion ?? info.VersionAndEditions.Version;
|
||||
info.CommonDiscInfo.CommentsSpecialFields![SiteCode.InternalName] = gcName ?? string.Empty;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -123,7 +106,8 @@ namespace MPF.Core.Modules.CleanRip
|
||||
// Fill in any artifacts that exist, Base64-encoded, if we need to
|
||||
if (includeArtifacts)
|
||||
{
|
||||
if (info.Artifacts == null) info.Artifacts = new Dictionary<string, string>();
|
||||
info.Artifacts ??= [];
|
||||
|
||||
if (File.Exists(basePath + ".bca"))
|
||||
info.Artifacts["bca"] = GetBase64(GetFullFile(basePath + ".bca", binary: true)) ?? string.Empty;
|
||||
if (File.Exists(basePath + "-dumpinfo.txt"))
|
||||
@@ -134,7 +118,7 @@ namespace MPF.Core.Modules.CleanRip
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetLogFilePaths(string basePath)
|
||||
{
|
||||
List<string> logFiles = new List<string>();
|
||||
var logFiles = new List<string>();
|
||||
switch (this.Type)
|
||||
{
|
||||
case MediaType.DVD: // Only added here to help users; not strictly correct
|
||||
@@ -161,62 +145,56 @@ namespace MPF.Core.Modules.CleanRip
|
||||
/// <param name="iso">Path to ISO file</param>
|
||||
/// <param name="dumpinfo">Path to discinfo file</param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
private static Datafile GenerateCleanripDatafile(string iso, string dumpinfo)
|
||||
#else
|
||||
private static Datafile? GenerateCleanripDatafile(string iso, string dumpinfo)
|
||||
#endif
|
||||
{
|
||||
// If the file doesn't exist, we can't get info from it
|
||||
if (!File.Exists(dumpinfo))
|
||||
// If the files don't exist, we can't get info from it
|
||||
if (!File.Exists(iso) || !File.Exists(dumpinfo))
|
||||
return null;
|
||||
|
||||
using (StreamReader sr = File.OpenText(dumpinfo))
|
||||
long size = new FileInfo(iso).Length;
|
||||
string crc = string.Empty;
|
||||
string md5 = string.Empty;
|
||||
string sha1 = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
long size = new FileInfo(iso).Length;
|
||||
string crc = string.Empty;
|
||||
string md5 = string.Empty;
|
||||
string sha1 = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
// Make sure this file is a dumpinfo
|
||||
if (sr.ReadLine()?.Contains("--File Generated by CleanRip") != true)
|
||||
return null;
|
||||
|
||||
// Read all lines and gather dat information
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
continue;
|
||||
else if (line.StartsWith("CRC32"))
|
||||
crc = line.Substring(7).ToLowerInvariant();
|
||||
else if (line.StartsWith("MD5"))
|
||||
md5 = line.Substring(5);
|
||||
else if (line.StartsWith("SHA-1"))
|
||||
sha1 = line.Substring(7);
|
||||
}
|
||||
|
||||
return new Datafile
|
||||
{
|
||||
Games = new Game[]
|
||||
{
|
||||
new Game
|
||||
{
|
||||
Roms = new Rom[]
|
||||
{
|
||||
new Rom { Name = Path.GetFileName(iso), Size = size.ToString(), Crc = crc, Md5 = md5, Sha1 = sha1 },
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We don't care what the exception is right now
|
||||
// Make sure this file is a dumpinfo
|
||||
using var sr = File.OpenText(dumpinfo);
|
||||
if (sr.ReadLine()?.Contains("--File Generated by CleanRip") != true)
|
||||
return null;
|
||||
|
||||
// Read all lines and gather dat information
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (string.IsNullOrEmpty(line))
|
||||
continue;
|
||||
else if (line!.StartsWith("CRC32"))
|
||||
crc = line.Substring(7).ToLowerInvariant();
|
||||
else if (line.StartsWith("MD5"))
|
||||
md5 = line.Substring(5);
|
||||
else if (line.StartsWith("SHA-1"))
|
||||
sha1 = line.Substring(7);
|
||||
}
|
||||
|
||||
return new Datafile
|
||||
{
|
||||
Games =
|
||||
[
|
||||
new()
|
||||
{
|
||||
Roms =
|
||||
[
|
||||
new Rom { Name = Path.GetFileName(iso), Size = size.ToString(), Crc = crc, Md5 = md5, Sha1 = sha1 },
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We don't care what the exception is right now
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,11 +204,7 @@ namespace MPF.Core.Modules.CleanRip
|
||||
/// <param name="bcaPath">Path to the BCA file associated with the dump</param>
|
||||
/// <returns>BCA data as a hex string if possible, null on error</returns>
|
||||
/// <remarks>https://stackoverflow.com/questions/9932096/add-separator-to-string-at-every-n-characters</remarks>
|
||||
#if NET48
|
||||
private static string GetBCA(string bcaPath)
|
||||
#else
|
||||
private static string? GetBCA(string bcaPath)
|
||||
#endif
|
||||
{
|
||||
// If the file doesn't exist, we can't get the info
|
||||
if (!File.Exists(bcaPath))
|
||||
@@ -257,50 +231,44 @@ namespace MPF.Core.Modules.CleanRip
|
||||
/// <param name="iso">Path to ISO file</param>
|
||||
/// <param name="dumpinfo">Path to discinfo file</param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
private static string GetCleanripDatfile(string iso, string dumpinfo)
|
||||
#else
|
||||
private static string? GetCleanripDatfile(string iso, string dumpinfo)
|
||||
#endif
|
||||
{
|
||||
// If the file doesn't exist, we can't get info from it
|
||||
if (!File.Exists(dumpinfo))
|
||||
// If the files don't exist, we can't get info from it
|
||||
if (!File.Exists(iso) || !File.Exists(dumpinfo))
|
||||
return null;
|
||||
|
||||
using (StreamReader sr = File.OpenText(dumpinfo))
|
||||
long size = new FileInfo(iso).Length;
|
||||
string crc = string.Empty;
|
||||
string md5 = string.Empty;
|
||||
string sha1 = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
long size = new FileInfo(iso).Length;
|
||||
string crc = string.Empty;
|
||||
string md5 = string.Empty;
|
||||
string sha1 = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
// Make sure this file is a dumpinfo
|
||||
if (sr.ReadLine()?.Contains("--File Generated by CleanRip") != true)
|
||||
return null;
|
||||
|
||||
// Read all lines and gather dat information
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
continue;
|
||||
else if (line.StartsWith("CRC32"))
|
||||
crc = line.Substring(7).ToLowerInvariant();
|
||||
else if (line.StartsWith("MD5"))
|
||||
md5 = line.Substring(5);
|
||||
else if (line.StartsWith("SHA-1"))
|
||||
sha1 = line.Substring(7);
|
||||
}
|
||||
|
||||
return $"<rom name=\"{Path.GetFileName(iso)}\" size=\"{size}\" crc=\"{crc}\" md5=\"{md5}\" sha1=\"{sha1}\" />";
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We don't care what the exception is right now
|
||||
// Make sure this file is a dumpinfo
|
||||
using var sr = File.OpenText(dumpinfo);
|
||||
if (sr.ReadLine()?.Contains("--File Generated by CleanRip") != true)
|
||||
return null;
|
||||
|
||||
// Read all lines and gather dat information
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (string.IsNullOrEmpty(line))
|
||||
continue;
|
||||
else if (line!.StartsWith("CRC32"))
|
||||
crc = line.Substring(7).ToLowerInvariant();
|
||||
else if (line.StartsWith("MD5"))
|
||||
md5 = line.Substring(5);
|
||||
else if (line.StartsWith("SHA-1"))
|
||||
sha1 = line.Substring(7);
|
||||
}
|
||||
|
||||
return $"<rom name=\"{Path.GetFileName(iso)}\" size=\"{size}\" crc=\"{crc}\" md5=\"{md5}\" sha1=\"{sha1}\" />";
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We don't care what the exception is right now
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,11 +280,7 @@ namespace MPF.Core.Modules.CleanRip
|
||||
/// <param name="version">Output internal version of the game</param>
|
||||
/// <param name="name">Output internal name of the game</param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
private static bool GetGameCubeWiiInformation(string dumpinfo, out Region? region, out string version, out string name)
|
||||
#else
|
||||
private static bool GetGameCubeWiiInformation(string dumpinfo, out Region? region, out string? version, out string? name)
|
||||
#endif
|
||||
{
|
||||
region = null; version = null; name = null;
|
||||
|
||||
@@ -324,99 +288,97 @@ namespace MPF.Core.Modules.CleanRip
|
||||
if (!File.Exists(dumpinfo))
|
||||
return false;
|
||||
|
||||
using (StreamReader sr = File.OpenText(dumpinfo))
|
||||
try
|
||||
{
|
||||
try
|
||||
// Make sure this file is a dumpinfo
|
||||
using var sr = File.OpenText(dumpinfo);
|
||||
if (sr.ReadLine()?.Contains("--File Generated by CleanRip") != true)
|
||||
return false;
|
||||
|
||||
// Read all lines and gather dat information
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
// Make sure this file is a dumpinfo
|
||||
if (sr.ReadLine()?.Contains("--File Generated by CleanRip") != true)
|
||||
return false;
|
||||
|
||||
// Read all lines and gather dat information
|
||||
while (!sr.EndOfStream)
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (string.IsNullOrEmpty(line))
|
||||
{
|
||||
var line = sr.ReadLine()?.Trim();
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (line.StartsWith("Version"))
|
||||
{
|
||||
version = line.Substring("Version: ".Length);
|
||||
}
|
||||
else if (line.StartsWith("Internal Name"))
|
||||
{
|
||||
name = line.Substring("Internal Name: ".Length);
|
||||
}
|
||||
else if (line.StartsWith("Filename"))
|
||||
{
|
||||
string serial = line.Substring("Filename: ".Length);
|
||||
continue;
|
||||
}
|
||||
else if (line!.StartsWith("Version"))
|
||||
{
|
||||
version = line.Substring("Version: ".Length);
|
||||
}
|
||||
else if (line.StartsWith("Internal Name"))
|
||||
{
|
||||
name = line.Substring("Internal Name: ".Length);
|
||||
}
|
||||
else if (line.StartsWith("Filename"))
|
||||
{
|
||||
string serial = line.Substring("Filename: ".Length);
|
||||
|
||||
// char gameType = serial[0];
|
||||
// string gameid = serial[1] + serial[2];
|
||||
// string version = serial[4] + serial[5]
|
||||
// char gameType = serial[0];
|
||||
// string gameid = serial[1] + serial[2];
|
||||
// string version = serial[4] + serial[5]
|
||||
|
||||
switch (serial[3])
|
||||
{
|
||||
case 'A':
|
||||
region = Region.World;
|
||||
break;
|
||||
case 'D':
|
||||
region = Region.Germany;
|
||||
break;
|
||||
case 'E':
|
||||
region = Region.UnitedStatesOfAmerica;
|
||||
break;
|
||||
case 'F':
|
||||
region = Region.France;
|
||||
break;
|
||||
case 'I':
|
||||
region = Region.Italy;
|
||||
break;
|
||||
case 'J':
|
||||
region = Region.Japan;
|
||||
break;
|
||||
case 'K':
|
||||
region = Region.SouthKorea;
|
||||
break;
|
||||
case 'L':
|
||||
region = Region.Europe; // Japanese import to Europe
|
||||
break;
|
||||
case 'M':
|
||||
region = Region.Europe; // American import to Europe
|
||||
break;
|
||||
case 'N':
|
||||
region = Region.UnitedStatesOfAmerica; // Japanese import to USA
|
||||
break;
|
||||
case 'P':
|
||||
region = Region.Europe;
|
||||
break;
|
||||
case 'R':
|
||||
region = Region.RussianFederation;
|
||||
break;
|
||||
case 'S':
|
||||
region = Region.Spain;
|
||||
break;
|
||||
case 'Q':
|
||||
region = Region.SouthKorea; // Korea with Japanese language
|
||||
break;
|
||||
case 'T':
|
||||
region = Region.SouthKorea; // Korea with English language
|
||||
break;
|
||||
case 'X':
|
||||
region = null; // Not a real region code
|
||||
break;
|
||||
}
|
||||
switch (serial[3])
|
||||
{
|
||||
case 'A':
|
||||
region = Region.World;
|
||||
break;
|
||||
case 'D':
|
||||
region = Region.Germany;
|
||||
break;
|
||||
case 'E':
|
||||
region = Region.UnitedStatesOfAmerica;
|
||||
break;
|
||||
case 'F':
|
||||
region = Region.France;
|
||||
break;
|
||||
case 'I':
|
||||
region = Region.Italy;
|
||||
break;
|
||||
case 'J':
|
||||
region = Region.Japan;
|
||||
break;
|
||||
case 'K':
|
||||
region = Region.SouthKorea;
|
||||
break;
|
||||
case 'L':
|
||||
region = Region.Europe; // Japanese import to Europe
|
||||
break;
|
||||
case 'M':
|
||||
region = Region.Europe; // American import to Europe
|
||||
break;
|
||||
case 'N':
|
||||
region = Region.UnitedStatesOfAmerica; // Japanese import to USA
|
||||
break;
|
||||
case 'P':
|
||||
region = Region.Europe;
|
||||
break;
|
||||
case 'R':
|
||||
region = Region.RussianFederation;
|
||||
break;
|
||||
case 'S':
|
||||
region = Region.Spain;
|
||||
break;
|
||||
case 'Q':
|
||||
region = Region.SouthKorea; // Korea with Japanese language
|
||||
break;
|
||||
case 'T':
|
||||
region = Region.SouthKorea; // Korea with English language
|
||||
break;
|
||||
case 'X':
|
||||
region = null; // Not a real region code
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We don't care what the exception is right now
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We don't care what the exception is right now
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,139 +6,67 @@ namespace MPF.Core.Modules
|
||||
public class Datafile
|
||||
{
|
||||
[XmlElement("header")]
|
||||
#if NET48
|
||||
public Header Header;
|
||||
#else
|
||||
public Header? Header;
|
||||
#endif
|
||||
|
||||
[XmlElement("game")]
|
||||
#if NET48
|
||||
public Game[] Games;
|
||||
#else
|
||||
public Game[]? Games;
|
||||
#endif
|
||||
}
|
||||
|
||||
public class Header
|
||||
{
|
||||
[XmlElement("name")]
|
||||
#if NET48
|
||||
public string Name;
|
||||
#else
|
||||
public string? Name;
|
||||
#endif
|
||||
|
||||
[XmlElement("description")]
|
||||
#if NET48
|
||||
public string Description;
|
||||
#else
|
||||
public string? Description;
|
||||
#endif
|
||||
|
||||
[XmlElement("version")]
|
||||
#if NET48
|
||||
public string Version;
|
||||
#else
|
||||
public string? Version;
|
||||
#endif
|
||||
|
||||
[XmlElement("date")]
|
||||
#if NET48
|
||||
public string Date;
|
||||
#else
|
||||
public string? Date;
|
||||
#endif
|
||||
|
||||
[XmlElement("author")]
|
||||
#if NET48
|
||||
public string Author;
|
||||
#else
|
||||
public string? Author;
|
||||
#endif
|
||||
|
||||
[XmlElement("homepage")]
|
||||
#if NET48
|
||||
public string Homepage;
|
||||
#else
|
||||
public string? Homepage;
|
||||
#endif
|
||||
|
||||
[XmlElement("url")]
|
||||
#if NET48
|
||||
public string Url;
|
||||
#else
|
||||
public string? Url;
|
||||
#endif
|
||||
}
|
||||
|
||||
public class Game
|
||||
{
|
||||
[XmlAttribute("name")]
|
||||
#if NET48
|
||||
public string Name;
|
||||
#else
|
||||
public string? Name;
|
||||
#endif
|
||||
|
||||
[XmlElement("category")]
|
||||
#if NET48
|
||||
public string Category;
|
||||
#else
|
||||
public string? Category;
|
||||
#endif
|
||||
|
||||
[XmlElement("description")]
|
||||
#if NET48
|
||||
public string Description;
|
||||
#else
|
||||
public string? Description;
|
||||
#endif
|
||||
|
||||
[XmlElement("rom")]
|
||||
#if NET48
|
||||
public Rom[] Roms;
|
||||
#else
|
||||
public Rom[]? Roms;
|
||||
#endif
|
||||
}
|
||||
|
||||
public class Rom
|
||||
{
|
||||
[XmlAttribute("name")]
|
||||
#if NET48
|
||||
public string Name;
|
||||
#else
|
||||
public string? Name;
|
||||
#endif
|
||||
|
||||
[XmlAttribute("size")]
|
||||
#if NET48
|
||||
public string Size;
|
||||
#else
|
||||
public string? Size;
|
||||
#endif
|
||||
|
||||
[XmlAttribute("crc")]
|
||||
#if NET48
|
||||
public string Crc;
|
||||
#else
|
||||
public string? Crc;
|
||||
#endif
|
||||
|
||||
[XmlAttribute("md5")]
|
||||
#if NET48
|
||||
public string Md5;
|
||||
#else
|
||||
public string? Md5;
|
||||
#endif
|
||||
|
||||
[XmlAttribute("sha1")]
|
||||
#if NET48
|
||||
public string Sha1;
|
||||
#else
|
||||
public string? Sha1;
|
||||
#endif
|
||||
|
||||
// TODO: Add extended hashes here
|
||||
}
|
||||
|
||||
@@ -13,33 +13,25 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
/// <returns>RedumpSystem if possible, null on error</returns>
|
||||
public static RedumpSystem? ToRedumpSystem(string baseCommand)
|
||||
{
|
||||
switch (baseCommand)
|
||||
return baseCommand switch
|
||||
{
|
||||
case CommandStrings.Audio:
|
||||
return RedumpSystem.AudioCD;
|
||||
case CommandStrings.CompactDisc:
|
||||
case CommandStrings.Data:
|
||||
case CommandStrings.DigitalVideoDisc:
|
||||
case CommandStrings.Disk:
|
||||
case CommandStrings.Floppy:
|
||||
case CommandStrings.Tape:
|
||||
return RedumpSystem.IBMPCcompatible;
|
||||
case CommandStrings.GDROM:
|
||||
case CommandStrings.Swap:
|
||||
return RedumpSystem.SegaDreamcast;
|
||||
case CommandStrings.BluRay:
|
||||
return RedumpSystem.SonyPlayStation3;
|
||||
case CommandStrings.SACD:
|
||||
return RedumpSystem.SuperAudioCD;
|
||||
case CommandStrings.XBOX:
|
||||
case CommandStrings.XBOXSwap:
|
||||
return RedumpSystem.MicrosoftXbox;
|
||||
case CommandStrings.XGD2Swap:
|
||||
case CommandStrings.XGD3Swap:
|
||||
return RedumpSystem.MicrosoftXbox360;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
CommandStrings.Audio => (RedumpSystem?)RedumpSystem.AudioCD,
|
||||
CommandStrings.CompactDisc
|
||||
or CommandStrings.Data
|
||||
or CommandStrings.DigitalVideoDisc
|
||||
or CommandStrings.Disk
|
||||
or CommandStrings.Floppy
|
||||
or CommandStrings.Tape => (RedumpSystem?)RedumpSystem.IBMPCcompatible,
|
||||
CommandStrings.GDROM
|
||||
or CommandStrings.Swap => (RedumpSystem?)RedumpSystem.SegaDreamcast,
|
||||
CommandStrings.BluRay => (RedumpSystem?)RedumpSystem.SonyPlayStation3,
|
||||
CommandStrings.SACD => (RedumpSystem?)RedumpSystem.SuperAudioCD,
|
||||
CommandStrings.XBOX
|
||||
or CommandStrings.XBOXSwap => (RedumpSystem?)RedumpSystem.MicrosoftXbox,
|
||||
CommandStrings.XGD2Swap
|
||||
or CommandStrings.XGD3Swap => (RedumpSystem?)RedumpSystem.MicrosoftXbox360,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -48,41 +40,29 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
/// <param name="baseCommand">Command value to check</param>
|
||||
/// <returns>MediaType if possible, null on error</returns>
|
||||
/// <remarks>This takes the "safe" route by assuming the larger of any given format</remarks>
|
||||
#if NET48
|
||||
public static MediaType? ToMediaType(string baseCommand)
|
||||
#else
|
||||
public static MediaType? ToMediaType(string? baseCommand)
|
||||
#endif
|
||||
{
|
||||
switch (baseCommand)
|
||||
return baseCommand switch
|
||||
{
|
||||
case CommandStrings.Audio:
|
||||
case CommandStrings.CompactDisc:
|
||||
case CommandStrings.Data:
|
||||
case CommandStrings.SACD:
|
||||
return MediaType.CDROM;
|
||||
case CommandStrings.GDROM:
|
||||
case CommandStrings.Swap:
|
||||
return MediaType.GDROM;
|
||||
case CommandStrings.DigitalVideoDisc:
|
||||
case CommandStrings.XBOX:
|
||||
case CommandStrings.XBOXSwap:
|
||||
case CommandStrings.XGD2Swap:
|
||||
case CommandStrings.XGD3Swap:
|
||||
return MediaType.DVD;
|
||||
case CommandStrings.BluRay:
|
||||
return MediaType.BluRay;
|
||||
CommandStrings.Audio
|
||||
or CommandStrings.CompactDisc
|
||||
or CommandStrings.Data
|
||||
or CommandStrings.SACD => (MediaType?)MediaType.CDROM,
|
||||
CommandStrings.GDROM
|
||||
or CommandStrings.Swap => (MediaType?)MediaType.GDROM,
|
||||
CommandStrings.DigitalVideoDisc
|
||||
or CommandStrings.XBOX
|
||||
or CommandStrings.XBOXSwap
|
||||
or CommandStrings.XGD2Swap
|
||||
or CommandStrings.XGD3Swap => (MediaType?)MediaType.DVD,
|
||||
CommandStrings.BluRay => (MediaType?)MediaType.BluRay,
|
||||
|
||||
// Non-optical
|
||||
case CommandStrings.Floppy:
|
||||
return MediaType.FloppyDisk;
|
||||
case CommandStrings.Disk:
|
||||
return MediaType.HardDisk;
|
||||
case CommandStrings.Tape:
|
||||
return MediaType.DataCartridge;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
CommandStrings.Floppy => (MediaType?)MediaType.FloppyDisk,
|
||||
CommandStrings.Disk => (MediaType?)MediaType.HardDisk,
|
||||
CommandStrings.Tape => (MediaType?)MediaType.DataCartridge,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,41 +70,29 @@ namespace MPF.Core.Modules.DiscImageCreator
|
||||
/// </summary>
|
||||
/// <param name="type">MediaType value to check</param>
|
||||
/// <returns>Valid extension (with leading '.'), null on error</returns>
|
||||
#if NET48
|
||||
public static string Extension(MediaType? type)
|
||||
#else
|
||||
public static string? Extension(MediaType? type)
|
||||
#endif
|
||||
{
|
||||
switch (type)
|
||||
return type switch
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
case MediaType.GDROM:
|
||||
case MediaType.Cartridge:
|
||||
case MediaType.HardDisk:
|
||||
case MediaType.CompactFlash:
|
||||
case MediaType.MMC:
|
||||
case MediaType.SDCard:
|
||||
case MediaType.FlashDrive:
|
||||
return ".bin";
|
||||
case MediaType.DVD:
|
||||
case MediaType.HDDVD:
|
||||
case MediaType.BluRay:
|
||||
case MediaType.NintendoWiiOpticalDisc:
|
||||
return ".iso";
|
||||
case MediaType.LaserDisc:
|
||||
case MediaType.NintendoGameCubeGameDisc:
|
||||
return ".raw";
|
||||
case MediaType.NintendoWiiUOpticalDisc:
|
||||
return ".wud";
|
||||
case MediaType.FloppyDisk:
|
||||
return ".img";
|
||||
case MediaType.Cassette:
|
||||
return ".wav";
|
||||
case MediaType.NONE:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
MediaType.CDROM
|
||||
or MediaType.GDROM
|
||||
or MediaType.Cartridge
|
||||
or MediaType.HardDisk
|
||||
or MediaType.CompactFlash
|
||||
or MediaType.MMC
|
||||
or MediaType.SDCard
|
||||
or MediaType.FlashDrive => ".bin",
|
||||
MediaType.DVD
|
||||
or MediaType.HDDVD
|
||||
or MediaType.BluRay
|
||||
or MediaType.NintendoWiiOpticalDisc => ".iso",
|
||||
MediaType.LaserDisc
|
||||
or MediaType.NintendoGameCubeGameDisc => ".raw",
|
||||
MediaType.NintendoWiiUOpticalDisc => ".wud",
|
||||
MediaType.FloppyDisk => ".img",
|
||||
MediaType.Cassette => ".wav",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,13 +11,15 @@ namespace MPF.Core.Modules.Redumper
|
||||
public const string BluRay = "bd"; // Synonym for CD
|
||||
public const string SACD = "sacd"; // Synonym for CD
|
||||
public const string Dump = "dump";
|
||||
public const string Info = "info";
|
||||
public const string Protection = "protection";
|
||||
public const string Refine = "refine";
|
||||
public const string Split = "split";
|
||||
public const string Verify = "verify";
|
||||
public const string DVDKey = "dvdkey";
|
||||
public const string DVDIsoKey = "dvdisokey";
|
||||
public const string Protection = "protection";
|
||||
public const string Split = "split";
|
||||
public const string Hash = "hash";
|
||||
public const string Info = "info";
|
||||
public const string Skeleton = "skeleton";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -11,24 +11,16 @@ namespace MPF.Core.Modules.Redumper
|
||||
/// </summary>
|
||||
/// <param name="type">MediaType value to check</param>
|
||||
/// <returns>Valid extension (with leading '.'), null on error</returns>
|
||||
#if NET48
|
||||
public static string Extension(MediaType? type)
|
||||
#else
|
||||
public static string? Extension(MediaType? type)
|
||||
#endif
|
||||
{
|
||||
switch (type)
|
||||
return type switch
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
return ".bin";
|
||||
case MediaType.DVD:
|
||||
case MediaType.HDDVD:
|
||||
case MediaType.BluRay:
|
||||
return ".iso";
|
||||
case MediaType.NONE:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
MediaType.CDROM => ".bin",
|
||||
MediaType.DVD
|
||||
or MediaType.HDDVD
|
||||
or MediaType.BluRay => ".iso",
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,8 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using MPF.Core.Converters;
|
||||
using MPF.Core.Data;
|
||||
using MPF.Core.Hashing;
|
||||
using SabreTools.RedumpLib;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
namespace MPF.Core.Modules.UmdImageCreator
|
||||
@@ -21,15 +23,11 @@ namespace MPF.Core.Modules.UmdImageCreator
|
||||
#endregion
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public Parameters(string parameters) : base(parameters) { }
|
||||
#else
|
||||
public Parameters(string? parameters) : base(parameters) { }
|
||||
#endif
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options)
|
||||
: base(system, type, driveLetter, filename, driveSpeed, options)
|
||||
public Parameters(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Options options)
|
||||
: base(system, type, drivePath, filename, driveSpeed, options)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -38,7 +36,7 @@ namespace MPF.Core.Modules.UmdImageCreator
|
||||
/// <inheritdoc/>
|
||||
public override (bool, List<string>) CheckAllOutputFilesExist(string basePath, bool preCheck)
|
||||
{
|
||||
List<string> missingFiles = new List<string>();
|
||||
var missingFiles = new List<string>();
|
||||
switch (this.Type)
|
||||
{
|
||||
case MediaType.UMD:
|
||||
@@ -65,28 +63,24 @@ namespace MPF.Core.Modules.UmdImageCreator
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, Options options, string basePath, Drive drive, bool includeArtifacts)
|
||||
#else
|
||||
public override void GenerateSubmissionInfo(SubmissionInfo info, Options options, string basePath, Drive? drive, bool includeArtifacts)
|
||||
#endif
|
||||
{
|
||||
// Ensure that required sections exist
|
||||
info = Builder.EnsureAllSections(info);
|
||||
|
||||
// TODO: Determine if there's a UMDImageCreator version anywhere
|
||||
if (info.DumpingInfo == null) info.DumpingInfo = new DumpingInfoSection();
|
||||
info.DumpingInfo.DumpingProgram = EnumConverter.LongName(this.InternalProgram);
|
||||
info.DumpingInfo.DumpingDate = GetFileModifiedDate(basePath + "_disc.txt")?.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
info.DumpingInfo!.DumpingProgram = EnumConverter.LongName(this.InternalProgram);
|
||||
info.DumpingInfo.DumpingDate = InfoTool.GetFileModifiedDate(basePath + "_disc.txt")?.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
// Extract info based generically on MediaType
|
||||
switch (this.Type)
|
||||
{
|
||||
case MediaType.UMD:
|
||||
if (info.Extras == null) info.Extras = new ExtrasSection();
|
||||
info.Extras.PVD = GetPVD(basePath + "_mainInfo.txt") ?? string.Empty;
|
||||
info.Extras!.PVD = GetPVD(basePath + "_mainInfo.txt") ?? string.Empty;
|
||||
|
||||
if (GetFileHashes(basePath + ".iso", out long filesize, out var crc32, out var md5, out var sha1))
|
||||
if (Hasher.GetFileHashes(basePath + ".iso", out long filesize, out var crc32, out var md5, out var sha1))
|
||||
{
|
||||
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
|
||||
info.SizeAndChecksums.Size = filesize;
|
||||
info.SizeAndChecksums!.Size = filesize;
|
||||
info.SizeAndChecksums.CRC32 = crc32;
|
||||
info.SizeAndChecksums.MD5 = md5;
|
||||
info.SizeAndChecksums.SHA1 = sha1;
|
||||
@@ -94,15 +88,12 @@ namespace MPF.Core.Modules.UmdImageCreator
|
||||
|
||||
if (GetUMDAuxInfo(basePath + "_disc.txt", out var title, out DiscCategory? umdcat, out var umdversion, out var umdlayer, out long umdsize))
|
||||
{
|
||||
if (info.CommonDiscInfo == null) info.CommonDiscInfo = new CommonDiscInfoSection();
|
||||
info.CommonDiscInfo.Title = title ?? string.Empty;
|
||||
info.CommonDiscInfo!.Title = title ?? string.Empty;
|
||||
info.CommonDiscInfo.Category = umdcat ?? DiscCategory.Games;
|
||||
if (info.VersionAndEditions == null) info.VersionAndEditions = new VersionAndEditionsSection();
|
||||
info.VersionAndEditions.Version = umdversion ?? string.Empty;
|
||||
if (info.SizeAndChecksums == null) info.SizeAndChecksums = new SizeAndChecksumsSection();
|
||||
info.SizeAndChecksums.Size = umdsize;
|
||||
info.VersionAndEditions!.Version = umdversion ?? string.Empty;
|
||||
info.SizeAndChecksums!.Size = umdsize;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(umdlayer))
|
||||
if (!string.IsNullOrEmpty(umdlayer))
|
||||
info.SizeAndChecksums.Layerbreak = Int64.Parse(umdlayer ?? "-1");
|
||||
}
|
||||
|
||||
@@ -112,7 +103,8 @@ namespace MPF.Core.Modules.UmdImageCreator
|
||||
// Fill in any artifacts that exist, Base64-encoded, if we need to
|
||||
if (includeArtifacts)
|
||||
{
|
||||
if (info.Artifacts == null) info.Artifacts = new Dictionary<string, string>();
|
||||
info.Artifacts ??= [];
|
||||
|
||||
if (File.Exists(basePath + "_disc.txt"))
|
||||
info.Artifacts["disc"] = GetBase64(GetFullFile(basePath + "_disc.txt")) ?? string.Empty;
|
||||
if (File.Exists(basePath + "_drive.txt"))
|
||||
@@ -129,7 +121,7 @@ namespace MPF.Core.Modules.UmdImageCreator
|
||||
/// <inheritdoc/>
|
||||
public override List<string> GetLogFilePaths(string basePath)
|
||||
{
|
||||
List<string> logFiles = new List<string>();
|
||||
var logFiles = new List<string>();
|
||||
switch (this.Type)
|
||||
{
|
||||
case MediaType.UMD:
|
||||
@@ -159,38 +151,32 @@ namespace MPF.Core.Modules.UmdImageCreator
|
||||
/// </summary>
|
||||
/// <param name="mainInfo">_mainInfo.txt file location</param>
|
||||
/// <returns>Newline-deliminated PVD if possible, null on error</returns>
|
||||
#if NET48
|
||||
private static string GetPVD(string mainInfo)
|
||||
#else
|
||||
private static string? GetPVD(string mainInfo)
|
||||
#endif
|
||||
{
|
||||
// If the file doesn't exist, we can't get info from it
|
||||
if (!File.Exists(mainInfo))
|
||||
return null;
|
||||
|
||||
using (StreamReader sr = File.OpenText(mainInfo))
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
// Make sure we're in the right sector
|
||||
while (sr.ReadLine()?.StartsWith("========== LBA[000016, 0x0000010]: Main Channel ==========") == false) ;
|
||||
// Make sure we're in the right sector
|
||||
using var sr = File.OpenText(mainInfo);
|
||||
while (sr.ReadLine()?.StartsWith("========== LBA[000016, 0x0000010]: Main Channel ==========") == false) ;
|
||||
|
||||
// Fast forward to the PVD
|
||||
while (sr.ReadLine()?.StartsWith("0310") == false) ;
|
||||
// Fast forward to the PVD
|
||||
while (sr.ReadLine()?.StartsWith("0310") == false) ;
|
||||
|
||||
// Now that we're at the PVD, read each line in and concatenate
|
||||
string pvd = "";
|
||||
for (int i = 0; i < 6; i++)
|
||||
pvd += sr.ReadLine() + "\n"; // 320-370
|
||||
// Now that we're at the PVD, read each line in and concatenate
|
||||
string pvd = "";
|
||||
for (int i = 0; i < 6; i++)
|
||||
pvd += sr.ReadLine() + "\n"; // 320-370
|
||||
|
||||
return pvd;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We don't care what the exception is right now
|
||||
return null;
|
||||
}
|
||||
return pvd;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We don't care what the exception is right now
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,11 +185,7 @@ namespace MPF.Core.Modules.UmdImageCreator
|
||||
/// </summary>
|
||||
/// <param name="disc">_disc.txt file location</param>
|
||||
/// <returns>True on successful extraction of info, false otherwise</returns>
|
||||
#if NET48
|
||||
private static bool GetUMDAuxInfo(string disc, out string title, out DiscCategory? umdcat, out string umdversion, out string umdlayer, out long umdsize)
|
||||
#else
|
||||
private static bool GetUMDAuxInfo(string disc, out string? title, out DiscCategory? umdcat, out string? umdversion, out string? umdlayer, out long umdsize)
|
||||
#endif
|
||||
{
|
||||
title = null; umdcat = null; umdversion = null; umdlayer = null; umdsize = -1;
|
||||
|
||||
@@ -211,41 +193,38 @@ namespace MPF.Core.Modules.UmdImageCreator
|
||||
if (!File.Exists(disc))
|
||||
return false;
|
||||
|
||||
using (StreamReader sr = File.OpenText(disc))
|
||||
try
|
||||
{
|
||||
try
|
||||
// Loop through everything to get the first instance of each required field
|
||||
using var sr = File.OpenText(disc);
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
// Loop through everything to get the first instance of each required field
|
||||
var line = string.Empty;
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
break;
|
||||
string? line = sr.ReadLine()?.Trim();
|
||||
if (line == null)
|
||||
break;
|
||||
|
||||
if (line.StartsWith("TITLE") && title == null)
|
||||
title = line.Substring("TITLE: ".Length);
|
||||
else if (line.StartsWith("DISC_VERSION") && umdversion == null)
|
||||
umdversion = line.Split(' ')[1];
|
||||
else if (line.StartsWith("pspUmdTypes"))
|
||||
umdcat = GetUMDCategory(line.Split(' ')[1]);
|
||||
else if (line.StartsWith("L0 length"))
|
||||
umdlayer = line.Split(' ')[2];
|
||||
else if (line.StartsWith("FileSize:"))
|
||||
umdsize = Int64.Parse(line.Split(' ')[1]);
|
||||
}
|
||||
|
||||
// If the L0 length is the size of the full disc, there's no layerbreak
|
||||
if (Int64.TryParse(umdlayer, out long umdlayerValue) && umdlayerValue * 2048 == umdsize)
|
||||
umdlayer = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We don't care what the exception is right now
|
||||
return false;
|
||||
if (line.StartsWith("TITLE") && title == null)
|
||||
title = line.Substring("TITLE: ".Length);
|
||||
else if (line.StartsWith("DISC_VERSION") && umdversion == null)
|
||||
umdversion = line.Split(' ')[1];
|
||||
else if (line.StartsWith("pspUmdTypes"))
|
||||
umdcat = InfoTool.GetUMDCategory(line.Split(' ')[1]);
|
||||
else if (line.StartsWith("L0 length"))
|
||||
umdlayer = line.Split(' ')[2];
|
||||
else if (line.StartsWith("FileSize:"))
|
||||
umdsize = Int64.Parse(line.Split(' ')[1]);
|
||||
}
|
||||
|
||||
// If the L0 length is the size of the full disc, there's no layerbreak
|
||||
if (Int64.TryParse(umdlayer, out long umdlayerValue) && umdlayerValue * 2048 == umdsize)
|
||||
umdlayer = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We don't care what the exception is right now
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using BinaryObjectScanner.Protection;
|
||||
using BurnOutSharp;
|
||||
using psxt001z;
|
||||
|
||||
#pragma warning disable SYSLIB1045 // Convert to 'GeneratedRegexAttribute'.
|
||||
|
||||
namespace MPF.Core
|
||||
{
|
||||
public static class Protection
|
||||
@@ -19,17 +19,14 @@ namespace MPF.Core
|
||||
/// <param name="options">Options object that determines what to scan</param>
|
||||
/// <param name="progress">Optional progress callback</param>
|
||||
/// <returns>Set of all detected copy protections with an optional error string</returns>
|
||||
#if NET48
|
||||
public static async Task<(Dictionary<string, List<string>>, string)> RunProtectionScanOnPath(string path, Data.Options options, IProgress<ProtectionProgress> progress = null)
|
||||
#else
|
||||
public static async Task<(Dictionary<string, List<string>>?, string?)> RunProtectionScanOnPath(string path, Data.Options options, IProgress<ProtectionProgress>? progress = null)
|
||||
#endif
|
||||
public static async Task<(Dictionary<string, List<string>>?, string?)> RunProtectionScanOnPath(string path, Data.Options options, IProgress<BinaryObjectScanner.ProtectionProgress>? progress = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var found = await Task.Run(() =>
|
||||
#if NET40
|
||||
var found = await Task.Factory.StartNew(() =>
|
||||
{
|
||||
var scanner = new Scanner(
|
||||
var scanner = new BinaryObjectScanner.Scanner(
|
||||
options.ScanArchivesForProtection,
|
||||
scanContents: true, // Hardcoded value to avoid issues
|
||||
scanGameEngines: false, // Hardcoded value to avoid issues
|
||||
@@ -40,14 +37,37 @@ namespace MPF.Core
|
||||
|
||||
return scanner.GetProtections(path);
|
||||
});
|
||||
#else
|
||||
var found = await Task.Run(() =>
|
||||
{
|
||||
var scanner = new BinaryObjectScanner.Scanner(
|
||||
options.ScanArchivesForProtection,
|
||||
scanContents: true, // Hardcoded value to avoid issues
|
||||
scanGameEngines: false, // Hardcoded value to avoid issues
|
||||
options.ScanPackersForProtection,
|
||||
scanPaths: true, // Hardcoded value to avoid issues
|
||||
options.IncludeDebugProtectionInformation,
|
||||
progress);
|
||||
|
||||
return scanner.GetProtections(path);
|
||||
});
|
||||
#endif
|
||||
|
||||
// If nothing was returned, return
|
||||
if (found == null || !found.Any())
|
||||
#if NET20 || NET35
|
||||
if (found == null || found.Count == 0)
|
||||
#else
|
||||
if (found == null || found.IsEmpty)
|
||||
#endif
|
||||
return (null, null);
|
||||
|
||||
// Filter out any empty protections
|
||||
var filteredProtections = found
|
||||
.Where(kvp => kvp.Value != null && kvp.Value.Any())
|
||||
#if NET20 || NET35
|
||||
.Where(kvp => kvp.Value != null && kvp.Value.Count > 0)
|
||||
#else
|
||||
.Where(kvp => kvp.Value != null && !kvp.Value.IsEmpty)
|
||||
#endif
|
||||
.ToDictionary(
|
||||
kvp => kvp.Key,
|
||||
kvp => kvp.Value.OrderBy(s => s).ToList());
|
||||
@@ -66,11 +86,7 @@ namespace MPF.Core
|
||||
/// </summary>
|
||||
/// <param name="protections">Dictionary of file to list of protection mappings</param>
|
||||
/// <returns>Detected protections, if any</returns>
|
||||
#if NET48
|
||||
public static string FormatProtections(Dictionary<string, List<string>> protections)
|
||||
#else
|
||||
public static string? FormatProtections(Dictionary<string, List<string>>? protections)
|
||||
#endif
|
||||
{
|
||||
// If the filtered list is empty in some way, return
|
||||
if (protections == null || !protections.Any())
|
||||
@@ -84,7 +100,7 @@ namespace MPF.Core
|
||||
|
||||
// Sanitize and join protections for writing
|
||||
string protectionString = SanitizeFoundProtections(orderedDistinctProtections);
|
||||
if (string.IsNullOrWhiteSpace(protectionString))
|
||||
if (string.IsNullOrEmpty(protectionString))
|
||||
return "None found [OMIT FROM SUBMISSION]";
|
||||
|
||||
return protectionString;
|
||||
@@ -95,20 +111,25 @@ namespace MPF.Core
|
||||
/// </summary>
|
||||
/// <param name="path">Path to scan for anti-modchip strings</param>
|
||||
/// <returns>Anti-modchip existence if possible, false on error</returns>
|
||||
public static async Task<bool> GetPlayStationAntiModchipDetected(string path)
|
||||
public static async Task<bool> GetPlayStationAntiModchipDetected(string? path)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
// If there is no valid path
|
||||
if (string.IsNullOrEmpty(path))
|
||||
return false;
|
||||
|
||||
#if NET40
|
||||
return await Task.Factory.StartNew(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var antiModchip = new PSXAntiModchip();
|
||||
var antiModchip = new BinaryObjectScanner.Protection.PSXAntiModchip();
|
||||
foreach (string file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] fileContent = File.ReadAllBytes(file);
|
||||
string protection = antiModchip.CheckContents(file, fileContent, false);
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
var protection = antiModchip.CheckContents(file, fileContent, false);
|
||||
if (!string.IsNullOrEmpty(protection))
|
||||
return true;
|
||||
}
|
||||
catch { }
|
||||
@@ -118,6 +139,33 @@ namespace MPF.Core
|
||||
|
||||
return false;
|
||||
});
|
||||
#else
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var antiModchip = new BinaryObjectScanner.Protection.PSXAntiModchip();
|
||||
#if NET20 || NET35
|
||||
foreach (string file in Directory.GetFiles(path, "*", SearchOption.AllDirectories))
|
||||
#else
|
||||
foreach (string file in Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories))
|
||||
#endif
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] fileContent = File.ReadAllBytes(file);
|
||||
var protection = antiModchip.CheckContents(file, fileContent, false);
|
||||
if (!string.IsNullOrEmpty(protection))
|
||||
return true;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
return false;
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -131,7 +179,7 @@ namespace MPF.Core
|
||||
if (!File.Exists(sub))
|
||||
return null;
|
||||
|
||||
return LibCrypt.CheckSubfile(sub);
|
||||
return LibCrypt.DetectLibCrypt([sub]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -144,9 +192,15 @@ namespace MPF.Core
|
||||
if (foundProtections.Any(p => p.StartsWith("[Exception opening file")))
|
||||
{
|
||||
foundProtections = foundProtections.Where(p => !p.StartsWith("[Exception opening file"));
|
||||
#if NET20 || NET35 || NET40 || NET452 || NET462
|
||||
var tempList = new List<string> { "Exception occurred while scanning [RESCAN NEEDED]" };
|
||||
tempList.AddRange(foundProtections);
|
||||
foundProtections = tempList.OrderBy(p => p);
|
||||
#else
|
||||
foundProtections = foundProtections
|
||||
.Prepend("Exception occurred while scanning [RESCAN NEEDED]")
|
||||
.OrderBy(p => p);
|
||||
#endif
|
||||
}
|
||||
|
||||
// ActiveMARK
|
||||
@@ -154,7 +208,7 @@ namespace MPF.Core
|
||||
foundProtections = foundProtections.Where(p => p != "ActiveMARK");
|
||||
|
||||
// Cactus Data Shield
|
||||
if (foundProtections.Any(p => Regex.IsMatch(p, @"Cactus Data Shield [0-9]{3} .+")) && foundProtections.Any(p => p == "Cactus Data Shield 200"))
|
||||
if (foundProtections.Any(p => Regex.IsMatch(p, @"Cactus Data Shield [0-9]{3} .+", RegexOptions.Compiled)) && foundProtections.Any(p => p == "Cactus Data Shield 200"))
|
||||
foundProtections = foundProtections.Where(p => p != "Cactus Data Shield 200");
|
||||
|
||||
// CD-Check
|
||||
@@ -184,7 +238,7 @@ namespace MPF.Core
|
||||
// JoWood X-Prot
|
||||
if (foundProtections.Any(p => p.StartsWith("JoWood X-Prot")))
|
||||
{
|
||||
if (foundProtections.Any(p => Regex.IsMatch(p, @"JoWood X-Prot [0-9]\.[0-9]\.[0-9]\.[0-9]{2}")))
|
||||
if (foundProtections.Any(p => Regex.IsMatch(p, @"JoWood X-Prot [0-9]\.[0-9]\.[0-9]\.[0-9]{2}", RegexOptions.Compiled)))
|
||||
{
|
||||
foundProtections = foundProtections.Where(p => p != "JoWood X-Prot")
|
||||
.Where(p => p != "JoWood X-Prot v1.0-v1.3")
|
||||
@@ -227,34 +281,43 @@ namespace MPF.Core
|
||||
.Where(p => p != "Cactus Data Shield 300 (Confirm presence of other CDS-300 files)");
|
||||
|
||||
if (foundProtections.Any(p => !p.StartsWith("SafeDisc")))
|
||||
{
|
||||
#if NET20 || NET35 || NET40 || NET452 || NET462
|
||||
var tempList = new List<string>();
|
||||
tempList.AddRange(foundProtections);
|
||||
tempList.Add("Cactus Data Shield 300");
|
||||
foundProtections = tempList;
|
||||
#else
|
||||
foundProtections = foundProtections.Append("Cactus Data Shield 300");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// SafeDisc
|
||||
if (foundProtections.Any(p => p.StartsWith("SafeDisc")))
|
||||
{
|
||||
if (foundProtections.Any(p => Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}")))
|
||||
if (foundProtections.Any(p => Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
|
||||
{
|
||||
foundProtections = foundProtections.Where(p => !p.StartsWith("Macrovision Protected Application"))
|
||||
.Where(p => !p.StartsWith("Macrovision Protection File"))
|
||||
.Where(p => !p.StartsWith("Macrovision Security Driver"))
|
||||
.Where(p => p != "SafeDisc")
|
||||
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}")))
|
||||
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}/+")))
|
||||
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
|
||||
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}/+", RegexOptions.Compiled)))
|
||||
.Where(p => p != "SafeDisc 1/Lite")
|
||||
.Where(p => p != "SafeDisc 2+");
|
||||
}
|
||||
else if (foundProtections.Any(p => Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}")))
|
||||
else if (foundProtections.Any(p => Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}-[0-9]\.[0-9]{2}\.[0-9]{3}", RegexOptions.Compiled)))
|
||||
{
|
||||
foundProtections = foundProtections.Where(p => !p.StartsWith("Macrovision Protected Application"))
|
||||
.Where(p => !p.StartsWith("Macrovision Protection File"))
|
||||
.Where(p => !p.StartsWith("Macrovision Security Driver"))
|
||||
.Where(p => p != "SafeDisc")
|
||||
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}/+")))
|
||||
.Where(p => !(Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}/+", RegexOptions.Compiled)))
|
||||
.Where(p => p != "SafeDisc 1/Lite")
|
||||
.Where(p => p != "SafeDisc 2+");
|
||||
}
|
||||
else if (foundProtections.Any(p => Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}/+")))
|
||||
else if (foundProtections.Any(p => Regex.IsMatch(p, @"SafeDisc [0-9]\.[0-9]{2}\.[0-9]{3}/+", RegexOptions.Compiled)))
|
||||
{
|
||||
foundProtections = foundProtections.Where(p => !p.StartsWith("Macrovision Protected Application"))
|
||||
.Where(p => !p.StartsWith("Macrovision Protection File"))
|
||||
@@ -294,7 +357,7 @@ namespace MPF.Core
|
||||
// StarForce
|
||||
if (foundProtections.Any(p => p.StartsWith("StarForce")))
|
||||
{
|
||||
if (foundProtections.Any(p => Regex.IsMatch(p, @"StarForce [0-9]+\..+")))
|
||||
if (foundProtections.Any(p => Regex.IsMatch(p, @"StarForce [0-9]+\..+", RegexOptions.Compiled)))
|
||||
{
|
||||
foundProtections = foundProtections.Where(p => p != "StarForce")
|
||||
.Where(p => p != "StarForce 3-5")
|
||||
@@ -329,7 +392,7 @@ namespace MPF.Core
|
||||
if (foundProtections.Any(p => p == "XCP") && foundProtections.Any(p => p.StartsWith("XCP") && p.Length > "XCP".Length))
|
||||
foundProtections = foundProtections.Where(p => p != "XCP");
|
||||
|
||||
return string.Join(", ", foundProtections);
|
||||
return string.Join(", ", foundProtections.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
635
MPF.Core/SubmissionInfoTool.cs
Normal file
635
MPF.Core/SubmissionInfoTool.cs
Normal file
@@ -0,0 +1,635 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MPF.Core.Data;
|
||||
using MPF.Core.Modules;
|
||||
using SabreTools.RedumpLib;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using SabreTools.RedumpLib.Web;
|
||||
|
||||
namespace MPF.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to hold all SubmissionInfo-related methods
|
||||
/// </summary>
|
||||
internal static class SubmissionInfoTool
|
||||
{
|
||||
#region Extraction and Filling
|
||||
|
||||
/// <summary>
|
||||
/// Extract all of the possible information from a given input combination
|
||||
/// </summary>
|
||||
/// <param name="outputPath">Output path to write to</param>
|
||||
/// <param name="drive">Drive object representing the current drive</param>
|
||||
/// <param name="system">Currently selected system</param>
|
||||
/// <param name="mediaType">Currently selected media type</param>
|
||||
/// <param name="options">Options object representing user-defined options</param>
|
||||
/// <param name="parameters">Parameters object representing what to send to the internal program</param>
|
||||
/// <param name="resultProgress">Optional result progress callback</param>
|
||||
/// <param name="protectionProgress">Optional protection progress callback</param>
|
||||
/// <returns>SubmissionInfo populated based on outputs, null on error</returns>
|
||||
public static async Task<SubmissionInfo?> ExtractOutputInformation(
|
||||
string outputPath,
|
||||
Drive? drive,
|
||||
RedumpSystem? system,
|
||||
MediaType? mediaType,
|
||||
Options options,
|
||||
BaseParameters? parameters,
|
||||
IProgress<Result>? resultProgress = null,
|
||||
IProgress<BinaryObjectScanner.ProtectionProgress>? protectionProgress = null)
|
||||
{
|
||||
// Ensure the current disc combination should exist
|
||||
if (!system.MediaTypes().Contains(mediaType))
|
||||
return null;
|
||||
|
||||
// Split the output path for easier use
|
||||
var outputDirectory = Path.GetDirectoryName(outputPath);
|
||||
string outputFilename = Path.GetFileName(outputPath);
|
||||
|
||||
// Check that all of the relevant files are there
|
||||
(bool foundFiles, List<string> missingFiles) = parameters.FoundAllFiles(outputDirectory, outputFilename, false);
|
||||
if (!foundFiles)
|
||||
{
|
||||
resultProgress?.Report(Result.Failure($"There were files missing from the output:\n{string.Join("\n", [.. missingFiles])}"));
|
||||
resultProgress?.Report(Result.Failure($"This may indicate an issue with the hardware or media, including unsupported devices.\nPlease see dumping program documentation for more details."));
|
||||
return null;
|
||||
}
|
||||
|
||||
// Sanitize the output filename to strip off any potential extension
|
||||
outputFilename = Path.GetFileNameWithoutExtension(outputFilename);
|
||||
|
||||
// Create the SubmissionInfo object with all user-inputted values by default
|
||||
string combinedBase;
|
||||
if (string.IsNullOrEmpty(outputDirectory))
|
||||
combinedBase = outputFilename;
|
||||
else
|
||||
combinedBase = Path.Combine(outputDirectory, outputFilename);
|
||||
|
||||
var info = new SubmissionInfo()
|
||||
{
|
||||
CommonDiscInfo = new CommonDiscInfoSection()
|
||||
{
|
||||
System = system,
|
||||
Media = mediaType.ToDiscType(),
|
||||
Title = options.AddPlaceholders ? Template.RequiredValue : string.Empty,
|
||||
ForeignTitleNonLatin = options.AddPlaceholders ? Template.OptionalValue : string.Empty,
|
||||
DiscNumberLetter = options.AddPlaceholders ? Template.OptionalValue : string.Empty,
|
||||
DiscTitle = options.AddPlaceholders ? Template.OptionalValue : string.Empty,
|
||||
Category = null,
|
||||
Region = null,
|
||||
Languages = null,
|
||||
Serial = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty,
|
||||
Barcode = options.AddPlaceholders ? Template.OptionalValue : string.Empty,
|
||||
Contents = string.Empty,
|
||||
},
|
||||
VersionAndEditions = new VersionAndEditionsSection()
|
||||
{
|
||||
Version = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty,
|
||||
OtherEditions = options.AddPlaceholders ? "(VERIFY THIS) Original" : string.Empty,
|
||||
},
|
||||
};
|
||||
|
||||
// Ensure that required sections exist
|
||||
info = Builder.EnsureAllSections(info);
|
||||
|
||||
// Get specific tool output handling
|
||||
parameters?.GenerateSubmissionInfo(info, options, combinedBase, drive, options.IncludeArtifacts);
|
||||
|
||||
// Get a list of matching IDs for each line in the DAT
|
||||
if (!string.IsNullOrEmpty(info.TracksAndWriteOffsets!.ClrMameProData) && options.HasRedumpLogin)
|
||||
#if NET40
|
||||
_ = FillFromRedump(options, info, resultProgress);
|
||||
#else
|
||||
_ = await FillFromRedump(options, info, resultProgress);
|
||||
#endif
|
||||
|
||||
// If we have both ClrMamePro and Size and Checksums data, remove the ClrMamePro
|
||||
if (!string.IsNullOrEmpty(info.SizeAndChecksums?.CRC32))
|
||||
info.TracksAndWriteOffsets.ClrMameProData = null;
|
||||
|
||||
// Add the volume label to comments, if possible or necessary
|
||||
if (drive?.VolumeLabel != null && drive.GetRedumpSystemFromVolumeLabel() == null)
|
||||
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.VolumeLabel] = drive.VolumeLabel;
|
||||
|
||||
// Extract info based generically on MediaType
|
||||
switch (mediaType)
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
case MediaType.GDROM:
|
||||
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0AdditionalMould = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
break;
|
||||
|
||||
case MediaType.DVD:
|
||||
case MediaType.HDDVD:
|
||||
case MediaType.BluRay:
|
||||
|
||||
// If we have a single-layer disc
|
||||
if (info.SizeAndChecksums!.Layerbreak == default)
|
||||
{
|
||||
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0AdditionalMould = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
}
|
||||
// If we have a dual-layer disc
|
||||
else
|
||||
{
|
||||
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0AdditionalMould = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
|
||||
info.CommonDiscInfo.Layer1MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MediaType.NintendoGameCubeGameDisc:
|
||||
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0AdditionalMould = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.Extras!.BCA ??= (options.AddPlaceholders ? Template.RequiredValue : string.Empty);
|
||||
break;
|
||||
|
||||
case MediaType.NintendoWiiOpticalDisc:
|
||||
|
||||
// If we have a single-layer disc
|
||||
if (info.SizeAndChecksums!.Layerbreak == default)
|
||||
{
|
||||
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0AdditionalMould = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
}
|
||||
// If we have a dual-layer disc
|
||||
else
|
||||
{
|
||||
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0AdditionalMould = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
|
||||
info.CommonDiscInfo.Layer1MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
}
|
||||
|
||||
info.Extras!.DiscKey = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
info.Extras.BCA = info.Extras.BCA ?? (options.AddPlaceholders ? Template.RequiredValue : string.Empty);
|
||||
|
||||
break;
|
||||
|
||||
case MediaType.UMD:
|
||||
// Both single- and dual-layer discs have two "layers" for the ring
|
||||
info.CommonDiscInfo!.Layer0MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer0MouldSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
|
||||
info.CommonDiscInfo.Layer1MasteringRing = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1MasteringSID = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
info.CommonDiscInfo.Layer1ToolstampMasteringCode = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
|
||||
info.SizeAndChecksums!.CRC32 ??= (options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : string.Empty);
|
||||
info.SizeAndChecksums.MD5 ??= (options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : string.Empty);
|
||||
info.SizeAndChecksums.SHA1 ??= (options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : string.Empty);
|
||||
info.TracksAndWriteOffsets.ClrMameProData = null;
|
||||
break;
|
||||
}
|
||||
|
||||
// Extract info based specifically on RedumpSystem
|
||||
switch (system)
|
||||
{
|
||||
case RedumpSystem.AcornArchimedes:
|
||||
info.CommonDiscInfo!.Region ??= Region.UnitedKingdom;
|
||||
break;
|
||||
|
||||
case RedumpSystem.AppleMacintosh:
|
||||
case RedumpSystem.EnhancedCD:
|
||||
case RedumpSystem.IBMPCcompatible:
|
||||
case RedumpSystem.PalmOS:
|
||||
case RedumpSystem.PocketPC:
|
||||
case RedumpSystem.RainbowDisc:
|
||||
case RedumpSystem.SonyElectronicBook:
|
||||
resultProgress?.Report(Result.Success("Running copy protection scan... this might take a while!"));
|
||||
var (protectionString, fullProtections) = await InfoTool.GetCopyProtection(drive, options, protectionProgress);
|
||||
|
||||
info.CopyProtection!.Protection += protectionString;
|
||||
info.CopyProtection.FullProtections = fullProtections as Dictionary<string, List<string>?> ?? [];
|
||||
resultProgress?.Report(Result.Success("Copy protection scan complete!"));
|
||||
|
||||
break;
|
||||
|
||||
case RedumpSystem.AudioCD:
|
||||
case RedumpSystem.DVDAudio:
|
||||
case RedumpSystem.SuperAudioCD:
|
||||
info.CommonDiscInfo!.Category ??= DiscCategory.Audio;
|
||||
break;
|
||||
|
||||
case RedumpSystem.BandaiPlaydiaQuickInteractiveSystem:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Japan;
|
||||
break;
|
||||
|
||||
case RedumpSystem.BDVideo:
|
||||
info.CommonDiscInfo!.Category ??= DiscCategory.BonusDiscs;
|
||||
info.CopyProtection!.Protection = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.CommodoreAmigaCD:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.CommodoreAmigaCD32:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
info.CommonDiscInfo.Region ??= Region.Europe;
|
||||
break;
|
||||
|
||||
case RedumpSystem.CommodoreAmigaCDTV:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
info.CommonDiscInfo.Region ??= Region.Europe;
|
||||
break;
|
||||
|
||||
case RedumpSystem.DVDVideo:
|
||||
info.CommonDiscInfo!.Category ??= DiscCategory.BonusDiscs;
|
||||
break;
|
||||
|
||||
case RedumpSystem.FujitsuFMTownsseries:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? Region.Japan;
|
||||
break;
|
||||
|
||||
case RedumpSystem.FujitsuFMTownsMarty:
|
||||
info.CommonDiscInfo!.Region ??= Region.Japan;
|
||||
break;
|
||||
|
||||
case RedumpSystem.IncredibleTechnologiesEagle:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.KonamieAmusement:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.KonamiFireBeat:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.KonamiSystemGV:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.KonamiSystem573:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.KonamiTwinkle:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.MattelHyperScan:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.MicrosoftXboxOne:
|
||||
if (drive?.Name != null)
|
||||
{
|
||||
string xboxOneMsxcPath = Path.Combine(drive.Name, "MSXC");
|
||||
if (drive != null && Directory.Exists(xboxOneMsxcPath))
|
||||
{
|
||||
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.Filename] = string.Join("\n",
|
||||
Directory.GetFiles(xboxOneMsxcPath, "*", SearchOption.TopDirectoryOnly).Select(Path.GetFileName).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RedumpSystem.MicrosoftXboxSeriesXS:
|
||||
if (drive?.Name != null)
|
||||
{
|
||||
string xboxSeriesXMsxcPath = Path.Combine(drive.Name, "MSXC");
|
||||
if (drive != null && Directory.Exists(xboxSeriesXMsxcPath))
|
||||
{
|
||||
info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.Filename] = string.Join("\n",
|
||||
Directory.GetFiles(xboxSeriesXMsxcPath, "*", SearchOption.TopDirectoryOnly).Select(Path.GetFileName).ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RedumpSystem.NamcoSegaNintendoTriforce:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.NavisoftNaviken21:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
info.CommonDiscInfo.Region ??= Region.Japan;
|
||||
break;
|
||||
|
||||
case RedumpSystem.NECPC88series:
|
||||
info.CommonDiscInfo!.Region ??= Region.Japan;
|
||||
break;
|
||||
|
||||
case RedumpSystem.NECPC98series:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
info.CommonDiscInfo!.Region ??= Region.Japan;
|
||||
break;
|
||||
|
||||
case RedumpSystem.NECPCFXPCFXGA:
|
||||
info.CommonDiscInfo!.Region ??= Region.Japan;
|
||||
break;
|
||||
|
||||
case RedumpSystem.SegaChihiro:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.SegaDreamcast:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.SegaNaomi:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.SegaNaomi2:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.SegaTitanVideo:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.SharpX68000:
|
||||
info.CommonDiscInfo!.Region ??= Region.Japan;
|
||||
break;
|
||||
|
||||
case RedumpSystem.SNKNeoGeoCD:
|
||||
info.CommonDiscInfo!.EXEDateBuildDate = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.SonyPlayStation:
|
||||
// Only check the disc if the dumping program couldn't detect
|
||||
if (drive != null && info.CopyProtection!.AntiModchip == YesNo.NULL)
|
||||
{
|
||||
resultProgress?.Report(Result.Success("Checking for anti-modchip strings... this might take a while!"));
|
||||
info.CopyProtection.AntiModchip = await InfoTool.GetAntiModchipDetected(drive) ? YesNo.Yes : YesNo.No;
|
||||
resultProgress?.Report(Result.Success("Anti-modchip string scan complete!"));
|
||||
}
|
||||
|
||||
// Special case for DIC only
|
||||
if (parameters?.InternalProgram == InternalProgram.DiscImageCreator)
|
||||
{
|
||||
resultProgress?.Report(Result.Success("Checking for LibCrypt status... this might take a while!"));
|
||||
InfoTool.GetLibCryptDetected(info, combinedBase);
|
||||
resultProgress?.Report(Result.Success("LibCrypt status checking complete!"));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case RedumpSystem.SonyPlayStation2:
|
||||
info.CommonDiscInfo!.LanguageSelection = [LanguageSelection.BiosSettings, LanguageSelection.LanguageSelector, LanguageSelection.OptionsMenu];
|
||||
break;
|
||||
|
||||
case RedumpSystem.SonyPlayStation3:
|
||||
info.Extras!.DiscKey = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
info.Extras.DiscID = options.AddPlaceholders ? Template.RequiredValue : string.Empty;
|
||||
break;
|
||||
|
||||
case RedumpSystem.TomyKissSite:
|
||||
info.CommonDiscInfo!.Region ??= Region.Japan;
|
||||
break;
|
||||
|
||||
case RedumpSystem.ZAPiTGamesGameWaveFamilyEntertainmentSystem:
|
||||
info.CopyProtection!.Protection = options.AddPlaceholders ? Template.RequiredIfExistsValue : string.Empty;
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the category if it's not overriden
|
||||
info.CommonDiscInfo!.Category ??= DiscCategory.Games;
|
||||
|
||||
// Comments and contents have odd handling
|
||||
if (string.IsNullOrEmpty(info.CommonDiscInfo.Comments))
|
||||
info.CommonDiscInfo.Comments = options.AddPlaceholders ? Template.OptionalValue : string.Empty;
|
||||
if (string.IsNullOrEmpty(info.CommonDiscInfo.Contents))
|
||||
info.CommonDiscInfo.Contents = options.AddPlaceholders ? Template.OptionalValue : string.Empty;
|
||||
|
||||
// Normalize the disc type with all current information
|
||||
Validator.NormalizeDiscType(info);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fill in a SubmissionInfo object from Redump, if possible
|
||||
/// </summary>
|
||||
/// <param name="options">Options object representing user-defined options</param>
|
||||
/// <param name="info">Existing SubmissionInfo object to fill</param>
|
||||
/// <param name="resultProgress">Optional result progress callback</param>
|
||||
#if NET40
|
||||
public static bool FillFromRedump(Options options, SubmissionInfo info, IProgress<Result>? resultProgress = null)
|
||||
#else
|
||||
public async static Task<bool> FillFromRedump(Options options, SubmissionInfo info, IProgress<Result>? resultProgress = null)
|
||||
#endif
|
||||
{
|
||||
// If no username is provided
|
||||
if (string.IsNullOrEmpty(options.RedumpUsername) || string.IsNullOrEmpty(options.RedumpPassword))
|
||||
return false;
|
||||
|
||||
// Set the current dumper based on username
|
||||
info.DumpersAndStatus ??= new DumpersAndStatusSection();
|
||||
info.DumpersAndStatus.Dumpers = [options.RedumpUsername!];
|
||||
info.PartiallyMatchedIDs = [];
|
||||
|
||||
// Login to Redump
|
||||
#if NETFRAMEWORK
|
||||
using var wc = new RedumpWebClient();
|
||||
bool? loggedIn = wc.Login(options.RedumpUsername!, options.RedumpPassword!);
|
||||
#else
|
||||
using var wc = new RedumpHttpClient();
|
||||
bool? loggedIn = await wc.Login(options.RedumpUsername, options.RedumpPassword);
|
||||
#endif
|
||||
if (loggedIn == null)
|
||||
{
|
||||
resultProgress?.Report(Result.Failure("There was an unknown error connecting to Redump"));
|
||||
return false;
|
||||
}
|
||||
else if (loggedIn == false)
|
||||
{
|
||||
// Don't log the as a failure or error
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup the full-track checks
|
||||
bool allFound = true;
|
||||
List<int>? fullyMatchedIDs = null;
|
||||
|
||||
// Loop through all of the hashdata to find matching IDs
|
||||
resultProgress?.Report(Result.Success("Finding disc matches on Redump..."));
|
||||
var splitData = info.TracksAndWriteOffsets?.ClrMameProData?.TrimEnd('\n')?.Split('\n');
|
||||
int trackCount = splitData?.Length ?? 0;
|
||||
foreach (string hashData in splitData ?? [])
|
||||
{
|
||||
// Catch any errant blank lines
|
||||
if (string.IsNullOrEmpty(hashData))
|
||||
{
|
||||
trackCount--;
|
||||
resultProgress?.Report(Result.Success("Blank line found, skipping!"));
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the line ends in a known extra track names, skip them for checking
|
||||
if (hashData.Contains("(Track 0).bin")
|
||||
|| hashData.Contains("(Track 0.2).bin")
|
||||
|| hashData.Contains("(Track 00).bin")
|
||||
|| hashData.Contains("(Track 00.2).bin")
|
||||
|| hashData.Contains("(Track A).bin")
|
||||
|| hashData.Contains("(Track AA).bin"))
|
||||
{
|
||||
trackCount--;
|
||||
resultProgress?.Report(Result.Success("Extra track found, skipping!"));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the SHA-1 hash
|
||||
if (!InfoTool.GetISOHashValues(hashData, out _, out _, out _, out string? sha1))
|
||||
{
|
||||
resultProgress?.Report(Result.Failure($"Line could not be parsed: {hashData}"));
|
||||
continue;
|
||||
}
|
||||
|
||||
#if NET40
|
||||
var validateTask = Validator.ValidateSingleTrack(wc, info, sha1!);
|
||||
validateTask.Wait();
|
||||
(bool singleFound, var foundIds, string? result) = validateTask.Result;
|
||||
#else
|
||||
(bool singleFound, var foundIds, string? result) = await Validator.ValidateSingleTrack(wc, info, sha1!);
|
||||
#endif
|
||||
if (singleFound)
|
||||
resultProgress?.Report(Result.Success(result));
|
||||
else
|
||||
resultProgress?.Report(Result.Failure(result));
|
||||
|
||||
// Ensure that all tracks are found
|
||||
allFound &= singleFound;
|
||||
|
||||
// If we found a track, only keep track of distinct found tracks
|
||||
if (singleFound && foundIds != null)
|
||||
{
|
||||
if (fullyMatchedIDs == null)
|
||||
fullyMatchedIDs = foundIds;
|
||||
else
|
||||
fullyMatchedIDs = fullyMatchedIDs.Intersect(foundIds).ToList();
|
||||
}
|
||||
// If no tracks were found, remove all fully matched IDs found so far
|
||||
else
|
||||
{
|
||||
fullyMatchedIDs = [];
|
||||
}
|
||||
}
|
||||
|
||||
// If we don't have any matches but we have a universal hash
|
||||
if (!info.PartiallyMatchedIDs.Any() && info.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.UniversalHash) == true)
|
||||
{
|
||||
#if NET40
|
||||
var validateTask = Validator.ValidateUniversalHash(wc, info);
|
||||
validateTask.Wait();
|
||||
(bool singleFound, var foundIds, string? result) = validateTask.Result;
|
||||
#else
|
||||
(bool singleFound, var foundIds, string? result) = await Validator.ValidateUniversalHash(wc, info);
|
||||
#endif
|
||||
if (singleFound)
|
||||
resultProgress?.Report(Result.Success(result));
|
||||
else
|
||||
resultProgress?.Report(Result.Failure(result));
|
||||
|
||||
// Ensure that the hash is found
|
||||
allFound = singleFound;
|
||||
|
||||
// If we found a track, only keep track of distinct found tracks
|
||||
if (singleFound && foundIds != null)
|
||||
{
|
||||
fullyMatchedIDs = foundIds;
|
||||
}
|
||||
// If no tracks were found, remove all fully matched IDs found so far
|
||||
else
|
||||
{
|
||||
fullyMatchedIDs = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure we only have unique IDs
|
||||
info.PartiallyMatchedIDs = [.. info.PartiallyMatchedIDs.Distinct().OrderBy(id => id)];
|
||||
|
||||
resultProgress?.Report(Result.Success("Match finding complete! " + (fullyMatchedIDs != null && fullyMatchedIDs.Count > 0
|
||||
? "Fully Matched IDs: " + string.Join(",", fullyMatchedIDs.Select(i => i.ToString()).ToArray())
|
||||
: "No matches found")));
|
||||
|
||||
// Exit early if one failed or there are no matched IDs
|
||||
if (!allFound || fullyMatchedIDs == null || fullyMatchedIDs.Count == 0)
|
||||
return false;
|
||||
|
||||
// Find the first matched ID where the track count matches, we can grab a bunch of info from it
|
||||
int totalMatchedIDsCount = fullyMatchedIDs.Count;
|
||||
for (int i = 0; i < totalMatchedIDsCount; i++)
|
||||
{
|
||||
// Skip if the track count doesn't match
|
||||
#if NET40
|
||||
var validateTask = Validator.ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount);
|
||||
validateTask.Wait();
|
||||
if (!validateTask.Result)
|
||||
#else
|
||||
if (!await Validator.ValidateTrackCount(wc, fullyMatchedIDs[i], trackCount))
|
||||
#endif
|
||||
continue;
|
||||
|
||||
// Fill in the fields from the existing ID
|
||||
resultProgress?.Report(Result.Success($"Filling fields from existing ID {fullyMatchedIDs[i]}..."));
|
||||
#if NET40
|
||||
var fillTask = Task.Factory.StartNew(() => Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation));
|
||||
fillTask.Wait();
|
||||
_ = fillTask.Result;
|
||||
#else
|
||||
_ = await Builder.FillFromId(wc, info, fullyMatchedIDs[i], options.PullAllInformation);
|
||||
#endif
|
||||
resultProgress?.Report(Result.Success("Information filling complete!"));
|
||||
|
||||
// Set the fully matched ID to the current
|
||||
info.FullyMatchedID = fullyMatchedIDs[i];
|
||||
break;
|
||||
}
|
||||
|
||||
// Clear out fully matched IDs from the partial list
|
||||
if (info.FullyMatchedID.HasValue)
|
||||
{
|
||||
if (info.PartiallyMatchedIDs.Count == 1)
|
||||
info.PartiallyMatchedIDs = null;
|
||||
else
|
||||
info.PartiallyMatchedIDs.Remove(info.FullyMatchedID.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -49,16 +49,21 @@ namespace MPF.Core.UI.ComboBoxItems
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Equals(Element<T> other)
|
||||
#else
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return Equals(obj as Element<T>);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(Element<T>? other)
|
||||
#endif
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
return Name == other.Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,7 @@ namespace MPF.Core.UI.ComboBoxItems
|
||||
/// </summary>
|
||||
public class RedumpSystemComboBoxItem : IEquatable<RedumpSystemComboBoxItem>, IElement
|
||||
{
|
||||
#if NET48
|
||||
private readonly object Data;
|
||||
#else
|
||||
private readonly object? Data;
|
||||
#endif
|
||||
|
||||
public RedumpSystemComboBoxItem(RedumpSystem? system) => Data = system;
|
||||
public RedumpSystemComboBoxItem(SystemCategory? category) => Data = category;
|
||||
@@ -85,16 +81,21 @@ namespace MPF.Core.UI.ComboBoxItems
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public bool Equals(RedumpSystemComboBoxItem other)
|
||||
#else
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
return Equals(obj as RedumpSystemComboBoxItem);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Equals(RedumpSystemComboBoxItem? other)
|
||||
#endif
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
return Value == other.Value;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override int GetHashCode() => base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,11 +38,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// List of Redump-supported Regions
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private static readonly List<Region> RedumpRegions = new List<Region>
|
||||
#else
|
||||
private static readonly List<Region> RedumpRegions = new()
|
||||
#endif
|
||||
{
|
||||
Region.Argentina,
|
||||
Region.Asia,
|
||||
@@ -133,11 +129,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// List of Redump-supported Languages
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private static readonly List<Language> RedumpLanguages = new List<Language>
|
||||
#else
|
||||
private static readonly List<Language> RedumpLanguages = new()
|
||||
#endif
|
||||
{
|
||||
Language.Afrikaans,
|
||||
Language.Albanian,
|
||||
@@ -199,11 +191,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public DiscInformationViewModel(Options options, SubmissionInfo submissionInfo)
|
||||
#else
|
||||
public DiscInformationViewModel(Options options, SubmissionInfo? submissionInfo)
|
||||
#endif
|
||||
{
|
||||
Options = options;
|
||||
SubmissionInfo = submissionInfo?.Clone() as SubmissionInfo ?? new SubmissionInfo();
|
||||
|
||||
@@ -4,11 +4,12 @@ using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BurnOutSharp;
|
||||
using BinaryObjectScanner;
|
||||
using MPF.Core.Converters;
|
||||
using MPF.Core.Data;
|
||||
using MPF.Core.Utilities;
|
||||
using MPF.Core.Modules;
|
||||
using MPF.Core.UI.ComboBoxItems;
|
||||
using MPF.Core.Utilities;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
namespace MPF.Core.UI.ViewModels
|
||||
@@ -37,20 +38,12 @@ namespace MPF.Core.UI.ViewModels
|
||||
public bool CanExecuteSelectionChanged { get; private set; } = false;
|
||||
|
||||
/// <inheritdoc/>
|
||||
#if NET48
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
#else
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Action to process logging statements
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private Action<LogLevel, string> _logger;
|
||||
#else
|
||||
private Action<LogLevel, string>? _logger;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Display a message to a user
|
||||
@@ -62,11 +55,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// T4 - true for inquiry, false otherwise
|
||||
/// TResult - true for positive, false for negative, null for neutral
|
||||
/// </remarks>
|
||||
#if NET48
|
||||
private Func<string, string, int, bool, bool?> _displayUserMessage;
|
||||
#else
|
||||
private Func<string, string, int, bool, bool?>? _displayUserMessage;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Detected media type, distinct from the selected one
|
||||
@@ -76,20 +65,12 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Current dumping environment
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private DumpEnvironment _environment;
|
||||
#else
|
||||
private DumpEnvironment? _environment;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Function to process user information
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private Func<SubmissionInfo, (bool?, SubmissionInfo)> _processUserInfo;
|
||||
#else
|
||||
private Func<SubmissionInfo?, (bool?, SubmissionInfo?)>? _processUserInfo;
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -210,11 +191,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Currently selected drive value
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Drive CurrentDrive
|
||||
#else
|
||||
public Drive? CurrentDrive
|
||||
#endif
|
||||
{
|
||||
get => _currentDrive;
|
||||
set
|
||||
@@ -223,11 +200,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
TriggerPropertyChanged(nameof(CurrentDrive));
|
||||
}
|
||||
}
|
||||
#if NET48
|
||||
private Drive _currentDrive;
|
||||
#else
|
||||
private Drive? _currentDrive;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the status of the drive combo box
|
||||
@@ -474,11 +447,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Current list of supported media types
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public List<Element<MediaType>> MediaTypes
|
||||
#else
|
||||
public List<Element<MediaType>>? MediaTypes
|
||||
#endif
|
||||
{
|
||||
get => _mediaTypes;
|
||||
set
|
||||
@@ -487,11 +456,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
TriggerPropertyChanged(nameof(MediaTypes));
|
||||
}
|
||||
}
|
||||
#if NET48
|
||||
private List<Element<MediaType>> _mediaTypes;
|
||||
#else
|
||||
private List<Element<MediaType>>? _mediaTypes;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Current list of supported system profiles
|
||||
@@ -531,14 +496,14 @@ namespace MPF.Core.UI.ViewModels
|
||||
_options = OptionsLoader.LoadFromConfig();
|
||||
|
||||
// Added to clear warnings, all are set externally
|
||||
_drives = new List<Drive>();
|
||||
_driveSpeeds = new List<int>();
|
||||
_internalPrograms = new List<Element<InternalProgram>>();
|
||||
_drives = [];
|
||||
_driveSpeeds = [];
|
||||
_internalPrograms = [];
|
||||
_outputPath = string.Empty;
|
||||
_parameters = string.Empty;
|
||||
_startStopButtonText = string.Empty;
|
||||
_status = string.Empty;
|
||||
_systems = new List<RedumpSystemComboBoxItem>();
|
||||
_systems = [];
|
||||
|
||||
OptionsMenuItemEnabled = true;
|
||||
SystemTypeComboBoxEnabled = true;
|
||||
@@ -550,11 +515,12 @@ namespace MPF.Core.UI.ViewModels
|
||||
StartStopButtonEnabled = true;
|
||||
StartStopButtonText = Interface.StartDumping;
|
||||
MediaScanButtonEnabled = true;
|
||||
EnableParametersCheckBoxEnabled = true;
|
||||
LogPanelExpanded = _options.OpenLogWindowAtStartup;
|
||||
|
||||
MediaTypes = new List<Element<MediaType>>();
|
||||
MediaTypes = [];
|
||||
Systems = RedumpSystemComboBoxItem.GenerateElements().ToList();
|
||||
InternalPrograms = new List<Element<InternalProgram>>();
|
||||
InternalPrograms = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -563,11 +529,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
public void Init(
|
||||
Action<LogLevel, string> loggerAction,
|
||||
Func<string, string, int, bool, bool?> displayUserMessage,
|
||||
#if NET48
|
||||
Func<SubmissionInfo, (bool?, SubmissionInfo)> processUserInfo)
|
||||
#else
|
||||
Func<SubmissionInfo?, (bool?, SubmissionInfo?)> processUserInfo)
|
||||
#endif
|
||||
{
|
||||
// Set the callbacks
|
||||
_logger = loggerAction;
|
||||
@@ -617,19 +579,19 @@ namespace MPF.Core.UI.ViewModels
|
||||
this.UpdateVolumeLabelEnabled = true;
|
||||
|
||||
// If we have a selected drive, keep track of it
|
||||
char? lastSelectedDrive = this.CurrentDrive?.Letter;
|
||||
char? lastSelectedDrive = this.CurrentDrive?.Name?[0] ?? null;
|
||||
|
||||
// Populate the list of drives and add it to the combo box
|
||||
Drives = Drive.CreateListOfDrives(this.Options.IgnoreFixedDrives);
|
||||
|
||||
if (Drives.Count > 0)
|
||||
{
|
||||
VerboseLogLn($"Found {Drives.Count} drives: {string.Join(", ", Drives.Select(d => d.Letter))}");
|
||||
VerboseLogLn($"Found {Drives.Count} drives: {string.Join(", ", Drives.Select(d => d.Name).ToArray())}");
|
||||
|
||||
// Check for the last selected drive, if possible
|
||||
int index = -1;
|
||||
if (lastSelectedDrive != null)
|
||||
index = Drives.FindIndex(d => d.MarkedActive && d.Letter == lastSelectedDrive);
|
||||
index = Drives.FindIndex(d => d.MarkedActive && (d.Name?[0] ?? '\0') == lastSelectedDrive);
|
||||
|
||||
// Check for active optical drives
|
||||
if (index == -1)
|
||||
@@ -764,11 +726,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Check for available updates
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public (bool, string, string) CheckForUpdates()
|
||||
#else
|
||||
public (bool, string, string?) CheckForUpdates()
|
||||
#endif
|
||||
{
|
||||
(bool different, string message, var url) = Tools.CheckForNewVersion();
|
||||
|
||||
@@ -807,7 +765,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
{
|
||||
SchemaVersion = 1,
|
||||
FullyMatchedID = 3,
|
||||
PartiallyMatchedIDs = new List<int> { 0, 1, 2, 3 },
|
||||
PartiallyMatchedIDs = [0, 1, 2, 3],
|
||||
Added = DateTime.UtcNow,
|
||||
LastModified = DateTime.UtcNow,
|
||||
|
||||
@@ -821,8 +779,8 @@ namespace MPF.Core.UI.ViewModels
|
||||
DiscTitle = "Install Disc",
|
||||
Category = DiscCategory.Games,
|
||||
Region = Region.World,
|
||||
Languages = new Language?[] { Language.English, Language.Spanish, Language.French },
|
||||
LanguageSelection = new LanguageSelection?[] { LanguageSelection.BiosSettings },
|
||||
Languages = [Language.English, Language.Spanish, Language.French],
|
||||
LanguageSelection = [LanguageSelection.BiosSettings],
|
||||
Serial = "Disc Serial",
|
||||
Layer0MasteringRing = "L0 Mastering Ring",
|
||||
Layer0MasteringSID = "L0 Mastering SID",
|
||||
@@ -845,20 +803,12 @@ namespace MPF.Core.UI.ViewModels
|
||||
EXEDateBuildDate = "19xx-xx-xx",
|
||||
ErrorsCount = "0",
|
||||
Comments = "Comment data line 1\r\nComment data line 2",
|
||||
#if NET48
|
||||
CommentsSpecialFields = new Dictionary<SiteCode?, string>()
|
||||
#else
|
||||
CommentsSpecialFields = new Dictionary<SiteCode, string>()
|
||||
#endif
|
||||
{
|
||||
[SiteCode.ISBN] = "ISBN",
|
||||
},
|
||||
Contents = "Special contents 1\r\nSpecial contents 2",
|
||||
#if NET48
|
||||
ContentsSpecialFields = new Dictionary<SiteCode?, string>()
|
||||
#else
|
||||
ContentsSpecialFields = new Dictionary<SiteCode, string>()
|
||||
#endif
|
||||
{
|
||||
[SiteCode.PlayableDemos] = "Game Demo 1",
|
||||
},
|
||||
@@ -868,7 +818,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
{
|
||||
Version = "Original",
|
||||
VersionDatfile = "Alt",
|
||||
CommonEditions = new string[] { "Taikenban" },
|
||||
CommonEditions = ["Taikenban"],
|
||||
OtherEditions = "Rerelease",
|
||||
},
|
||||
|
||||
@@ -906,7 +856,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
DumpersAndStatus = new DumpersAndStatusSection()
|
||||
{
|
||||
Status = DumpStatus.TwoOrMoreGreen,
|
||||
Dumpers = new string[] { "Dumper1", "Dumper2" },
|
||||
Dumpers = ["Dumper1", "Dumper2"],
|
||||
OtherDumpers = "Dumper3",
|
||||
},
|
||||
|
||||
@@ -914,7 +864,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
{
|
||||
ClrMameProData = "Datfile",
|
||||
Cuesheet = "Cuesheet",
|
||||
CommonWriteOffsets = new int[] { 0, 12, -12 },
|
||||
CommonWriteOffsets = [0, 12, -12],
|
||||
OtherWriteOffsets = "-2",
|
||||
},
|
||||
|
||||
@@ -964,13 +914,13 @@ namespace MPF.Core.UI.ViewModels
|
||||
|
||||
if (_environment != null && _environment.Options.EjectAfterDump)
|
||||
{
|
||||
VerboseLogLn($"Ejecting disc in drive {_environment.Drive?.Letter}");
|
||||
VerboseLogLn($"Ejecting disc in drive {_environment.Drive?.Name}");
|
||||
await _environment.EjectDisc();
|
||||
}
|
||||
|
||||
if (_environment != null && this.Options.DICResetDriveAfterDump)
|
||||
{
|
||||
VerboseLogLn($"Resetting drive {_environment.Drive?.Letter}");
|
||||
VerboseLogLn($"Resetting drive {_environment.Drive?.Name}");
|
||||
await _environment.ResetDrive();
|
||||
}
|
||||
}
|
||||
@@ -981,17 +931,18 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// </summary>
|
||||
/// <param name="savedSettings">Indicates if the settings were saved or not</param>
|
||||
/// <param name="newOptions">Options representing the new, saved values</param>
|
||||
#if NET48
|
||||
public void UpdateOptions(bool savedSettings, Data.Options newOptions)
|
||||
#else
|
||||
public void UpdateOptions(bool savedSettings, Data.Options? newOptions)
|
||||
#endif
|
||||
{
|
||||
// Get which options to save
|
||||
var optionsToSave = savedSettings ? newOptions : Options;
|
||||
|
||||
// Ensure the first run flag is unset
|
||||
var continuingOptions = new Data.Options(optionsToSave) { FirstRun = false };
|
||||
this.Options = continuingOptions;
|
||||
|
||||
// If settings were changed, reinitialize the UI
|
||||
if (savedSettings)
|
||||
{
|
||||
this.Options = new Data.Options(newOptions);
|
||||
InitializeUIValues(removeEventHandlers: true, rescanDrives: true);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -1202,7 +1153,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
// If the drive is marked active, try to read from it
|
||||
else if (this.CurrentDrive.MarkedActive)
|
||||
{
|
||||
VerboseLog($"Trying to detect media type for drive {this.CurrentDrive.Letter} [{this.CurrentDrive.DriveFormat}] using size and filesystem.. ");
|
||||
VerboseLog($"Trying to detect media type for drive {this.CurrentDrive.Name} [{this.CurrentDrive.DriveFormat}] using size and filesystem.. ");
|
||||
(MediaType? detectedMediaType, var errorMessage) = this.CurrentDrive.GetMediaType(this.CurrentSystem);
|
||||
|
||||
// If we got an error message, post it to the log
|
||||
@@ -1262,7 +1213,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
}
|
||||
else if (!this.Options.SkipSystemDetection)
|
||||
{
|
||||
VerboseLog($"Trying to detect system for drive {this.CurrentDrive.Letter}.. ");
|
||||
VerboseLog($"Trying to detect system for drive {this.CurrentDrive.Name}.. ");
|
||||
var currentSystem = this.CurrentDrive?.GetRedumpSystem(this.Options.DefaultSystem) ?? this.Options.DefaultSystem;
|
||||
VerboseLogLn(currentSystem == null ? "unable to detect." : ($"detected {currentSystem.LongName()}."));
|
||||
|
||||
@@ -1375,7 +1326,11 @@ namespace MPF.Core.UI.ViewModels
|
||||
directory = Path.GetDirectoryName(directory);
|
||||
|
||||
if (directory != null && label != null)
|
||||
#if NET20 || NET35
|
||||
this.OutputPath = Path.Combine(Path.Combine(directory, label), filename);
|
||||
#else
|
||||
this.OutputPath = Path.Combine(directory, label, filename);
|
||||
#endif
|
||||
else
|
||||
this.OutputPath = filename;
|
||||
}
|
||||
@@ -1398,7 +1353,11 @@ namespace MPF.Core.UI.ViewModels
|
||||
directory = Path.GetDirectoryName(directory);
|
||||
|
||||
if (directory != null && label != null)
|
||||
#if NET20 || NET35
|
||||
this.OutputPath = Path.Combine(Path.Combine(directory, label), filename);
|
||||
#else
|
||||
this.OutputPath = Path.Combine(directory, label, filename);
|
||||
#endif
|
||||
else
|
||||
this.OutputPath = filename;
|
||||
}
|
||||
@@ -1430,7 +1389,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
// Catch this in case there's an input path issue
|
||||
try
|
||||
{
|
||||
int driveIndex = Drives.Select(d => d.Letter).ToList().IndexOf(_environment.Parameters?.InputPath?[0] ?? default);
|
||||
int driveIndex = Drives.Select(d => d.Name?[0] ?? '\0').ToList().IndexOf(_environment.Parameters?.InputPath?[0] ?? default);
|
||||
this.CurrentDrive = (driveIndex != -1 ? Drives[driveIndex] : Drives[0]);
|
||||
}
|
||||
catch { }
|
||||
@@ -1444,7 +1403,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
// Disable change handling
|
||||
DisableEventHandlers();
|
||||
|
||||
this.OutputPath = InfoTool.NormalizeOutputPaths(_environment.Parameters?.OutputPath, true);
|
||||
this.OutputPath = InfoTool.NormalizeOutputPaths(_environment.Parameters?.OutputPath, false);
|
||||
|
||||
if (MediaTypes != null)
|
||||
{
|
||||
@@ -1460,25 +1419,20 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Scan and show copy protection for the current disc
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public async Task<(string, string)> ScanAndShowProtection()
|
||||
#if NET40
|
||||
public (string?, string?) ScanAndShowProtection()
|
||||
#else
|
||||
public async Task<(string?, string?)> ScanAndShowProtection()
|
||||
#endif
|
||||
{
|
||||
// Determine current environment, just in case
|
||||
#if NET48
|
||||
if (_environment == null)
|
||||
_environment = DetermineEnvironment();
|
||||
#else
|
||||
_environment ??= DetermineEnvironment();
|
||||
#endif
|
||||
|
||||
// If we don't have a valid drive
|
||||
if (this.CurrentDrive == null || this.CurrentDrive.Letter == default(char))
|
||||
if (this.CurrentDrive?.Name == null)
|
||||
return (null, "No valid drive found!");
|
||||
|
||||
VerboseLogLn($"Scanning for copy protection in {this.CurrentDrive.Letter}");
|
||||
VerboseLogLn($"Scanning for copy protection in {this.CurrentDrive.Name}");
|
||||
|
||||
var tempContent = this.Status;
|
||||
this.Status = "Scanning for copy protection... this might take a while!";
|
||||
@@ -1489,7 +1443,13 @@ namespace MPF.Core.UI.ViewModels
|
||||
|
||||
var progress = new Progress<ProtectionProgress>();
|
||||
progress.ProgressChanged += ProgressUpdated;
|
||||
var (protections, error) = await Protection.RunProtectionScanOnPath(this.CurrentDrive.Letter + ":\\", this.Options, progress);
|
||||
#if NET40
|
||||
var protectionTask = Protection.RunProtectionScanOnPath(this.CurrentDrive.Name, this.Options, progress);
|
||||
protectionTask.Wait();
|
||||
var (protections, error) = protectionTask.Result;
|
||||
#else
|
||||
var (protections, error) = await Protection.RunProtectionScanOnPath(this.CurrentDrive.Name, this.Options, progress);
|
||||
#endif
|
||||
var output = Protection.FormatProtections(protections);
|
||||
|
||||
// If SmartE is detected on the current disc, remove `/sf` from the flags for DIC only -- Disabled until further notice
|
||||
@@ -1501,7 +1461,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
//}
|
||||
|
||||
if (string.IsNullOrEmpty(error))
|
||||
LogLn($"Detected the following protections in {this.CurrentDrive.Letter}:\r\n\r\n{output}");
|
||||
LogLn($"Detected the following protections in {this.CurrentDrive.Name}:\r\n\r\n{output}");
|
||||
else
|
||||
ErrorLogLn($"Path could not be scanned! Exception information:\r\n\r\n{error}");
|
||||
|
||||
@@ -1553,31 +1513,29 @@ namespace MPF.Core.UI.ViewModels
|
||||
{
|
||||
// Set the drive speed list that's appropriate
|
||||
this.DriveSpeeds = (List<int>)Interface.GetSpeedsForMediaType(CurrentMediaType);
|
||||
VerboseLogLn($"Supported media speeds: {string.Join(", ", this.DriveSpeeds)}");
|
||||
VerboseLogLn($"Supported media speeds: {string.Join(", ", this.DriveSpeeds.Select(ds => ds.ToString()).ToArray())}");
|
||||
|
||||
// Set the selected speed
|
||||
int speed;
|
||||
switch (this.CurrentMediaType)
|
||||
int speed = (CurrentMediaType) switch
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
case MediaType.GDROM:
|
||||
speed = this.Options.PreferredDumpSpeedCD;
|
||||
break;
|
||||
case MediaType.DVD:
|
||||
case MediaType.NintendoGameCubeGameDisc:
|
||||
case MediaType.NintendoWiiOpticalDisc:
|
||||
speed = this.Options.PreferredDumpSpeedDVD;
|
||||
break;
|
||||
case MediaType.HDDVD:
|
||||
speed = this.Options.PreferredDumpSpeedHDDVD;
|
||||
break;
|
||||
case MediaType.BluRay:
|
||||
speed = this.Options.PreferredDumpSpeedBD;
|
||||
break;
|
||||
default:
|
||||
speed = this.Options.PreferredDumpSpeedCD;
|
||||
break;
|
||||
}
|
||||
// CD dump speed
|
||||
MediaType.CDROM => Options.PreferredDumpSpeedCD,
|
||||
MediaType.GDROM => Options.PreferredDumpSpeedCD,
|
||||
|
||||
// DVD dump speed
|
||||
MediaType.DVD => Options.PreferredDumpSpeedDVD,
|
||||
MediaType.NintendoGameCubeGameDisc => Options.PreferredDumpSpeedDVD,
|
||||
MediaType.NintendoWiiOpticalDisc => Options.PreferredDumpSpeedDVD,
|
||||
|
||||
// HD-DVD dump speed
|
||||
MediaType.HDDVD => Options.PreferredDumpSpeedHDDVD,
|
||||
|
||||
// BD dump speed
|
||||
MediaType.BluRay => Options.PreferredDumpSpeedBD,
|
||||
|
||||
// Default
|
||||
_ => Options.PreferredDumpSpeedCD,
|
||||
};
|
||||
|
||||
VerboseLogLn($"Setting drive speed to: {speed}");
|
||||
this.DriveSpeed = speed;
|
||||
@@ -1591,7 +1549,8 @@ namespace MPF.Core.UI.ViewModels
|
||||
return Drives != null
|
||||
&& Drives.Count > 0
|
||||
&& this.CurrentSystem != null
|
||||
&& this.CurrentMediaType != null;
|
||||
&& this.CurrentMediaType != null
|
||||
&& Tools.ProgramSupportsMedia(this.CurrentProgram, this.CurrentMediaType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1652,7 +1611,11 @@ namespace MPF.Core.UI.ViewModels
|
||||
_environment.ReportStatus += ProgressUpdated;
|
||||
|
||||
// Run the program with the parameters
|
||||
#if NET40
|
||||
Result result = _environment.Run(resultProgress);
|
||||
#else
|
||||
Result result = await _environment.Run(resultProgress);
|
||||
#endif
|
||||
|
||||
// If we didn't execute a dumping command we cannot get submission output
|
||||
if (_environment.Parameters?.IsDumpingCommand() != true)
|
||||
@@ -1728,7 +1691,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
private bool ValidateBeforeDumping()
|
||||
{
|
||||
// Validate that we have an output path of any sort
|
||||
if (string.IsNullOrWhiteSpace(_environment?.OutputPath))
|
||||
if (string.IsNullOrEmpty(_environment?.OutputPath))
|
||||
{
|
||||
if (_displayUserMessage != null)
|
||||
_ = _displayUserMessage("Missing Path", "No output path was provided so dumping cannot continue.", 1, false);
|
||||
@@ -1737,10 +1700,10 @@ namespace MPF.Core.UI.ViewModels
|
||||
}
|
||||
|
||||
// Validate that the user explicitly wants an inactive drive to be considered for dumping
|
||||
if (_environment.Drive?.MarkedActive != true && _displayUserMessage != null)
|
||||
if (_environment?.Drive?.MarkedActive != true && _displayUserMessage != null)
|
||||
{
|
||||
string message = "The currently selected drive does not appear to contain a disc! "
|
||||
+ (!_environment.System.DetectedByWindows() ? $"This is normal for {_environment.System.LongName()} as the discs may not be readable on Windows. " : string.Empty)
|
||||
+ (!_environment!.System.DetectedByWindows() ? $"This is normal for {_environment.System.LongName()} as the discs may not be readable on Windows. " : string.Empty)
|
||||
+ "Do you want to continue?";
|
||||
|
||||
bool? mbresult = _displayUserMessage("No Disc Detected", message, 2, false);
|
||||
@@ -1752,11 +1715,11 @@ namespace MPF.Core.UI.ViewModels
|
||||
}
|
||||
|
||||
// Pre-split the output path
|
||||
var outputDirectory = Path.GetDirectoryName(_environment.OutputPath);
|
||||
var outputDirectory = Path.GetDirectoryName(_environment!.OutputPath);
|
||||
string outputFilename = Path.GetFileName(_environment.OutputPath);
|
||||
|
||||
// If a complete dump already exists
|
||||
(bool foundFiles, List<string> _) = InfoTool.FoundAllFiles(outputDirectory, outputFilename, _environment.Parameters, true);
|
||||
(bool foundFiles, List<string> _) = _environment.Parameters.FoundAllFiles(outputDirectory, outputFilename, true);
|
||||
if (foundFiles && _displayUserMessage != null)
|
||||
{
|
||||
bool? mbresult = _displayUserMessage("Overwrite?", "A complete dump already exists! Are you sure you want to overwrite?", 2, true);
|
||||
@@ -1770,7 +1733,7 @@ namespace MPF.Core.UI.ViewModels
|
||||
// Validate that at least some space exists
|
||||
// TODO: Tie this to the size of the disc, type of disc, etc.
|
||||
string fullPath;
|
||||
if (string.IsNullOrWhiteSpace(outputDirectory))
|
||||
if (string.IsNullOrEmpty(outputDirectory))
|
||||
fullPath = Path.GetFullPath(_environment.OutputPath);
|
||||
else
|
||||
fullPath = Path.GetFullPath(outputDirectory);
|
||||
@@ -1797,20 +1760,21 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Handler for Result ProgressChanged event
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private void ProgressUpdated(object sender, string value)
|
||||
#if NET20 || NET35 || NET40
|
||||
private void ProgressUpdated(object? sender, BaseParameters.StringEventArgs value)
|
||||
#else
|
||||
private void ProgressUpdated(object? sender, string value)
|
||||
#endif
|
||||
{
|
||||
try
|
||||
{
|
||||
#if NET48
|
||||
value = value ?? string.Empty;
|
||||
#if NET20 || NET35 || NET40
|
||||
value.Value ??= string.Empty;
|
||||
LogLn(value.Value);
|
||||
#else
|
||||
value ??= string.Empty;
|
||||
#endif
|
||||
LogLn(value);
|
||||
#endif
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
@@ -1818,20 +1782,12 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Handler for Result ProgressChanged event
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private void ProgressUpdated(object sender, Result value)
|
||||
#else
|
||||
private void ProgressUpdated(object? sender, Result value)
|
||||
#endif
|
||||
{
|
||||
var message = value?.Message;
|
||||
|
||||
// Update the label with only the first line of output
|
||||
#if NET48
|
||||
if (message != null && message.Contains("\n"))
|
||||
#else
|
||||
if (message != null && message.Contains('\n'))
|
||||
#endif
|
||||
this.Status = value?.Message?.Split('\n')[0] + " (See log output)";
|
||||
else
|
||||
this.Status = value?.Message ?? string.Empty;
|
||||
@@ -1846,17 +1802,13 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Handler for ProtectionProgress ProgressChanged event
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private void ProgressUpdated(object sender, ProtectionProgress value)
|
||||
#else
|
||||
private void ProgressUpdated(object? sender, ProtectionProgress value)
|
||||
#endif
|
||||
{
|
||||
string message = $"{value.Percentage * 100:N2}%: {value.Filename} - {value.Protection}";
|
||||
this.Status = message;
|
||||
VerboseLogLn(message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MPF.Core.Data;
|
||||
@@ -7,10 +8,27 @@ using SabreTools.RedumpLib.Web;
|
||||
|
||||
namespace MPF.Core.UI.ViewModels
|
||||
{
|
||||
public class OptionsViewModel
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public class OptionsViewModel : INotifyPropertyChanged
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Title for the window
|
||||
/// </summary>
|
||||
public string? Title
|
||||
{
|
||||
get => _title;
|
||||
set
|
||||
{
|
||||
_title = value;
|
||||
TriggerPropertyChanged(nameof(Title));
|
||||
}
|
||||
}
|
||||
private string? _title;
|
||||
|
||||
/// <summary>
|
||||
/// Current set of options
|
||||
/// </summary>
|
||||
@@ -21,6 +39,9 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// </summary>
|
||||
public bool SavedSettings { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Lists
|
||||
@@ -28,17 +49,25 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// List of available internal programs
|
||||
/// </summary>
|
||||
public List<Element<InternalProgram>> InternalPrograms => PopulateInternalPrograms();
|
||||
public static List<Element<InternalProgram>> InternalPrograms => PopulateInternalPrograms();
|
||||
|
||||
/// <summary>
|
||||
/// Current list of supported system profiles
|
||||
/// </summary>
|
||||
public List<RedumpSystemComboBoxItem> Systems => RedumpSystemComboBoxItem.GenerateElements().ToList();
|
||||
public static List<RedumpSystemComboBoxItem> Systems => RedumpSystemComboBoxItem.GenerateElements().ToList();
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// Constructor for pure view model
|
||||
/// </summary>
|
||||
public OptionsViewModel()
|
||||
{
|
||||
Options = new Options();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for in-code
|
||||
/// </summary>
|
||||
public OptionsViewModel(Options baseOptions)
|
||||
{
|
||||
@@ -63,19 +92,34 @@ namespace MPF.Core.UI.ViewModels
|
||||
/// <summary>
|
||||
/// Test Redump login credentials
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public (bool?, string) TestRedumpLogin(string username, string password)
|
||||
#if NET40
|
||||
public static Task<(bool?, string?)> TestRedumpLogin(string username, string password)
|
||||
#else
|
||||
public async Task<(bool?, string?)> TestRedumpLogin(string username, string password)
|
||||
public static async Task<(bool?, string?)> TestRedumpLogin(string username, string password)
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
return RedumpWebClient.ValidateCredentials(username, password);
|
||||
#if NET40
|
||||
return Task.Factory.StartNew(() => RedumpWebClient.ValidateCredentials(username, password));
|
||||
#elif NETFRAMEWORK
|
||||
return await Task.Run(() => RedumpWebClient.ValidateCredentials(username, password));
|
||||
#else
|
||||
return await RedumpHttpClient.ValidateCredentials(username, password);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Property Updates
|
||||
|
||||
/// <summary>
|
||||
/// Trigger a property changed event
|
||||
/// </summary>
|
||||
private void TriggerPropertyChanged(string propertyName)
|
||||
{
|
||||
// If the property change event is initialized
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,35 +8,6 @@ namespace MPF.Core.Utilities
|
||||
{
|
||||
public static class EnumExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Determine if a system is okay if it's not detected by Windows
|
||||
/// </summary>
|
||||
/// <param name="system">RedumpSystem value to check</param>
|
||||
/// <returns>True if Windows show see a disc when dumping, false otherwise</returns>
|
||||
public static bool DetectedByWindows(this RedumpSystem? system)
|
||||
{
|
||||
switch (system)
|
||||
{
|
||||
case RedumpSystem.AmericanLaserGames3DO:
|
||||
case RedumpSystem.AppleMacintosh:
|
||||
case RedumpSystem.Atari3DO:
|
||||
case RedumpSystem.AtariJaguarCDInteractiveMultimediaSystem:
|
||||
case RedumpSystem.NewJatreCDi:
|
||||
case RedumpSystem.NintendoGameCube:
|
||||
case RedumpSystem.NintendoWii:
|
||||
case RedumpSystem.NintendoWiiU:
|
||||
case RedumpSystem.PhilipsCDi:
|
||||
case RedumpSystem.PhilipsCDiDigitalVideo:
|
||||
case RedumpSystem.Panasonic3DOInteractiveMultiplayer:
|
||||
case RedumpSystem.PanasonicM2:
|
||||
case RedumpSystem.PioneerLaserActive:
|
||||
case RedumpSystem.SuperAudioCD:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if the media supports drive speeds
|
||||
/// </summary>
|
||||
@@ -44,88 +15,17 @@ namespace MPF.Core.Utilities
|
||||
/// <returns>True if the media has variable dumping speeds, false otherwise</returns>
|
||||
public static bool DoesSupportDriveSpeed(this MediaType? type)
|
||||
{
|
||||
switch (type)
|
||||
return type switch
|
||||
{
|
||||
case MediaType.CDROM:
|
||||
case MediaType.DVD:
|
||||
case MediaType.GDROM:
|
||||
case MediaType.HDDVD:
|
||||
case MediaType.BluRay:
|
||||
case MediaType.NintendoGameCubeGameDisc:
|
||||
case MediaType.NintendoWiiOpticalDisc:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if a system has reversed ringcodes
|
||||
/// </summary>
|
||||
/// <param name="system">RedumpSystem value to check</param>
|
||||
/// <returns>True if the system has reversed ringcodes, false otherwise</returns>
|
||||
public static bool HasReversedRingcodes(this RedumpSystem? system)
|
||||
{
|
||||
switch (system)
|
||||
{
|
||||
case RedumpSystem.SonyPlayStation2:
|
||||
case RedumpSystem.SonyPlayStation3:
|
||||
case RedumpSystem.SonyPlayStation4:
|
||||
//case RedumpSystem.SonyPlayStation5:
|
||||
case RedumpSystem.SonyPlayStationPortable:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if a system is considered audio-only
|
||||
/// </summary>
|
||||
/// <param name="system">RedumpSystem value to check</param>
|
||||
/// <returns>True if the system is audio-only, false otherwise</returns>
|
||||
/// <remarks>
|
||||
/// Philips CD-i should NOT be in this list. It's being included until there's a
|
||||
/// reasonable distinction between CD-i and CD-i ready on the database side.
|
||||
/// </remarks>
|
||||
public static bool IsAudio(this RedumpSystem? system)
|
||||
{
|
||||
switch (system)
|
||||
{
|
||||
case RedumpSystem.AtariJaguarCDInteractiveMultimediaSystem:
|
||||
case RedumpSystem.AudioCD:
|
||||
case RedumpSystem.DVDAudio:
|
||||
case RedumpSystem.HasbroiONEducationalGamingSystem:
|
||||
case RedumpSystem.HasbroVideoNow:
|
||||
case RedumpSystem.HasbroVideoNowColor:
|
||||
case RedumpSystem.HasbroVideoNowJr:
|
||||
case RedumpSystem.HasbroVideoNowXP:
|
||||
case RedumpSystem.PhilipsCDi:
|
||||
case RedumpSystem.PlayStationGameSharkUpdates:
|
||||
case RedumpSystem.SuperAudioCD:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if a system is considered XGD
|
||||
/// </summary>
|
||||
/// <param name="system">RedumpSystem value to check</param>
|
||||
/// <returns>True if the system is XGD, false otherwise</returns>
|
||||
public static bool IsXGD(this RedumpSystem? system)
|
||||
{
|
||||
switch (system)
|
||||
{
|
||||
case RedumpSystem.MicrosoftXbox:
|
||||
case RedumpSystem.MicrosoftXbox360:
|
||||
case RedumpSystem.MicrosoftXboxOne:
|
||||
case RedumpSystem.MicrosoftXboxSeriesXS:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
MediaType.CDROM
|
||||
or MediaType.DVD
|
||||
or MediaType.GDROM
|
||||
or MediaType.HDDVD
|
||||
or MediaType.BluRay
|
||||
or MediaType.NintendoGameCubeGameDisc
|
||||
or MediaType.NintendoWiiOpticalDisc => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -137,7 +37,7 @@ namespace MPF.Core.Utilities
|
||||
|
||||
foreach (var val in Enum.GetValues(typeof(InternalProgram)))
|
||||
{
|
||||
if (((InternalProgram)val) == InternalProgram.NONE)
|
||||
if (((InternalProgram)val!) == InternalProgram.NONE)
|
||||
continue;
|
||||
|
||||
programs.Add($"{((InternalProgram?)val).LongName()}");
|
||||
|
||||
@@ -14,8 +14,10 @@ namespace MPF.Core.Utilities
|
||||
/// <param name="reader">TextReader representing the input</param>
|
||||
/// <param name="baseClass">Invoking class, passed on to the event handler</param>
|
||||
/// <param name="handler">Event handler to be invoked to write to log</param>
|
||||
#if NET48
|
||||
public static async Task OutputToLog(TextReader reader, object baseClass, EventHandler<string> handler)
|
||||
#if NET20 || NET35
|
||||
public static async Task OutputToLog(TextReader reader, object baseClass, EventHandler<Modules.BaseParameters.StringEventArgs>? handler)
|
||||
#elif NET40
|
||||
public static void OutputToLog(TextReader reader, object baseClass, EventHandler<Modules.BaseParameters.StringEventArgs>? handler)
|
||||
#else
|
||||
public static async Task OutputToLog(TextReader reader, object baseClass, EventHandler<string>? handler)
|
||||
#endif
|
||||
@@ -30,7 +32,15 @@ namespace MPF.Core.Utilities
|
||||
while (true)
|
||||
{
|
||||
// Try to read the next chunk of characters
|
||||
#if NET20 || NET35
|
||||
read = await Task.Run(() => reader.Read(buffer, 0, buffer.Length));
|
||||
#elif NET40
|
||||
var readTask = Task.Factory.StartNew(() => reader.Read(buffer, 0, buffer.Length));
|
||||
readTask.Wait();
|
||||
read = readTask.Result;
|
||||
#else
|
||||
read = await reader.ReadAsync(buffer, 0, buffer.Length);
|
||||
#endif
|
||||
if (read == 0)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
@@ -38,25 +48,41 @@ namespace MPF.Core.Utilities
|
||||
}
|
||||
|
||||
// Convert the characters into a string
|
||||
string line = new string(buffer, 0, read);
|
||||
string line = new(buffer, 0, read);
|
||||
|
||||
// If we have no newline characters, store in the string builder
|
||||
#if NETFRAMEWORK
|
||||
if (!line.Contains("\r") && !line.Contains("\n"))
|
||||
#else
|
||||
if (!line.Contains('\r') && !line.Contains('\n'))
|
||||
#endif
|
||||
sb.Append(line);
|
||||
|
||||
// If we have a newline, append and log
|
||||
#if NETFRAMEWORK
|
||||
else if (line.Contains("\n") || line.Contains("\r\n"))
|
||||
#else
|
||||
else if (line.Contains('\n') || line.Contains("\r\n"))
|
||||
#endif
|
||||
ProcessNewLines(sb, line, baseClass, handler);
|
||||
|
||||
// If we have a carriage return only, append and log first and last instances
|
||||
#if NETFRAMEWORK
|
||||
else if (line.Contains("\r"))
|
||||
#else
|
||||
else if (line.Contains('\r'))
|
||||
#endif
|
||||
ProcessCarriageReturns(sb, line, baseClass, handler);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
finally
|
||||
{
|
||||
#if NET20 || NET35 || NET40
|
||||
handler?.Invoke(baseClass, new Modules.BaseParameters.StringEventArgs { Value = sb.ToString() });
|
||||
#else
|
||||
handler?.Invoke(baseClass, sb.ToString());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +93,8 @@ namespace MPF.Core.Utilities
|
||||
/// <param name="line">Current line to process</param>
|
||||
/// <param name="baseClass">Invoking class, passed on to the event handler</param>
|
||||
/// <param name="handler">Event handler to be invoked to write to log</param>
|
||||
#if NET48
|
||||
private static void ProcessNewLines(StringBuilder sb, string line, object baseClass, EventHandler<string> handler)
|
||||
#if NET20 || NET35 || NET40
|
||||
private static void ProcessNewLines(StringBuilder sb, string line, object baseClass, EventHandler<Modules.BaseParameters.StringEventArgs>? handler)
|
||||
#else
|
||||
private static void ProcessNewLines(StringBuilder sb, string line, object baseClass, EventHandler<string>? handler)
|
||||
#endif
|
||||
@@ -78,7 +104,11 @@ namespace MPF.Core.Utilities
|
||||
for (int i = 0; i < split.Length; i++)
|
||||
{
|
||||
// If the chunk contains a carriage return, handle it like a separate line
|
||||
#if NETFRAMEWORK
|
||||
if (split[i].Contains("\r"))
|
||||
#else
|
||||
if (split[i].Contains('\r'))
|
||||
#endif
|
||||
{
|
||||
ProcessCarriageReturns(sb, split[i], baseClass, handler);
|
||||
continue;
|
||||
@@ -88,8 +118,13 @@ namespace MPF.Core.Utilities
|
||||
if (i == 0)
|
||||
{
|
||||
sb.Append(split[i]);
|
||||
#if NET20 || NET35 || NET40
|
||||
handler?.Invoke(baseClass, new Modules.BaseParameters.StringEventArgs { Value = sb.ToString() });
|
||||
sb = new();
|
||||
#else
|
||||
handler?.Invoke(baseClass, sb.ToString());
|
||||
sb.Clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
// For the last item, just append so it's dealt with the next time
|
||||
@@ -101,7 +136,11 @@ namespace MPF.Core.Utilities
|
||||
// For everything else, directly write out
|
||||
else
|
||||
{
|
||||
#if NET20 || NET35 || NET40
|
||||
handler?.Invoke(baseClass, new Modules.BaseParameters.StringEventArgs { Value = split[i] });
|
||||
#else
|
||||
handler?.Invoke(baseClass, split[i]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,8 +152,8 @@ namespace MPF.Core.Utilities
|
||||
/// <param name="line">Current line to process</param>
|
||||
/// <param name="baseClass">Invoking class, passed on to the event handler</param>
|
||||
/// <param name="handler">Event handler to be invoked to write to log</param>
|
||||
#if NET48
|
||||
private static void ProcessCarriageReturns(StringBuilder sb, string line, object baseClass, EventHandler<string> handler)
|
||||
#if NET20 || NET35 || NET40
|
||||
private static void ProcessCarriageReturns(StringBuilder sb, string line, object baseClass, EventHandler<Modules.BaseParameters.StringEventArgs>? handler)
|
||||
#else
|
||||
private static void ProcessCarriageReturns(StringBuilder sb, string line, object baseClass, EventHandler<string>? handler)
|
||||
#endif
|
||||
@@ -123,10 +162,15 @@ namespace MPF.Core.Utilities
|
||||
|
||||
// Append and log the first
|
||||
sb.Append(split[0]);
|
||||
#if NET20 || NET35 || NET40
|
||||
handler?.Invoke(baseClass, new Modules.BaseParameters.StringEventArgs { Value = sb.ToString() });
|
||||
sb = new();
|
||||
#else
|
||||
handler?.Invoke(baseClass, sb.ToString());
|
||||
sb.Clear();
|
||||
#endif
|
||||
|
||||
// Append the last
|
||||
sb.Clear();
|
||||
sb.Append($"\r{split[split.Length - 1]}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using MPF.Core.Converters;
|
||||
using MPF.Core.Data;
|
||||
using Newtonsoft.Json;
|
||||
using SabreTools.RedumpLib;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
namespace MPF.Core.Utilities
|
||||
@@ -63,11 +64,7 @@ namespace MPF.Core.Utilities
|
||||
/// Process common arguments for all functionality
|
||||
/// </summary>
|
||||
/// <returns>True if all arguments pass, false otherwise</returns>
|
||||
#if NET48
|
||||
public static (bool, MediaType, RedumpSystem?, string) ProcessCommonArguments(string[] args)
|
||||
#else
|
||||
public static (bool, MediaType, RedumpSystem?, string?) ProcessCommonArguments(string[] args)
|
||||
#endif
|
||||
{
|
||||
// All other use requires at least 3 arguments
|
||||
if (args.Length < 3)
|
||||
@@ -89,11 +86,7 @@ namespace MPF.Core.Utilities
|
||||
/// <summary>
|
||||
/// Load the current set of options from application arguments
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static (Options, SubmissionInfo, string, int) LoadFromArguments(string[] args, int startIndex = 0)
|
||||
#else
|
||||
public static (Options, SubmissionInfo?, string?, int) LoadFromArguments(string[] args, int startIndex = 0)
|
||||
#endif
|
||||
{
|
||||
// Create the output values with defaults
|
||||
var options = new Options()
|
||||
@@ -101,18 +94,15 @@ namespace MPF.Core.Utilities
|
||||
RedumpUsername = null,
|
||||
RedumpPassword = null,
|
||||
InternalProgram = InternalProgram.NONE,
|
||||
AddFilenameSuffix = false,
|
||||
OutputSubmissionJSON = false,
|
||||
CompressLogFiles = false,
|
||||
DeleteUnnecessaryFiles = false,
|
||||
};
|
||||
|
||||
// Create the submission info to return, if necessary
|
||||
#if NET48
|
||||
SubmissionInfo info = null;
|
||||
string parsedPath = null;
|
||||
#else
|
||||
SubmissionInfo? info = null;
|
||||
string? parsedPath = null;
|
||||
#endif
|
||||
|
||||
// These values require multiple parts to be active
|
||||
bool scan = false, protectFile = false;
|
||||
@@ -185,18 +175,24 @@ namespace MPF.Core.Utilities
|
||||
}
|
||||
|
||||
// Include seed info file
|
||||
if (args[startIndex].StartsWith("-l=") || args[startIndex].StartsWith("--load-seed="))
|
||||
else if (args[startIndex].StartsWith("-l=") || args[startIndex].StartsWith("--load-seed="))
|
||||
{
|
||||
string seedInfo = args[startIndex].Split('=')[1];
|
||||
info = InfoTool.CreateFromFile(seedInfo);
|
||||
info = Builder.CreateFromFile(seedInfo);
|
||||
}
|
||||
else if (args[startIndex] == "-l" || args[startIndex] == "--load-seed")
|
||||
{
|
||||
string seedInfo = args[startIndex + 1];
|
||||
info = InfoTool.CreateFromFile(seedInfo);
|
||||
info = Builder.CreateFromFile(seedInfo);
|
||||
startIndex++;
|
||||
}
|
||||
|
||||
// Add filename suffix
|
||||
else if (args[startIndex].Equals("-x") || args[startIndex].Equals("--suffix"))
|
||||
{
|
||||
options.AddFilenameSuffix = true;
|
||||
}
|
||||
|
||||
// Output submission JSON
|
||||
else if (args[startIndex].Equals("-j") || args[startIndex].Equals("--json"))
|
||||
{
|
||||
@@ -209,6 +205,12 @@ namespace MPF.Core.Utilities
|
||||
options.CompressLogFiles = true;
|
||||
}
|
||||
|
||||
// Delete unnecessary files files
|
||||
else if (args[startIndex].Equals("-d") || args[startIndex].Equals("--delete"))
|
||||
{
|
||||
options.DeleteUnnecessaryFiles = true;
|
||||
}
|
||||
|
||||
// Default, we fall out
|
||||
else
|
||||
{
|
||||
@@ -217,8 +219,8 @@ namespace MPF.Core.Utilities
|
||||
}
|
||||
|
||||
// Now deal with the complex options
|
||||
options.ScanForProtection = scan && !string.IsNullOrWhiteSpace(parsedPath);
|
||||
options.OutputSeparateProtectionFile = scan && protectFile && !string.IsNullOrWhiteSpace(parsedPath);
|
||||
options.ScanForProtection = scan && !string.IsNullOrEmpty(parsedPath);
|
||||
options.OutputSeparateProtectionFile = scan && protectFile && !string.IsNullOrEmpty(parsedPath);
|
||||
|
||||
return (options, info, parsedPath, startIndex);
|
||||
}
|
||||
@@ -237,14 +239,16 @@ namespace MPF.Core.Utilities
|
||||
"-s, --scan Enable copy protection scan (requires --path)",
|
||||
"-f, --protect-file Output protection to separate file (requires --scan)",
|
||||
"-l, --load-seed <path> Load a seed submission JSON for user information",
|
||||
"-x, --suffix Enable adding filename suffix",
|
||||
"-j, --json Enable submission JSON output",
|
||||
"-z, --zip Enable log file compression"
|
||||
"-z, --zip Enable log file compression",
|
||||
"-d, --delete Enable unnecessary file deletion",
|
||||
};
|
||||
|
||||
return supportedArguments;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Configuration
|
||||
|
||||
@@ -261,11 +265,7 @@ namespace MPF.Core.Utilities
|
||||
|
||||
var serializer = JsonSerializer.Create();
|
||||
var reader = new StreamReader(ConfigurationPath);
|
||||
#if NET48
|
||||
var settings = serializer.Deserialize(reader, typeof(Dictionary<string, string>)) as Dictionary<string, string>;
|
||||
#else
|
||||
var settings = serializer.Deserialize(reader, typeof(Dictionary<string, string?>)) as Dictionary<string, string?>;
|
||||
#endif
|
||||
return new Options(settings);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using MPF.Core.Data;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -84,38 +85,84 @@ namespace MPF.Core.Utilities
|
||||
return Result.Failure("Please select a valid system");
|
||||
|
||||
// If we're on an unsupported type, update the status accordingly
|
||||
switch (type)
|
||||
return type switch
|
||||
{
|
||||
// Fully supported types
|
||||
case MediaType.BluRay:
|
||||
case MediaType.CDROM:
|
||||
case MediaType.DVD:
|
||||
case MediaType.FloppyDisk:
|
||||
case MediaType.HardDisk:
|
||||
case MediaType.CompactFlash:
|
||||
case MediaType.SDCard:
|
||||
case MediaType.FlashDrive:
|
||||
case MediaType.HDDVD:
|
||||
return Result.Success($"{type.LongName()} ready to dump");
|
||||
MediaType.BluRay
|
||||
or MediaType.CDROM
|
||||
or MediaType.DVD
|
||||
or MediaType.FloppyDisk
|
||||
or MediaType.HardDisk
|
||||
or MediaType.CompactFlash
|
||||
or MediaType.SDCard
|
||||
or MediaType.FlashDrive
|
||||
or MediaType.HDDVD => Result.Success($"{type.LongName()} ready to dump"),
|
||||
|
||||
// Partially supported types
|
||||
case MediaType.GDROM:
|
||||
case MediaType.NintendoGameCubeGameDisc:
|
||||
case MediaType.NintendoWiiOpticalDisc:
|
||||
return Result.Success($"{type.LongName()} partially supported for dumping");
|
||||
MediaType.GDROM
|
||||
or MediaType.NintendoGameCubeGameDisc
|
||||
or MediaType.NintendoWiiOpticalDisc => Result.Success($"{type.LongName()} partially supported for dumping"),
|
||||
|
||||
// Special case for other supported tools
|
||||
case MediaType.UMD:
|
||||
return Result.Failure($"{type.LongName()} supported for submission info parsing");
|
||||
MediaType.UMD => Result.Failure($"{type.LongName()} supported for submission info parsing"),
|
||||
|
||||
// Specifically unknown type
|
||||
case MediaType.NONE:
|
||||
return Result.Failure($"Please select a valid media type");
|
||||
MediaType.NONE => Result.Failure($"Please select a valid media type"),
|
||||
|
||||
// Undumpable but recognized types
|
||||
default:
|
||||
return Result.Failure($"{type.LongName()} media are not supported for dumping");
|
||||
}
|
||||
_ => Result.Failure($"{type.LongName()} media are not supported for dumping"),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns false if a given InternalProgram does not support a given MediaType
|
||||
/// </summary>
|
||||
public static bool ProgramSupportsMedia(InternalProgram program, MediaType? type)
|
||||
{
|
||||
// If the media type is not set, return false
|
||||
if (type == null || type == MediaType.NONE)
|
||||
return false;
|
||||
|
||||
return (program) switch
|
||||
{
|
||||
// Aaru
|
||||
InternalProgram.Aaru when type == MediaType.BluRay => true,
|
||||
InternalProgram.Aaru when type == MediaType.CDROM => true,
|
||||
InternalProgram.Aaru when type == MediaType.CompactFlash => true,
|
||||
InternalProgram.Aaru when type == MediaType.DVD => true,
|
||||
InternalProgram.Aaru when type == MediaType.GDROM => true,
|
||||
InternalProgram.Aaru when type == MediaType.FlashDrive => true,
|
||||
InternalProgram.Aaru when type == MediaType.FloppyDisk => true,
|
||||
InternalProgram.Aaru when type == MediaType.HardDisk => true,
|
||||
InternalProgram.Aaru when type == MediaType.HDDVD => true,
|
||||
InternalProgram.Aaru when type == MediaType.NintendoGameCubeGameDisc => true,
|
||||
InternalProgram.Aaru when type == MediaType.NintendoWiiOpticalDisc => true,
|
||||
InternalProgram.Aaru when type == MediaType.SDCard => true,
|
||||
|
||||
// DiscImageCreator
|
||||
InternalProgram.DiscImageCreator when type == MediaType.BluRay => true,
|
||||
InternalProgram.DiscImageCreator when type == MediaType.CDROM => true,
|
||||
InternalProgram.DiscImageCreator when type == MediaType.CompactFlash => true,
|
||||
InternalProgram.DiscImageCreator when type == MediaType.DVD => true,
|
||||
InternalProgram.DiscImageCreator when type == MediaType.GDROM => true,
|
||||
InternalProgram.DiscImageCreator when type == MediaType.FlashDrive => true,
|
||||
InternalProgram.DiscImageCreator when type == MediaType.FloppyDisk => true,
|
||||
InternalProgram.DiscImageCreator when type == MediaType.HardDisk => true,
|
||||
InternalProgram.DiscImageCreator when type == MediaType.HDDVD => true,
|
||||
InternalProgram.DiscImageCreator when type == MediaType.NintendoGameCubeGameDisc => true,
|
||||
InternalProgram.DiscImageCreator when type == MediaType.NintendoWiiOpticalDisc => true,
|
||||
InternalProgram.DiscImageCreator when type == MediaType.SDCard => true,
|
||||
|
||||
// Redumper
|
||||
InternalProgram.Redumper when type == MediaType.BluRay => true,
|
||||
InternalProgram.Redumper when type == MediaType.CDROM => true,
|
||||
InternalProgram.Redumper when type == MediaType.DVD => true,
|
||||
InternalProgram.Redumper when type == MediaType.GDROM => true,
|
||||
InternalProgram.Redumper when type == MediaType.HDDVD => true,
|
||||
|
||||
// Default
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -130,11 +177,7 @@ namespace MPF.Core.Utilities
|
||||
/// String representing the message to display the the user.
|
||||
/// String representing the new release URL.
|
||||
/// </returns>
|
||||
#if NET48
|
||||
public static (bool different, string message, string url) CheckForNewVersion()
|
||||
#else
|
||||
public static (bool different, string message, string? url) CheckForNewVersion()
|
||||
#endif
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -147,7 +190,7 @@ namespace MPF.Core.Utilities
|
||||
|
||||
// Get the latest tag from GitHub
|
||||
var (tag, url) = GetRemoteVersionAndUrl();
|
||||
bool different = version != tag;
|
||||
bool different = version != tag && tag != null;
|
||||
|
||||
string message = $"Local version: {version}"
|
||||
+ $"{Environment.NewLine}Remote version: {tag}"
|
||||
@@ -166,11 +209,7 @@ namespace MPF.Core.Utilities
|
||||
/// <summary>
|
||||
/// Get the current informational version formatted as a string
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public static string GetCurrentVersion()
|
||||
#else
|
||||
public static string? GetCurrentVersion()
|
||||
#endif
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -190,46 +229,34 @@ namespace MPF.Core.Utilities
|
||||
/// <summary>
|
||||
/// Get the latest version of MPF from GitHub and the release URL
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private static (string tag, string url) GetRemoteVersionAndUrl()
|
||||
#else
|
||||
private static (string? tag, string? url) GetRemoteVersionAndUrl()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
using (System.Net.WebClient wc = new System.Net.WebClient())
|
||||
{
|
||||
wc.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0";
|
||||
|
||||
// TODO: Figure out a better way than having this hardcoded...
|
||||
string url = "https://api.github.com/repos/SabreTools/MPF/releases/latest";
|
||||
string latestReleaseJsonString = wc.DownloadString(url);
|
||||
var latestReleaseJson = JObject.Parse(latestReleaseJsonString);
|
||||
string latestTag = latestReleaseJson["tag_name"].ToString();
|
||||
string releaseUrl = latestReleaseJson["html_url"].ToString();
|
||||
|
||||
return (latestTag, releaseUrl);
|
||||
}
|
||||
#if NET20 || NET35 || NET40
|
||||
// Not supported in .NET Frameworks 2.0, 3.5, or 4.0
|
||||
return (null, null);
|
||||
#else
|
||||
using (System.Net.Http.HttpClient hc = new System.Net.Http.HttpClient())
|
||||
{
|
||||
// TODO: Figure out a better way than having this hardcoded...
|
||||
string url = "https://api.github.com/repos/SabreTools/MPF/releases/latest";
|
||||
var message = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Get, url);
|
||||
message.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0");
|
||||
var latestReleaseJsonString = hc.Send(message)?.Content?.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
if (latestReleaseJsonString == null)
|
||||
return (null, null);
|
||||
using var hc = new System.Net.Http.HttpClient();
|
||||
#if NET452
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
||||
#endif
|
||||
|
||||
var latestReleaseJson = JObject.Parse(latestReleaseJsonString);
|
||||
if (latestReleaseJson == null)
|
||||
return (null, null);
|
||||
// TODO: Figure out a better way than having this hardcoded...
|
||||
string url = "https://api.github.com/repos/SabreTools/MPF/releases/latest";
|
||||
var message = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Get, url);
|
||||
message.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0");
|
||||
var latestReleaseJsonString = hc.SendAsync(message)?.ConfigureAwait(false).GetAwaiter().GetResult()
|
||||
.Content?.ReadAsStringAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
if (latestReleaseJsonString == null)
|
||||
return (null, null);
|
||||
|
||||
var latestTag = latestReleaseJson["tag_name"]?.ToString();
|
||||
var releaseUrl = latestReleaseJson["html_url"]?.ToString();
|
||||
var latestReleaseJson = JObject.Parse(latestReleaseJsonString);
|
||||
if (latestReleaseJson == null)
|
||||
return (null, null);
|
||||
|
||||
return (latestTag, releaseUrl);
|
||||
}
|
||||
var latestTag = latestReleaseJson["tag_name"]?.ToString();
|
||||
var releaseUrl = latestReleaseJson["html_url"]?.ToString();
|
||||
|
||||
return (latestTag, releaseUrl);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ namespace MPF.Test.Core.Converters
|
||||
/// <summary>
|
||||
/// DiscType values that map to InternalDriveType
|
||||
/// </summary>
|
||||
private static readonly DriveType[] _mappableDriveTypes = new DriveType[]
|
||||
{
|
||||
private static readonly DriveType[] _mappableDriveTypes =
|
||||
[
|
||||
DriveType.CDRom,
|
||||
DriveType.Fixed,
|
||||
DriveType.Removable,
|
||||
};
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Check that every supported DriveType maps to an InternalDriveType
|
||||
@@ -43,37 +43,21 @@ namespace MPF.Test.Core.Converters
|
||||
/// Generate a test set of DriveType values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of DriveType values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateDriveTypeMappingTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateDriveTypeMappingTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
foreach (DriveType driveType in Enum.GetValues(typeof(DriveType)))
|
||||
{
|
||||
if (_mappableDriveTypes.Contains(driveType))
|
||||
#if NET48
|
||||
testData.Add(new object[] { driveType, false });
|
||||
#else
|
||||
testData.Add(new object?[] { driveType, false });
|
||||
#endif
|
||||
testData.Add([driveType, false]);
|
||||
else
|
||||
#if NET48
|
||||
testData.Add(new object[] { driveType, true });
|
||||
#else
|
||||
testData.Add(new object?[] { driveType, true });
|
||||
#endif
|
||||
testData.Add([driveType, true]);
|
||||
}
|
||||
|
||||
return testData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Convert to Long Name
|
||||
|
||||
@@ -95,30 +79,18 @@ namespace MPF.Test.Core.Converters
|
||||
/// Generate a test set of InternalProgram values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of InternalProgram values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateInternalProgramTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateInternalProgramTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null } };
|
||||
#endif
|
||||
foreach (InternalProgram? internalProgram in Enum.GetValues(typeof(InternalProgram)))
|
||||
{
|
||||
#if NET48
|
||||
testData.Add(new object[] { internalProgram });
|
||||
#else
|
||||
testData.Add(new object?[] { internalProgram });
|
||||
#endif
|
||||
testData.Add([internalProgram]);
|
||||
}
|
||||
|
||||
return testData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// TODO: Add from-string tests
|
||||
}
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
using MPF.Core.Data;
|
||||
using Xunit;
|
||||
|
||||
namespace MPF.Test.Core.Data
|
||||
{
|
||||
public class XgdInfoTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("")]
|
||||
[InlineData("1234567")]
|
||||
[InlineData("1234567\0")]
|
||||
[InlineData("123456789")]
|
||||
public void UnmatchedStringTests(string invalidString)
|
||||
{
|
||||
var xgdInfo = new XgdInfo(invalidString);
|
||||
Assert.False(xgdInfo.Initialized);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("AV00100W", "AV", "001", "00", 'W')]
|
||||
[InlineData("AV00100W\0", "AV", "001", "00", 'W')]
|
||||
public void XGD1ValidTests(string validString, string publisher, string gameId, string version, char regionIdentifier)
|
||||
{
|
||||
var xgdInfo = new XgdInfo(validString);
|
||||
|
||||
Assert.True(xgdInfo.Initialized);
|
||||
Assert.NotNull(xgdInfo.XMID);
|
||||
Assert.Equal(publisher, xgdInfo.XMID.PublisherIdentifier);
|
||||
Assert.Equal(gameId, xgdInfo.XMID.GameID);
|
||||
Assert.Equal(version, xgdInfo.XMID.VersionNumber);
|
||||
Assert.Equal(regionIdentifier, xgdInfo.XMID.RegionIdentifier);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
// Invalid publisher identifier
|
||||
[InlineData("ZZ000000")]
|
||||
[InlineData("ZZ000000\0")]
|
||||
// Invalid region identifier
|
||||
[InlineData("AV00000Z")]
|
||||
[InlineData("AV00000Z\0")]
|
||||
public void XGD1InvalidTests(string invalidString)
|
||||
{
|
||||
var xgdInfo = new XgdInfo(invalidString);
|
||||
Assert.False(xgdInfo.Initialized);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("AV200100W0F11", "AV", "001", "00", 'W', "0", 'F', "11", null)]
|
||||
[InlineData("AV200100W0F11\0", "AV", "001", "00", 'W', "0", 'F', "11", null)]
|
||||
[InlineData("AV200100W01F11", "AV", "001", "00", 'W', "01", 'F', "11", null)]
|
||||
[InlineData("AV200100W01F11\0", "AV", "001", "00", 'W', "01", 'F', "11", null)]
|
||||
[InlineData("AV200100W0F11DEADBEEF", "AV", "001", "00", 'W', "0", 'F', "11", "DEADBEEF")]
|
||||
[InlineData("AV200100W0F11DEADBEEF\0", "AV", "001", "00", 'W', "0", 'F', "11", "DEADBEEF")]
|
||||
[InlineData("AV200100W01F11DEADBEEF", "AV", "001", "00", 'W', "01", 'F', "11", "DEADBEEF")]
|
||||
[InlineData("AV200100W01F11DEADBEEF\0", "AV", "001", "00", 'W', "01", 'F', "11", "DEADBEEF")]
|
||||
public void XGD23ValidTests(string validString, string publisher, string gameId, string sku, char regionIdentifier, string baseVersion, char mediaSubtype, string discNumber, string cert)
|
||||
{
|
||||
var xgdInfo = new XgdInfo(validString);
|
||||
|
||||
Assert.True(xgdInfo.Initialized);
|
||||
Assert.NotNull(xgdInfo.XeMID);
|
||||
Assert.Equal(publisher, xgdInfo.XeMID.PublisherIdentifier);
|
||||
Assert.Equal('2', xgdInfo.XeMID.PlatformIdentifier);
|
||||
Assert.Equal(gameId, xgdInfo.XeMID.GameID);
|
||||
Assert.Equal(sku, xgdInfo.XeMID.SKU);
|
||||
Assert.Equal(regionIdentifier, xgdInfo.XeMID.RegionIdentifier);
|
||||
Assert.Equal(baseVersion, xgdInfo.XeMID.BaseVersion);
|
||||
Assert.Equal(mediaSubtype, xgdInfo.XeMID.MediaSubtypeIdentifier);
|
||||
Assert.Equal(discNumber, xgdInfo.XeMID.DiscNumberIdentifier);
|
||||
Assert.Equal(cert, xgdInfo.XeMID.CertificationSubmissionIdentifier);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
// Invalid publisher identifier
|
||||
[InlineData("ZZ00000000000")]
|
||||
[InlineData("ZZ00000000000\0")]
|
||||
[InlineData("ZZ000000000000")]
|
||||
[InlineData("ZZ000000000000\0")]
|
||||
[InlineData("ZZ0000000000000000000")]
|
||||
[InlineData("ZZ0000000000000000000\0")]
|
||||
[InlineData("ZZ00000000000000000000")]
|
||||
[InlineData("ZZ00000000000000000000\0")]
|
||||
// Invalid platform identifier
|
||||
[InlineData("AV90000000000")]
|
||||
[InlineData("AV90000000000\0")]
|
||||
[InlineData("AV900000000000")]
|
||||
[InlineData("AV900000000000\0")]
|
||||
[InlineData("AV9000000000000000000")]
|
||||
[InlineData("AV9000000000000000000\0")]
|
||||
[InlineData("AV90000000000000000000")]
|
||||
[InlineData("AV90000000000000000000\0")]
|
||||
// Invalid region identifier
|
||||
[InlineData("AV200000Z0000")]
|
||||
[InlineData("AV200000Z0000\0")]
|
||||
[InlineData("AV200000Z00000")]
|
||||
[InlineData("AV200000Z00000\0")]
|
||||
[InlineData("AV200000Z000000000000")]
|
||||
[InlineData("AV200000Z000000000000\0")]
|
||||
[InlineData("AV200000Z0000000000000")]
|
||||
[InlineData("AV200000Z0000000000000\0")]
|
||||
// Invalid media subtype identifier
|
||||
[InlineData("AV200000W0A00")]
|
||||
[InlineData("AV200000W0A00\0")]
|
||||
[InlineData("AV200000W00A00")]
|
||||
[InlineData("AV200000W00A00\0")]
|
||||
[InlineData("AV200000W00A000000000")]
|
||||
[InlineData("AV200000W00A000000000\0")]
|
||||
[InlineData("AV200000W00A0000000000")]
|
||||
[InlineData("AV200000W00A0000000000\0")]
|
||||
public void XGD23InvalidTests(string invalidString)
|
||||
{
|
||||
var xgdInfo = new XgdInfo(invalidString);
|
||||
Assert.False(xgdInfo.Initialized);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ namespace MPF.Test.Core.Utilities
|
||||
/// <summary>
|
||||
/// MediaType values that support drive speeds
|
||||
/// </summary>
|
||||
private static readonly MediaType?[] _supportDriveSpeeds = new MediaType?[]
|
||||
{
|
||||
private static readonly MediaType?[] _supportDriveSpeeds =
|
||||
[
|
||||
MediaType.CDROM,
|
||||
MediaType.DVD,
|
||||
MediaType.GDROM,
|
||||
@@ -21,13 +21,13 @@ namespace MPF.Test.Core.Utilities
|
||||
MediaType.BluRay,
|
||||
MediaType.NintendoGameCubeGameDisc,
|
||||
MediaType.NintendoWiiOpticalDisc,
|
||||
};
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// RedumpSystem values that are considered Audio
|
||||
/// </summary>
|
||||
private static readonly RedumpSystem?[] _audioSystems = new RedumpSystem?[]
|
||||
{
|
||||
private static readonly RedumpSystem?[] _audioSystems =
|
||||
[
|
||||
RedumpSystem.AtariJaguarCDInteractiveMultimediaSystem,
|
||||
RedumpSystem.AudioCD,
|
||||
RedumpSystem.DVDAudio,
|
||||
@@ -39,40 +39,41 @@ namespace MPF.Test.Core.Utilities
|
||||
RedumpSystem.PlayStationGameSharkUpdates,
|
||||
RedumpSystem.PhilipsCDi,
|
||||
RedumpSystem.SuperAudioCD,
|
||||
};
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// RedumpSystem values that are considered markers
|
||||
/// </summary>
|
||||
private static readonly RedumpSystem?[] _markerSystems = new RedumpSystem?[]
|
||||
{
|
||||
private static readonly RedumpSystem?[] _markerSystems =
|
||||
[
|
||||
RedumpSystem.MarkerArcadeEnd,
|
||||
RedumpSystem.MarkerComputerEnd,
|
||||
RedumpSystem.MarkerDiscBasedConsoleEnd,
|
||||
RedumpSystem.MarkerOtherEnd,
|
||||
};
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// RedumpSystem values that are have reversed ringcodes
|
||||
/// </summary>
|
||||
private static readonly RedumpSystem?[] _reverseRingcodeSystems = new RedumpSystem?[]
|
||||
{
|
||||
private static readonly RedumpSystem?[] _reverseRingcodeSystems =
|
||||
[
|
||||
RedumpSystem.SonyPlayStation2,
|
||||
RedumpSystem.SonyPlayStation3,
|
||||
RedumpSystem.SonyPlayStation4,
|
||||
RedumpSystem.SonyPlayStation5,
|
||||
RedumpSystem.SonyPlayStationPortable,
|
||||
};
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// RedumpSystem values that are considered XGD
|
||||
/// </summary>
|
||||
private static readonly RedumpSystem?[] _xgdSystems = new RedumpSystem?[]
|
||||
{
|
||||
private static readonly RedumpSystem?[] _xgdSystems =
|
||||
[
|
||||
RedumpSystem.MicrosoftXbox,
|
||||
RedumpSystem.MicrosoftXbox360,
|
||||
RedumpSystem.MicrosoftXboxOne,
|
||||
RedumpSystem.MicrosoftXboxSeriesXS,
|
||||
};
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Check that all optical media support drive speeds
|
||||
@@ -143,31 +144,15 @@ namespace MPF.Test.Core.Utilities
|
||||
/// Generate a test set of MediaType values that support drive speeds
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of MediaType values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateSupportDriveSpeedsTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateSupportDriveSpeedsTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, false } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, false } };
|
||||
#endif
|
||||
foreach (MediaType mediaType in Enum.GetValues(typeof(MediaType)))
|
||||
{
|
||||
if (_supportDriveSpeeds.Contains(mediaType))
|
||||
#if NET48
|
||||
testData.Add(new object[] { mediaType, true });
|
||||
#else
|
||||
testData.Add(new object?[] { mediaType, true });
|
||||
#endif
|
||||
testData.Add([mediaType, true]);
|
||||
else
|
||||
#if NET48
|
||||
testData.Add(new object[] { mediaType, false });
|
||||
#else
|
||||
testData.Add(new object?[] { mediaType, false });
|
||||
#endif
|
||||
testData.Add([mediaType, false]);
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -177,31 +162,15 @@ namespace MPF.Test.Core.Utilities
|
||||
/// Generate a test set of RedumpSystem values that are considered Audio
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of RedumpSystem values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateAudioSystemsTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateAudioSystemsTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, false } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, false } };
|
||||
#endif
|
||||
foreach (RedumpSystem redumpSystem in Enum.GetValues(typeof(RedumpSystem)))
|
||||
{
|
||||
if (_audioSystems.Contains(redumpSystem))
|
||||
#if NET48
|
||||
testData.Add(new object[] { redumpSystem, true });
|
||||
#else
|
||||
testData.Add(new object?[] { redumpSystem, true });
|
||||
#endif
|
||||
testData.Add([redumpSystem, true]);
|
||||
else
|
||||
#if NET48
|
||||
testData.Add(new object[] { redumpSystem, false });
|
||||
#else
|
||||
testData.Add(new object?[] { redumpSystem, false });
|
||||
#endif
|
||||
testData.Add([redumpSystem, false]);
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -211,31 +180,15 @@ namespace MPF.Test.Core.Utilities
|
||||
/// Generate a test set of RedumpSystem values that are considered markers
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of RedumpSystem values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateMarkerSystemsTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateMarkerSystemsTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, false } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, false } };
|
||||
#endif
|
||||
foreach (RedumpSystem redumpSystem in Enum.GetValues(typeof(RedumpSystem)))
|
||||
{
|
||||
if (_markerSystems.Contains(redumpSystem))
|
||||
#if NET48
|
||||
testData.Add(new object[] { redumpSystem, true });
|
||||
#else
|
||||
testData.Add(new object?[] { redumpSystem, true });
|
||||
#endif
|
||||
testData.Add([redumpSystem, true]);
|
||||
else
|
||||
#if NET48
|
||||
testData.Add(new object[] { redumpSystem, false });
|
||||
#else
|
||||
testData.Add(new object?[] { redumpSystem, false });
|
||||
#endif
|
||||
testData.Add([redumpSystem, false]);
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -245,31 +198,15 @@ namespace MPF.Test.Core.Utilities
|
||||
/// Generate a test set of RedumpSystem values that are considered markers
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of RedumpSystem values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateReversedRingcodeSystemsTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateReversedRingcodeSystemsTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, false } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, false } };
|
||||
#endif
|
||||
foreach (RedumpSystem redumpSystem in Enum.GetValues(typeof(RedumpSystem)))
|
||||
{
|
||||
if (_reverseRingcodeSystems.Contains(redumpSystem))
|
||||
#if NET48
|
||||
testData.Add(new object[] { redumpSystem, true });
|
||||
#else
|
||||
testData.Add(new object?[] { redumpSystem, true });
|
||||
#endif
|
||||
testData.Add([redumpSystem, true]);
|
||||
else
|
||||
#if NET48
|
||||
testData.Add(new object[] { redumpSystem, false });
|
||||
#else
|
||||
testData.Add(new object?[] { redumpSystem, false });
|
||||
#endif
|
||||
testData.Add([redumpSystem, false]);
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -279,31 +216,15 @@ namespace MPF.Test.Core.Utilities
|
||||
/// Generate a test set of RedumpSystem values that are considered XGD
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of RedumpSystem values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateXGDSystemsTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateXGDSystemsTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, false } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, false } };
|
||||
#endif
|
||||
foreach (RedumpSystem redumpSystem in Enum.GetValues(typeof(RedumpSystem)))
|
||||
{
|
||||
if (_xgdSystems.Contains(redumpSystem))
|
||||
#if NET48
|
||||
testData.Add(new object[] { redumpSystem, true });
|
||||
#else
|
||||
testData.Add(new object?[] { redumpSystem, true });
|
||||
#endif
|
||||
testData.Add([redumpSystem, true]);
|
||||
else
|
||||
#if NET48
|
||||
testData.Add(new object[] { redumpSystem, false });
|
||||
#else
|
||||
testData.Add(new object?[] { redumpSystem, false });
|
||||
#endif
|
||||
testData.Add([redumpSystem, false]);
|
||||
}
|
||||
|
||||
return testData;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace MPF.Test.Library
|
||||
[InlineData("fd A test.img", 'A', true, MediaType.FloppyDisk, true)]
|
||||
[InlineData("dvd X test.iso 8 /raw", 'X', false, MediaType.FloppyDisk, false)]
|
||||
[InlineData("stop D", 'D', false, MediaType.DVD, true)]
|
||||
public void ParametersValidTest(string parameters, char letter, bool isFloppy, MediaType? mediaType, bool expected)
|
||||
public void ParametersValidTest(string? parameters, char letter, bool isFloppy, MediaType? mediaType, bool expected)
|
||||
{
|
||||
var options = new Options() { InternalProgram = InternalProgram.DiscImageCreator };
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using MPF.Core;
|
||||
using SabreTools.RedumpLib;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
|
||||
@@ -8,67 +9,18 @@ namespace MPF.Test.Library
|
||||
{
|
||||
public class InfoToolTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(null, 0, 0, 0, 0, null)]
|
||||
[InlineData(null, 12345, 0, 0, 0, null)]
|
||||
[InlineData(null, 12345, 1, 0, 0, null)]
|
||||
[InlineData(null, 12345, 1, 2, 0, null)]
|
||||
[InlineData(null, 12345, 1, 2, 3, null)]
|
||||
[InlineData(MediaType.CDROM, 0, 0, 0, 0, "CD-ROM")]
|
||||
[InlineData(MediaType.CDROM, 12345, 0, 0, 0, "CD-ROM")]
|
||||
[InlineData(MediaType.CDROM, 12345, 1, 0, 0, "CD-ROM")]
|
||||
[InlineData(MediaType.CDROM, 12345, 1, 2, 0, "CD-ROM")]
|
||||
[InlineData(MediaType.CDROM, 12345, 1, 2, 3, "CD-ROM")]
|
||||
[InlineData(MediaType.DVD, 0, 0, 0, 0, "DVD-ROM-5")]
|
||||
[InlineData(MediaType.DVD, 12345, 0, 0, 0, "DVD-ROM-5")]
|
||||
[InlineData(MediaType.DVD, 12345, 1, 0, 0, "DVD-ROM-9")]
|
||||
[InlineData(MediaType.DVD, 12345, 1, 2, 0, "DVD-ROM-9")]
|
||||
[InlineData(MediaType.DVD, 12345, 1, 2, 3, "DVD-ROM-9")]
|
||||
[InlineData(MediaType.BluRay, 0, 0, 0, 0, "BD-ROM-25")]
|
||||
[InlineData(MediaType.BluRay, 12345, 0, 0, 0, "BD-ROM-25")]
|
||||
[InlineData(MediaType.BluRay, 26_843_531_857, 0, 0, 0, "BD-ROM-33")]
|
||||
[InlineData(MediaType.BluRay, 12345, 1, 0, 0, "BD-ROM-50")]
|
||||
[InlineData(MediaType.BluRay, 53_687_063_713, 1, 0, 0, "BD-ROM-66")]
|
||||
[InlineData(MediaType.BluRay, 12345, 1, 2, 0, "BD-ROM-100")]
|
||||
[InlineData(MediaType.BluRay, 12345, 1, 2, 3, "BD-ROM-128")]
|
||||
[InlineData(MediaType.UMD, 0, 0, 0, 0, "UMD-SL")]
|
||||
[InlineData(MediaType.UMD, 12345, 0, 0, 0, "UMD-SL")]
|
||||
[InlineData(MediaType.UMD, 12345, 1, 0, 0, "UMD-DL")]
|
||||
[InlineData(MediaType.UMD, 12345, 1, 2, 0, "UMD-DL")]
|
||||
[InlineData(MediaType.UMD, 12345, 1, 2, 3, "UMD-DL")]
|
||||
public void GetFixedMediaTypeTest(
|
||||
MediaType? mediaType,
|
||||
long size,
|
||||
long layerbreak,
|
||||
long layerbreak2,
|
||||
long layerbreak3,
|
||||
#if NET48
|
||||
string expected)
|
||||
#else
|
||||
string? expected)
|
||||
#endif
|
||||
{
|
||||
// TODO: Add tests around BDU
|
||||
var actual = InfoTool.GetFixedMediaType(mediaType, null, size, layerbreak, layerbreak2, layerbreak3);
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, "")]
|
||||
[InlineData(" ", "")]
|
||||
[InlineData(" ", " ")]
|
||||
[InlineData("super\\blah.bin", "super\\blah.bin")]
|
||||
[InlineData("super\\hero\\blah.bin", "super\\hero\\blah.bin")]
|
||||
[InlineData("super.hero\\blah.bin", "super.hero\\blah.bin")]
|
||||
[InlineData("superhero\\blah.rev.bin", "superhero\\blah.rev.bin")]
|
||||
[InlineData("super&hero\\blah.bin", "super&hero\\blah.bin")]
|
||||
[InlineData("superhero\\blah&foo.bin", "superhero\\blah&foo.bin")]
|
||||
#if NET48
|
||||
public void NormalizeOutputPathsTest(string outputPath, string expectedPath)
|
||||
#else
|
||||
public void NormalizeOutputPathsTest(string? outputPath, string? expectedPath)
|
||||
#endif
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(expectedPath))
|
||||
if (!string.IsNullOrEmpty(expectedPath))
|
||||
expectedPath = Path.GetFullPath(expectedPath);
|
||||
|
||||
string actualPath = InfoTool.NormalizeOutputPaths(outputPath, true);
|
||||
@@ -84,21 +36,13 @@ namespace MPF.Test.Library
|
||||
CommonDiscInfo = new CommonDiscInfoSection()
|
||||
{
|
||||
Comments = "This is a comments line\n[T:ISBN] ISBN Value",
|
||||
#if NET48
|
||||
CommentsSpecialFields = new Dictionary<SiteCode?, string>()
|
||||
#else
|
||||
CommentsSpecialFields = new Dictionary<SiteCode, string>()
|
||||
#endif
|
||||
{
|
||||
[SiteCode.VolumeLabel] = "VOLUME_LABEL",
|
||||
},
|
||||
|
||||
Contents = "This is a contents line\n[T:GF] Game Footage",
|
||||
#if NET48
|
||||
ContentsSpecialFields = new Dictionary<SiteCode?, string>()
|
||||
#else
|
||||
ContentsSpecialFields = new Dictionary<SiteCode, string>()
|
||||
#endif
|
||||
{
|
||||
[SiteCode.Patches] = "1.04 patch",
|
||||
},
|
||||
@@ -106,7 +50,7 @@ namespace MPF.Test.Library
|
||||
};
|
||||
|
||||
// Process the special fields
|
||||
InfoTool.ProcessSpecialFields(info);
|
||||
Formatter.ProcessSpecialFields(info);
|
||||
|
||||
// Validate the basics
|
||||
Assert.NotNull(info.CommonDiscInfo.Comments);
|
||||
@@ -133,7 +77,7 @@ namespace MPF.Test.Library
|
||||
};
|
||||
|
||||
// Process the special fields
|
||||
InfoTool.ProcessSpecialFields(info);
|
||||
Formatter.ProcessSpecialFields(info);
|
||||
|
||||
// Validate
|
||||
Assert.Null(info.CommonDiscInfo);
|
||||
@@ -148,21 +92,13 @@ namespace MPF.Test.Library
|
||||
CommonDiscInfo = new CommonDiscInfoSection()
|
||||
{
|
||||
Comments = null,
|
||||
#if NET48
|
||||
CommentsSpecialFields = new Dictionary<SiteCode?, string>()
|
||||
#else
|
||||
CommentsSpecialFields = new Dictionary<SiteCode, string>()
|
||||
#endif
|
||||
{
|
||||
[SiteCode.VolumeLabel] = "VOLUME_LABEL",
|
||||
},
|
||||
|
||||
Contents = null,
|
||||
#if NET48
|
||||
ContentsSpecialFields = new Dictionary<SiteCode?, string>()
|
||||
#else
|
||||
ContentsSpecialFields = new Dictionary<SiteCode, string>()
|
||||
#endif
|
||||
{
|
||||
[SiteCode.Patches] = "1.04 patch",
|
||||
},
|
||||
@@ -170,7 +106,7 @@ namespace MPF.Test.Library
|
||||
};
|
||||
|
||||
// Process the special fields
|
||||
InfoTool.ProcessSpecialFields(info);
|
||||
Formatter.ProcessSpecialFields(info);
|
||||
|
||||
// Validate the basics
|
||||
Assert.NotNull(info.CommonDiscInfo.Comments);
|
||||
@@ -204,7 +140,7 @@ namespace MPF.Test.Library
|
||||
};
|
||||
|
||||
// Process the special fields
|
||||
InfoTool.ProcessSpecialFields(info);
|
||||
Formatter.ProcessSpecialFields(info);
|
||||
|
||||
// Validate the basics
|
||||
Assert.NotNull(info.CommonDiscInfo.Comments);
|
||||
|
||||
@@ -11,11 +11,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsActiveMARKTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"ActiveMARK",
|
||||
"ActiveMARK 5",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("ActiveMARK 5", sanitized);
|
||||
@@ -24,11 +24,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsCactusDataShieldTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"Cactus Data Shield 200",
|
||||
"Cactus Data Shield 200 (Build 3.0.100a)",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("Cactus Data Shield 200 (Build 3.0.100a)", sanitized);
|
||||
@@ -37,11 +37,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsCDCheckTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"Anything Else Protection",
|
||||
"Executable-Based CD Check",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("Anything Else Protection", sanitized);
|
||||
@@ -50,11 +50,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsCDCopsTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"CD-Cops",
|
||||
"CD-Cops v1.2.0",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("CD-Cops v1.2.0", sanitized);
|
||||
@@ -63,11 +63,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsCDKeyTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"Anything Else Protection",
|
||||
"CD-Key / Serial",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("Anything Else Protection", sanitized);
|
||||
@@ -76,11 +76,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsEACdKeyTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"EA CdKey Registration Module",
|
||||
"EA CdKey Registration Module v1.2.0",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("EA CdKey Registration Module v1.2.0", sanitized);
|
||||
@@ -89,11 +89,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsEADRMTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"EA DRM Protection",
|
||||
"EA DRM Protection v1.2.0",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("EA DRM Protection v1.2.0", sanitized);
|
||||
@@ -102,11 +102,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsGFWLTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"Games for Windows LIVE",
|
||||
"Games for Windows LIVE v1.2.0",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("Games for Windows LIVE v1.2.0", sanitized);
|
||||
@@ -115,11 +115,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsGFWLZDPPTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"Games for Windows LIVE",
|
||||
"Games for Windows LIVE Zero Day Piracy Protection",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("Games for Windows LIVE, Games for Windows LIVE Zero Day Piracy Protection", sanitized);
|
||||
@@ -128,11 +128,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsImpulseReactorTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"Impulse Reactor",
|
||||
"Impulse Reactor Core Module v1.2.0",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("Impulse Reactor Core Module v1.2.0", sanitized);
|
||||
@@ -145,14 +145,14 @@ namespace MPF.Test.Library
|
||||
[InlineData(3)]
|
||||
public void SanitizeFoundProtectionsJoWoodXProtTest(int skip)
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"JoWood X-Prot 1.2.0.00",
|
||||
"JoWood X-Prot v2",
|
||||
"JoWood X-Prot v1.4+",
|
||||
"JoWood X-Prot v1.0-v1.3",
|
||||
"JoWood X-Prot",
|
||||
};
|
||||
];
|
||||
|
||||
// Safeguard for the future
|
||||
if (skip >= protections.Count)
|
||||
@@ -168,11 +168,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsOnlineRegistrationTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"Anything Else Protection",
|
||||
"Executable-Based Online Registration",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("Anything Else Protection", sanitized);
|
||||
@@ -185,14 +185,14 @@ namespace MPF.Test.Library
|
||||
[InlineData(3)]
|
||||
public void SanitizeFoundProtectionStarForceTest(int skip)
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"StarForce 1.20.000.000",
|
||||
"StarForce 5 [Protected Module]",
|
||||
"StarForce 5",
|
||||
"StarForce 3-5",
|
||||
"StarForce",
|
||||
};
|
||||
];
|
||||
|
||||
// Safeguard for the future
|
||||
if (skip >= protections.Count)
|
||||
@@ -208,11 +208,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsSysiphusTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"Sysiphus",
|
||||
"Sysiphus v1.2.0",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("Sysiphus v1.2.0", sanitized);
|
||||
@@ -221,11 +221,11 @@ namespace MPF.Test.Library
|
||||
[Fact]
|
||||
public void SanitizeFoundProtectionsXCPTest()
|
||||
{
|
||||
List<string> protections = new List<string>()
|
||||
{
|
||||
List<string> protections =
|
||||
[
|
||||
"XCP",
|
||||
"XCP v1.2.0",
|
||||
};
|
||||
];
|
||||
|
||||
string sanitized = Protection.SanitizeFoundProtections(protections);
|
||||
Assert.Equal("XCP v1.2.0", sanitized);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net48;net6.0-windows;net7.0-windows</TargetFrameworks>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">
|
||||
<TargetFrameworks>net6.0-windows;net8.0-windows</TargetFrameworks>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -14,22 +14,22 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeCoverage" Version="17.7.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
|
||||
<PackageReference Include="Microsoft.CodeCoverage" Version="17.9.0-preview-23531-01" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23531-01" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.1.1" />
|
||||
<PackageReference Include="xunit" Version="2.5.1" />
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.3.1" />
|
||||
<PackageReference Include="xunit" Version="2.6.2" />
|
||||
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
|
||||
<PackageReference Include="xunit.analyzers" Version="1.3.0" />
|
||||
<PackageReference Include="xunit.assert" Version="2.5.1" />
|
||||
<PackageReference Include="xunit.core" Version="2.5.1" />
|
||||
<PackageReference Include="xunit.extensibility.core" Version="2.5.1" />
|
||||
<PackageReference Include="xunit.extensibility.execution" Version="2.5.1" />
|
||||
<PackageReference Include="xunit.runner.console" Version="2.5.1">
|
||||
<PackageReference Include="xunit.analyzers" Version="1.6.0" />
|
||||
<PackageReference Include="xunit.assert" Version="2.6.2" />
|
||||
<PackageReference Include="xunit.core" Version="2.6.2" />
|
||||
<PackageReference Include="xunit.extensibility.core" Version="2.6.2" />
|
||||
<PackageReference Include="xunit.extensibility.execution" Version="2.6.2" />
|
||||
<PackageReference Include="xunit.runner.console" Version="2.6.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace MPF.Test.Modules
|
||||
[InlineData(RedumpSystem.SonyPlayStation3, MediaType.BluRay, CommandStrings.BluRay)]
|
||||
[InlineData(RedumpSystem.AppleMacintosh, MediaType.FloppyDisk, CommandStrings.Floppy)]
|
||||
[InlineData(RedumpSystem.RawThrillsVarious, MediaType.GDROM, null)]
|
||||
public void ParametersFromSystemAndTypeTest(RedumpSystem? knownSystem, MediaType? mediaType, string expected)
|
||||
public void ParametersFromSystemAndTypeTest(RedumpSystem? knownSystem, MediaType? mediaType, string? expected)
|
||||
{
|
||||
var options = new Options();
|
||||
var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options);
|
||||
var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options);
|
||||
Assert.Equal(expected, actual.BaseCommand);
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ namespace MPF.Test.Modules
|
||||
[InlineData(RedumpSystem.AppleMacintosh, MediaType.LaserDisc, null)] // Deliberately unsupported
|
||||
[InlineData(RedumpSystem.IBMPCcompatible, MediaType.CDROM, new string[] { FlagStrings.C2Opcode, FlagStrings.NoFixSubQSecuROM, FlagStrings.ScanFileProtect })]
|
||||
[InlineData(RedumpSystem.NintendoGameCube, MediaType.NintendoGameCubeGameDisc, new string[] { FlagStrings.Raw })]
|
||||
public void ParametersFromOptionsSpecialDefaultTest(RedumpSystem? knownSystem, MediaType? mediaType,string[] expected)
|
||||
public void ParametersFromOptionsSpecialDefaultTest(RedumpSystem? knownSystem, MediaType? mediaType, string[]? expected)
|
||||
{
|
||||
var options = new Options();
|
||||
var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options);
|
||||
var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options);
|
||||
|
||||
var expectedSet = new HashSet<string>(expected ?? Array.Empty<string>());
|
||||
HashSet<string> actualSet = GenerateUsedKeys(actual);
|
||||
@@ -45,7 +45,7 @@ namespace MPF.Test.Modules
|
||||
public void ParametersFromOptionsC2RereadTest(RedumpSystem? knownSystem, MediaType? mediaType, int rereadC2, string[] expected)
|
||||
{
|
||||
var options = new Options { DICRereadCount = rereadC2 };
|
||||
var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options);
|
||||
var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options);
|
||||
|
||||
var expectedSet = new HashSet<string>(expected ?? Array.Empty<string>());
|
||||
HashSet<string> actualSet = GenerateUsedKeys(actual);
|
||||
@@ -65,7 +65,7 @@ namespace MPF.Test.Modules
|
||||
public void ParametersFromOptionsDVDRereadTest(RedumpSystem? knownSystem, MediaType? mediaType, int rereadDVDBD, string[] expected)
|
||||
{
|
||||
var options = new Options { DICDVDRereadCount = rereadDVDBD };
|
||||
var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options);
|
||||
var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options);
|
||||
|
||||
var expectedSet = new HashSet<string>(expected ?? Array.Empty<string>());
|
||||
HashSet<string> actualSet = GenerateUsedKeys(actual);
|
||||
@@ -89,7 +89,7 @@ namespace MPF.Test.Modules
|
||||
public void ParametersFromOptionsMultiSectorReadTest(RedumpSystem? knownSystem, MediaType? mediaType, bool multiSectorRead, string[] expected)
|
||||
{
|
||||
var options = new Options { DICMultiSectorRead = multiSectorRead };
|
||||
var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options);
|
||||
var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options);
|
||||
|
||||
var expectedSet = new HashSet<string>(expected ?? Array.Empty<string>());
|
||||
HashSet<string> actualSet = GenerateUsedKeys(actual);
|
||||
@@ -110,7 +110,7 @@ namespace MPF.Test.Modules
|
||||
public void ParametersFromOptionsParanoidModeTest(RedumpSystem? knownSystem, MediaType? mediaType, bool paranoidMode, string[] expected)
|
||||
{
|
||||
var options = new Options { DICParanoidMode = paranoidMode };
|
||||
var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options);
|
||||
var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options);
|
||||
|
||||
var expectedSet = new HashSet<string>(expected ?? Array.Empty<string>());
|
||||
HashSet<string> actualSet = GenerateUsedKeys(actual);
|
||||
@@ -147,7 +147,7 @@ namespace MPF.Test.Modules
|
||||
[InlineData("bd D longer\\path_test.iso 16", true)]
|
||||
[InlineData("stop D", true)]
|
||||
[InlineData("ls", false)]
|
||||
public void ValidateParametersTest(string parameters, bool expected)
|
||||
public void ValidateParametersTest(string? parameters, bool expected)
|
||||
{
|
||||
var actual = new Parameters(parameters);
|
||||
Assert.Equal(expected, actual.IsValid());
|
||||
@@ -161,11 +161,7 @@ namespace MPF.Test.Modules
|
||||
[InlineData(MediaType.FloppyDisk, ".img")]
|
||||
[InlineData(MediaType.Cassette, ".wav")]
|
||||
[InlineData(MediaType.NONE, null)]
|
||||
#if NET48
|
||||
public void MediaTypeToExtensionTest(MediaType? mediaType, string expected)
|
||||
#else
|
||||
public void MediaTypeToExtensionTest(MediaType? mediaType, string? expected)
|
||||
#endif
|
||||
{
|
||||
var actual = Converters.Extension(mediaType);
|
||||
Assert.Equal(expected, actual);
|
||||
@@ -219,7 +215,7 @@ namespace MPF.Test.Modules
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
[Fact]
|
||||
public void DiscImageCreatorAudioParametersTest()
|
||||
|
||||
@@ -95,31 +95,15 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of DiscType values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of DiscType values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateDiscTypeMappingTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateDiscTypeMappingTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
foreach (DiscType? discType in Enum.GetValues(typeof(DiscType)))
|
||||
{
|
||||
if (_mappableDiscTypes.Contains(discType))
|
||||
#if NET48
|
||||
testData.Add(new object[] { discType, false });
|
||||
#else
|
||||
testData.Add(new object?[] { discType, false });
|
||||
#endif
|
||||
else
|
||||
#if NET48
|
||||
testData.Add(new object[] { discType, true });
|
||||
#else
|
||||
testData.Add(new object?[] { discType, true });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -129,24 +113,12 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of RedumpSystem values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of RedumpSystem values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateRedumpSystemMappingTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateRedumpSystemMappingTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null } };
|
||||
#endif
|
||||
foreach (RedumpSystem? redumpSystem in Enum.GetValues(typeof(RedumpSystem)))
|
||||
{
|
||||
#if NET48
|
||||
testData.Add(new object[] { redumpSystem });
|
||||
#else
|
||||
testData.Add(new object?[] { redumpSystem });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -156,32 +128,16 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of mappable media types
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of MediaTypes</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateMediaTypeMappingTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateMediaTypeMappingTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
|
||||
foreach (MediaType? mediaType in Enum.GetValues(typeof(MediaType)))
|
||||
{
|
||||
if (_mappableMediaTypes.Contains(mediaType))
|
||||
#if NET48
|
||||
testData.Add(new object[] { mediaType, false });
|
||||
#else
|
||||
testData.Add(new object?[] { mediaType, false });
|
||||
#endif
|
||||
else
|
||||
#if NET48
|
||||
testData.Add(new object[] { mediaType, true });
|
||||
#else
|
||||
testData.Add(new object?[] { mediaType, true });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -212,24 +168,12 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of DiscCategory values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of DiscCategory values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateDiscCategoryTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateDiscCategoryTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
foreach (DiscCategory? discCategory in Enum.GetValues(typeof(DiscCategory)))
|
||||
{
|
||||
#if NET48
|
||||
testData.Add(new object[] { discCategory, false });
|
||||
#else
|
||||
testData.Add(new object?[] { discCategory, false });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -260,31 +204,15 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of DiscType values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of DiscType values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateDiscTypeTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateDiscTypeTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
foreach (DiscType? discType in Enum.GetValues(typeof(DiscType)))
|
||||
{
|
||||
if (discType == DiscType.NONE)
|
||||
#if NET48
|
||||
testData.Add(new object[] { discType, true });
|
||||
#else
|
||||
testData.Add(new object?[] { discType, true });
|
||||
#endif
|
||||
else
|
||||
#if NET48
|
||||
testData.Add(new object[] { discType, false });
|
||||
#else
|
||||
testData.Add(new object?[] { discType, false });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -341,7 +269,7 @@ namespace MPF.Test.RedumpLib
|
||||
foreach (Language? language in fullLanguages)
|
||||
{
|
||||
var code = language.TwoLetterCode();
|
||||
if (string.IsNullOrWhiteSpace(code))
|
||||
if (string.IsNullOrEmpty(code))
|
||||
continue;
|
||||
|
||||
// Throw if the code already exists
|
||||
@@ -368,7 +296,7 @@ namespace MPF.Test.RedumpLib
|
||||
foreach (Language? language in fullLanguages)
|
||||
{
|
||||
var code = language.ThreeLetterCode();
|
||||
if (string.IsNullOrWhiteSpace(code))
|
||||
if (string.IsNullOrEmpty(code))
|
||||
continue;
|
||||
|
||||
// Throw if the code already exists
|
||||
@@ -395,7 +323,7 @@ namespace MPF.Test.RedumpLib
|
||||
foreach (Language? language in fullLanguages)
|
||||
{
|
||||
var code = language.ThreeLetterCodeAlt();
|
||||
if (string.IsNullOrWhiteSpace(code))
|
||||
if (string.IsNullOrEmpty(code))
|
||||
continue;
|
||||
|
||||
// Throw if the code already exists
|
||||
@@ -413,24 +341,12 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of Language values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of Language values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateLanguageTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateLanguageTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
foreach (Language? language in Enum.GetValues(typeof(Language)))
|
||||
{
|
||||
#if NET48
|
||||
testData.Add(new object[] { language, false });
|
||||
#else
|
||||
testData.Add(new object?[] { language, false });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -461,24 +377,12 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of LanguageSelection values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of LanguageSelection values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateLanguageSelectionTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateLanguageSelectionTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
foreach (LanguageSelection? languageSelection in Enum.GetValues(typeof(LanguageSelection)))
|
||||
{
|
||||
#if NET48
|
||||
testData.Add(new object[] { languageSelection, false });
|
||||
#else
|
||||
testData.Add(new object?[] { languageSelection, false });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -526,24 +430,12 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of MediaType values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of MediaType values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateMediaTypeTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateMediaTypeTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
foreach (MediaType? mediaType in Enum.GetValues(typeof(MediaType)))
|
||||
{
|
||||
#if NET48
|
||||
testData.Add(new object[] { mediaType, false });
|
||||
#else
|
||||
testData.Add(new object?[] { mediaType, false });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -600,7 +492,7 @@ namespace MPF.Test.RedumpLib
|
||||
foreach (Region? region in fullRegions)
|
||||
{
|
||||
var code = region.ShortName();
|
||||
if (string.IsNullOrWhiteSpace(code))
|
||||
if (string.IsNullOrEmpty(code))
|
||||
continue;
|
||||
|
||||
// Throw if the code already exists
|
||||
@@ -618,24 +510,12 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of Region values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of Region values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateRegionTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateRegionTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
foreach (Region? region in Enum.GetValues(typeof(Region)))
|
||||
{
|
||||
#if NET48
|
||||
testData.Add(new object[] { region, false });
|
||||
#else
|
||||
testData.Add(new object?[] { region, false });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -683,24 +563,12 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of SiteCode values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of SiteCode values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateSiteCodeTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateSiteCodeTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
foreach (SiteCode? siteCode in Enum.GetValues(typeof(SiteCode)))
|
||||
{
|
||||
#if NET48
|
||||
testData.Add(new object[] { siteCode, false });
|
||||
#else
|
||||
testData.Add(new object?[] { siteCode, false });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -754,28 +622,16 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of RedumpSystem values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of RedumpSystem values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateRedumpSystemTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateRedumpSystemTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
foreach (RedumpSystem? redumpSystem in Enum.GetValues(typeof(RedumpSystem)))
|
||||
{
|
||||
// We want to skip all markers for this
|
||||
if (redumpSystem.IsMarker())
|
||||
continue;
|
||||
|
||||
#if NET48
|
||||
testData.Add(new object[] { redumpSystem, false });
|
||||
#else
|
||||
testData.Add(new object?[] { redumpSystem, false });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -806,31 +662,15 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of SystemCategory values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of SystemCategory values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateSystemCategoryTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateSystemCategoryTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, true } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, true } };
|
||||
#endif
|
||||
foreach (SystemCategory? systemCategory in Enum.GetValues(typeof(SystemCategory)))
|
||||
{
|
||||
if (systemCategory == SystemCategory.NONE)
|
||||
#if NET48
|
||||
testData.Add(new object[] { systemCategory, true });
|
||||
#else
|
||||
testData.Add(new object?[] { systemCategory, true });
|
||||
#endif
|
||||
else
|
||||
#if NET48
|
||||
testData.Add(new object[] { systemCategory, false });
|
||||
#else
|
||||
testData.Add(new object?[] { systemCategory, false });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
@@ -861,24 +701,12 @@ namespace MPF.Test.RedumpLib
|
||||
/// Generate a test set of YesNo values
|
||||
/// </summary>
|
||||
/// <returns>MemberData-compatible list of YesNo values</returns>
|
||||
#if NET48
|
||||
public static List<object[]> GenerateYesNoTestData()
|
||||
#else
|
||||
public static List<object?[]> GenerateYesNoTestData()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
var testData = new List<object[]>() { new object[] { null, false } };
|
||||
#else
|
||||
var testData = new List<object?[]>() { new object?[] { null, false } };
|
||||
#endif
|
||||
foreach (YesNo? yesNo in Enum.GetValues(typeof(YesNo)))
|
||||
{
|
||||
#if NET48
|
||||
testData.Add(new object[] { yesNo, false });
|
||||
#else
|
||||
testData.Add(new object?[] { yesNo, false });
|
||||
#endif
|
||||
}
|
||||
|
||||
return testData;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using psxt001z;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
|
||||
@@ -82,20 +81,12 @@ namespace MPF.Test.RedumpLib
|
||||
EXEDateBuildDate = "19xx-xx-xx",
|
||||
ErrorsCount = "0",
|
||||
Comments = "Comment data line 1\r\nComment data line 2",
|
||||
#if NET48
|
||||
CommentsSpecialFields = new Dictionary<SiteCode?, string>()
|
||||
#else
|
||||
CommentsSpecialFields = new Dictionary<SiteCode, string>()
|
||||
#endif
|
||||
{
|
||||
[SiteCode.ISBN] = "ISBN",
|
||||
},
|
||||
Contents = "Special contents 1\r\nSpecial contents 2",
|
||||
#if NET48
|
||||
ContentsSpecialFields = new Dictionary<SiteCode?, string>()
|
||||
#else
|
||||
ContentsSpecialFields = new Dictionary<SiteCode, string>()
|
||||
#endif
|
||||
{
|
||||
[SiteCode.PlayableDemos] = "Game Demo 1",
|
||||
},
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Linq;
|
||||
using MPF.Core.Data;
|
||||
using MPF.Core.Data;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using Xunit;
|
||||
|
||||
@@ -16,7 +15,7 @@ namespace MPF.Test.Data
|
||||
public void GetAllowedDriveSpeedForMediaTypeTest(MediaType? mediaType, int maxExpected)
|
||||
{
|
||||
var actual = Interface.GetSpeedsForMediaType(mediaType);
|
||||
Assert.Equal(maxExpected, actual.Last());
|
||||
Assert.Equal(maxExpected, actual[actual.Count - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,12 @@ namespace MPF.UI.Core
|
||||
public static DoubleCollection SpeedsForDVDAsCollection { get; } = GetDoubleCollectionFromIntList(DVD);
|
||||
public static DoubleCollection SpeedsForHDDVDAsCollection { get; } = GetDoubleCollectionFromIntList(HDDVD);
|
||||
public static DoubleCollection SpeedsForBDAsCollection { get; } = GetDoubleCollectionFromIntList(BD);
|
||||
|
||||
#if NET20 || NET35 || NET40
|
||||
private static DoubleCollection GetDoubleCollectionFromIntList(IList<int> list)
|
||||
#else
|
||||
private static DoubleCollection GetDoubleCollectionFromIntList(IReadOnlyList<int> list)
|
||||
=> new DoubleCollection(list.Select(i => Convert.ToDouble(i)).ToList());
|
||||
#endif
|
||||
=> new(list.Select(i => Convert.ToDouble(i)).ToList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,54 +11,34 @@ namespace MPF.UI.Core
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
switch (value)
|
||||
return value switch
|
||||
{
|
||||
case DiscCategory discCategory:
|
||||
return new Element<DiscCategory>(discCategory);
|
||||
case InternalProgram internalProgram:
|
||||
return new Element<InternalProgram>(internalProgram);
|
||||
case MediaType mediaType:
|
||||
return new Element<MediaType>(mediaType);
|
||||
case RedumpSystem redumpSystem:
|
||||
return new RedumpSystemComboBoxItem(redumpSystem);
|
||||
case Region region:
|
||||
return new Element<Region>(region);
|
||||
DiscCategory discCategory => new Element<DiscCategory>(discCategory),
|
||||
InternalProgram internalProgram => new Element<InternalProgram>(internalProgram),
|
||||
MediaType mediaType => new Element<MediaType>(mediaType),
|
||||
RedumpSystem redumpSystem => new RedumpSystemComboBoxItem(redumpSystem),
|
||||
Region region => new Element<Region>(region),
|
||||
|
||||
// Null values are treated as a system value
|
||||
default:
|
||||
return new RedumpSystemComboBoxItem((RedumpSystem?)null);
|
||||
}
|
||||
_ => new RedumpSystemComboBoxItem((RedumpSystem?)null),
|
||||
};
|
||||
}
|
||||
|
||||
#if NET48
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
#else
|
||||
public object? ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
#endif
|
||||
{
|
||||
// If it's an IElement but ends up null
|
||||
#if NET48
|
||||
if (!(value is IElement element))
|
||||
#else
|
||||
if (value is not IElement element)
|
||||
#endif
|
||||
return null;
|
||||
|
||||
switch (element)
|
||||
return element switch
|
||||
{
|
||||
case Element<DiscCategory> dcElement:
|
||||
return dcElement.Value;
|
||||
case Element<InternalProgram> ipElement:
|
||||
return ipElement.Value;
|
||||
case Element<MediaType> mtElement:
|
||||
return mtElement.Value;
|
||||
case RedumpSystemComboBoxItem rsElement:
|
||||
return rsElement.Value;
|
||||
case Element<Region> reValue:
|
||||
return reValue.Value;
|
||||
|
||||
default: return null;
|
||||
}
|
||||
Element<DiscCategory> dcElement => dcElement.Value,
|
||||
Element<InternalProgram> ipElement => ipElement.Value,
|
||||
Element<MediaType> mtElement => mtElement.Value,
|
||||
RedumpSystemComboBoxItem rsElement => rsElement.Value,
|
||||
Element<Region> reValue => reValue.Value,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,11 +173,7 @@ namespace WPFCustomMessageBox
|
||||
/// </param>
|
||||
/// <param name="timeoutResult">If the message box closes automatically due to the <paramref name="timeout"/> being exceeded, this result is returned.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
#if NET48
|
||||
public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, int? timeout = null, MessageBoxResult timeoutResult = MessageBoxResult.None)
|
||||
#else
|
||||
public static MessageBoxResult Show(Window owner, string? messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, int? timeout = null, MessageBoxResult timeoutResult = MessageBoxResult.None)
|
||||
#endif
|
||||
{
|
||||
switch (button)
|
||||
{
|
||||
@@ -519,11 +515,7 @@ namespace WPFCustomMessageBox
|
||||
/// <param name="timeout">The message box will close automatically after given milliseconds</param>
|
||||
/// <param name="timeoutResult">If the message box closes automatically due to <paramref name="timeout"/> being exceeded, this result is returned.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
#if NET48
|
||||
private static MessageBoxResult ShowOKMessage(Window owner, string messageBoxText, string caption, string okButtonText, string cancelButtonText, MessageBoxImage? icon, int? timeout = null, MessageBoxResult timeoutResult = MessageBoxResult.None)
|
||||
#else
|
||||
private static MessageBoxResult ShowOKMessage(Window? owner, string? messageBoxText, string caption, string? okButtonText, string? cancelButtonText, MessageBoxImage? icon, int? timeout = null, MessageBoxResult timeoutResult = MessageBoxResult.None)
|
||||
#endif
|
||||
{
|
||||
MessageBoxButton buttonLayout = string.IsNullOrEmpty(cancelButtonText) ? MessageBoxButton.OK : MessageBoxButton.OKCancel;
|
||||
|
||||
@@ -553,11 +545,7 @@ namespace WPFCustomMessageBox
|
||||
/// <param name="timeout">The message box will close automatically after given milliseconds</param>
|
||||
/// <param name="timeoutResult">If the message box closes automatically due to <paramref name="timeout"/> being exceeded, this result is returned.</param>
|
||||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
#if NET48
|
||||
private static MessageBoxResult ShowYesNoMessage(Window owner, string messageBoxText, string caption, string yesButtonText, string noButtonText, string cancelButtonText, MessageBoxImage? icon, int? timeout = null, MessageBoxResult timeoutResult = MessageBoxResult.None)
|
||||
#else
|
||||
private static MessageBoxResult ShowYesNoMessage(Window? owner, string? messageBoxText, string caption, string? yesButtonText, string? noButtonText, string? cancelButtonText, MessageBoxImage? icon, int? timeout = null, MessageBoxResult timeoutResult = MessageBoxResult.None)
|
||||
#endif
|
||||
{
|
||||
MessageBoxButton buttonLayout = string.IsNullOrEmpty(cancelButtonText) ? MessageBoxButton.YesNo : MessageBoxButton.YesNoCancel;
|
||||
|
||||
|
||||
@@ -5,14 +5,9 @@
|
||||
WindowStartupLocation="CenterScreen"
|
||||
WindowStyle="None"
|
||||
ResizeMode="NoResize" SizeToContent="WidthAndHeight"
|
||||
TextOptions.TextFormattingMode="Display" TextOptions.TextRenderingMode="ClearType" UseLayoutRounding="True"
|
||||
Title="" MinHeight="155" MaxWidth="470" MinWidth="154"
|
||||
BorderBrush="DarkGray" BorderThickness="2">
|
||||
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" ResizeBorderThickness="0" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using MPF.UI.Core;
|
||||
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
namespace WPFCustomMessageBox
|
||||
{
|
||||
@@ -12,11 +16,7 @@ namespace WPFCustomMessageBox
|
||||
{
|
||||
private readonly bool _removeTitleBarIcon = true;
|
||||
|
||||
#if NET48
|
||||
public string Caption
|
||||
#else
|
||||
public string? Caption
|
||||
#endif
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -28,102 +28,150 @@ namespace WPFCustomMessageBox
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
public string Message
|
||||
#else
|
||||
public string? Message
|
||||
#endif
|
||||
{
|
||||
get
|
||||
{
|
||||
#if NET35
|
||||
return _TextBlock_Message!.Text;
|
||||
#else
|
||||
return TextBlock_Message.Text;
|
||||
#endif
|
||||
}
|
||||
set
|
||||
{
|
||||
#if NET35
|
||||
_TextBlock_Message!.Text = value;
|
||||
#else
|
||||
TextBlock_Message.Text = value;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
public string OkButtonText
|
||||
#else
|
||||
public string? OkButtonText
|
||||
#endif
|
||||
{
|
||||
get
|
||||
{
|
||||
#if NET35
|
||||
return _Label_Ok!.Content.ToString();
|
||||
#else
|
||||
return Label_Ok.Content.ToString();
|
||||
#endif
|
||||
}
|
||||
set
|
||||
{
|
||||
#if NET35
|
||||
_Label_Ok!.Content = value.TryAddKeyboardAccellerator();
|
||||
#else
|
||||
Label_Ok.Content = value.TryAddKeyboardAccellerator();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
public string CancelButtonText
|
||||
#else
|
||||
public string? CancelButtonText
|
||||
#endif
|
||||
{
|
||||
get
|
||||
{
|
||||
#if NET35
|
||||
return _Label_Cancel!.Content.ToString();
|
||||
#else
|
||||
return Label_Cancel.Content.ToString();
|
||||
#endif
|
||||
}
|
||||
set
|
||||
{
|
||||
#if NET35
|
||||
_Label_Cancel!.Content = value.TryAddKeyboardAccellerator();
|
||||
#else
|
||||
Label_Cancel.Content = value.TryAddKeyboardAccellerator();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
public string YesButtonText
|
||||
#else
|
||||
public string? YesButtonText
|
||||
#endif
|
||||
{
|
||||
get
|
||||
{
|
||||
#if NET35
|
||||
return _Label_Yes!.Content.ToString();
|
||||
#else
|
||||
return Label_Yes.Content.ToString();
|
||||
#endif
|
||||
}
|
||||
set
|
||||
{
|
||||
#if NET35
|
||||
_Label_Yes!.Content = value.TryAddKeyboardAccellerator();
|
||||
#else
|
||||
Label_Yes.Content = value.TryAddKeyboardAccellerator();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if NET48
|
||||
public string NoButtonText
|
||||
#else
|
||||
public string? NoButtonText
|
||||
#endif
|
||||
{
|
||||
get
|
||||
{
|
||||
#if NET35
|
||||
return _Label_No!.Content.ToString();
|
||||
#else
|
||||
return Label_No.Content.ToString();
|
||||
#endif
|
||||
}
|
||||
set
|
||||
{
|
||||
#if NET35
|
||||
_Label_No!.Content = value.TryAddKeyboardAccellerator();
|
||||
#else
|
||||
Label_No.Content = value.TryAddKeyboardAccellerator();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public MessageBoxResult Result { get; set; }
|
||||
|
||||
#if NET48
|
||||
internal CustomMessageBoxWindow(Window owner, string message, string caption = null, MessageBoxButton? button = null, MessageBoxImage? image = null, bool removeTitleBarIcon = true)
|
||||
#else
|
||||
internal CustomMessageBoxWindow(Window? owner, string? message, string? caption = null, MessageBoxButton? button = null, MessageBoxImage? image = null, bool removeTitleBarIcon = true)
|
||||
#if NET35
|
||||
|
||||
private Button? _Button_Cancel => ItemHelper.FindChild<Button>(this, "Button_Cancel");
|
||||
private Button? _Button_No => ItemHelper.FindChild<Button>(this, "Button_No");
|
||||
private Button? _Button_OK => ItemHelper.FindChild<Button>(this, "Button_OK");
|
||||
private Button? _Button_Yes => ItemHelper.FindChild<Button>(this, "Button_Yes");
|
||||
private System.Windows.Controls.Image? _Image_MessageBox => ItemHelper.FindChild<System.Windows.Controls.Image>(this, "Image_MessageBox");
|
||||
private Label? _Label_Cancel => ItemHelper.FindChild<Label>(this, "Label_Cancel");
|
||||
private Label? _Label_No => ItemHelper.FindChild<Label>(this, "Label_No");
|
||||
private Label? _Label_Ok => ItemHelper.FindChild<Label>(this, "Label_Ok");
|
||||
private Label? _Label_Yes => ItemHelper.FindChild<Label>(this, "Label_Yes");
|
||||
private TextBlock? _TextBlock_Message => ItemHelper.FindChild<TextBlock>(this, "TextBlock_Message");
|
||||
|
||||
#endif
|
||||
|
||||
internal CustomMessageBoxWindow(Window? owner, string? message, string? caption = null, MessageBoxButton? button = null, MessageBoxImage? image = null, bool removeTitleBarIcon = true)
|
||||
{
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
System.Windows.Media.TextOptions.SetTextFormattingMode(this, System.Windows.Media.TextFormattingMode.Display);
|
||||
System.Windows.Media.TextOptions.SetTextRenderingMode(this, System.Windows.Media.TextRenderingMode.ClearType);
|
||||
UseLayoutRounding = true;
|
||||
#endif
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
var chrome = new System.Windows.Shell.WindowChrome
|
||||
{
|
||||
CaptionHeight = 0,
|
||||
ResizeBorderThickness = new Thickness(0),
|
||||
};
|
||||
System.Windows.Shell.WindowChrome.SetWindowChrome(this, chrome);
|
||||
#endif
|
||||
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
InitializeComponent();
|
||||
#endif
|
||||
|
||||
_removeTitleBarIcon = removeTitleBarIcon;
|
||||
Focusable = true;
|
||||
ShowActivated = true;
|
||||
ShowInTaskbar = true;
|
||||
|
||||
if (owner != null)
|
||||
if (owner != null && owner.IsLoaded)
|
||||
{
|
||||
Owner = owner;
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
@@ -137,7 +185,11 @@ namespace WPFCustomMessageBox
|
||||
if (image.HasValue)
|
||||
DisplayImage(image.Value);
|
||||
else
|
||||
#if NET35
|
||||
_Image_MessageBox!.Visibility = Visibility.Collapsed;
|
||||
#else
|
||||
Image_MessageBox.Visibility = Visibility.Collapsed;
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
@@ -154,39 +206,75 @@ namespace WPFCustomMessageBox
|
||||
{
|
||||
case MessageBoxButton.OKCancel:
|
||||
// Hide all but OK, Cancel
|
||||
#if NET35
|
||||
_Button_OK!.Visibility = Visibility.Visible;
|
||||
_Button_OK.Focus();
|
||||
_Button_Cancel!.Visibility = Visibility.Visible;
|
||||
|
||||
_Button_Yes!.Visibility = Visibility.Collapsed;
|
||||
_Button_No!.Visibility = Visibility.Collapsed;
|
||||
#else
|
||||
Button_OK.Visibility = Visibility.Visible;
|
||||
Button_OK.Focus();
|
||||
Button_Cancel.Visibility = Visibility.Visible;
|
||||
|
||||
Button_Yes.Visibility = Visibility.Collapsed;
|
||||
Button_No.Visibility = Visibility.Collapsed;
|
||||
#endif
|
||||
break;
|
||||
case MessageBoxButton.YesNo:
|
||||
// Hide all but Yes, No
|
||||
#if NET35
|
||||
_Button_Yes!.Visibility = Visibility.Visible;
|
||||
_Button_Yes.Focus();
|
||||
_Button_No!.Visibility = Visibility.Visible;
|
||||
|
||||
_Button_OK!.Visibility = Visibility.Collapsed;
|
||||
_Button_Cancel!.Visibility = Visibility.Collapsed;
|
||||
#else
|
||||
Button_Yes.Visibility = Visibility.Visible;
|
||||
Button_Yes.Focus();
|
||||
Button_No.Visibility = Visibility.Visible;
|
||||
|
||||
Button_OK.Visibility = Visibility.Collapsed;
|
||||
Button_Cancel.Visibility = Visibility.Collapsed;
|
||||
#endif
|
||||
break;
|
||||
case MessageBoxButton.YesNoCancel:
|
||||
// Hide only OK
|
||||
#if NET35
|
||||
_Button_Yes!.Visibility = Visibility.Visible;
|
||||
_Button_Yes.Focus();
|
||||
_Button_No!.Visibility = Visibility.Visible;
|
||||
_Button_Cancel!.Visibility = Visibility.Visible;
|
||||
|
||||
_Button_OK!.Visibility = Visibility.Collapsed;
|
||||
#else
|
||||
Button_Yes.Visibility = Visibility.Visible;
|
||||
Button_Yes.Focus();
|
||||
Button_No.Visibility = Visibility.Visible;
|
||||
Button_Cancel.Visibility = Visibility.Visible;
|
||||
|
||||
Button_OK.Visibility = Visibility.Collapsed;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
// Hide all but OK
|
||||
#if NET35
|
||||
_Button_OK!.Visibility = Visibility.Visible;
|
||||
_Button_OK.Focus();
|
||||
|
||||
_Button_Yes!.Visibility = Visibility.Collapsed;
|
||||
_Button_No!.Visibility = Visibility.Collapsed;
|
||||
_Button_Cancel!.Visibility = Visibility.Collapsed;
|
||||
#else
|
||||
Button_OK.Visibility = Visibility.Visible;
|
||||
Button_OK.Focus();
|
||||
|
||||
Button_Yes.Visibility = Visibility.Collapsed;
|
||||
Button_No.Visibility = Visibility.Collapsed;
|
||||
Button_Cancel.Visibility = Visibility.Collapsed;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -214,8 +302,13 @@ namespace WPFCustomMessageBox
|
||||
break;
|
||||
}
|
||||
|
||||
#if NET35
|
||||
_Image_MessageBox!.Source = icon.ToImageSource();
|
||||
_Image_MessageBox.Visibility = Visibility.Visible;
|
||||
#else
|
||||
Image_MessageBox.Source = icon.ToImageSource();
|
||||
Image_MessageBox.Visibility = Visibility.Visible;
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Button_OK_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -60,11 +60,7 @@ namespace WPFCustomMessageBox
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
#if NET48
|
||||
internal static string TryAddKeyboardAccellerator(this string input)
|
||||
#else
|
||||
internal static string? TryAddKeyboardAccellerator(this string? input)
|
||||
#endif
|
||||
{
|
||||
if (input == null)
|
||||
return input;
|
||||
|
||||
124
MPF.UI.Core/ItemHelper.cs
Normal file
124
MPF.UI.Core/ItemHelper.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows;
|
||||
|
||||
namespace MPF.UI.Core
|
||||
{
|
||||
internal static class ItemHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Finds a Child of a given item in the visual tree.
|
||||
/// </summary>
|
||||
/// <param name="parent">A direct parent of the queried item.</param>
|
||||
/// <typeparam name="T">The type of the queried item.</typeparam>
|
||||
/// <param name="childName">x:Name or Name of child. </param>
|
||||
/// <returns>The first parent item that matches the submitted type parameter.
|
||||
/// If not matching item can be found,
|
||||
/// a null parent is being returned.</returns>
|
||||
public static T? FindChild<T>(DependencyObject? parent, string childName) where T : DependencyObject
|
||||
{
|
||||
// Confirm parent and childName are valid.
|
||||
if (parent == null) return null;
|
||||
|
||||
T? foundChild = null;
|
||||
|
||||
if (parent is ItemsControl itemsControl && itemsControl.Items != null)
|
||||
{
|
||||
int childrenCount = itemsControl.Items.Count;
|
||||
for (int i = 0; i < childrenCount; i++)
|
||||
{
|
||||
var child = itemsControl.Items[i] as DependencyObject;
|
||||
|
||||
// If the child is not of the request child type child
|
||||
if (child is not T)
|
||||
{
|
||||
// recursively drill down the tree
|
||||
foundChild = FindChild<T>(child, childName);
|
||||
|
||||
// If the child is found, break so we do not overwrite the found child.
|
||||
if (foundChild != null)
|
||||
break;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(childName))
|
||||
{
|
||||
// If the child's name is set for search
|
||||
if (child is FrameworkElement frameworkElement && frameworkElement.Name == childName)
|
||||
{
|
||||
// if the child's name is of the request name
|
||||
foundChild = (T)child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// child element found.
|
||||
foundChild = (T)child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parent is ContentControl contentControl && contentControl.Content != null)
|
||||
{
|
||||
var child = contentControl.Content as DependencyObject;
|
||||
|
||||
// If the child is not of the request child type child
|
||||
if (child is not T)
|
||||
{
|
||||
// recursively drill down the tree
|
||||
foundChild = FindChild<T>(child, childName);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(childName))
|
||||
{
|
||||
// If the child's name is set for search
|
||||
if (child is FrameworkElement frameworkElement && frameworkElement.Name == childName)
|
||||
{
|
||||
// if the child's name is of the request name
|
||||
foundChild = (T)child;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// child element found.
|
||||
foundChild = (T)child;
|
||||
}
|
||||
}
|
||||
else if (parent is Visual)
|
||||
{
|
||||
int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
|
||||
for (int i = 0; i < childrenCount; i++)
|
||||
{
|
||||
var child = VisualTreeHelper.GetChild(parent, i);
|
||||
|
||||
// If the child is not of the request child type child
|
||||
if (child is not T)
|
||||
{
|
||||
// recursively drill down the tree
|
||||
foundChild = FindChild<T>(child, childName);
|
||||
|
||||
// If the child is found, break so we do not overwrite the found child.
|
||||
if (foundChild != null)
|
||||
break;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(childName))
|
||||
{
|
||||
// If the child's name is set for search
|
||||
if (child is FrameworkElement frameworkElement && frameworkElement.Name == childName)
|
||||
{
|
||||
// if the child's name is of the request name
|
||||
foundChild = (T)child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// child element found.
|
||||
foundChild = (T)child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return foundChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net48;net6.0-windows;net7.0-windows</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
|
||||
<!-- Assembly Properties -->
|
||||
<TargetFrameworks>net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<ImportFrameworkWinFXTargets Condition="$(TargetFramework.StartsWith(`net3`))">true</ImportFrameworkWinFXTargets>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<VersionPrefix>3.0.3</VersionPrefix>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
|
||||
<Copyright>Copyright (c)2019-2023</Copyright>
|
||||
<VersionPrefix>2.7.1</VersionPrefix>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">
|
||||
<Nullable>enable</Nullable>
|
||||
<!-- Package Properties -->
|
||||
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
|
||||
<Description>Common code for all MPF UI implementations</Description>
|
||||
<Copyright>Copyright (c) Matt Nadareski 2019-2023</Copyright>
|
||||
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/SabreTools/MPF</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -23,12 +32,16 @@
|
||||
<ProjectReference Include="..\MPF.Core\MPF.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)'=='net48'">
|
||||
<Reference Include="PresentationFramework.Aero" />
|
||||
<!-- Support for old .NET versions -->
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net3`))">
|
||||
<Reference Include="PresentationBuildTasks" HintPath="$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\v3.0\PresentationBuildTasks.dll" />
|
||||
<Reference Include="PresentationCore" HintPath="$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll" />
|
||||
<Reference Include="PresentationFramework" HintPath="$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" />
|
||||
<Reference Include="WindowsBase" HintPath="$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.1.1" />
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -13,56 +13,32 @@ namespace MPF.UI.Core
|
||||
/// <summary>
|
||||
/// SolidColorBrush used to paint the active window's border.
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public SolidColorBrush ActiveBorderBrush { get; protected set; }
|
||||
#else
|
||||
public SolidColorBrush? ActiveBorderBrush { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// SolidColorBrush that paints the face of a three-dimensional display element.
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public SolidColorBrush ControlBrush { get; protected set; }
|
||||
#else
|
||||
public SolidColorBrush? ControlBrush { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// SolidColorBrush that paints text in a three-dimensional display element.
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public SolidColorBrush ControlTextBrush { get; protected set; }
|
||||
#else
|
||||
public SolidColorBrush? ControlTextBrush { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// SolidColorBrush that paints disabled text.
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public SolidColorBrush GrayTextBrush { get; protected set; }
|
||||
#else
|
||||
public SolidColorBrush? GrayTextBrush { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// SolidColorBrush that paints the background of a window's client area.
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public SolidColorBrush WindowBrush { get; protected set; }
|
||||
#else
|
||||
public SolidColorBrush? WindowBrush { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// SolidColorBrush that paints the text in the client area of a window.
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public SolidColorBrush WindowTextBrush { get; protected set; }
|
||||
#else
|
||||
public SolidColorBrush? WindowTextBrush { get; protected set; }
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -71,38 +47,22 @@ namespace MPF.UI.Core
|
||||
/// <summary>
|
||||
/// Brush for the Button.Disabled.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush Button_Disabled_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? Button_Disabled_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the Button.MouseOver.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush Button_MouseOver_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? Button_MouseOver_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the Button.Pressed.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush Button_Pressed_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? Button_Pressed_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the Button.Static.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush Button_Static_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? Button_Static_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -111,110 +71,62 @@ namespace MPF.UI.Core
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.Disabled.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_Disabled_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_Disabled_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.Disabled.Editable.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_Disabled_Editable_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_Disabled_Editable_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.Disabled.Editable.Button.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_Disabled_Editable_Button_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_Disabled_Editable_Button_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.MouseOver.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_MouseOver_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_MouseOver_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.MouseOver.Editable.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_MouseOver_Editable_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_MouseOver_Editable_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.MouseOver.Editable.Button.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_MouseOver_Editable_Button_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_MouseOver_Editable_Button_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.Pressed.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_Pressed_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_Pressed_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.Pressed.Editable.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_Pressed_Editable_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_Pressed_Editable_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.Pressed.Editable.Button.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_Pressed_Editable_Button_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_Pressed_Editable_Button_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.Static.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_Static_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_Static_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.Static.Editable.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_Static_Editable_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_Static_Editable_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the ComboBox.Static.Editable.Button.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ComboBox_Static_Editable_Button_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ComboBox_Static_Editable_Button_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -223,11 +135,7 @@ namespace MPF.UI.Core
|
||||
/// <summary>
|
||||
/// Brush for the CustomMessageBox.Static.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush CustomMessageBox_Static_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? CustomMessageBox_Static_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -236,20 +144,12 @@ namespace MPF.UI.Core
|
||||
/// <summary>
|
||||
/// Brush for the MenuItem.SubMenu.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush MenuItem_SubMenu_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? MenuItem_SubMenu_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the MenuItem.SubMenu.Border resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush MenuItem_SubMenu_Border { get; protected set; }
|
||||
#else
|
||||
public Brush? MenuItem_SubMenu_Border { get; protected set; }
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -258,11 +158,7 @@ namespace MPF.UI.Core
|
||||
/// <summary>
|
||||
/// Brush for the ProgressBar.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ProgressBar_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ProgressBar_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -271,11 +167,7 @@ namespace MPF.UI.Core
|
||||
/// <summary>
|
||||
/// Brush for the ScrollViewer.ScrollBar.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush ScrollViewer_ScrollBar_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? ScrollViewer_ScrollBar_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -284,29 +176,17 @@ namespace MPF.UI.Core
|
||||
/// <summary>
|
||||
/// Brush for the TabItem.Selected.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush TabItem_Selected_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? TabItem_Selected_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the TabItem.Static.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush TabItem_Static_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? TabItem_Static_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Brush for the TabItem.Static.Border resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush TabItem_Static_Border { get; protected set; }
|
||||
#else
|
||||
public Brush? TabItem_Static_Border { get; protected set; }
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -315,11 +195,7 @@ namespace MPF.UI.Core
|
||||
/// <summary>
|
||||
/// Brush for the TextBox.Static.Background resource
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public Brush TextBox_Static_Background { get; protected set; }
|
||||
#else
|
||||
public Brush? TextBox_Static_Background { get; protected set; }
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using MPF.Core.Data;
|
||||
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
namespace MPF.UI.Core.UserControls
|
||||
{
|
||||
public partial class LogOutput : UserControl
|
||||
@@ -29,15 +31,22 @@ namespace MPF.UI.Core.UserControls
|
||||
/// <summary>
|
||||
/// Cached value of the last line written
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private Run lastLine = null;
|
||||
#else
|
||||
private Run? lastLine = null;
|
||||
|
||||
#if NET35
|
||||
|
||||
private Button? _ClearButton => ItemHelper.FindChild<Button>(this, "ClearButton");
|
||||
private RichTextBox? _Output => ItemHelper.FindChild<RichTextBox>(this, "Output");
|
||||
private ScrollViewer? _OutputViewer => ItemHelper.FindChild<ScrollViewer>(this, "OutputViewer");
|
||||
private Button? _SaveButton => ItemHelper.FindChild<Button>(this, "SaveButton");
|
||||
|
||||
#endif
|
||||
|
||||
public LogOutput()
|
||||
{
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
InitializeComponent();
|
||||
#endif
|
||||
|
||||
// Update the internal state
|
||||
Document = new FlowDocument()
|
||||
@@ -51,13 +60,24 @@ namespace MPF.UI.Core.UserControls
|
||||
LogQueue = new ProcessingQueue<LogLine>(ProcessLogLine);
|
||||
|
||||
// Add handlers
|
||||
#if NET35
|
||||
_OutputViewer!.SizeChanged += OutputViewerSizeChanged;
|
||||
_Output!.TextChanged += OnTextChanged;
|
||||
_ClearButton!.Click += OnClearButton;
|
||||
_SaveButton!.Click += OnSaveButton;
|
||||
#else
|
||||
OutputViewer.SizeChanged += OutputViewerSizeChanged;
|
||||
Output.TextChanged += OnTextChanged;
|
||||
ClearButton.Click += OnClearButton;
|
||||
SaveButton.Click += OnSaveButton;
|
||||
#endif
|
||||
|
||||
// Update the internal state
|
||||
#if NET35
|
||||
_Output.Document = Document;
|
||||
#else
|
||||
Output.Document = Document;
|
||||
#endif
|
||||
}
|
||||
|
||||
#region Logging
|
||||
@@ -97,18 +117,13 @@ namespace MPF.UI.Core.UserControls
|
||||
/// <returns>Brush representing the color</returns>
|
||||
public Brush GetForegroundColor()
|
||||
{
|
||||
switch (this.LogLevel)
|
||||
return this.LogLevel switch
|
||||
{
|
||||
case LogLevel.SECRET:
|
||||
return Brushes.Blue;
|
||||
case LogLevel.ERROR:
|
||||
return Brushes.Red;
|
||||
case LogLevel.VERBOSE:
|
||||
return Brushes.Yellow;
|
||||
case LogLevel.USER:
|
||||
default:
|
||||
return Brushes.White;
|
||||
}
|
||||
LogLevel.SECRET => Brushes.Blue,
|
||||
LogLevel.ERROR => Brushes.Red,
|
||||
LogLevel.VERBOSE => Brushes.Yellow,
|
||||
_ => Brushes.White,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -168,17 +183,13 @@ namespace MPF.UI.Core.UserControls
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
#if NET48
|
||||
if (lastLine == null) lastLine = new Run();
|
||||
#else
|
||||
lastLine ??= new Run();
|
||||
#endif
|
||||
lastLine.Text = logLine.Text;
|
||||
lastLine.Foreground = logLine.GetForegroundColor();
|
||||
});
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
|
||||
@@ -192,20 +203,22 @@ namespace MPF.UI.Core.UserControls
|
||||
/// </summary>
|
||||
private void SaveInlines()
|
||||
{
|
||||
using (var sw = new StreamWriter(File.OpenWrite("console.log")))
|
||||
using var sw = new StreamWriter(File.OpenWrite("console.log"));
|
||||
foreach (var inline in _paragraph.Inlines)
|
||||
{
|
||||
foreach (var inline in _paragraph.Inlines)
|
||||
{
|
||||
if (inline is Run run)
|
||||
sw.Write(run.Text);
|
||||
}
|
||||
if (inline is Run run)
|
||||
sw.Write(run.Text);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scroll the current view to the bottom
|
||||
/// </summary>
|
||||
#if NET35
|
||||
public void ScrollToBottom() => _OutputViewer!.ScrollToBottom();
|
||||
#else
|
||||
public void ScrollToBottom() => OutputViewer.ScrollToBottom();
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace MPF.UI.Core.UserControls
|
||||
|
||||
public static readonly DependencyProperty VerticalScrollBarVisibilityProperty =
|
||||
DependencyProperty.Register("VerticalScrollBarVisibility", typeof(ScrollBarVisibility), typeof(UserInput));
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
@@ -118,7 +118,9 @@ namespace MPF.UI.Core.UserControls
|
||||
HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
|
||||
VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
|
||||
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
InitializeComponent();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,7 @@
|
||||
<Window.Resources>
|
||||
<core:ElementConverter x:Key="ElementConverter" />
|
||||
</Window.Resources>
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" ResizeBorderThickness="0" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
|
||||
<Grid>
|
||||
<StackPanel Orientation="Vertical" Width="500" MaxHeight="650">
|
||||
<Grid Margin="0,10,0,0">
|
||||
@@ -34,7 +31,7 @@
|
||||
<Image Grid.Column="0" Source="/Images/Icon.ico" Height="20" Width="20" Margin="1" />
|
||||
<Label Grid.Column="1" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" MouseDown="TitleMouseDown">
|
||||
<Label.Content>
|
||||
<TextBlock TextAlignment="Center"><Bold>Disc Information</Bold></TextBlock>
|
||||
<Run FontWeight="Bold" Text="Disc Information" />
|
||||
</Label.Content>
|
||||
<Label.ContextMenu>
|
||||
<ContextMenu Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
|
||||
@@ -175,6 +172,10 @@
|
||||
<controls:UserInput x:Name="CommentsTextBox" Label="Comments"
|
||||
Text="{Binding SubmissionInfo.CommonDiscInfo.Comments, Mode=TwoWay}" TextHeight="50"
|
||||
Enter="True" TextWrapping="Wrap" VerticalContentAlignmentValue="Top" />
|
||||
<controls:UserInput x:Name="DiscKeyTextBox" Label="Disc Key" Visibility="Collapsed"
|
||||
Text="{Binding Path=SubmissionInfo.Extras.DiscKey, Mode=TwoWay}"/>
|
||||
<controls:UserInput x:Name="DiscIDTextBox" Label="Disc ID" Visibility="Collapsed"
|
||||
Text="{Binding Path=SubmissionInfo.Extras.DiscID, Mode=TwoWay}"/>
|
||||
<controls:UserInput x:Name="GenreTextBox" Label="Genre"
|
||||
Text="{Binding Path=SubmissionInfo.CommonDiscInfo.CommentsSpecialFields[(redump:SiteCode)Genre], Mode=TwoWay}"/>
|
||||
<controls:UserInput x:Name="ProtectionTextBox" Label="Protection" ToolTip="CAUTION: Only edit if you know what you are doing!"
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using MPF.Core.Data;
|
||||
using MPF.Core.UI.ViewModels;
|
||||
using MPF.Core.Utilities;
|
||||
using MPF.UI.Core.UserControls;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
namespace MPF.UI.Core.Windows
|
||||
{
|
||||
/// <summary>
|
||||
@@ -12,6 +16,105 @@ namespace MPF.UI.Core.Windows
|
||||
/// </summary>
|
||||
public partial class DiscInformationWindow : WindowBase
|
||||
{
|
||||
#if NET35
|
||||
|
||||
#region Common Info
|
||||
|
||||
private Grid? _LanguageSelectionGrid => ItemHelper.FindChild<Grid>(this, "LanguageSelectionGrid");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Additional Info
|
||||
|
||||
private UserInput? _CommentsTextBox => ItemHelper.FindChild<UserInput>(this, "CommentsTextBox");
|
||||
private UserInput? _DiscIDTextBox => ItemHelper.FindChild<UserInput>(this, "DiscIDTextBox");
|
||||
private UserInput? _DiscKeyTextBox => ItemHelper.FindChild<UserInput>(this, "DiscKeyTextBox");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Contents
|
||||
|
||||
private UserInput? _ExtrasTextBox => ItemHelper.FindChild<UserInput>(this, "ExtrasTextBox");
|
||||
private UserInput? _GameFootageTextBox => ItemHelper.FindChild<UserInput>(this, "GameFootageTextBox");
|
||||
private UserInput? _GamesTextBox => ItemHelper.FindChild<UserInput>(this, "GamesTextBox");
|
||||
private UserInput? _GeneralContent => ItemHelper.FindChild<UserInput>(this, "GeneralContent");
|
||||
private UserInput? _NetYarozeGamesTextBox => ItemHelper.FindChild<UserInput>(this, "NetYarozeGamesTextBox");
|
||||
private UserInput? _PatchesTextBox => ItemHelper.FindChild<UserInput>(this, "PatchesTextBox");
|
||||
private UserInput? _PlayableDemosTextBox => ItemHelper.FindChild<UserInput>(this, "PlayableDemosTextBox");
|
||||
private UserInput? _RollingDemosTextBox => ItemHelper.FindChild<UserInput>(this, "RollingDemosTextBox");
|
||||
private UserInput? _SavegamesTextBox => ItemHelper.FindChild<UserInput>(this, "SavegamesTextBox");
|
||||
private UserInput? _TechDemosTextBox => ItemHelper.FindChild<UserInput>(this, "TechDemosTextBox");
|
||||
private UserInput? _VideosTextBox => ItemHelper.FindChild<UserInput>(this, "VideosTextBox");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Ringcodes
|
||||
|
||||
private GroupBox? _L0Info => ItemHelper.FindChild<GroupBox>(this, "L0Info");
|
||||
private UserInput? _L0MasteringRing => ItemHelper.FindChild<UserInput>(this, "L0MasteringRing");
|
||||
private UserInput? _L0MasteringSID => ItemHelper.FindChild<UserInput>(this, "L0MasteringSID");
|
||||
private UserInput? _L0Toolstamp => ItemHelper.FindChild<UserInput>(this, "L0Toolstamp");
|
||||
private UserInput? _L0MouldSID => ItemHelper.FindChild<UserInput>(this, "L0MouldSID");
|
||||
private UserInput? _L0AdditionalMould => ItemHelper.FindChild<UserInput>(this, "L0AdditionalMould");
|
||||
private GroupBox? _L1Info => ItemHelper.FindChild<GroupBox>(this, "L1Info");
|
||||
private UserInput? _L1MasteringRing => ItemHelper.FindChild<UserInput>(this, "L1MasteringRing");
|
||||
private UserInput? _L1MasteringSID => ItemHelper.FindChild<UserInput>(this, "L1MasteringSID");
|
||||
private UserInput? _L1Toolstamp => ItemHelper.FindChild<UserInput>(this, "L1Toolstamp");
|
||||
private UserInput? _L1MouldSID => ItemHelper.FindChild<UserInput>(this, "L1MouldSID");
|
||||
private UserInput? _L1AdditionalMould => ItemHelper.FindChild<UserInput>(this, "L1AdditionalMould");
|
||||
private GroupBox? _L2Info => ItemHelper.FindChild<GroupBox>(this, "L2Info");
|
||||
private UserInput? _L2MasteringRing => ItemHelper.FindChild<UserInput>(this, "L2MasteringRing");
|
||||
private UserInput? _L2MasteringSID => ItemHelper.FindChild<UserInput>(this, "L2MasteringSID");
|
||||
private UserInput? _L2Toolstamp => ItemHelper.FindChild<UserInput>(this, "L2Toolstamp");
|
||||
private GroupBox? _L3Info => ItemHelper.FindChild<GroupBox>(this, "L3Info");
|
||||
private UserInput? _L3MasteringRing => ItemHelper.FindChild<UserInput>(this, "L3MasteringRing");
|
||||
private UserInput? _L3MasteringSID => ItemHelper.FindChild<UserInput>(this, "L3MasteringSID");
|
||||
private UserInput? _L3Toolstamp => ItemHelper.FindChild<UserInput>(this, "L3Toolstamp");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read-Only Info
|
||||
|
||||
private UserInput? _FullyMatchedID => ItemHelper.FindChild<UserInput>(this, "FullyMatchedID");
|
||||
private UserInput? _PartiallyMatchedIDs => ItemHelper.FindChild<UserInput>(this, "PartiallyMatchedIDs");
|
||||
private UserInput? _AntiModchip => ItemHelper.FindChild<UserInput>(this, "AntiModchip");
|
||||
private UserInput? _DiscOffset => ItemHelper.FindChild<UserInput>(this, "DiscOffset");
|
||||
private UserInput? _DMIHash => ItemHelper.FindChild<UserInput>(this, "DMIHash");
|
||||
private UserInput? _EDC => ItemHelper.FindChild<UserInput>(this, "EDC");
|
||||
private UserInput? _ErrorsCount => ItemHelper.FindChild<UserInput>(this, "ErrorsCount");
|
||||
private UserInput? _EXEDateBuildDate => ItemHelper.FindChild<UserInput>(this, "EXEDateBuildDate");
|
||||
private UserInput? _Filename => ItemHelper.FindChild<UserInput>(this, "Filename");
|
||||
private UserInput? _Header => ItemHelper.FindChild<UserInput>(this, "Header");
|
||||
private UserInput? _InternalName => ItemHelper.FindChild<UserInput>(this, "InternalName");
|
||||
private UserInput? _InternalSerialName => ItemHelper.FindChild<UserInput>(this, "InternalSerialName");
|
||||
private UserInput? _Multisession => ItemHelper.FindChild<UserInput>(this, "Multisession");
|
||||
private UserInput? _LibCrypt => ItemHelper.FindChild<UserInput>(this, "LibCrypt");
|
||||
private UserInput? _LibCryptData => ItemHelper.FindChild<UserInput>(this, "LibCryptData");
|
||||
private UserInput? _PFIHash => ItemHelper.FindChild<UserInput>(this, "PFIHash");
|
||||
private UserInput? _PIC => ItemHelper.FindChild<UserInput>(this, "PIC");
|
||||
private UserInput? _PVD => ItemHelper.FindChild<UserInput>(this, "PVD");
|
||||
private UserInput? _RingNonZeroDataStart => ItemHelper.FindChild<UserInput>(this, "RingNonZeroDataStart");
|
||||
private UserInput? _SecuROMData => ItemHelper.FindChild<UserInput>(this, "SecuROMData");
|
||||
private UserInput? _SSHash => ItemHelper.FindChild<UserInput>(this, "SSHash");
|
||||
private UserInput? _SecuritySectorRanges => ItemHelper.FindChild<UserInput>(this, "SecuritySectorRanges");
|
||||
private UserInput? _SSVersion => ItemHelper.FindChild<UserInput>(this, "SSVersion");
|
||||
private UserInput? _UniversalHash => ItemHelper.FindChild<UserInput>(this, "UniversalHash");
|
||||
private UserInput? _VolumeLabel => ItemHelper.FindChild<UserInput>(this, "VolumeLabel");
|
||||
private UserInput? _XeMID => ItemHelper.FindChild<UserInput>(this, "XeMID");
|
||||
private UserInput? _XMID => ItemHelper.FindChild<UserInput>(this, "XMID");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accept / Cancel
|
||||
|
||||
private Button? _AcceptButton => ItemHelper.FindChild<Button>(this, "AcceptButton");
|
||||
private Button? _CancelButton => ItemHelper.FindChild<Button>(this, "CancelButton");
|
||||
private Button? _RingCodeGuideButton => ItemHelper.FindChild<Button>(this, "RingCodeGuideButton");
|
||||
|
||||
#endregion
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Read-only access to the current disc information view model
|
||||
/// </summary>
|
||||
@@ -20,13 +123,21 @@ namespace MPF.UI.Core.Windows
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public DiscInformationWindow(Options options, SubmissionInfo submissionInfo)
|
||||
#else
|
||||
public DiscInformationWindow(Options options, SubmissionInfo? submissionInfo)
|
||||
#endif
|
||||
{
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
InitializeComponent();
|
||||
#endif
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
var chrome = new System.Windows.Shell.WindowChrome
|
||||
{
|
||||
CaptionHeight = 0,
|
||||
ResizeBorderThickness = new Thickness(0),
|
||||
};
|
||||
System.Windows.Shell.WindowChrome.SetWindowChrome(this, chrome);
|
||||
#endif
|
||||
|
||||
DataContext = new DiscInformationViewModel(options, submissionInfo);
|
||||
DiscInformationViewModel.Load();
|
||||
|
||||
@@ -38,9 +149,15 @@ namespace MPF.UI.Core.Windows
|
||||
}
|
||||
|
||||
// Add handlers
|
||||
#if NET35
|
||||
_AcceptButton!.Click += OnAcceptClick;
|
||||
_CancelButton!.Click += OnCancelClick;
|
||||
_RingCodeGuideButton!.Click += OnRingCodeGuideClick;
|
||||
#else
|
||||
AcceptButton.Click += OnAcceptClick;
|
||||
CancelButton.Click += OnCancelClick;
|
||||
RingCodeGuideButton.Click += OnRingCodeGuideClick;
|
||||
#endif
|
||||
|
||||
// Update UI with new values
|
||||
ManipulateFields(options, submissionInfo);
|
||||
@@ -51,11 +168,7 @@ namespace MPF.UI.Core.Windows
|
||||
/// <summary>
|
||||
/// Manipulate fields based on the current disc
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private void ManipulateFields(Options options, SubmissionInfo submissionInfo)
|
||||
#else
|
||||
private void ManipulateFields(Options options, SubmissionInfo? submissionInfo)
|
||||
#endif
|
||||
{
|
||||
// Enable tabs in all fields, if required
|
||||
if (options.EnableTabsInInputFields)
|
||||
@@ -78,9 +191,26 @@ namespace MPF.UI.Core.Windows
|
||||
private void EnableTabsInInputFields()
|
||||
{
|
||||
// Additional Information
|
||||
#if NET35
|
||||
_CommentsTextBox!.Tab = true;
|
||||
#else
|
||||
CommentsTextBox.Tab = true;
|
||||
#endif
|
||||
|
||||
// Contents
|
||||
#if NET35
|
||||
_GeneralContent!.Tab = true;
|
||||
_GamesTextBox!.Tab = true;
|
||||
_NetYarozeGamesTextBox!.Tab = true;
|
||||
_PlayableDemosTextBox!.Tab = true;
|
||||
_RollingDemosTextBox!.Tab = true;
|
||||
_TechDemosTextBox!.Tab = true;
|
||||
_GameFootageTextBox!.Tab = true;
|
||||
_VideosTextBox!.Tab = true;
|
||||
_PatchesTextBox!.Tab = true;
|
||||
_SavegamesTextBox!.Tab = true;
|
||||
_ExtrasTextBox!.Tab = true;
|
||||
#else
|
||||
GeneralContent.Tab = true;
|
||||
GamesTextBox.Tab = true;
|
||||
NetYarozeGamesTextBox.Tab = true;
|
||||
@@ -92,30 +222,59 @@ namespace MPF.UI.Core.Windows
|
||||
PatchesTextBox.Tab = true;
|
||||
SavegamesTextBox.Tab = true;
|
||||
ExtrasTextBox.Tab = true;
|
||||
#endif
|
||||
|
||||
// L0
|
||||
#if NET35
|
||||
_L0MasteringRing!.Tab = true;
|
||||
_L0MasteringSID!.Tab = true;
|
||||
_L0Toolstamp!.Tab = true;
|
||||
_L0MouldSID!.Tab = true;
|
||||
_L0AdditionalMould!.Tab = true;
|
||||
#else
|
||||
L0MasteringRing.Tab = true;
|
||||
L0MasteringSID.Tab = true;
|
||||
L0Toolstamp.Tab = true;
|
||||
L0MouldSID.Tab = true;
|
||||
L0AdditionalMould.Tab = true;
|
||||
#endif
|
||||
|
||||
// L1
|
||||
#if NET35
|
||||
_L1MasteringRing!.Tab = true;
|
||||
_L1MasteringSID!.Tab = true;
|
||||
_L1Toolstamp!.Tab = true;
|
||||
_L1MouldSID!.Tab = true;
|
||||
_L1AdditionalMould!.Tab = true;
|
||||
#else
|
||||
L1MasteringRing.Tab = true;
|
||||
L1MasteringSID.Tab = true;
|
||||
L1Toolstamp.Tab = true;
|
||||
L1MouldSID.Tab = true;
|
||||
L1AdditionalMould.Tab = true;
|
||||
#endif
|
||||
|
||||
// L2
|
||||
#if NET35
|
||||
_L2MasteringRing!.Tab = true;
|
||||
_L2MasteringSID!.Tab = true;
|
||||
_L2Toolstamp!.Tab = true;
|
||||
#else
|
||||
L2MasteringRing.Tab = true;
|
||||
L2MasteringSID.Tab = true;
|
||||
L2Toolstamp.Tab = true;
|
||||
#endif
|
||||
|
||||
// L3
|
||||
#if NET35
|
||||
_L3MasteringRing!.Tab = true;
|
||||
_L3MasteringSID!.Tab = true;
|
||||
_L3Toolstamp!.Tab = true;
|
||||
#else
|
||||
L3MasteringRing.Tab = true;
|
||||
L3MasteringSID.Tab = true;
|
||||
L3Toolstamp.Tab = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -123,22 +282,76 @@ namespace MPF.UI.Core.Windows
|
||||
/// </summary>
|
||||
/// TODO: Figure out how to bind the PartiallyMatchedIDs array to a text box
|
||||
/// TODO: Convert visibility to a binding
|
||||
#if NET48
|
||||
private void HideReadOnlyFields(SubmissionInfo submissionInfo)
|
||||
#else
|
||||
private void HideReadOnlyFields(SubmissionInfo? submissionInfo)
|
||||
#endif
|
||||
{
|
||||
// If there's no submission information
|
||||
if (submissionInfo == null)
|
||||
return;
|
||||
|
||||
#if NET35
|
||||
if (submissionInfo.FullyMatchedID == null)
|
||||
_FullyMatchedID!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.PartiallyMatchedIDs == null)
|
||||
_PartiallyMatchedIDs!.Visibility = Visibility.Collapsed;
|
||||
else
|
||||
_PartiallyMatchedIDs!.Text = string.Join(", ", submissionInfo.PartiallyMatchedIDs.Select(i => i.ToString()).ToArray());
|
||||
if (submissionInfo.CopyProtection?.AntiModchip == null)
|
||||
_AntiModchip!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.TracksAndWriteOffsets?.OtherWriteOffsets == null)
|
||||
_DiscOffset!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.Keys?.Contains(SiteCode.DMIHash) != true)
|
||||
_DMIHash!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.EDC?.EDC == null)
|
||||
_EDC!.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrEmpty(submissionInfo.CommonDiscInfo?.ErrorsCount))
|
||||
_ErrorsCount!.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrEmpty(submissionInfo.CommonDiscInfo?.EXEDateBuildDate))
|
||||
_EXEDateBuildDate!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.Filename) != true)
|
||||
_Filename!.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrEmpty(submissionInfo.Extras?.Header))
|
||||
_Header!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.InternalName) != true)
|
||||
_InternalName!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.InternalSerialName) != true)
|
||||
_InternalSerialName!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.Multisession) != true)
|
||||
_Multisession!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CopyProtection?.LibCrypt == null)
|
||||
_LibCrypt!.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrEmpty(submissionInfo.CopyProtection?.LibCryptData))
|
||||
_LibCryptData!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.PFIHash) != true)
|
||||
_PFIHash!.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrEmpty(submissionInfo.Extras?.PIC))
|
||||
_PIC!.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrEmpty(submissionInfo.Extras?.PVD))
|
||||
_PVD!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.RingNonZeroDataStart) != true)
|
||||
_RingNonZeroDataStart!.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrEmpty(submissionInfo.CopyProtection?.SecuROMData))
|
||||
_SecuROMData!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.SSHash) != true)
|
||||
_SSHash!.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrEmpty(submissionInfo.Extras?.SecuritySectorRanges))
|
||||
_SecuritySectorRanges!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.SSVersion) != true)
|
||||
_SSVersion!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.UniversalHash) != true)
|
||||
_UniversalHash!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.VolumeLabel) != true)
|
||||
_VolumeLabel!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.XeMID) != true)
|
||||
_XeMID!.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.XMID) != true)
|
||||
_XMID!.Visibility = Visibility.Collapsed;
|
||||
#else
|
||||
if (submissionInfo.FullyMatchedID == null)
|
||||
FullyMatchedID.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.PartiallyMatchedIDs == null)
|
||||
PartiallyMatchedIDs.Visibility = Visibility.Collapsed;
|
||||
else
|
||||
PartiallyMatchedIDs.Text = string.Join(", ", submissionInfo.PartiallyMatchedIDs);
|
||||
PartiallyMatchedIDs.Text = string.Join(", ", submissionInfo.PartiallyMatchedIDs.Select(i => i.ToString()).ToArray());
|
||||
if (submissionInfo.CopyProtection?.AntiModchip == null)
|
||||
AntiModchip.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.TracksAndWriteOffsets?.OtherWriteOffsets == null)
|
||||
@@ -147,13 +360,13 @@ namespace MPF.UI.Core.Windows
|
||||
DMIHash.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.EDC?.EDC == null)
|
||||
EDC.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrWhiteSpace(submissionInfo.CommonDiscInfo?.ErrorsCount))
|
||||
if (string.IsNullOrEmpty(submissionInfo.CommonDiscInfo?.ErrorsCount))
|
||||
ErrorsCount.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrWhiteSpace(submissionInfo.CommonDiscInfo?.EXEDateBuildDate))
|
||||
if (string.IsNullOrEmpty(submissionInfo.CommonDiscInfo?.EXEDateBuildDate))
|
||||
EXEDateBuildDate.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.Filename) != true)
|
||||
Filename.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrWhiteSpace(submissionInfo.Extras?.Header))
|
||||
if (string.IsNullOrEmpty(submissionInfo.Extras?.Header))
|
||||
Header.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.InternalName) != true)
|
||||
InternalName.Visibility = Visibility.Collapsed;
|
||||
@@ -163,21 +376,21 @@ namespace MPF.UI.Core.Windows
|
||||
Multisession.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CopyProtection?.LibCrypt == null)
|
||||
LibCrypt.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrWhiteSpace(submissionInfo.CopyProtection?.LibCryptData))
|
||||
if (string.IsNullOrEmpty(submissionInfo.CopyProtection?.LibCryptData))
|
||||
LibCryptData.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.PFIHash) != true)
|
||||
PFIHash.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrWhiteSpace(submissionInfo.Extras?.PIC))
|
||||
if (string.IsNullOrEmpty(submissionInfo.Extras?.PIC))
|
||||
PIC.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrWhiteSpace(submissionInfo.Extras?.PVD))
|
||||
if (string.IsNullOrEmpty(submissionInfo.Extras?.PVD))
|
||||
PVD.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.RingNonZeroDataStart) != true)
|
||||
RingNonZeroDataStart.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrWhiteSpace(submissionInfo.CopyProtection?.SecuROMData))
|
||||
if (string.IsNullOrEmpty(submissionInfo.CopyProtection?.SecuROMData))
|
||||
SecuROMData.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.SSHash) != true)
|
||||
SSHash.Visibility = Visibility.Collapsed;
|
||||
if (string.IsNullOrWhiteSpace(submissionInfo.Extras?.SecuritySectorRanges))
|
||||
if (string.IsNullOrEmpty(submissionInfo.Extras?.SecuritySectorRanges))
|
||||
SecuritySectorRanges.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.SSVersion) != true)
|
||||
SSVersion.Visibility = Visibility.Collapsed;
|
||||
@@ -189,17 +402,14 @@ namespace MPF.UI.Core.Windows
|
||||
XeMID.Visibility = Visibility.Collapsed;
|
||||
if (submissionInfo.CommonDiscInfo?.CommentsSpecialFields?.ContainsKey(SiteCode.XMID) != true)
|
||||
XMID.Visibility = Visibility.Collapsed;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update visible fields and sections based on the media type
|
||||
/// </summary>
|
||||
/// TODO: See if these can be done by binding
|
||||
#if NET48
|
||||
private void UpdateFromDiscType(SubmissionInfo submissionInfo)
|
||||
#else
|
||||
private void UpdateFromDiscType(SubmissionInfo? submissionInfo)
|
||||
#endif
|
||||
{
|
||||
// Sony-printed discs have layers in the opposite order
|
||||
var system = submissionInfo?.CommonDiscInfo?.System;
|
||||
@@ -209,19 +419,37 @@ namespace MPF.UI.Core.Windows
|
||||
{
|
||||
case DiscType.CD:
|
||||
case DiscType.GDROM:
|
||||
#if NET35
|
||||
_L0Info!.Header = "Data Side";
|
||||
_L0MasteringRing!.Label = "Mastering Ring";
|
||||
_L0MasteringSID!.Label = "Mastering SID";
|
||||
_L0Toolstamp!.Label = "Toolstamp/Mastering Code";
|
||||
_L0MouldSID!.Label = "Mould SID";
|
||||
_L0AdditionalMould!.Label = "Additional Mould";
|
||||
#else
|
||||
L0Info.Header = "Data Side";
|
||||
L0MasteringRing.Label = "Mastering Ring";
|
||||
L0MasteringSID.Label = "Mastering SID";
|
||||
L0Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
L0MouldSID.Label = "Mould SID";
|
||||
L0AdditionalMould.Label = "Additional Mould";
|
||||
#endif
|
||||
|
||||
#if NET35
|
||||
_L1Info!.Header = "Label Side";
|
||||
_L1MasteringRing!.Visibility = Visibility.Collapsed;
|
||||
_L1MasteringSID!.Visibility = Visibility.Collapsed;
|
||||
_L1Toolstamp!.Visibility = Visibility.Collapsed;
|
||||
_L1MouldSID!.Label = "Mould SID";
|
||||
_L1AdditionalMould!.Label = "Additional Mould";
|
||||
#else
|
||||
L1Info.Header = "Label Side";
|
||||
L1MasteringRing.Visibility = Visibility.Collapsed;
|
||||
L1MasteringSID.Visibility = Visibility.Collapsed;
|
||||
L1Toolstamp.Visibility = Visibility.Collapsed;
|
||||
L1MouldSID.Label = "Mould SID";
|
||||
L1AdditionalMould.Label = "Additional Mould";
|
||||
#endif
|
||||
break;
|
||||
|
||||
case DiscType.DVD5:
|
||||
@@ -241,103 +469,212 @@ namespace MPF.UI.Core.Windows
|
||||
// Quad-layer discs
|
||||
if (submissionInfo?.SizeAndChecksums?.Layerbreak3 != default(long))
|
||||
{
|
||||
#if NET35
|
||||
_L2Info!.Visibility = Visibility.Visible;
|
||||
_L3Info!.Visibility = Visibility.Visible;
|
||||
#else
|
||||
L2Info.Visibility = Visibility.Visible;
|
||||
L3Info.Visibility = Visibility.Visible;
|
||||
#endif
|
||||
|
||||
#if NET35
|
||||
_L0Info!.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
|
||||
_L0MasteringRing!.Label = "Mastering Ring";
|
||||
_L0MasteringSID!.Label = "Mastering SID";
|
||||
_L0Toolstamp!.Label = "Toolstamp/Mastering Code";
|
||||
_L0MouldSID!.Label = "Data Side Mould SID";
|
||||
_L0AdditionalMould!.Label = "Data Side Additional Mould";
|
||||
#else
|
||||
L0Info.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
|
||||
L0MasteringRing.Label = "Mastering Ring";
|
||||
L0MasteringSID.Label = "Mastering SID";
|
||||
L0Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
L0MouldSID.Label = "Data Side Mould SID";
|
||||
L0AdditionalMould.Label = "Data Side Additional Mould";
|
||||
#endif
|
||||
|
||||
#if NET35
|
||||
_L1Info!.Header = "Layer 1";
|
||||
_L1MasteringRing!.Label = "Mastering Ring";
|
||||
_L1MasteringSID!.Label = "Mastering SID";
|
||||
_L1Toolstamp!.Label = "Toolstamp/Mastering Code";
|
||||
_L1MouldSID!.Label = "Label Side Mould SID";
|
||||
_L1AdditionalMould!.Label = "Label Side Additional Mould";
|
||||
#else
|
||||
L1Info.Header = "Layer 1";
|
||||
L1MasteringRing.Label = "Mastering Ring";
|
||||
L1MasteringSID.Label = "Mastering SID";
|
||||
L1Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
L1MouldSID.Label = "Label Side Mould SID";
|
||||
L1AdditionalMould.Label = "Label Side Additional Mould";
|
||||
#endif
|
||||
|
||||
#if NET35
|
||||
_L2Info!.Header = "Layer 2";
|
||||
_L2MasteringRing!.Label = "Mastering Ring";
|
||||
_L2MasteringSID!.Label = "Mastering SID";
|
||||
_L2Toolstamp!.Label = "Toolstamp/Mastering Code";
|
||||
#else
|
||||
L2Info.Header = "Layer 2";
|
||||
L2MasteringRing.Label = "Mastering Ring";
|
||||
L2MasteringSID.Label = "Mastering SID";
|
||||
L2Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
#endif
|
||||
|
||||
#if NET35
|
||||
_L3Info!.Header = reverseOrder ? "Layer 3 (Inner)" : "Layer 3 (Outer)";
|
||||
_L3MasteringRing!.Label = "Mastering Ring";
|
||||
_L3MasteringSID!.Label = "Mastering SID";
|
||||
_L3Toolstamp!.Label = "Toolstamp/Mastering Code";
|
||||
#else
|
||||
L3Info.Header = reverseOrder ? "Layer 3 (Inner)" : "Layer 3 (Outer)";
|
||||
L3MasteringRing.Label = "Mastering Ring";
|
||||
L3MasteringSID.Label = "Mastering SID";
|
||||
L3Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
#endif
|
||||
}
|
||||
|
||||
// Triple-layer discs
|
||||
else if (submissionInfo?.SizeAndChecksums?.Layerbreak2 != default(long))
|
||||
{
|
||||
#if NET35
|
||||
_L2Info!.Visibility = Visibility.Visible;
|
||||
#else
|
||||
L2Info.Visibility = Visibility.Visible;
|
||||
#endif
|
||||
|
||||
#if NET35
|
||||
_L0Info!.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
|
||||
_L0MasteringRing!.Label = "Mastering Ring";
|
||||
_L0MasteringSID!.Label = "Mastering SID";
|
||||
_L0Toolstamp!.Label = "Toolstamp/Mastering Code";
|
||||
_L0MouldSID!.Label = "Data Side Mould SID";
|
||||
_L0AdditionalMould!.Label = "Data Side Additional Mould";
|
||||
#else
|
||||
L0Info.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
|
||||
L0MasteringRing.Label = "Mastering Ring";
|
||||
L0MasteringSID.Label = "Mastering SID";
|
||||
L0Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
L0MouldSID.Label = "Data Side Mould SID";
|
||||
L0AdditionalMould.Label = "Data Side Additional Mould";
|
||||
#endif
|
||||
|
||||
#if NET35
|
||||
_L1Info!.Header = "Layer 1";
|
||||
_L1MasteringRing!.Label = "Mastering Ring";
|
||||
_L1MasteringSID!.Label = "Mastering SID";
|
||||
_L1Toolstamp!.Label = "Toolstamp/Mastering Code";
|
||||
_L1MouldSID!.Label = "Label Side Mould SID";
|
||||
_L1AdditionalMould!.Label = "Label Side Additional Mould";
|
||||
#else
|
||||
L1Info.Header = "Layer 1";
|
||||
L1MasteringRing.Label = "Mastering Ring";
|
||||
L1MasteringSID.Label = "Mastering SID";
|
||||
L1Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
L1MouldSID.Label = "Label Side Mould SID";
|
||||
L1AdditionalMould.Label = "Label Side Additional Mould";
|
||||
#endif
|
||||
|
||||
#if NET35
|
||||
_L2Info!.Header = reverseOrder ? "Layer 2 (Inner)" : "Layer 2 (Outer)";
|
||||
_L2MasteringRing!.Label = "Mastering Ring";
|
||||
_L2MasteringSID!.Label = "Mastering SID";
|
||||
_L2Toolstamp!.Label = "Toolstamp/Mastering Code";
|
||||
#else
|
||||
L2Info.Header = reverseOrder ? "Layer 2 (Inner)" : "Layer 2 (Outer)";
|
||||
L2MasteringRing.Label = "Mastering Ring";
|
||||
L2MasteringSID.Label = "Mastering SID";
|
||||
L2Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
#endif
|
||||
}
|
||||
|
||||
// Double-layer discs
|
||||
else if (submissionInfo?.SizeAndChecksums?.Layerbreak != default(long))
|
||||
{
|
||||
#if NET35
|
||||
_L0Info!.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
|
||||
_L0MasteringRing!.Label = "Mastering Ring";
|
||||
_L0MasteringSID!.Label = "Mastering SID";
|
||||
_L0Toolstamp!.Label = "Toolstamp/Mastering Code";
|
||||
_L0MouldSID!.Label = "Data Side Mould SID";
|
||||
_L0AdditionalMould!.Label = "Data Side Additional Mould";
|
||||
#else
|
||||
L0Info.Header = reverseOrder ? "Layer 0 (Outer)" : "Layer 0 (Inner)";
|
||||
L0MasteringRing.Label = "Mastering Ring";
|
||||
L0MasteringSID.Label = "Mastering SID";
|
||||
L0Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
L0MouldSID.Label = "Data Side Mould SID";
|
||||
L0AdditionalMould.Label = "Data Side Additional Mould";
|
||||
#endif
|
||||
|
||||
#if NET35
|
||||
_L1Info!.Header = reverseOrder ? "Layer 1 (Inner)" : "Layer 1 (Outer)";
|
||||
_L1MasteringRing!.Label = "Mastering Ring";
|
||||
_L1MasteringSID!.Label = "Mastering SID";
|
||||
_L1Toolstamp!.Label = "Toolstamp/Mastering Code";
|
||||
_L1MouldSID!.Label = "Label Side Mould SID";
|
||||
_L1AdditionalMould!.Label = "Label Side Additional Mould";
|
||||
#else
|
||||
L1Info.Header = reverseOrder ? "Layer 1 (Inner)" : "Layer 1 (Outer)";
|
||||
L1MasteringRing.Label = "Mastering Ring";
|
||||
L1MasteringSID.Label = "Mastering SID";
|
||||
L1Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
L1MouldSID.Label = "Label Side Mould SID";
|
||||
L1AdditionalMould.Label = "Label Side Additional Mould";
|
||||
#endif
|
||||
}
|
||||
|
||||
// Single-layer discs
|
||||
else
|
||||
{
|
||||
#if NET35
|
||||
_L0Info!.Header = "Data Side";
|
||||
_L0MasteringRing!.Label = "Mastering Ring";
|
||||
_L0MasteringSID!.Label = "Mastering SID";
|
||||
_L0Toolstamp!.Label = "Toolstamp/Mastering Code";
|
||||
_L0MouldSID!.Label = "Mould SID";
|
||||
_L0AdditionalMould!.Label = "Additional Mould";
|
||||
#else
|
||||
L0Info.Header = "Data Side";
|
||||
L0MasteringRing.Label = "Mastering Ring";
|
||||
L0MasteringSID.Label = "Mastering SID";
|
||||
L0Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
L0MouldSID.Label = "Mould SID";
|
||||
L0AdditionalMould.Label = "Additional Mould";
|
||||
#endif
|
||||
|
||||
#if NET35
|
||||
_L1Info!.Header = "Label Side";
|
||||
_L1MasteringRing!.Visibility = Visibility.Collapsed;
|
||||
_L1MasteringSID!.Visibility = Visibility.Collapsed;
|
||||
_L1Toolstamp!.Visibility = Visibility.Collapsed;
|
||||
_L1MouldSID!.Label = "Mould SID";
|
||||
_L1AdditionalMould!.Label = "Additional Mould";
|
||||
#else
|
||||
L1Info.Header = "Label Side";
|
||||
L1MasteringRing.Label = "Mastering Ring";
|
||||
L1MasteringSID.Label = "Mastering SID";
|
||||
L1Toolstamp.Label = "Toolstamp/Mastering Code";
|
||||
L1MasteringRing.Visibility = Visibility.Collapsed;
|
||||
L1MasteringSID.Visibility = Visibility.Collapsed;
|
||||
L1Toolstamp.Visibility = Visibility.Collapsed;
|
||||
L1MouldSID.Label = "Mould SID";
|
||||
L1AdditionalMould.Label = "Additional Mould";
|
||||
#endif
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// All other media we assume to have no rings
|
||||
default:
|
||||
#if NET35
|
||||
_L0Info!.Visibility = Visibility.Collapsed;
|
||||
_L1Info!.Visibility = Visibility.Collapsed;
|
||||
_L2Info!.Visibility = Visibility.Collapsed;
|
||||
_L3Info!.Visibility = Visibility.Collapsed;
|
||||
#else
|
||||
L0Info.Visibility = Visibility.Collapsed;
|
||||
L1Info.Visibility = Visibility.Collapsed;
|
||||
L2Info.Visibility = Visibility.Collapsed;
|
||||
L3Info.Visibility = Visibility.Collapsed;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -346,22 +683,40 @@ namespace MPF.UI.Core.Windows
|
||||
/// Update visible fields and sections based on the system type
|
||||
/// </summary>
|
||||
/// TODO: See if these can be done by binding
|
||||
#if NET48
|
||||
private void UpdateFromSystemType(SubmissionInfo submissionInfo)
|
||||
#else
|
||||
private void UpdateFromSystemType(SubmissionInfo? submissionInfo)
|
||||
#endif
|
||||
{
|
||||
var system = submissionInfo?.CommonDiscInfo?.System;
|
||||
switch (system)
|
||||
{
|
||||
case RedumpSystem.NintendoWiiU:
|
||||
#if NET35
|
||||
_DiscKeyTextBox!.Visibility = Visibility.Visible;
|
||||
#else
|
||||
DiscKeyTextBox.Visibility = Visibility.Visible;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case RedumpSystem.SonyPlayStation2:
|
||||
#if NET35
|
||||
_LanguageSelectionGrid!.Visibility = Visibility.Visible;
|
||||
#else
|
||||
LanguageSelectionGrid.Visibility = Visibility.Visible;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case RedumpSystem.SonyPlayStation3:
|
||||
#if NET35
|
||||
_DiscKeyTextBox!.Visibility = Visibility.Visible;
|
||||
_DiscIDTextBox!.Visibility = Visibility.Visible;
|
||||
#else
|
||||
DiscKeyTextBox.Visibility = Visibility.Visible;
|
||||
DiscIDTextBox.Visibility = Visibility.Visible;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@
|
||||
<Window.Resources>
|
||||
<core:ElementConverter x:Key="ElementConverter" />
|
||||
</Window.Resources>
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" ResizeBorderThickness="0" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<Grid>
|
||||
<StackPanel Orientation="Vertical">
|
||||
@@ -79,7 +76,7 @@
|
||||
</StackPanel>
|
||||
<Label Panel.ZIndex="0" Grid.Column="1" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" MouseDown="TitleMouseDown">
|
||||
<Label.Content>
|
||||
<TextBlock TextAlignment="Center"><Bold>Media Preservation Frontend</Bold></TextBlock>
|
||||
<TextBlock TextAlignment="Center"><Run FontWeight="Bold" Text="Media Preservation Frontend" /></TextBlock>
|
||||
</Label.Content>
|
||||
<Label.ContextMenu>
|
||||
<ContextMenu Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
|
||||
|
||||
@@ -2,12 +2,15 @@ using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using MPF.Core;
|
||||
using MPF.Core.UI.ViewModels;
|
||||
using MPF.UI.Core.UserControls;
|
||||
using SabreTools.RedumpLib;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
using WPFCustomMessageBox;
|
||||
using WinForms = System.Windows.Forms;
|
||||
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
namespace MPF.UI.Core.Windows
|
||||
{
|
||||
public partial class MainWindow : WindowBase
|
||||
@@ -17,10 +20,66 @@ namespace MPF.UI.Core.Windows
|
||||
/// </summary>
|
||||
public MainViewModel MainViewModel => DataContext as MainViewModel ?? new MainViewModel();
|
||||
|
||||
#if NET35
|
||||
|
||||
#region Top Menu Bar
|
||||
|
||||
private MenuItem? _AboutMenuItem => ItemHelper.FindChild<MenuItem>(this, "AboutMenuItem");
|
||||
private MenuItem? _AppExitMenuItem => ItemHelper.FindChild<MenuItem>(this, "AppExitMenuItem");
|
||||
private MenuItem? _CheckForUpdatesMenuItem => ItemHelper.FindChild<MenuItem>(this, "CheckForUpdatesMenuItem");
|
||||
private MenuItem? _DebugViewMenuItem => ItemHelper.FindChild<MenuItem>(this, "DebugViewMenuItem");
|
||||
private MenuItem? _OptionsMenuItem => ItemHelper.FindChild<MenuItem>(this, "OptionsMenuItem");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Settings
|
||||
|
||||
private ComboBox? _DriveLetterComboBox => ItemHelper.FindChild<ComboBox>(this, "DriveLetterComboBox");
|
||||
private ComboBox? _DriveSpeedComboBox => ItemHelper.FindChild<ComboBox>(this, "DriveSpeedComboBox");
|
||||
private ComboBox? _DumpingProgramComboBox => ItemHelper.FindChild<ComboBox>(this, "DumpingProgramComboBox");
|
||||
private CheckBox? _EnableParametersCheckBox => ItemHelper.FindChild<CheckBox>(this, "EnableParametersCheckBox");
|
||||
private ComboBox? _MediaTypeComboBox => ItemHelper.FindChild<ComboBox>(this, "MediaTypeComboBox");
|
||||
private Button? _OutputPathBrowseButton => ItemHelper.FindChild<Button>(this, "OutputPathBrowseButton");
|
||||
private TextBox? _OutputPathTextBox => ItemHelper.FindChild<TextBox>(this, "OutputPathTextBox");
|
||||
private ComboBox? _SystemTypeComboBox => ItemHelper.FindChild<ComboBox>(this, "SystemTypeComboBox");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Controls
|
||||
|
||||
private Button? _CopyProtectScanButton => ItemHelper.FindChild<Button>(this, "CopyProtectScanButton");
|
||||
private Button? _MediaScanButton => ItemHelper.FindChild<Button>(this, "MediaScanButton");
|
||||
private Button? _StartStopButton => ItemHelper.FindChild<Button>(this, "StartStopButton");
|
||||
private Button? _UpdateVolumeLabel => ItemHelper.FindChild<Button>(this, "UpdateVolumeLabel");
|
||||
|
||||
#endregion
|
||||
|
||||
#region Status
|
||||
|
||||
private LogOutput? _LogOutput => ItemHelper.FindChild<LogOutput>(this, "LogOutput");
|
||||
|
||||
#endregion
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public MainWindow() => InitializeComponent();
|
||||
public MainWindow()
|
||||
{
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
InitializeComponent();
|
||||
#endif
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
var chrome = new System.Windows.Shell.WindowChrome
|
||||
{
|
||||
CaptionHeight = 0,
|
||||
ResizeBorderThickness = new Thickness(0),
|
||||
};
|
||||
System.Windows.Shell.WindowChrome.SetWindowChrome(this, chrome);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for MainWindow OnContentRendered event
|
||||
@@ -40,19 +99,31 @@ namespace MPF.UI.Core.Windows
|
||||
|
||||
// Display the debug option in the menu, if necessary
|
||||
if (MainViewModel.Options.ShowDebugViewMenuItem)
|
||||
#if NET35
|
||||
_DebugViewMenuItem!.Visibility = Visibility.Visible;
|
||||
#else
|
||||
DebugViewMenuItem.Visibility = Visibility.Visible;
|
||||
#endif
|
||||
|
||||
#if NET35
|
||||
MainViewModel.Init(_LogOutput!.EnqueueLog, DisplayUserMessage, ShowDiscInformationWindow);
|
||||
#else
|
||||
MainViewModel.Init(LogOutput.EnqueueLog, DisplayUserMessage, ShowDiscInformationWindow);
|
||||
#endif
|
||||
|
||||
// Set the UI color scheme according to the options
|
||||
if (MainViewModel.Options.EnableDarkMode)
|
||||
EnableDarkMode();
|
||||
else
|
||||
EnableLightMode();
|
||||
ApplyTheme();
|
||||
|
||||
// Check for updates, if necessary
|
||||
if (MainViewModel.Options.CheckForUpdatesOnStartup)
|
||||
CheckForUpdates(showIfSame: false);
|
||||
|
||||
// Handle first-run, if necessary
|
||||
if (MainViewModel.Options.FirstRun)
|
||||
{
|
||||
// Show the options window
|
||||
ShowOptionsWindow("Welcome to MPF, Explore the Options");
|
||||
}
|
||||
}
|
||||
|
||||
#region UI Functionality
|
||||
@@ -63,29 +134,58 @@ namespace MPF.UI.Core.Windows
|
||||
public void AddEventHandlers()
|
||||
{
|
||||
// Menu Bar Click
|
||||
#if NET35
|
||||
_AboutMenuItem!.Click += AboutClick;
|
||||
_AppExitMenuItem!.Click += AppExitClick;
|
||||
_CheckForUpdatesMenuItem!.Click += CheckForUpdatesClick;
|
||||
_DebugViewMenuItem!.Click += DebugViewClick;
|
||||
_OptionsMenuItem!.Click += OptionsMenuItemClick;
|
||||
#else
|
||||
AboutMenuItem.Click += AboutClick;
|
||||
AppExitMenuItem.Click += AppExitClick;
|
||||
CheckForUpdatesMenuItem.Click += CheckForUpdatesClick;
|
||||
DebugViewMenuItem.Click += DebugViewClick;
|
||||
OptionsMenuItem.Click += OptionsMenuItemClick;
|
||||
#endif
|
||||
|
||||
// User Area Click
|
||||
#if NET35
|
||||
_CopyProtectScanButton!.Click += CopyProtectScanButtonClick;
|
||||
_EnableParametersCheckBox!.Click += EnableParametersCheckBoxClick;
|
||||
_MediaScanButton!.Click += MediaScanButtonClick;
|
||||
_UpdateVolumeLabel!.Click += UpdateVolumeLabelClick;
|
||||
_OutputPathBrowseButton!.Click += OutputPathBrowseButtonClick;
|
||||
_StartStopButton!.Click += StartStopButtonClick;
|
||||
#else
|
||||
CopyProtectScanButton.Click += CopyProtectScanButtonClick;
|
||||
EnableParametersCheckBox.Click += EnableParametersCheckBoxClick;
|
||||
MediaScanButton.Click += MediaScanButtonClick;
|
||||
UpdateVolumeLabel.Click += UpdateVolumeLabelClick;
|
||||
OutputPathBrowseButton.Click += OutputPathBrowseButtonClick;
|
||||
StartStopButton.Click += StartStopButtonClick;
|
||||
#endif
|
||||
|
||||
// User Area SelectionChanged
|
||||
#if NET35
|
||||
_SystemTypeComboBox!.SelectionChanged += SystemTypeComboBoxSelectionChanged;
|
||||
_MediaTypeComboBox!.SelectionChanged += MediaTypeComboBoxSelectionChanged;
|
||||
_DriveLetterComboBox!.SelectionChanged += DriveLetterComboBoxSelectionChanged;
|
||||
_DriveSpeedComboBox!.SelectionChanged += DriveSpeedComboBoxSelectionChanged;
|
||||
_DumpingProgramComboBox!.SelectionChanged += DumpingProgramComboBoxSelectionChanged;
|
||||
#else
|
||||
SystemTypeComboBox.SelectionChanged += SystemTypeComboBoxSelectionChanged;
|
||||
MediaTypeComboBox.SelectionChanged += MediaTypeComboBoxSelectionChanged;
|
||||
DriveLetterComboBox.SelectionChanged += DriveLetterComboBoxSelectionChanged;
|
||||
DriveSpeedComboBox.SelectionChanged += DriveSpeedComboBoxSelectionChanged;
|
||||
DumpingProgramComboBox.SelectionChanged += DumpingProgramComboBoxSelectionChanged;
|
||||
#endif
|
||||
|
||||
// User Area TextChanged
|
||||
#if NET35
|
||||
_OutputPathTextBox!.TextChanged += OutputPathTextBoxTextChanged;
|
||||
#else
|
||||
OutputPathTextBox.TextChanged += OutputPathTextBoxTextChanged;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -95,12 +195,12 @@ namespace MPF.UI.Core.Windows
|
||||
{
|
||||
// Get the current path, if possible
|
||||
string currentPath = MainViewModel.OutputPath;
|
||||
if (string.IsNullOrWhiteSpace(currentPath) && !string.IsNullOrWhiteSpace(MainViewModel.Options.DefaultOutputPath))
|
||||
if (string.IsNullOrEmpty(currentPath) && !string.IsNullOrEmpty(MainViewModel.Options.DefaultOutputPath))
|
||||
currentPath = Path.Combine(MainViewModel.Options.DefaultOutputPath, "track.bin");
|
||||
else if (string.IsNullOrWhiteSpace(currentPath))
|
||||
else if (string.IsNullOrEmpty(currentPath))
|
||||
currentPath = "track.bin";
|
||||
if (string.IsNullOrWhiteSpace(currentPath))
|
||||
currentPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "track.bin");
|
||||
if (string.IsNullOrEmpty(currentPath))
|
||||
currentPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory!, "track.bin");
|
||||
|
||||
// Get the full path
|
||||
currentPath = Path.GetFullPath(currentPath);
|
||||
@@ -133,7 +233,7 @@ namespace MPF.UI.Core.Windows
|
||||
(bool different, string message, var url) = MainViewModel.CheckForUpdates();
|
||||
|
||||
// If we have a new version, put it in the clipboard
|
||||
if (different)
|
||||
if (different && !string.IsNullOrEmpty(url))
|
||||
Clipboard.SetText(url);
|
||||
|
||||
if (showIfSame || different)
|
||||
@@ -151,44 +251,27 @@ namespace MPF.UI.Core.Windows
|
||||
public bool? DisplayUserMessage(string title, string message, int optionCount, bool flag)
|
||||
{
|
||||
// Set the correct button style
|
||||
MessageBoxButton button;
|
||||
switch (optionCount)
|
||||
var button = optionCount switch
|
||||
{
|
||||
case 1:
|
||||
button = MessageBoxButton.OK;
|
||||
break;
|
||||
case 2:
|
||||
button = MessageBoxButton.YesNo;
|
||||
break;
|
||||
case 3:
|
||||
button = MessageBoxButton.YesNoCancel;
|
||||
break;
|
||||
1 => MessageBoxButton.OK,
|
||||
2 => MessageBoxButton.YesNo,
|
||||
3 => MessageBoxButton.YesNoCancel,
|
||||
|
||||
// This should not happen, but default to "OK"
|
||||
default:
|
||||
button = MessageBoxButton.OK;
|
||||
break;
|
||||
}
|
||||
_ => MessageBoxButton.OK,
|
||||
};
|
||||
|
||||
// Set the correct icon
|
||||
MessageBoxImage image = flag ? MessageBoxImage.Question : MessageBoxImage.Exclamation;
|
||||
|
||||
// Display and get the result
|
||||
MessageBoxResult result = CustomMessageBox.Show(this, message, title, button, image);
|
||||
switch (result)
|
||||
return result switch
|
||||
{
|
||||
case MessageBoxResult.OK:
|
||||
case MessageBoxResult.Yes:
|
||||
return true;
|
||||
|
||||
case MessageBoxResult.No:
|
||||
return false;
|
||||
|
||||
case MessageBoxResult.Cancel:
|
||||
case MessageBoxResult.None:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
MessageBoxResult.OK or MessageBoxResult.Yes => true,
|
||||
MessageBoxResult.No => false,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -198,7 +281,7 @@ namespace MPF.UI.Core.Windows
|
||||
{
|
||||
var submissionInfo = MainViewModel.CreateDebugSubmissionInfo();
|
||||
var result = ShowDiscInformationWindow(submissionInfo);
|
||||
InfoTool.ProcessSpecialFields(result.Item2);
|
||||
Formatter.ProcessSpecialFields(result.Item2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -206,11 +289,7 @@ namespace MPF.UI.Core.Windows
|
||||
/// </summary>
|
||||
/// <param name="submissionInfo">SubmissionInfo object to display and possibly change</param>
|
||||
/// <returns>Dialog open result</returns>
|
||||
#if NET48
|
||||
public (bool?, SubmissionInfo) ShowDiscInformationWindow(SubmissionInfo submissionInfo)
|
||||
#else
|
||||
public (bool?, SubmissionInfo?) ShowDiscInformationWindow(SubmissionInfo? submissionInfo)
|
||||
#endif
|
||||
{
|
||||
if (MainViewModel.Options.ShowDiscEjectReminder)
|
||||
CustomMessageBox.Show(this, "It is now safe to eject the disc", "Eject", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
@@ -223,27 +302,21 @@ namespace MPF.UI.Core.Windows
|
||||
ShowInTaskbar = true,
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
};
|
||||
|
||||
discInformationWindow.Closed += delegate { this.Activate(); };
|
||||
bool? result = discInformationWindow.ShowDialog();
|
||||
|
||||
// Copy back the submission info changes, if necessary
|
||||
if (result == true)
|
||||
#if NET48
|
||||
submissionInfo = discInformationWindow.DiscInformationViewModel.SubmissionInfo.Clone() as SubmissionInfo;
|
||||
#else
|
||||
submissionInfo = (discInformationWindow.DiscInformationViewModel.SubmissionInfo.Clone() as SubmissionInfo)!;
|
||||
#endif
|
||||
|
||||
#if NET48
|
||||
return (result, submissionInfo);
|
||||
#else
|
||||
return (result, submissionInfo!);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show the Options window
|
||||
/// </summary>
|
||||
public void ShowOptionsWindow()
|
||||
public void ShowOptionsWindow(string? title = null)
|
||||
{
|
||||
var optionsWindow = new OptionsWindow(MainViewModel.Options)
|
||||
{
|
||||
@@ -251,46 +324,49 @@ namespace MPF.UI.Core.Windows
|
||||
Owner = this,
|
||||
ShowActivated = true,
|
||||
ShowInTaskbar = true,
|
||||
Title = title ?? "Options",
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
};
|
||||
|
||||
optionsWindow.Closed += delegate { this.Activate(); };
|
||||
optionsWindow.Closed += OnOptionsUpdated;
|
||||
optionsWindow.Show();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recolor all UI elements for light mode
|
||||
/// Set the UI color scheme according to the options
|
||||
/// </summary>
|
||||
private static void EnableLightMode()
|
||||
private void ApplyTheme()
|
||||
{
|
||||
var theme = new LightModeTheme();
|
||||
Theme theme;
|
||||
if (MainViewModel.Options.EnableDarkMode)
|
||||
theme = new DarkModeTheme();
|
||||
else
|
||||
theme = new LightModeTheme();
|
||||
|
||||
theme.Apply();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recolor all UI elements for dark mode
|
||||
/// </summary>
|
||||
private static void EnableDarkMode()
|
||||
{
|
||||
var theme = new DarkModeTheme();
|
||||
theme.Apply();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
/// <summary>
|
||||
/// Handler for OptionsWindow OnUpdated event
|
||||
/// </summary>
|
||||
#if NET48
|
||||
public void OnOptionsUpdated(object sender, EventArgs e)
|
||||
#else
|
||||
public void OnOptionsUpdated(object? sender, EventArgs e)
|
||||
#endif
|
||||
{
|
||||
bool savedSettings = (sender as OptionsWindow)?.OptionsViewModel?.SavedSettings ?? false;
|
||||
var options = (sender as OptionsWindow)?.OptionsViewModel?.Options;
|
||||
// Get the options window
|
||||
var optionsWindow = (sender as OptionsWindow);
|
||||
if (optionsWindow?.OptionsViewModel == null)
|
||||
return;
|
||||
|
||||
bool savedSettings = optionsWindow.OptionsViewModel.SavedSettings;
|
||||
var options = optionsWindow.OptionsViewModel.Options;
|
||||
MainViewModel.UpdateOptions(savedSettings, options);
|
||||
|
||||
// Set the UI color scheme according to the options
|
||||
ApplyTheme();
|
||||
}
|
||||
|
||||
#region Menu Bar
|
||||
@@ -335,9 +411,17 @@ namespace MPF.UI.Core.Windows
|
||||
/// <summary>
|
||||
/// Handler for CopyProtectScanButton Click event
|
||||
/// </summary>
|
||||
#if NET40
|
||||
public void CopyProtectScanButtonClick(object sender, RoutedEventArgs e)
|
||||
#else
|
||||
public async void CopyProtectScanButtonClick(object sender, RoutedEventArgs e)
|
||||
#endif
|
||||
{
|
||||
#if NET40
|
||||
var (output, error) = MainViewModel.ScanAndShowProtection();
|
||||
#else
|
||||
var (output, error) = await MainViewModel.ScanAndShowProtection();
|
||||
#endif
|
||||
|
||||
if (!MainViewModel.LogPanelExpanded)
|
||||
{
|
||||
|
||||
@@ -5,17 +5,18 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:core="clr-namespace:MPF.UI.Core"
|
||||
xmlns:coreWindows="clr-namespace:MPF.UI.Core.Windows"
|
||||
xmlns:viewModels="clr-namespace:MPF.Core.UI.ViewModels;assembly=MPF.Core"
|
||||
mc:Ignorable="d"
|
||||
Title="Options" Width="515.132" WindowStyle="None"
|
||||
Width="515.132" WindowStyle="None"
|
||||
WindowStartupLocation="CenterOwner" ResizeMode="CanMinimize" SizeToContent="Height"
|
||||
BorderBrush="DarkGray" BorderThickness="2">
|
||||
|
||||
<Window.DataContext>
|
||||
<viewModels:OptionsViewModel/>
|
||||
</Window.DataContext>
|
||||
<Window.Resources>
|
||||
<core:ElementConverter x:Key="ElementConverter" />
|
||||
</Window.Resources>
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" ResizeBorderThickness="0" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<Grid>
|
||||
<StackPanel Orientation="Vertical">
|
||||
@@ -30,10 +31,8 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image Grid.Column="0" Source="/Images/Icon.ico" Height="20" Width="20" Margin="1" />
|
||||
<Label Grid.Column="1" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" MouseDown="TitleMouseDown">
|
||||
<Label.Content>
|
||||
<TextBlock TextAlignment="Center"><Bold>Options</Bold></TextBlock>
|
||||
</Label.Content>
|
||||
<Label Grid.Column="1" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" MouseDown="TitleMouseDown"
|
||||
Content="{Binding Path=Title, Mode=OneWay}" FontWeight="Bold">
|
||||
<Label.ContextMenu>
|
||||
<ContextMenu Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
|
||||
Foreground="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"
|
||||
@@ -68,21 +67,77 @@
|
||||
Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
|
||||
Foreground="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"
|
||||
Style="{DynamicResource CustomTabControlStyle}">
|
||||
<TabItem Header="User Interface" Style="{DynamicResource CustomTabItemStyle}">
|
||||
<UniformGrid Columns="2" Rows="3">
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable Dark Mode"
|
||||
IsChecked="{Binding Options.EnableDarkMode}"
|
||||
ToolTip="(Experimental) Enable dark mode across the entire application" Margin="0,4"
|
||||
/>
|
||||
<CheckBox VerticalAlignment="Center" Content="Check for Updates on Startup"
|
||||
IsChecked="{Binding Options.CheckForUpdatesOnStartup}"
|
||||
ToolTip="Check for updates when the application starts" Margin="0,4"
|
||||
/>
|
||||
<CheckBox VerticalAlignment="Center" Content="Fast Update Label"
|
||||
IsChecked="{Binding Options.FastUpdateLabel}"
|
||||
ToolTip="Bypasses disc checks to quickly update the output path. Use with caution!" Margin="0,4"
|
||||
/>
|
||||
</UniformGrid>
|
||||
<TabItem Header="General" Style="{DynamicResource CustomTabItemStyle}">
|
||||
<StackPanel>
|
||||
<GroupBox Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="User Interface">
|
||||
<UniformGrid Columns="2" Rows="2">
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable Dark Mode"
|
||||
IsChecked="{Binding Options.EnableDarkMode}"
|
||||
ToolTip="(Experimental) Enable dark mode across the entire application" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Check for Updates on Startup"
|
||||
IsChecked="{Binding Options.CheckForUpdatesOnStartup}"
|
||||
ToolTip="Check for updates when the application starts" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Fast Update Label"
|
||||
IsChecked="{Binding Options.FastUpdateLabel}"
|
||||
ToolTip="Bypasses disc checks to quickly update the output path. Use with caution!" Margin="0,4"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="Detection">
|
||||
<UniformGrid Columns="2" Rows="3">
|
||||
<CheckBox x:Name="SkipMediaTypeDetectionCheckBox" VerticalAlignment="Center" Content="Skip Type Detect"
|
||||
IsChecked="{Binding Options.SkipMediaTypeDetection}"
|
||||
ToolTip="Disable trying to guess media type inserted (may improve performance at startup)" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Skip System Detect"
|
||||
IsChecked="{Binding Options.SkipSystemDetection}"
|
||||
ToolTip="Disable trying to guess system (may improve performance at startup)" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="No Fixed Drives"
|
||||
IsChecked="{Binding Options.IgnoreFixedDrives}"
|
||||
ToolTip="Ignore hard drives and other fixed drives" Margin="0,4"
|
||||
/>
|
||||
<Label/>
|
||||
<!-- Empty label for padding -->
|
||||
|
||||
<Label VerticalAlignment="Center" Content="Default System:" HorizontalAlignment="Right" />
|
||||
<ComboBox x:Name="DefaultSystemComboBox" Height="22" Width="200" HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding Systems}" SelectedItem="{Binding Options.DefaultSystem, Converter={StaticResource ElementConverter}, Mode=TwoWay}"
|
||||
SelectedIndex="0" Style="{DynamicResource CustomComboBoxStyle}">
|
||||
<ComboBox.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type ComboBoxItem}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsHeader}" Value="True">
|
||||
<Setter Property="IsEnabled" Value="False"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ComboBox.ItemContainerStyle>
|
||||
</ComboBox>
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="Logging">
|
||||
<UniformGrid Columns="2" Rows="1">
|
||||
<CheckBox VerticalAlignment="Center" Content="Verbose Logging"
|
||||
IsChecked="{Binding Options.VerboseLogging}"
|
||||
ToolTip="Display all logging statements" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Auto-Open Log"
|
||||
IsChecked="{Binding Options.OpenLogWindowAtStartup}"
|
||||
ToolTip="Open the log panel when the program launches" Margin="0,4"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Paths" Style="{DynamicResource CustomTabItemStyle}">
|
||||
@@ -135,47 +190,12 @@
|
||||
<TabItem Header="Dumping" Style="{DynamicResource CustomTabItemStyle}">
|
||||
<StackPanel>
|
||||
<GroupBox Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="Dumping">
|
||||
<UniformGrid Columns="2" Rows="9">
|
||||
<CheckBox x:Name="SkipMediaTypeDetectionCheckBox" VerticalAlignment="Center" Content="Skip Type Detect"
|
||||
IsChecked="{Binding Options.SkipMediaTypeDetection}"
|
||||
ToolTip="Disable trying to guess media type inserted (may improve performance at startup)" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Skip System Detect"
|
||||
IsChecked="{Binding Options.SkipSystemDetection}"
|
||||
ToolTip="Disable trying to guess system (may improve performance at startup)" Margin="0,4"
|
||||
/>
|
||||
|
||||
<Label VerticalAlignment="Center" Content="Default System:" HorizontalAlignment="Right" />
|
||||
<ComboBox x:Name="DefaultSystemComboBox" Height="22" Width="200" HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding Systems}" SelectedItem="{Binding Options.DefaultSystem, Converter={StaticResource ElementConverter}, Mode=TwoWay}"
|
||||
SelectedIndex="0" Style="{DynamicResource CustomComboBoxStyle}">
|
||||
<ComboBox.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type ComboBoxItem}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsHeader}" Value="True">
|
||||
<Setter Property="IsEnabled" Value="False"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ComboBox.ItemContainerStyle>
|
||||
</ComboBox>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="No Fixed Drives"
|
||||
IsChecked="{Binding Options.IgnoreFixedDrives}"
|
||||
ToolTip="Ignore hard drives and other fixed drives" Margin="0,4"
|
||||
/>
|
||||
|
||||
<UniformGrid Columns="2" Rows="7">
|
||||
<CheckBox VerticalAlignment="Center" Content="Show Separate Window"
|
||||
IsChecked="{Binding Options.ToolsInSeparateWindow}"
|
||||
ToolTip="Show program output in separate command window instead of in the log. Enable this if you have a weaker system as there is an increased processing load otherwise." Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Protection Scan"
|
||||
IsChecked="{Binding Options.ScanForProtection}"
|
||||
ToolTip="Enable automatic checking for copy protection on dumped media" Margin="0,4,0,0"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Output Protection File"
|
||||
IsChecked="{Binding Options.OutputSeparateProtectionFile}" IsEnabled="{Binding Options.ScanForProtection}"
|
||||
ToolTip="Output protection information to a separate file" Margin="0,4,0,0"
|
||||
@@ -216,6 +236,11 @@
|
||||
ToolTip="Enable adding placeholder text in the output for required and optional fields" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Add Filename Suffix"
|
||||
IsChecked="{Binding Options.AddFilenameSuffix}"
|
||||
ToolTip="Enable appending the output filename to the generated files" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Output Submission JSON"
|
||||
IsChecked="{Binding Options.OutputSubmissionJSON}"
|
||||
ToolTip="Enable outputting a compressed JSON version of the submission info" Margin="0,4"
|
||||
@@ -230,6 +255,35 @@
|
||||
IsChecked="{Binding Options.CompressLogFiles}"
|
||||
ToolTip="Compress output log files to reduce space" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Delete Unnecessary Files"
|
||||
IsChecked="{Binding Options.DeleteUnnecessaryFiles}"
|
||||
ToolTip="Delete unnecesary output files to reduce space" Margin="0,4"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="Protection">
|
||||
<UniformGrid Columns="2" Rows="2">
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable Protection Scan"
|
||||
IsChecked="{Binding Options.ScanForProtection}"
|
||||
ToolTip="Enable automatic checking for copy protection on dumped media" Margin="0,4,0,0"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Scan Archive Contents"
|
||||
IsChecked="{Binding Options.ScanArchivesForProtection}"
|
||||
ToolTip="Enable scanning archive contents during protection scanning (may drastically increase scanning time but is more accurate)" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Include Executable Packers"
|
||||
IsChecked="{Binding Options.ScanPackersForProtection}"
|
||||
ToolTip="Include executable packers in outputted protections" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Include Debug Information"
|
||||
IsChecked="{Binding Options.IncludeDebugProtectionInformation}"
|
||||
ToolTip="Include debug information during protection scans" Margin="0,4"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
|
||||
@@ -252,181 +306,149 @@
|
||||
<Slider x:Name="DumpSpeedCDSlider" Grid.Row="0" Grid.Column="1" Minimum="1" Maximum="72" IsSnapToTickEnabled="True" TickPlacement="BottomRight"
|
||||
Ticks="{Binding Source={x:Static core:Constants.SpeedsForCDAsCollection}}"
|
||||
Value="{Binding Options.PreferredDumpSpeedCD}" />
|
||||
<TextBox x:Name="DumpSpeedCDTextBox" Grid.Row="0" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" IsReadOnlyCaretVisible="False" VerticalAlignment="Center"
|
||||
<TextBox x:Name="DumpSpeedCDTextBox" Grid.Row="0" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" VerticalAlignment="Center"
|
||||
Text="{Binding ElementName=DumpSpeedCDSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" Background="LightGray" Foreground="Gray"/>
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Content="DVD" />
|
||||
<Slider x:Name="DumpSpeedDVDSlider" Grid.Row="1" Grid.Column="1" Minimum="1" Maximum="24" IsSnapToTickEnabled="True" TickPlacement="BottomRight"
|
||||
Ticks="{Binding Source={x:Static core:Constants.SpeedsForDVDAsCollection}}"
|
||||
Value="{Binding Options.PreferredDumpSpeedDVD}" />
|
||||
<TextBox x:Name="DumpSpeedDVDTextBox" Grid.Row="1" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" IsReadOnlyCaretVisible="False" VerticalAlignment="Center"
|
||||
<TextBox x:Name="DumpSpeedDVDTextBox" Grid.Row="1" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" VerticalAlignment="Center"
|
||||
Text="{Binding ElementName=DumpSpeedDVDSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" Background="LightGray" Foreground="Gray"/>
|
||||
|
||||
<Label Grid.Row="2" Grid.Column="0" Content="HD-DVD" />
|
||||
<Slider x:Name="DumpSpeedHDDVDSlider" Grid.Row="2" Grid.Column="1" Minimum="1" Maximum="24" IsSnapToTickEnabled="True" TickPlacement="BottomRight"
|
||||
Ticks="{Binding Source={x:Static core:Constants.SpeedsForHDDVDAsCollection}}"
|
||||
Value="{Binding Options.PreferredDumpSpeedHDDVD}" />
|
||||
<TextBox x:Name="DumpSpeedHDDVDTextBox" Grid.Row="2" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" IsReadOnlyCaretVisible="False" VerticalAlignment="Center"
|
||||
<TextBox x:Name="DumpSpeedHDDVDTextBox" Grid.Row="2" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" VerticalAlignment="Center"
|
||||
Text="{Binding ElementName=DumpSpeedHDDVDSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" Background="LightGray" Foreground="Gray"/>
|
||||
|
||||
<Label Grid.Row="3" Grid.Column="0" Content="BD" />
|
||||
<Slider x:Name="DumpSpeedBDSlider" Grid.Row="3" Grid.Column="1" Minimum="1" Maximum="16" IsSnapToTickEnabled="True" TickPlacement="BottomRight"
|
||||
Ticks="{Binding Source={x:Static core:Constants.SpeedsForBDAsCollection}}"
|
||||
Value="{Binding Options.PreferredDumpSpeedBD}" />
|
||||
<TextBox x:Name="DumpSpeedBDTextBox" Grid.Row="3" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" IsReadOnlyCaretVisible="False" VerticalAlignment="Center"
|
||||
<TextBox x:Name="DumpSpeedBDTextBox" Grid.Row="3" Grid.Column="2" Width="22" Height="22" TextAlignment="Center" IsReadOnly="True" VerticalAlignment="Center"
|
||||
Text="{Binding ElementName=DumpSpeedBDSlider, Path=Value, UpdateSourceTrigger=PropertyChanged}" Background="LightGray" Foreground="Gray"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Protection Scanning" Style="{DynamicResource CustomTabItemStyle}">
|
||||
<TabItem Header="Programs" Style="{DynamicResource CustomTabItemStyle}">
|
||||
<StackPanel>
|
||||
<UniformGrid Columns="2" Rows="2">
|
||||
<CheckBox VerticalAlignment="Center" Content="Scan Archive Contents"
|
||||
IsChecked="{Binding Options.ScanArchivesForProtection}"
|
||||
ToolTip="Enable scanning archive contents during protection scanning (may drastically increase scanning time but is more accurate)" Margin="0,4"
|
||||
/>
|
||||
<GroupBox Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="Aaru">
|
||||
<UniformGrid Columns="2" Rows="3">
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable Debug Output"
|
||||
IsChecked="{Binding Options.AaruEnableDebug}"
|
||||
ToolTip="Enable debug output in logs" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Include Executable Packers"
|
||||
IsChecked="{Binding Options.ScanPackersForProtection}"
|
||||
ToolTip="Include executable packers in outputted protections" Margin="0,4"
|
||||
/>
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable Verbose Output"
|
||||
IsChecked="{Binding Options.AaruEnableVerbose}"
|
||||
ToolTip="Enable verbose output in logs" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Include Debug Information"
|
||||
IsChecked="{Binding Options.IncludeDebugProtectionInformation}"
|
||||
ToolTip="Include debug information during protection scans" Margin="0,4"
|
||||
/>
|
||||
</UniformGrid>
|
||||
<CheckBox VerticalAlignment="Center" Content="Force Dumping"
|
||||
IsChecked="{Binding Options.AaruForceDumping}"
|
||||
ToolTip="Enable forcing dump even if there are issues" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Strip Personal Data"
|
||||
IsChecked="{Binding Options.AaruStripPersonalData}"
|
||||
ToolTip="Enable stripping of personally identifiable information from metadata" Margin="0,4,0,0"
|
||||
/>
|
||||
|
||||
<Label Content="Reread Tries:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
|
||||
<TextBox VerticalAlignment="Center" VerticalContentAlignment="Center"
|
||||
Text="{Binding Options.AaruRereadCount}"
|
||||
ToolTip="Specifies how many rereads are attempted for sector and subchannel errors"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="DiscImageCreator">
|
||||
<UniformGrid Columns="2" Rows="6">
|
||||
<CheckBox VerticalAlignment="Center" Content="Quiet Mode"
|
||||
IsChecked="{Binding Options.DICQuietMode}"
|
||||
ToolTip="Disable sounds (beeps) during and after operations" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Paranoid Mode"
|
||||
IsChecked="{Binding Options.DICParanoidMode}"
|
||||
ToolTip="Enable pedantic and super-safe flags" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Use CMI Flag"
|
||||
IsChecked="{Binding Options.DICUseCMIFlag}"
|
||||
ToolTip="Enable the CMI flag for supported disc types (DVD/HD-DVD only)" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Reset After Dump"
|
||||
IsChecked="{Binding Options.DICResetDriveAfterDump}"
|
||||
ToolTip="Reset disc drives after dumping; useful for some older machines" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Multi-Sector Read"
|
||||
IsChecked="{Binding Options.DICMultiSectorRead}"
|
||||
ToolTip="Enable the /mr flag for BD drive dumping" Margin="0,4"
|
||||
/>
|
||||
<Label/> <!-- Empty label for padding -->
|
||||
|
||||
<Label Content="Multi-Sector Read Value:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
|
||||
<TextBox VerticalAlignment="Center" VerticalContentAlignment="Center"
|
||||
Text="{Binding Options.DICMultiSectorReadValue}" IsEnabled="{Binding Options.DICMultiSectorRead}"
|
||||
ToolTip="Set the default value for the /mr flag"
|
||||
/>
|
||||
|
||||
<Label Content="CD Reread Tries:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
|
||||
<TextBox VerticalAlignment="Center" VerticalContentAlignment="Center"
|
||||
Text="{Binding Options.DICRereadCount}"
|
||||
ToolTip="Specifies how many rereads are attempted on C2 error [CD only]"
|
||||
/>
|
||||
|
||||
<Label Content="DVD/HD-DVD/BD Reread Tries:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
|
||||
<TextBox VerticalAlignment="Center" VerticalContentAlignment="Center"
|
||||
Text="{Binding Options.DICDVDRereadCount}"
|
||||
ToolTip="Specifies how many rereads are attempted on read error [DVD/HD-DVD/BD only]"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="Redumper">
|
||||
<UniformGrid Columns="2" Rows="3">
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable Debug Output"
|
||||
IsChecked="{Binding Options.RedumperEnableDebug}"
|
||||
ToolTip="Enable debug output in logs" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable Verbose Output"
|
||||
IsChecked="{Binding Options.RedumperEnableVerbose}"
|
||||
ToolTip="Enable verbose output in logs" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable BE Drive Reading"
|
||||
IsChecked="{Binding Options.RedumperUseBEReading}"
|
||||
ToolTip="Enable setting drive read method to BE_CDDA by default" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Set Generic Drive Type"
|
||||
IsChecked="{Binding Options.RedumperUseGenericDriveType}"
|
||||
ToolTip="Enable setting drive type to Generic by default" Margin="0,4"
|
||||
/>
|
||||
|
||||
<Label Content="Reread Tries:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
|
||||
<TextBox VerticalAlignment="Center" VerticalContentAlignment="Center"
|
||||
Text="{Binding Options.RedumperRereadCount}"
|
||||
ToolTip="Specifies how many rereads are attempted on read error"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Aaru" Style="{DynamicResource CustomTabItemStyle}">
|
||||
<UniformGrid Columns="2" Rows="3">
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable Debug Output"
|
||||
IsChecked="{Binding Options.AaruEnableDebug}"
|
||||
ToolTip="Enable debug output in logs" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable Verbose Output"
|
||||
IsChecked="{Binding Options.AaruEnableVerbose}"
|
||||
ToolTip="Enable verbose output in logs" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Force Dumping"
|
||||
IsChecked="{Binding Options.AaruForceDumping}"
|
||||
ToolTip="Enable forcing dump even if there are issues" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Strip Personal Data"
|
||||
IsChecked="{Binding Options.AaruStripPersonalData}"
|
||||
ToolTip="Enable stripping of personally identifiable information from metadata" Margin="0,4,0,0"
|
||||
/>
|
||||
|
||||
<Label Content="Reread Tries:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
|
||||
<TextBox VerticalAlignment="Center" VerticalContentAlignment="Center"
|
||||
Text="{Binding Options.AaruRereadCount}"
|
||||
ToolTip="Specifies how many rereads are attempted for sector and subchannel errors"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="DiscImageCreator" Style="{DynamicResource CustomTabItemStyle}">
|
||||
<UniformGrid Columns="2" Rows="6">
|
||||
<CheckBox VerticalAlignment="Center" Content="Quiet Mode"
|
||||
IsChecked="{Binding Options.DICQuietMode}"
|
||||
ToolTip="Disable sounds (beeps) during and after operations" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Paranoid Mode"
|
||||
IsChecked="{Binding Options.DICParanoidMode}"
|
||||
ToolTip="Enable pedantic and super-safe flags" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Use CMI Flag"
|
||||
IsChecked="{Binding Options.DICUseCMIFlag}"
|
||||
ToolTip="Enable the CMI flag for supported disc types (DVD/HD-DVD only)" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Reset After Dump"
|
||||
IsChecked="{Binding Options.DICResetDriveAfterDump}"
|
||||
ToolTip="Reset disc drives after dumping; useful for some older machines" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Multi-Sector Read"
|
||||
IsChecked="{Binding Options.DICMultiSectorRead}"
|
||||
ToolTip="Enable the /mr flag for BD drive dumping" Margin="0,4"
|
||||
/>
|
||||
<Label/>
|
||||
<!-- Empty label for padding -->
|
||||
|
||||
<Label Content="Multi-Sector Read Value:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
|
||||
<TextBox VerticalAlignment="Center" VerticalContentAlignment="Center"
|
||||
Text="{Binding Options.DICMultiSectorReadValue}" IsEnabled="{Binding Options.DICMultiSectorRead}"
|
||||
ToolTip="Set the default value for the /mr flag"
|
||||
/>
|
||||
|
||||
<Label Content="CD Reread Tries:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
|
||||
<TextBox VerticalAlignment="Center" VerticalContentAlignment="Center"
|
||||
Text="{Binding Options.DICRereadCount}"
|
||||
ToolTip="Specifies how many rereads are attempted on C2 error [CD only]"
|
||||
/>
|
||||
|
||||
<Label Content="DVD/HD-DVD/BD Reread Tries:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
|
||||
<TextBox VerticalAlignment="Center" VerticalContentAlignment="Center"
|
||||
Text="{Binding Options.DICDVDRereadCount}"
|
||||
ToolTip="Specifies how many rereads are attempted on read error [DVD/HD-DVD/BD only]"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Redumper" Style="{DynamicResource CustomTabItemStyle}">
|
||||
<UniformGrid Columns="2" Rows="2">
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable Debug Output"
|
||||
IsChecked="{Binding Options.RedumperEnableDebug}"
|
||||
ToolTip="Enable debug output in logs" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable Verbose Output"
|
||||
IsChecked="{Binding Options.RedumperEnableVerbose}"
|
||||
ToolTip="Enable verbose output in logs" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Enable BE Drive Reading"
|
||||
IsChecked="{Binding Options.RedumperUseBEReading}"
|
||||
ToolTip="Enable setting drive read method to BE_CDDA by default" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Set Generic Drive Type"
|
||||
IsChecked="{Binding Options.RedumperUseGenericDriveType}"
|
||||
ToolTip="Enable setting drive type to Generic by default" Margin="0,4"
|
||||
/>
|
||||
|
||||
<Label Content="Reread Tries:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
|
||||
<TextBox VerticalAlignment="Center" VerticalContentAlignment="Center"
|
||||
Text="{Binding Options.RedumperRereadCount}"
|
||||
ToolTip="Specifies how many rereads are attempted on read error"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Logging" Style="{DynamicResource CustomTabItemStyle}">
|
||||
<UniformGrid Columns="2">
|
||||
<CheckBox VerticalAlignment="Center" Content="Verbose Logging"
|
||||
IsChecked="{Binding Options.VerboseLogging}"
|
||||
ToolTip="Display all logging statements" Margin="0,4"
|
||||
/>
|
||||
|
||||
<CheckBox VerticalAlignment="Center" Content="Auto-Open Log"
|
||||
IsChecked="{Binding Options.OpenLogWindowAtStartup}"
|
||||
ToolTip="Open the log panel when the program launches" Margin="0,4"
|
||||
/>
|
||||
</UniformGrid>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="Login Info" Style="{DynamicResource CustomTabItemStyle}">
|
||||
<StackPanel>
|
||||
<GroupBox Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="Redump Credentials">
|
||||
<GroupBox Margin="5,5,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Header="Redump">
|
||||
<UniformGrid Columns="5">
|
||||
<Label VerticalAlignment="Center" HorizontalAlignment="Right" Content="Username" />
|
||||
<TextBox x:Name="RedumpUsernameTextBox" Height="22" HorizontalAlignment="Stretch"
|
||||
@@ -442,7 +464,10 @@
|
||||
|
||||
<Label>
|
||||
<Label.Content>
|
||||
<TextBlock TextWrapping="Wrap"><Bold Foreground="Red">WARNING:</Bold> If you choose to enable validation and information retrieval, you are responsible for ensuring that all data populated matches your actual media. Some information may be marked to check for validity as a reminder, but all information should be subject to the same scrutiny.</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap">
|
||||
<Run FontWeight="Bold" Foreground="Red" Text="WARNING:" />
|
||||
<Run Text="If you choose to enable validation and information retrieval, you are responsible for ensuring that all data populated matches your actual media. Some information may be marked to check for validity as a reminder, but all information should be subject to the same scrutiny." />
|
||||
</TextBlock>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
</StackPanel>
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using MPF.Core.Data;
|
||||
using MPF.Core.UI.ViewModels;
|
||||
using WPFCustomMessageBox;
|
||||
|
||||
#pragma warning disable IDE1006 // Naming Styles
|
||||
|
||||
namespace MPF.UI.Core.Windows
|
||||
{
|
||||
/// <summary>
|
||||
@@ -19,26 +22,86 @@ namespace MPF.UI.Core.Windows
|
||||
/// </summary>
|
||||
public OptionsViewModel OptionsViewModel => DataContext as OptionsViewModel ?? new OptionsViewModel(new Options());
|
||||
|
||||
#if NET35
|
||||
|
||||
private System.Windows.Controls.Button? _AaruPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "AaruPathButton");
|
||||
private System.Windows.Controls.Button? _AcceptButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "AcceptButton");
|
||||
private System.Windows.Controls.Button? _CancelButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "CancelButton");
|
||||
private System.Windows.Controls.Button? _DefaultOutputPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "DefaultOutputPathButton");
|
||||
private System.Windows.Controls.Button? _DiscImageCreatorPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "DiscImageCreatorPathButton");
|
||||
private System.Windows.Controls.Button? _RedumperPathButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "RedumperPathButton");
|
||||
private System.Windows.Controls.Button? _RedumpLoginTestButton => ItemHelper.FindChild<System.Windows.Controls.Button>(this, "RedumpLoginTestButton");
|
||||
private PasswordBox? _RedumpPasswordBox => ItemHelper.FindChild<PasswordBox>(this, "RedumpPasswordBox");
|
||||
private System.Windows.Controls.TextBox? _RedumpUsernameTextBox => ItemHelper.FindChild<System.Windows.Controls.TextBox>(this, "RedumpUsernameTextBox");
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public OptionsWindow(Options options)
|
||||
{
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
InitializeComponent();
|
||||
#endif
|
||||
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
DumpSpeedCDTextBox.IsReadOnlyCaretVisible = false;
|
||||
DumpSpeedDVDTextBox.IsReadOnlyCaretVisible = false;
|
||||
DumpSpeedHDDVDTextBox.IsReadOnlyCaretVisible = false;
|
||||
DumpSpeedBDTextBox.IsReadOnlyCaretVisible = false;
|
||||
#endif
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
var chrome = new System.Windows.Shell.WindowChrome
|
||||
{
|
||||
CaptionHeight = 0,
|
||||
ResizeBorderThickness = new Thickness(0),
|
||||
};
|
||||
System.Windows.Shell.WindowChrome.SetWindowChrome(this, chrome);
|
||||
#endif
|
||||
DataContext = new OptionsViewModel(options);
|
||||
|
||||
// Set initial value for binding
|
||||
#if NET35
|
||||
_RedumpPasswordBox!.Password = options.RedumpPassword;
|
||||
#else
|
||||
RedumpPasswordBox.Password = options.RedumpPassword;
|
||||
#endif
|
||||
|
||||
// Add handlers
|
||||
#if NET35
|
||||
_AaruPathButton!.Click += BrowseForPathClick;
|
||||
_DiscImageCreatorPathButton!.Click += BrowseForPathClick;
|
||||
_RedumperPathButton!.Click += BrowseForPathClick;
|
||||
_DefaultOutputPathButton!.Click += BrowseForPathClick;
|
||||
|
||||
_AcceptButton!.Click += OnAcceptClick;
|
||||
_CancelButton!.Click += OnCancelClick;
|
||||
_RedumpPasswordBox!.PasswordChanged += OnPasswordChanged;
|
||||
_RedumpLoginTestButton!.Click += OnRedumpTestClick;
|
||||
#else
|
||||
AaruPathButton.Click += BrowseForPathClick;
|
||||
DiscImageCreatorPathButton.Click += BrowseForPathClick;
|
||||
RedumperPathButton.Click += BrowseForPathClick;
|
||||
DefaultOutputPathButton.Click += BrowseForPathClick;
|
||||
|
||||
AcceptButton.Click += OnAcceptClick;
|
||||
CancelButton.Click += OnCancelClick;
|
||||
RedumpPasswordBox.PasswordChanged += OnPasswordChanged;
|
||||
RedumpLoginTestButton.Click += OnRedumpTestClick;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handler for OptionsWindow OnContentRendered event
|
||||
/// </summary>
|
||||
protected override void OnContentRendered(EventArgs e)
|
||||
{
|
||||
base.OnContentRendered(e);
|
||||
|
||||
// Set the window title
|
||||
OptionsViewModel.Title = this.Title;
|
||||
}
|
||||
|
||||
#region UI Commands
|
||||
@@ -46,22 +109,14 @@ namespace MPF.UI.Core.Windows
|
||||
/// <summary>
|
||||
/// Browse and set a path based on the invoking button
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private void BrowseForPath(Window parent, System.Windows.Controls.Button button)
|
||||
#else
|
||||
private void BrowseForPath(Window parent, System.Windows.Controls.Button? button)
|
||||
#endif
|
||||
{
|
||||
// If the button is null, we can't do anything
|
||||
if (button == null)
|
||||
return;
|
||||
|
||||
// Strips button prefix to obtain the setting name
|
||||
#if NET48
|
||||
string pathSettingName = button.Name.Substring(0, button.Name.IndexOf("Button"));
|
||||
#else
|
||||
string pathSettingName = button.Name[..button.Name.IndexOf("Button")];
|
||||
#endif
|
||||
|
||||
// TODO: hack for now, then we'll see
|
||||
bool shouldBrowseForPath = pathSettingName == "DefaultOutputPath";
|
||||
@@ -118,30 +173,18 @@ namespace MPF.UI.Core.Windows
|
||||
/// </summary>
|
||||
/// <param name="name">Setting name to find</param>
|
||||
/// <returns>TextBox for that setting</returns>
|
||||
#if NET48
|
||||
private static System.Windows.Controls.TextBox TextBoxForPathSetting(Window parent, string name) =>
|
||||
#else
|
||||
private static System.Windows.Controls.TextBox? TextBoxForPathSetting(Window parent, string name) =>
|
||||
#endif
|
||||
parent.FindName(name + "TextBox") as System.Windows.Controls.TextBox;
|
||||
|
||||
/// <summary>
|
||||
/// Create an open folder dialog box
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private static FolderBrowserDialog CreateFolderBrowserDialog() => new FolderBrowserDialog();
|
||||
#else
|
||||
private static FolderBrowserDialog CreateFolderBrowserDialog() => new();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Create an open file dialog box
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private static OpenFileDialog CreateOpenFileDialog(string initialDirectory)
|
||||
#else
|
||||
private static OpenFileDialog CreateOpenFileDialog(string? initialDirectory)
|
||||
#endif
|
||||
{
|
||||
return new OpenFileDialog()
|
||||
{
|
||||
@@ -155,14 +198,10 @@ namespace MPF.UI.Core.Windows
|
||||
/// <summary>
|
||||
/// Test Redump credentials for validity
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private void ValidateRedumpCredentials()
|
||||
#else
|
||||
private async Task ValidateRedumpCredentials()
|
||||
#endif
|
||||
{
|
||||
#if NET48
|
||||
(bool? success, string message) = OptionsViewModel.TestRedumpLogin(RedumpUsernameTextBox.Text, RedumpPasswordBox.Password);
|
||||
#if NET35
|
||||
(bool? success, string? message) = await OptionsViewModel.TestRedumpLogin(_RedumpUsernameTextBox!.Text, _RedumpPasswordBox!.Password);
|
||||
#else
|
||||
(bool? success, string? message) = await OptionsViewModel.TestRedumpLogin(RedumpUsernameTextBox.Text, RedumpPasswordBox.Password);
|
||||
#endif
|
||||
@@ -208,18 +247,26 @@ namespace MPF.UI.Core.Windows
|
||||
/// </summary>
|
||||
private void OnPasswordChanged(object sender, EventArgs e)
|
||||
{
|
||||
#if NET35
|
||||
OptionsViewModel.Options.RedumpPassword = _RedumpPasswordBox!.Password;
|
||||
#else
|
||||
OptionsViewModel.Options.RedumpPassword = RedumpPasswordBox.Password;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test Redump credentials for validity
|
||||
/// </summary>
|
||||
#if NET48
|
||||
private void OnRedumpTestClick(object sender, EventArgs e) => ValidateRedumpCredentials();
|
||||
#if NET40
|
||||
private void OnRedumpTestClick(object sender, EventArgs e)
|
||||
{
|
||||
var validateTask = ValidateRedumpCredentials();
|
||||
validateTask.Wait();
|
||||
}
|
||||
#else
|
||||
private async void OnRedumpTestClick(object sender, EventArgs e) => await ValidateRedumpCredentials();
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
WindowStartupLocation="CenterOwner" ResizeMode="CanMinimize" SizeToContent="Height"
|
||||
BorderBrush="DarkGray" BorderThickness="2">
|
||||
|
||||
<WindowChrome.WindowChrome>
|
||||
<WindowChrome CaptionHeight="0" ResizeBorderThickness="0" />
|
||||
</WindowChrome.WindowChrome>
|
||||
|
||||
<Grid>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Grid Margin="0,10,0,0">
|
||||
@@ -29,7 +25,7 @@
|
||||
<Image Grid.Column="0" Source="/Images/Icon.ico" Height="20" Width="20" Margin="1" />
|
||||
<Label Grid.Column="1" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" MouseDown="TitleMouseDown">
|
||||
<Label.Content>
|
||||
<TextBlock TextAlignment="Center"><Bold>Ring Code Guide</Bold></TextBlock>
|
||||
<Run FontWeight="Bold" BaselineAlignment="Center" Text="Ring Code Guide" />
|
||||
</Label.Content>
|
||||
<Label.ContextMenu>
|
||||
<ContextMenu Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
|
||||
@@ -85,22 +81,34 @@
|
||||
RenderOptions.BitmapScalingMode="HighQuality" />
|
||||
<Label Grid.Row="1">
|
||||
<Label.Content>
|
||||
<TextBlock><Bold Foreground="Red">1. Mastering Ring:</Bold> Sony DADC<tab>A0100368905-0101<tab>13</TextBlock>
|
||||
<TextBlock>
|
||||
<Run FontWeight="Bold" Foreground="Red" Text="1. Mastering Ring:" />
|
||||
<Run Text=" Sony DADC<tab>A0100368905-0101<tab>13" />
|
||||
</TextBlock>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
<Label Grid.Row="2">
|
||||
<Label.Content>
|
||||
<TextBlock><Bold Foreground="Green">2. Mastering SID:</Bold> IFPI L553</TextBlock>
|
||||
<TextBlock>
|
||||
<Run FontWeight="Bold" Foreground="Green" Text="2. Mastering SID:" />
|
||||
<Run Text=" IFPI L553" />
|
||||
</TextBlock>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
<Label Grid.Row="3">
|
||||
<Label.Content>
|
||||
<TextBlock><Bold Foreground="Purple">3. Toolstamp/Mastering Code:</Bold> A2</TextBlock>
|
||||
<TextBlock>
|
||||
<Run FontWeight="Bold" Foreground="Purple" Text="3. Toolstamp/Mastering Code:" />
|
||||
<Run Text=" A2" />
|
||||
</TextBlock>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
<Label Grid.Row="4">
|
||||
<Label.Content>
|
||||
<TextBlock><Bold Foreground="LightBlue">4. Mould SID:</Bold> IFPI 94V1</TextBlock>
|
||||
<TextBlock>
|
||||
<Run FontWeight="Bold" Foreground="LightBlue" Text="4. Mould SID:" />
|
||||
<Run Text=" IFPI 94V1" />
|
||||
</TextBlock>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
</Grid>
|
||||
@@ -126,27 +134,42 @@
|
||||
RenderOptions.BitmapScalingMode="HighQuality" />
|
||||
<Label Grid.Row="1">
|
||||
<Label.Content>
|
||||
<TextBlock><Bold Foreground="Red">1. Outer Mastering Ring:</Bold> IM01501A-L1<tab>03 +<tab>+</TextBlock>
|
||||
<TextBlock>
|
||||
<Run FontWeight="Bold" Foreground="Red" Text="1. Outer Mastering Ring:" />
|
||||
<Run Text=" IM01501A-L1<tab>03 +<tab>+" />
|
||||
</TextBlock>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
<Label Grid.Row="2">
|
||||
<Label.Content>
|
||||
<TextBlock><Bold Foreground="Green">2. Inner Mastering Ring:</Bold> IM01501A-L0<tab>01 +<tab>+</TextBlock>
|
||||
<TextBlock>
|
||||
<Run FontWeight="Bold" Foreground="Green" Text="2. Inner Mastering Ring:" />
|
||||
<Run Text=" IM01501A-L0<tab>01 +<tab>+" />
|
||||
</TextBlock>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
<Label Grid.Row="3">
|
||||
<Label.Content>
|
||||
<TextBlock><Bold Foreground="Purple">3. Outer Mastering SID:</Bold> IFPI LB48</TextBlock>
|
||||
<TextBlock>
|
||||
<Run FontWeight="Bold" Foreground="Purple" Text="3. Outer Mastering SID:" />
|
||||
<Run Text=" IFPI LB48" />
|
||||
</TextBlock>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
<Label Grid.Row="4">
|
||||
<Label.Content>
|
||||
<TextBlock><Bold Foreground="LightBlue">4. Inner Mastering SID:</Bold> IFPI LB48</TextBlock>
|
||||
<TextBlock>
|
||||
<Run FontWeight="Bold" Foreground="LightBlue" Text="4. Inner Mastering SID:" />
|
||||
<Run Text=" IFPI LB48" />
|
||||
</TextBlock>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
<Label Grid.Row="5">
|
||||
<Label.Content>
|
||||
<TextBlock><Bold>Note:</Bold> See the 1-Layer guide for more details on additional fields</TextBlock>
|
||||
<TextBlock>
|
||||
<Run FontWeight="Bold" Text="Note:" />
|
||||
<Run Text=" See the 1-Layer guide for more details on additional fields" />
|
||||
</TextBlock>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
</Grid>
|
||||
|
||||
@@ -5,6 +5,20 @@
|
||||
/// </summary>
|
||||
public partial class RingCodeGuideWindow : WindowBase
|
||||
{
|
||||
public RingCodeGuideWindow() => InitializeComponent();
|
||||
public RingCodeGuideWindow()
|
||||
{
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
InitializeComponent();
|
||||
#endif
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
var chrome = new System.Windows.Shell.WindowChrome
|
||||
{
|
||||
CaptionHeight = 0,
|
||||
ResizeBorderThickness = new System.Windows.Thickness(0),
|
||||
};
|
||||
System.Windows.Shell.WindowChrome.SetWindowChrome(this, chrome);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
MPF.sln
2
MPF.sln
@@ -17,7 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
.github\ISSUE_TEMPLATE\informational.md = .github\ISSUE_TEMPLATE\informational.md
|
||||
.github\ISSUE_TEMPLATE\issue-report.md = .github\ISSUE_TEMPLATE\issue-report.md
|
||||
publish-nix.sh = publish-nix.sh
|
||||
publish-win.bat = publish-win.bat
|
||||
publish-win.ps1 = publish-win.ps1
|
||||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
||||
197
MPF/App.xaml
197
MPF/App.xaml
@@ -1,7 +1,6 @@
|
||||
<Application
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
|
||||
xmlns:windows="clr-namespace:MPF.UI.Core.Windows;assembly=MPF.UI.Core"
|
||||
x:Class="MPF.App">
|
||||
<Application.MainWindow>
|
||||
@@ -205,140 +204,7 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}">
|
||||
<Grid x:Name="templateRoot" SnapsToDevicePixels="true">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
|
||||
<Themes:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
|
||||
<Border x:Name="dropDownBorder" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
|
||||
<ScrollViewer x:Name="DropDownScrollViewer">
|
||||
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
|
||||
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
|
||||
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
|
||||
</Canvas>
|
||||
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Themes:SystemDropShadowChrome>
|
||||
</Popup>
|
||||
<ToggleButton x:Name="toggleButton" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{DynamicResource ComboBoxToggleButton}"/>
|
||||
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Content="{TemplateBinding SelectionBoxItem}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
|
||||
<Setter Property="Margin" TargetName="shadow" Value="0,0,5,5"/>
|
||||
<Setter Property="Color" TargetName="shadow" Value="#71000000"/>
|
||||
</Trigger>
|
||||
<Trigger Property="HasItems" Value="false">
|
||||
<Setter Property="Height" TargetName="dropDownBorder" Value="95"/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsGrouping" Value="true"/>
|
||||
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
|
||||
<Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
|
||||
<Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
<SolidColorBrush x:Key="TextBox.Static.Background" Color="#FFFFFFFF"/>
|
||||
<Style x:Key="ComboBoxEditableTextBox" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="true"/>
|
||||
<Setter Property="AllowDrop" Value="true"/>
|
||||
<Setter Property="MinWidth" Value="0"/>
|
||||
<Setter Property="MinHeight" Value="0"/>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<ScrollViewer x:Name="PART_ContentHost" Background="Transparent" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
|
||||
<Grid x:Name="templateRoot" SnapsToDevicePixels="true">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
|
||||
<Themes:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
|
||||
<Border x:Name="dropDownBorder" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
|
||||
<ScrollViewer x:Name="DropDownScrollViewer">
|
||||
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
|
||||
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
|
||||
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/>
|
||||
</Canvas>
|
||||
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Themes:SystemDropShadowChrome>
|
||||
</Popup>
|
||||
<ToggleButton x:Name="toggleButton" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{DynamicResource ComboBoxToggleButton}"/>
|
||||
<Border x:Name="border" Background="{DynamicResource TextBox.Static.Background}" Margin="{TemplateBinding BorderThickness}">
|
||||
<TextBox x:Name="PART_EditableTextBox" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" Margin="{TemplateBinding Padding}" Style="{DynamicResource ComboBoxEditableTextBox}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocusWithin" Value="true">
|
||||
<Setter Property="Foreground" Value="Black"/>
|
||||
</Trigger>
|
||||
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
|
||||
<Setter Property="Margin" TargetName="shadow" Value="0,0,5,5"/>
|
||||
<Setter Property="Color" TargetName="shadow" Value="#71000000"/>
|
||||
</Trigger>
|
||||
<Trigger Property="HasItems" Value="false">
|
||||
<Setter Property="Height" TargetName="dropDownBorder" Value="95"/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsGrouping" Value="true"/>
|
||||
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
|
||||
<Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
|
||||
<Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
<Style x:Key="CustomComboBoxStyle" TargetType="{x:Type ComboBox}">
|
||||
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource ComboBox.Static.Background}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ComboBox.Static.Border}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
|
||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
|
||||
<Setter Property="Padding" Value="6,3,5,3"/>
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
||||
<Setter Property="Template" Value="{DynamicResource ComboBoxTemplate}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsEditable" Value="true">
|
||||
<Setter Property="IsTabStop" Value="false"/>
|
||||
<Setter Property="Padding" Value="2"/>
|
||||
<Setter Property="Template" Value="{DynamicResource ComboBoxEditableTemplate}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!-- ContextMenu -->
|
||||
<SolidColorBrush x:Key="ContextMenu.Static.Border" Color="#FF888888"/>
|
||||
@@ -384,7 +250,8 @@
|
||||
<Popup x:Name="PART_Popup" AllowsTransparency="True" Focusable="False" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" Placement="Bottom">
|
||||
<Border x:Name="SubMenuBorder" BorderBrush="{DynamicResource MenuItem.SubMenu.Border}" BorderThickness="1" Background="{DynamicResource MenuItem.SubMenu.Background}" Padding="2">
|
||||
<ScrollViewer x:Name="SubMenuScrollViewer" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
|
||||
<Grid RenderOptions.ClearTypeHint="Enabled">
|
||||
<!--<Grid RenderOptions.ClearTypeHint="Enabled">--> <!-- Not supported in .NET Framework 3.5 -->
|
||||
<Grid> <!-- Not supported in .NET Framework 3.5 -->
|
||||
<Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
|
||||
<Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=SubMenuBorder}" Height="{Binding ActualHeight, ElementName=SubMenuBorder}" Width="{Binding ActualWidth, ElementName=SubMenuBorder}"/>
|
||||
</Canvas>
|
||||
@@ -426,66 +293,6 @@
|
||||
<SolidColorBrush x:Key="ProgressBar.Progress" Color="#FF06B025"/>
|
||||
<SolidColorBrush x:Key="ProgressBar.Background" Color="#FFE6E6E6"/>
|
||||
<SolidColorBrush x:Key="ProgressBar.Border" Color="#FFBCBCBC"/>
|
||||
<Style x:Key="CustomProgressBarStyle" TargetType="{x:Type ProgressBar}">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ProgressBar.Progress}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource ProgressBar.Background}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ProgressBar.Border}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ProgressBar}">
|
||||
<Grid x:Name="TemplateRoot">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Determinate"/>
|
||||
<VisualState x:Name="Indeterminate">
|
||||
<Storyboard RepeatBehavior="Forever">
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="Animation">
|
||||
<EasingDoubleKeyFrame KeyTime="0" Value="0.25"/>
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.25"/>
|
||||
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="0.25"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransformOrigin)" Storyboard.TargetName="Animation">
|
||||
<EasingPointKeyFrame KeyTime="0" Value="-0.5,0.5"/>
|
||||
<EasingPointKeyFrame KeyTime="0:0:1" Value="0.5,0.5"/>
|
||||
<EasingPointKeyFrame KeyTime="0:0:2" Value="1.5,0.5"/>
|
||||
</PointAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"/>
|
||||
<Rectangle x:Name="PART_Track"/>
|
||||
<Grid x:Name="PART_Indicator" ClipToBounds="true" HorizontalAlignment="Left">
|
||||
<Rectangle x:Name="Indicator" Fill="{TemplateBinding Foreground}"/>
|
||||
<Rectangle x:Name="Animation" Fill="{TemplateBinding Foreground}" RenderTransformOrigin="0.5,0.5">
|
||||
<Rectangle.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform/>
|
||||
<SkewTransform/>
|
||||
<RotateTransform/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="Orientation" Value="Vertical">
|
||||
<Setter Property="LayoutTransform" TargetName="TemplateRoot">
|
||||
<Setter.Value>
|
||||
<RotateTransform Angle="-90"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsIndeterminate" Value="true">
|
||||
<Setter Property="Visibility" TargetName="Indicator" Value="Collapsed"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- ScrollViewer -->
|
||||
<SolidColorBrush x:Key="ScrollViewer.ScrollBar.Background" Color="LightGray"/>
|
||||
|
||||
493
MPF/App.xaml.cs
493
MPF/App.xaml.cs
@@ -1,7 +1,496 @@
|
||||
namespace MPF
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace MPF
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : System.Windows.Application { }
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
#if NET35_OR_GREATER || NETCOREAPP
|
||||
|
||||
#region ControlTemplates
|
||||
|
||||
/// <summary>
|
||||
/// ComboBoxTemplate ControlTemplate XAML (.NET Framework 4.0 and above)
|
||||
/// </summary>
|
||||
private const string _comboBoxTemplateDefault = @"<ControlTemplate TargetType=""{x:Type ComboBox}"">
|
||||
<Grid x:Name=""templateRoot"" SnapsToDevicePixels=""true"">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width=""*""/>
|
||||
<ColumnDefinition MinWidth=""{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"" Width=""0""/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Popup x:Name=""PART_Popup"" AllowsTransparency=""true"" Grid.ColumnSpan=""2"" IsOpen=""{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"" Margin=""1"" PopupAnimation=""{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"" Placement=""Bottom"">
|
||||
<themes:SystemDropShadowChrome x:Name=""shadow"" Color=""Transparent"" MaxHeight=""{TemplateBinding MaxDropDownHeight}"" MinWidth=""{Binding ActualWidth, ElementName=templateRoot}"">
|
||||
<Border x:Name=""dropDownBorder"" BorderBrush=""{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}"" BorderThickness=""1"" Background=""{DynamicResource {x:Static SystemColors.WindowBrushKey}}"">
|
||||
<ScrollViewer x:Name=""DropDownScrollViewer"">
|
||||
<Grid x:Name=""grid"" RenderOptions.ClearTypeHint=""Enabled"">
|
||||
<Canvas x:Name=""canvas"" HorizontalAlignment=""Left"" Height=""0"" VerticalAlignment=""Top"" Width=""0"">
|
||||
<Rectangle x:Name=""opaqueRect"" Fill=""{Binding Background, ElementName=dropDownBorder}"" Height=""{Binding ActualHeight, ElementName=dropDownBorder}"" Width=""{Binding ActualWidth, ElementName=dropDownBorder}""/>
|
||||
</Canvas>
|
||||
<ItemsPresenter x:Name=""ItemsPresenter"" KeyboardNavigation.DirectionalNavigation=""Contained"" SnapsToDevicePixels=""{TemplateBinding SnapsToDevicePixels}""/>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</themes:SystemDropShadowChrome>
|
||||
</Popup>
|
||||
<ToggleButton x:Name=""toggleButton"" BorderBrush=""{TemplateBinding BorderBrush}"" BorderThickness=""{TemplateBinding BorderThickness}"" Background=""{TemplateBinding Background}"" Grid.ColumnSpan=""2"" IsChecked=""{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"" Style=""{DynamicResource ComboBoxToggleButton}""/>
|
||||
<ContentPresenter x:Name=""contentPresenter"" ContentTemplate=""{TemplateBinding SelectionBoxItemTemplate}"" ContentTemplateSelector=""{TemplateBinding ItemTemplateSelector}"" Content=""{TemplateBinding SelectionBoxItem}"" ContentStringFormat=""{TemplateBinding SelectionBoxItemStringFormat}"" HorizontalAlignment=""{TemplateBinding HorizontalContentAlignment}"" IsHitTestVisible=""false"" Margin=""{TemplateBinding Padding}"" SnapsToDevicePixels=""{TemplateBinding SnapsToDevicePixels}"" VerticalAlignment=""{TemplateBinding VerticalContentAlignment}""/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property=""HasDropShadow"" SourceName=""PART_Popup"" Value=""true"">
|
||||
<Setter Property=""Margin"" TargetName=""shadow"" Value=""0,0,5,5""/>
|
||||
<Setter Property=""Color"" TargetName=""shadow"" Value=""#71000000""/>
|
||||
</Trigger>
|
||||
<Trigger Property=""HasItems"" Value=""false"">
|
||||
<Setter Property=""Height"" TargetName=""dropDownBorder"" Value=""95""/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property=""IsGrouping"" Value=""true""/>
|
||||
<Condition Property=""VirtualizingPanel.IsVirtualizingWhenGrouping"" Value=""false""/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property=""ScrollViewer.CanContentScroll"" Value=""false""/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property=""ScrollViewer.CanContentScroll"" SourceName=""DropDownScrollViewer"" Value=""false"">
|
||||
<Setter Property=""Canvas.Top"" TargetName=""opaqueRect"" Value=""{Binding VerticalOffset, ElementName=DropDownScrollViewer}""/>
|
||||
<Setter Property=""Canvas.Left"" TargetName=""opaqueRect"" Value=""{Binding HorizontalOffset, ElementName=DropDownScrollViewer}""/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>";
|
||||
|
||||
/// <summary>
|
||||
/// ComboBoxTemplate ControlTemplate XAML (.NET Framework 3.5)
|
||||
/// </summary>
|
||||
private const string _comboBoxTemplateNet35 = @"<ControlTemplate TargetType=""{x:Type ComboBox}"">
|
||||
<Grid x:Name=""templateRoot"" SnapsToDevicePixels=""true"">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width=""*""/>
|
||||
<ColumnDefinition MinWidth=""{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"" Width=""0""/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Popup x:Name=""PART_Popup"" AllowsTransparency=""true"" Grid.ColumnSpan=""2"" IsOpen=""{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"" Margin=""1"" PopupAnimation=""{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"" Placement=""Bottom"">
|
||||
<Border x:Name=""dropDownBorder"" BorderBrush=""{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}"" BorderThickness=""1"" Background=""{DynamicResource {x:Static SystemColors.WindowBrushKey}}"">
|
||||
<ScrollViewer x:Name=""DropDownScrollViewer"">
|
||||
<Grid x:Name=""grid"">
|
||||
<Canvas x:Name=""canvas"" HorizontalAlignment=""Left"" Height=""0"" VerticalAlignment=""Top"" Width=""0"">
|
||||
<Rectangle x:Name=""opaqueRect"" Fill=""{Binding Background, ElementName=dropDownBorder}"" Height=""{Binding ActualHeight, ElementName=dropDownBorder}"" Width=""{Binding ActualWidth, ElementName=dropDownBorder}""/>
|
||||
</Canvas>
|
||||
<ItemsPresenter x:Name=""ItemsPresenter"" KeyboardNavigation.DirectionalNavigation=""Contained"" SnapsToDevicePixels=""{TemplateBinding SnapsToDevicePixels}""/>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Popup>
|
||||
<ToggleButton x:Name=""toggleButton"" BorderBrush=""{TemplateBinding BorderBrush}"" BorderThickness=""{TemplateBinding BorderThickness}"" Background=""{TemplateBinding Background}"" Grid.ColumnSpan=""2"" IsChecked=""{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"" Style=""{DynamicResource ComboBoxToggleButton}""/>
|
||||
<ContentPresenter x:Name=""contentPresenter"" ContentTemplate=""{TemplateBinding SelectionBoxItemTemplate}"" ContentTemplateSelector=""{TemplateBinding ItemTemplateSelector}"" Content=""{TemplateBinding SelectionBoxItem}"" ContentStringFormat=""{TemplateBinding SelectionBoxItemStringFormat}"" HorizontalAlignment=""{TemplateBinding HorizontalContentAlignment}"" IsHitTestVisible=""false"" Margin=""{TemplateBinding Padding}"" SnapsToDevicePixels=""{TemplateBinding SnapsToDevicePixels}"" VerticalAlignment=""{TemplateBinding VerticalContentAlignment}""/>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property=""HasItems"" Value=""false"">
|
||||
<Setter Property=""Height"" TargetName=""dropDownBorder"" Value=""95""/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property=""IsGrouping"" Value=""true""/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property=""ScrollViewer.CanContentScroll"" Value=""false""/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property=""ScrollViewer.CanContentScroll"" SourceName=""DropDownScrollViewer"" Value=""false"">
|
||||
<Setter Property=""Canvas.Top"" TargetName=""opaqueRect"" Value=""{Binding VerticalOffset, ElementName=DropDownScrollViewer}""/>
|
||||
<Setter Property=""Canvas.Left"" TargetName=""opaqueRect"" Value=""{Binding HorizontalOffset, ElementName=DropDownScrollViewer}""/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>";
|
||||
|
||||
/// <summary>
|
||||
/// ComboBoxEditableTemplate ControlTemplate XAML (.NET Framework 4.0 and above)
|
||||
/// </summary>
|
||||
private const string _comboBoxEditableTemplateDefault = @"<ControlTemplate TargetType=""{x:Type ComboBox}"">
|
||||
<Grid x:Name=""templateRoot"" SnapsToDevicePixels=""true"">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width=""*""/>
|
||||
<ColumnDefinition MinWidth=""{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"" Width=""0""/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Popup x:Name=""PART_Popup"" AllowsTransparency=""true"" Grid.ColumnSpan=""2"" IsOpen=""{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"" PopupAnimation=""{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"" Placement=""Bottom"">
|
||||
<themes:SystemDropShadowChrome x:Name=""shadow"" Color=""Transparent"" MaxHeight=""{TemplateBinding MaxDropDownHeight}"" MinWidth=""{Binding ActualWidth, ElementName=templateRoot}"">
|
||||
<Border x:Name=""dropDownBorder"" BorderBrush=""{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}"" BorderThickness=""1"" Background=""{DynamicResource {x:Static SystemColors.WindowBrushKey}}"">
|
||||
<ScrollViewer x:Name=""DropDownScrollViewer"">
|
||||
<Grid x:Name=""grid"" RenderOptions.ClearTypeHint=""Enabled"">
|
||||
<Canvas x:Name=""canvas"" HorizontalAlignment=""Left"" Height=""0"" VerticalAlignment=""Top"" Width=""0"">
|
||||
<Rectangle x:Name=""opaqueRect"" Fill=""{Binding Background, ElementName=dropDownBorder}"" Height=""{Binding ActualHeight, ElementName=dropDownBorder}"" Width=""{Binding ActualWidth, ElementName=dropDownBorder}""/>
|
||||
</Canvas>
|
||||
<ItemsPresenter x:Name=""ItemsPresenter"" KeyboardNavigation.DirectionalNavigation=""Contained"" SnapsToDevicePixels=""{TemplateBinding SnapsToDevicePixels}""/>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</themes:SystemDropShadowChrome>
|
||||
</Popup>
|
||||
<ToggleButton x:Name=""toggleButton"" BorderBrush=""{TemplateBinding BorderBrush}"" BorderThickness=""{TemplateBinding BorderThickness}"" Background=""{TemplateBinding Background}"" Grid.ColumnSpan=""2"" IsChecked=""{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"" Style=""{DynamicResource ComboBoxToggleButton}""/>
|
||||
<Border x:Name=""border"" Background=""{DynamicResource TextBox.Static.Background}"" Margin=""{TemplateBinding BorderThickness}"">
|
||||
<TextBox x:Name=""PART_EditableTextBox"" HorizontalContentAlignment=""{TemplateBinding HorizontalContentAlignment}"" IsReadOnly=""{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"" Margin=""{TemplateBinding Padding}"" Style=""{DynamicResource ComboBoxEditableTextBox}"" VerticalContentAlignment=""{TemplateBinding VerticalContentAlignment}""/>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property=""IsEnabled"" Value=""false"">
|
||||
<Setter Property=""Opacity"" TargetName=""border"" Value=""0.56""/>
|
||||
</Trigger>
|
||||
<Trigger Property=""IsKeyboardFocusWithin"" Value=""true"">
|
||||
<Setter Property=""Foreground"" Value=""Black""/>
|
||||
</Trigger>
|
||||
<Trigger Property=""HasDropShadow"" SourceName=""PART_Popup"" Value=""true"">
|
||||
<Setter Property=""Margin"" TargetName=""shadow"" Value=""0,0,5,5""/>
|
||||
<Setter Property=""Color"" TargetName=""shadow"" Value=""#71000000""/>
|
||||
</Trigger>
|
||||
<Trigger Property=""HasItems"" Value=""false"">
|
||||
<Setter Property=""Height"" TargetName=""dropDownBorder"" Value=""95""/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property=""IsGrouping"" Value=""true""/>
|
||||
<Condition Property=""VirtualizingPanel.IsVirtualizingWhenGrouping"" Value=""false""/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property=""ScrollViewer.CanContentScroll"" Value=""false""/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property=""ScrollViewer.CanContentScroll"" SourceName=""DropDownScrollViewer"" Value=""false"">
|
||||
<Setter Property=""Canvas.Top"" TargetName=""opaqueRect"" Value=""{Binding VerticalOffset, ElementName=DropDownScrollViewer}""/>
|
||||
<Setter Property=""Canvas.Left"" TargetName=""opaqueRect"" Value=""{Binding HorizontalOffset, ElementName=DropDownScrollViewer}""/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>";
|
||||
|
||||
/// <summary>
|
||||
/// ComboBoxEditableTemplate ControlTemplate XAML (.NET Framework 3.5)
|
||||
/// </summary>
|
||||
private const string _comboBoxEditableTemplateNet35 = @"<ControlTemplate TargetType=""{x:Type ComboBox}"">
|
||||
<Grid x:Name=""templateRoot"" SnapsToDevicePixels=""true"">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width=""*""/>
|
||||
<ColumnDefinition MinWidth=""{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"" Width=""0""/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Popup x:Name=""PART_Popup"" AllowsTransparency=""true"" Grid.ColumnSpan=""2"" IsOpen=""{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"" PopupAnimation=""{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"" Placement=""Bottom"">
|
||||
<Border x:Name=""dropDownBorder"" BorderBrush=""{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}"" BorderThickness=""1"" Background=""{DynamicResource {x:Static SystemColors.WindowBrushKey}}"">
|
||||
<ScrollViewer x:Name=""DropDownScrollViewer"">
|
||||
<Grid x:Name=""grid"">
|
||||
<Canvas x:Name=""canvas"" HorizontalAlignment=""Left"" Height=""0"" VerticalAlignment=""Top"" Width=""0"">
|
||||
<Rectangle x:Name=""opaqueRect"" Fill=""{Binding Background, ElementName=dropDownBorder}"" Height=""{Binding ActualHeight, ElementName=dropDownBorder}"" Width=""{Binding ActualWidth, ElementName=dropDownBorder}""/>
|
||||
</Canvas>
|
||||
<ItemsPresenter x:Name=""ItemsPresenter"" KeyboardNavigation.DirectionalNavigation=""Contained"" SnapsToDevicePixels=""{TemplateBinding SnapsToDevicePixels}""/>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Popup>
|
||||
<ToggleButton x:Name=""toggleButton"" BorderBrush=""{TemplateBinding BorderBrush}"" BorderThickness=""{TemplateBinding BorderThickness}"" Background=""{TemplateBinding Background}"" Grid.ColumnSpan=""2"" IsChecked=""{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"" Style=""{DynamicResource ComboBoxToggleButton}""/>
|
||||
<Border x:Name=""border"" Background=""{DynamicResource TextBox.Static.Background}"" Margin=""{TemplateBinding BorderThickness}"">
|
||||
<TextBox x:Name=""PART_EditableTextBox"" HorizontalContentAlignment=""{TemplateBinding HorizontalContentAlignment}"" IsReadOnly=""{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"" Margin=""{TemplateBinding Padding}"" Style=""{DynamicResource ComboBoxEditableTextBox}"" VerticalContentAlignment=""{TemplateBinding VerticalContentAlignment}""/>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property=""IsEnabled"" Value=""false"">
|
||||
<Setter Property=""Opacity"" TargetName=""border"" Value=""0.56""/>
|
||||
</Trigger>
|
||||
<Trigger Property=""IsKeyboardFocusWithin"" Value=""true"">
|
||||
<Setter Property=""Foreground"" Value=""Black""/>
|
||||
</Trigger>
|
||||
<Trigger Property=""HasItems"" Value=""false"">
|
||||
<Setter Property=""Height"" TargetName=""dropDownBorder"" Value=""95""/>
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property=""IsGrouping"" Value=""true""/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property=""ScrollViewer.CanContentScroll"" Value=""false""/>
|
||||
</MultiTrigger>
|
||||
<Trigger Property=""ScrollViewer.CanContentScroll"" SourceName=""DropDownScrollViewer"" Value=""false"">
|
||||
<Setter Property=""Canvas.Top"" TargetName=""opaqueRect"" Value=""{Binding VerticalOffset, ElementName=DropDownScrollViewer}""/>
|
||||
<Setter Property=""Canvas.Left"" TargetName=""opaqueRect"" Value=""{Binding HorizontalOffset, ElementName=DropDownScrollViewer}""/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Styles
|
||||
|
||||
/// <summary>
|
||||
/// ComboBoxEditableTextBox Style XAML (.NET Framework 4.0 and above)
|
||||
/// </summary>
|
||||
private const string _comboBoxEditableTextBoxStyleDefault = @"<Style TargetType=""{x:Type TextBox}"">
|
||||
<Setter Property=""OverridesDefaultStyle"" Value=""true""/>
|
||||
<Setter Property=""AllowDrop"" Value=""true""/>
|
||||
<Setter Property=""MinWidth"" Value=""0""/>
|
||||
<Setter Property=""MinHeight"" Value=""0""/>
|
||||
<Setter Property=""FocusVisualStyle"" Value=""{x:Null}""/>
|
||||
<Setter Property=""ScrollViewer.PanningMode"" Value=""VerticalFirst""/>
|
||||
<Setter Property=""Stylus.IsFlicksEnabled"" Value=""False""/>
|
||||
<Setter Property=""Template"">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType=""{x:Type TextBox}"">
|
||||
<ScrollViewer x:Name=""PART_ContentHost"" Background=""Transparent"" Focusable=""false"" HorizontalScrollBarVisibility=""Hidden"" VerticalScrollBarVisibility=""Hidden""/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>";
|
||||
|
||||
/// <summary>
|
||||
/// ComboBoxEditableTextBox Style XAML (.NET Framework 3.5)
|
||||
/// </summary>
|
||||
private const string _comboBoxEditableTextBoxStyleNet35 = @"<Style TargetType=""{x:Type TextBox}"">
|
||||
<Setter Property=""OverridesDefaultStyle"" Value=""true""/>
|
||||
<Setter Property=""AllowDrop"" Value=""true""/>
|
||||
<Setter Property=""MinWidth"" Value=""0""/>
|
||||
<Setter Property=""MinHeight"" Value=""0""/>
|
||||
<Setter Property=""FocusVisualStyle"" Value=""{x:Null}""/>
|
||||
<Setter Property=""Stylus.IsFlicksEnabled"" Value=""False""/>
|
||||
<Setter Property=""Template"">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType=""{x:Type TextBox}"">
|
||||
<ScrollViewer x:Name=""PART_ContentHost"" Background=""Transparent"" Focusable=""false"" HorizontalScrollBarVisibility=""Hidden"" VerticalScrollBarVisibility=""Hidden""/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>";
|
||||
|
||||
/// <summary>
|
||||
/// CustomComboBoxStyle Style XAML (.NET Framework 4.0 and above)
|
||||
/// </summary>
|
||||
private const string _customComboBoxStyleDefault = @"<Style x:Key=""CustomComboBoxStyle"" TargetType=""{x:Type ComboBox}"">
|
||||
<Setter Property=""FocusVisualStyle"" Value=""{DynamicResource FocusVisual}""/>
|
||||
<Setter Property=""Background"" Value=""{DynamicResource ComboBox.Static.Background}""/>
|
||||
<Setter Property=""BorderBrush"" Value=""{DynamicResource ComboBox.Static.Border}""/>
|
||||
<Setter Property=""Foreground"" Value=""{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}""/>
|
||||
<Setter Property=""BorderThickness"" Value=""1""/>
|
||||
<Setter Property=""ScrollViewer.HorizontalScrollBarVisibility"" Value=""Auto""/>
|
||||
<Setter Property=""ScrollViewer.VerticalScrollBarVisibility"" Value=""Auto""/>
|
||||
<Setter Property=""Padding"" Value=""6,3,5,3""/>
|
||||
<Setter Property=""ScrollViewer.CanContentScroll"" Value=""true""/>
|
||||
<Setter Property=""ScrollViewer.PanningMode"" Value=""VerticalFirst""/>
|
||||
<Setter Property=""Stylus.IsFlicksEnabled"" Value=""False""/>
|
||||
<Setter Property=""Template"" Value=""{DynamicResource ComboBoxTemplate}""/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property=""IsEditable"" Value=""true"">
|
||||
<Setter Property=""IsTabStop"" Value=""false""/>
|
||||
<Setter Property=""Padding"" Value=""2""/>
|
||||
<Setter Property=""Template"" Value=""{DynamicResource ComboBoxEditableTemplate}""/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>";
|
||||
|
||||
/// <summary>
|
||||
/// CustomComboBoxStyle Style XAML (.NET Framework 3.5)
|
||||
/// </summary>
|
||||
private const string _customComboBoxStyleNet35 = @"<Style TargetType=""{x:Type ComboBox}"">
|
||||
<Setter Property=""FocusVisualStyle"" Value=""{DynamicResource FocusVisual}""/>
|
||||
<Setter Property=""Background"" Value=""{DynamicResource ComboBox.Static.Background}""/>
|
||||
<Setter Property=""BorderBrush"" Value=""{DynamicResource ComboBox.Static.Border}""/>
|
||||
<Setter Property=""Foreground"" Value=""{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}""/>
|
||||
<Setter Property=""BorderThickness"" Value=""1""/>
|
||||
<Setter Property=""ScrollViewer.HorizontalScrollBarVisibility"" Value=""Auto""/>
|
||||
<Setter Property=""ScrollViewer.VerticalScrollBarVisibility"" Value=""Auto""/>
|
||||
<Setter Property=""Padding"" Value=""6,3,5,3""/>
|
||||
<Setter Property=""ScrollViewer.CanContentScroll"" Value=""true""/>
|
||||
<Setter Property=""Stylus.IsFlicksEnabled"" Value=""False""/>
|
||||
<Setter Property=""Template"" Value=""{DynamicResource ComboBoxTemplate}""/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property=""IsEditable"" Value=""true"">
|
||||
<Setter Property=""IsTabStop"" Value=""false""/>
|
||||
<Setter Property=""Padding"" Value=""2""/>
|
||||
<Setter Property=""Template"" Value=""{DynamicResource ComboBoxEditableTemplate}""/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>";
|
||||
|
||||
/// <summary>
|
||||
/// CustomProgressBarStyle Style XAML (.NET Framework 4.0 and above)
|
||||
/// </summary>
|
||||
private const string _customProgressBarStyleDefault = @"<Style x:Key=""CustomProgressBarStyle"" TargetType=""{x:Type ProgressBar}"">
|
||||
<Setter Property=""Foreground"" Value=""{DynamicResource ProgressBar.Progress}""/>
|
||||
<Setter Property=""Background"" Value=""{DynamicResource ProgressBar.Background}""/>
|
||||
<Setter Property=""BorderBrush"" Value=""{DynamicResource ProgressBar.Border}""/>
|
||||
<Setter Property=""BorderThickness"" Value=""1""/>
|
||||
<Setter Property=""Template"">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType=""{x:Type ProgressBar}"">
|
||||
<Grid x:Name=""TemplateRoot"">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name=""CommonStates"">
|
||||
<VisualState x:Name=""Determinate""/>
|
||||
<VisualState x:Name=""Indeterminate"">
|
||||
<Storyboard RepeatBehavior=""Forever"">
|
||||
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=""(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"" Storyboard.TargetName=""Animation"">
|
||||
<EasingDoubleKeyFrame KeyTime=""0"" Value=""0.25""/>
|
||||
<EasingDoubleKeyFrame KeyTime=""0:0:1"" Value=""0.25""/>
|
||||
<EasingDoubleKeyFrame KeyTime=""0:0:2"" Value=""0.25""/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<PointAnimationUsingKeyFrames Storyboard.TargetProperty=""(UIElement.RenderTransformOrigin)"" Storyboard.TargetName=""Animation"">
|
||||
<EasingPointKeyFrame KeyTime=""0"" Value=""-0.5,0.5""/>
|
||||
<EasingPointKeyFrame KeyTime=""0:0:1"" Value=""0.5,0.5""/>
|
||||
<EasingPointKeyFrame KeyTime=""0:0:2"" Value=""1.5,0.5""/>
|
||||
</PointAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Border BorderBrush=""{TemplateBinding BorderBrush}"" BorderThickness=""{TemplateBinding BorderThickness}"" Background=""{TemplateBinding Background}""/>
|
||||
<Rectangle x:Name=""PART_Track""/>
|
||||
<Grid x:Name=""PART_Indicator"" ClipToBounds=""true"" HorizontalAlignment=""Left"">
|
||||
<Rectangle x:Name=""Indicator"" Fill=""{TemplateBinding Foreground}""/>
|
||||
<Rectangle x:Name=""Animation"" Fill=""{TemplateBinding Foreground}"" RenderTransformOrigin=""0.5,0.5"">
|
||||
<Rectangle.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform/>
|
||||
<SkewTransform/>
|
||||
<RotateTransform/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property=""Orientation"" Value=""Vertical"">
|
||||
<Setter Property=""LayoutTransform"" TargetName=""TemplateRoot"">
|
||||
<Setter.Value>
|
||||
<RotateTransform Angle=""-90""/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
<Trigger Property=""IsIndeterminate"" Value=""true"">
|
||||
<Setter Property=""Visibility"" TargetName=""Indicator"" Value=""Collapsed""/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>";
|
||||
|
||||
/// <summary>
|
||||
/// CustomProgressBarStyle Style XAML (.NET Framework 3.5)
|
||||
/// </summary>
|
||||
private const string _customProgressBarStyleNet35 = @"<Style TargetType=""{x:Type ProgressBar}"">
|
||||
<Setter Property=""Foreground"" Value=""{DynamicResource ProgressBar.Progress}""/>
|
||||
<Setter Property=""Background"" Value=""{DynamicResource ProgressBar.Background}""/>
|
||||
<Setter Property=""BorderBrush"" Value=""{DynamicResource ProgressBar.Border}""/>
|
||||
<Setter Property=""BorderThickness"" Value=""1""/>
|
||||
<Setter Property=""Template"">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType=""{x:Type ProgressBar}"">
|
||||
<Grid x:Name=""TemplateRoot"">
|
||||
<Border BorderBrush=""{TemplateBinding BorderBrush}"" BorderThickness=""{TemplateBinding BorderThickness}"" Background=""{TemplateBinding Background}""/>
|
||||
<Rectangle x:Name=""PART_Track""/>
|
||||
<Grid x:Name=""PART_Indicator"" ClipToBounds=""true"" HorizontalAlignment=""Left"">
|
||||
<Rectangle x:Name=""Indicator"" Fill=""{TemplateBinding Foreground}""/>
|
||||
<Rectangle x:Name=""Animation"" Fill=""{TemplateBinding Foreground}"" RenderTransformOrigin=""0.5,0.5"">
|
||||
<Rectangle.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform/>
|
||||
<SkewTransform/>
|
||||
<RotateTransform/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property=""Orientation"" Value=""Vertical"">
|
||||
<Setter Property=""LayoutTransform"" TargetName=""TemplateRoot"">
|
||||
<Setter.Value>
|
||||
<RotateTransform Angle=""-90""/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
<Trigger Property=""IsIndeterminate"" Value=""true"">
|
||||
<Setter Property=""Visibility"" TargetName=""Indicator"" Value=""Collapsed""/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>";
|
||||
|
||||
#endregion
|
||||
public App()
|
||||
{
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
InitializeComponent();
|
||||
#endif
|
||||
|
||||
// Create control templates
|
||||
CreateControlTemplate("ComboBoxTemplate");
|
||||
CreateControlTemplate("ComboBoxEditableTemplate");
|
||||
|
||||
// Create styles
|
||||
CreateStyle("ComboBoxEditableTextBox");
|
||||
CreateStyle("CustomComboBoxStyle");
|
||||
CreateStyle("CustomProgressBarStyle");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an XAML parser context with the required namespaces
|
||||
/// </summary>
|
||||
private ParserContext CreateParserContext()
|
||||
{
|
||||
var context = new ParserContext();
|
||||
|
||||
context.XmlnsDictionary[""] = "http://schemas.microsoft.com/winfx/2006/xaml/presentation";
|
||||
context.XmlnsDictionary["x"] = "http://schemas.microsoft.com/winfx/2006/xaml";
|
||||
#if NETFRAMEWORK
|
||||
context.XmlnsDictionary["themes"] = "clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero";
|
||||
#else
|
||||
context.XmlnsDictionary["themes"] = "clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2";
|
||||
#endif
|
||||
context.XamlTypeMapper = new XamlTypeMapper([]);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a named control template and add it to the current set of resources
|
||||
/// </summary>
|
||||
private void CreateControlTemplate(string resourceName)
|
||||
{
|
||||
var parserContext = CreateParserContext();
|
||||
var controlTemplate = resourceName switch
|
||||
{
|
||||
#if NET35
|
||||
"ComboBoxTemplate" => XamlReader.Parse(_comboBoxTemplateNet35, parserContext) as ControlTemplate,
|
||||
"ComboBoxEditableTemplate" => XamlReader.Parse(_comboBoxEditableTemplateNet35, parserContext) as ControlTemplate,
|
||||
#else
|
||||
"ComboBoxTemplate" => XamlReader.Parse(_comboBoxTemplateDefault, parserContext) as ControlTemplate,
|
||||
"ComboBoxEditableTemplate" => XamlReader.Parse(_comboBoxEditableTemplateDefault, parserContext) as ControlTemplate,
|
||||
#endif
|
||||
_ => throw new ArgumentException($"'{resourceName}' is not a recognized control template", nameof(resourceName)),
|
||||
};
|
||||
|
||||
// Add the control template
|
||||
Resources[resourceName] = controlTemplate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a named style and add it to the current set of resources
|
||||
/// </summary>
|
||||
private void CreateStyle(string resourceName)
|
||||
{
|
||||
var parserContext = CreateParserContext();
|
||||
var style = resourceName switch
|
||||
{
|
||||
#if NET35
|
||||
"ComboBoxEditableTextBox" => XamlReader.Parse(_comboBoxEditableTextBoxStyleNet35, parserContext) as Style,
|
||||
"CustomComboBoxStyle" => XamlReader.Parse(_customComboBoxStyleNet35, parserContext) as Style,
|
||||
"CustomProgressBarStyle" => XamlReader.Parse(_customProgressBarStyleNet35, parserContext) as Style,
|
||||
#else
|
||||
"ComboBoxEditableTextBox" => XamlReader.Parse(_comboBoxEditableTextBoxStyleDefault, parserContext) as Style,
|
||||
"CustomComboBoxStyle" => XamlReader.Parse(_customComboBoxStyleDefault, parserContext) as Style,
|
||||
"CustomProgressBarStyle" => XamlReader.Parse(_customProgressBarStyleDefault, parserContext) as Style,
|
||||
#endif
|
||||
_ => throw new ArgumentException($"'{resourceName}' is not a recognized style", nameof(resourceName)),
|
||||
};
|
||||
|
||||
// Add the style
|
||||
Resources[resourceName] = style;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,51 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net48;net6.0-windows;net7.0-windows</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
|
||||
<!-- Assembly Properties -->
|
||||
<TargetFrameworks>net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0-windows;net6.0-windows;net7.0-windows;net8.0-windows</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<ApplicationIcon>Images\Icon.ico</ApplicationIcon>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<ImportFrameworkWinFXTargets Condition="$(TargetFramework.StartsWith(`net3`))">true</ImportFrameworkWinFXTargets>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<VersionPrefix>3.0.3</VersionPrefix>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ApplicationIcon>Images\Icon.ico</ApplicationIcon>
|
||||
<Title>MPF</Title>
|
||||
<Description>Frontend for various dumping programs</Description>
|
||||
|
||||
<!-- Package Properties -->
|
||||
<Authors>Matt Nadareski;ReignStumble;Jakz</Authors>
|
||||
<Copyright>Copyright (c)2019-2023</Copyright>
|
||||
<VersionPrefix>2.7.1</VersionPrefix>
|
||||
<InternalsVisibleTo>MPF.Test</InternalsVisibleTo>
|
||||
<Description>Frontend for various dumping programs</Description>
|
||||
<Copyright>Copyright (c) Matt Nadareski 2019-2023</Copyright>
|
||||
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
|
||||
<RepositoryUrl>https://github.com/SabreTools/MPF</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'!='net48'">
|
||||
<Nullable>enable</Nullable>
|
||||
<!-- Special handling for Aero2 on non-Framework .NET -->
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net4`))">
|
||||
<ReferenceWpfAeroTheme>true</ReferenceWpfAeroTheme>
|
||||
<ReferenceWpfAero2Theme>false</ReferenceWpfAero2Theme>
|
||||
<ReferenceWpfAeroLiteTheme>false</ReferenceWpfAeroLiteTheme>
|
||||
<ReferenceWpfClassicTheme>false</ReferenceWpfClassicTheme>
|
||||
<ReferenceWpfLunaTheme>false</ReferenceWpfLunaTheme>
|
||||
<ReferenceWpfRoyaleTheme>false</ReferenceWpfRoyaleTheme>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`)) OR $(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`))">
|
||||
<ReferenceWpfAeroTheme>false</ReferenceWpfAeroTheme>
|
||||
<ReferenceWpfAero2Theme>true</ReferenceWpfAero2Theme>
|
||||
<ReferenceWpfAeroLiteTheme>false</ReferenceWpfAeroLiteTheme>
|
||||
<ReferenceWpfClassicTheme>false</ReferenceWpfClassicTheme>
|
||||
<ReferenceWpfLunaTheme>false</ReferenceWpfLunaTheme>
|
||||
<ReferenceWpfRoyaleTheme>false</ReferenceWpfRoyaleTheme>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="MPF.Test" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\Icon.ico" />
|
||||
@@ -28,19 +56,62 @@
|
||||
<ProjectReference Include="..\MPF.UI.Core\MPF.UI.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)'=='net48'">
|
||||
<!-- Support for old .NET versions -->
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net3`))">
|
||||
<Reference Include="PresentationBuildTasks" HintPath="$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\v3.0\PresentationBuildTasks.dll" />
|
||||
<Reference Include="PresentationCore" HintPath="$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll" />
|
||||
<Reference Include="PresentationFramework" HintPath="$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" />
|
||||
<Reference Include="WindowsBase" HintPath="$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net4`))">
|
||||
<Reference Include="PresentationFramework.Aero" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`)) OR $(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`))">
|
||||
<Reference Include="PresentationFramework.Aero2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BurnOutSharp" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="2.8.0" GeneratePathProperty="true">
|
||||
<PackageReference Include="BinaryObjectScanner" PrivateAssets="build; analyzers" ExcludeAssets="contentFiles" Version="3.0.2" GeneratePathProperty="true">
|
||||
<IncludeAssets>runtime; compile; build; native; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.1.1" />
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="$(PkgBurnOutSharp)\content\**" PackagePath="contentFiles\any\any;content" CopyToOutputDirectory="Always" PackageCopyToOutput="true" />
|
||||
<Content Include="$(PkgBinaryObjectScanner)\content\**" PackagePath="contentFiles\any\any;content" CopyToOutputDirectory="Always" PackageCopyToOutput="true" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Special handling for Aero2 on non-Framework .NET -->
|
||||
<Target Name="SelectWpfThemeAssembly" AfterTargets="ResolveAssemblyReferences" Condition="'$(ReferenceWpfAeroTheme)' == 'true' OR '$(ReferenceWpfAero2Theme)' == 'true' OR '$(ReferenceWpfAeroLiteTheme)' == 'true' OR '$(ReferenceWpfClassicTheme)' == 'true' OR '$(ReferenceWpfLunaTheme)' == 'true' OR '$(ReferenceWpfRoyaleTheme)' == 'true'">
|
||||
<ItemGroup>
|
||||
<_WpfThemeAssemblies Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)'=='Microsoft.WindowsDesktop.App.Ref' AND '%(ReferencePath.FileName)'=='PresentationFramework.Aero'">
|
||||
<Aliases Condition="'$(WpfAeroThemeAliases)'!=''">$(WpfAeroThemeAliases)</Aliases>
|
||||
</_WpfThemeAssemblies>
|
||||
|
||||
<_WpfThemeAssemblies Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)'=='Microsoft.WindowsDesktop.App.Ref' AND '%(ReferencePath.FileName)'=='PresentationFramework.Aero2'">
|
||||
<Aliases Condition="'$(WpfAero2ThemeAliases)'!=''">$(WpfAero2ThemeAliases)</Aliases>
|
||||
</_WpfThemeAssemblies>
|
||||
|
||||
<_WpfThemeAssemblies Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)'=='Microsoft.WindowsDesktop.App.Ref' AND '%(ReferencePath.FileName)'=='PresentationFramework.AeroLite'">
|
||||
<Aliases Condition="'$(WpfAeroLiteThemeAliases)'!=''">$(WpfAeroLiteThemeAliases)</Aliases>
|
||||
</_WpfThemeAssemblies>
|
||||
|
||||
<_WpfThemeAssemblies Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)'=='Microsoft.WindowsDesktop.App.Ref' AND '%(ReferencePath.FileName)'=='PresentationFramework.Classic'">
|
||||
<Aliases Condition="'$(WpfClassicThemeAliases)'!=''">$(WpfClassicThemeAliases)</Aliases>
|
||||
</_WpfThemeAssemblies>
|
||||
|
||||
<_WpfThemeAssemblies Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)'=='Microsoft.WindowsDesktop.App.Ref' AND '%(ReferencePath.FileName)'=='PresentationFramework.Luna'">
|
||||
<Aliases Condition="'$(WpfLunaThemeAliases)'!=''">$(WpfLunaThemeAliases)</Aliases>
|
||||
</_WpfThemeAssemblies>
|
||||
|
||||
<_WpfThemeAssemblies Include="@(ReferencePath)" Condition="'%(ReferencePath.NuGetPackageId)'=='Microsoft.WindowsDesktop.App.Ref' AND '%(ReferencePath.FileName)'=='PresentationFramework.Royale'">
|
||||
<Aliases Condition="'$(WpfRoyaleThemeAliases)'!=''">$(WpfRoyaleThemeAliases)</Aliases>
|
||||
</_WpfThemeAssemblies>
|
||||
|
||||
<ReferencePath Remove="@(_WpfThemeAssemblies)" />
|
||||
<ReferencePath Include="@(_WpfThemeAssemblies)" Condition="('%(_WpfThemeAssemblies.FileName)'=='PresentationFramework.Aero' AND'$(ReferenceWpfAeroTheme)'=='true') OR ('%(_WpfThemeAssemblies.FileName)'=='PresentationFramework.Aero2' AND '$(ReferenceWpfAero2Theme)'=='true') OR ('%(_WpfThemeAssemblies.FileName)'=='PresentationFramework.AeroLite' AND '$(ReferenceWpfAeroLiteTheme)'=='true') OR ('%(_WpfThemeAssemblies.FileName)'=='PresentationFramework.Classic' AND '$(ReferenceWpfClassicTheme)'=='true') OR ('%(_WpfThemeAssemblies.FileName)'=='PresentationFramework.Luna' AND '$(ReferenceWpfLunaTheme)'=='true') OR ('%(_WpfThemeAssemblies.FileName)'=='PresentationFramework.Royale' AND '$(ReferenceWpfRoyaleTheme)'=='true')" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
|
||||
</Project>
|
||||
79
README.md
79
README.md
@@ -8,66 +8,64 @@ This is a community project, so if you have some time and knowledge to give, we'
|
||||
|
||||
## Releases
|
||||
|
||||
For those who would rather use the most recent stable build, download the latest release here:
|
||||
[Releases Page](https://github.com/SabreTools/MPF/releases)
|
||||
For the most recent stable build, download the latest release here: [Releases Page](https://github.com/SabreTools/MPF/releases)
|
||||
|
||||
For those who like to test the newest features, download the latest AppVeyor WIP build here: [AppVeyor](https://ci.appveyor.com/project/mnadareski/MPF/build/artifacts)
|
||||
For the latest AppVeyor WIP build here: [AppVeyor](https://ci.appveyor.com/project/mnadareski/MPF/build/artifacts)
|
||||
|
||||
## Media Preservation Frontend (MPF)
|
||||
## Media Preservation Frontend UI (MPF)
|
||||
|
||||
MPF is the main, UI-centric application of the MPF suite. This program allows users to use Redumper, Aaru, or DiscImageCreator in a more user-friendly way. Each backend dumping program is supported as fully as possible to ensure that all information is captured on output. There are many customization options and quality of life settings that can be access through the Options menu.
|
||||
|
||||
### System Requirements
|
||||
|
||||
- Windows 8.1 (x64) or newer
|
||||
- Users who wish to use MPF on Windows 7 need to disable strong name validation due to `Microsoft.Management.Infrastructure` being unsigned. Add the following registry keys (accurate at time of writing):
|
||||
```
|
||||
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\StrongName\Verification\*,31bf3856ad364e35]
|
||||
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification\*,31bf3856ad364e35]
|
||||
```
|
||||
- Alternatively, look at this [StackOverflow question](https://stackoverflow.com/questions/403731/strong-name-validation-failed) for more information.
|
||||
|
||||
- .NET Framework 4.8, .NET 6.0, or .NET 7.0 Runtimes
|
||||
- As much hard drive space as the amount of discs you will be dumping (20+ GB recommended)
|
||||
|
||||
Ensure that your operating system is as up-to-date as possible, since some features may rely on those updates.
|
||||
|
||||
### Support Limitations
|
||||
|
||||
The main UI has some known limitations that are documented in code and in some prior support tickets:
|
||||
|
||||
- Windows-only due to reliance on WPF and Winforms
|
||||
- MAUI is not a viable alternative due to lack of out-of-box support for Linux
|
||||
- Avalonia is being heavily considered as an alternative
|
||||
|
||||
### Build Instructions
|
||||
|
||||
To build for .NET Framework 4.8, .NET 6.0, or .NET 7.0 (all Windows only), ensure that the .NET 7.0 SDK (or later) is installed and included in your PATH. Then, run the following commands from command prompt, Powershell, or Terminal:
|
||||
|
||||
```
|
||||
dotnet build MPF\MPF.csproj --framework [net48|net6.0-windows|net7.0-windows] --runtime win-x64 --self-contained
|
||||
```
|
||||
|
||||
You may also run `publish-win.bat` (on Windows) or `publish-nix.sh` (on Linux) to build and package all variants MPF and MPF.Check at once. The Windows script additionally requires 7-zip commandline, Git for Windows, and .NET Framework 4.8 SDK to be installed and in PATH. The Linux script additionally requires `zip` and Git to be installed and in PATH.
|
||||
- MAUI is not a viable alternative due to lack of out-of-box support for Linux
|
||||
- Avalonia is being heavily considered as an alternative
|
||||
- For those who need .NET Framework 4.8, there is an official fork: [MPF Legacy](https://github.com/Deterous/MPF-Legacy)
|
||||
|
||||
## Media Preservation Frontend Checker (MPF.Check)
|
||||
|
||||
MPF.Check is a commandline-only program that allows users to generate submission information from their personal rips. This program supports the outputs from Redumper, Aaru, DiscImageCreator, Cleanrip, and UmdImageCreator. Running this program without any parameters will display the help text, including all supported parameters.
|
||||
|
||||
### System Requirements
|
||||
## System Requirements
|
||||
|
||||
- Windows 8.1 (x64) or newer, GNU/Linux x64, or OSX x64
|
||||
- .NET Framework 4.8 (Windows or `mono` only), .NET 6.0, or .NET 7.0 Runtimes
|
||||
Both MPF UI and MPF.Check have the same system requirements for running, with the exception that MPF UI is Windows-only.
|
||||
|
||||
### Build Instructions
|
||||
- [Supported OS versions for .NET 6](https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md)
|
||||
- Requires [.NET 6.0 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) if built without bundled runtime
|
||||
- [Supported OS versions for .NET 8](https://github.com/dotnet/core/blob/main/release-notes/8.0/supported-os.md)
|
||||
- Requires [.NET 8.0 Runtime](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) if built without bundled runtime
|
||||
|
||||
To build for .NET Framework 4.8 (Windows only), .NET 6.0, and .NET 7.0 (both all supported OSes), ensure that the .NET 7.0 SDK (or later) is installed and included in your PATH. Then, run the following commands from command prompt, Powershell, Terminal, or shell:
|
||||
Ensure that your operating system and runtimes are as up-to-date as possible, since some features may rely on those updates.
|
||||
|
||||
```
|
||||
dotnet build MPF.Check\MPF.Check.csproj --framework [net48|net6.0|net7.0] --runtime [win-x64|linux-x64|osx-x64] --self-contained
|
||||
## Build Instructions
|
||||
|
||||
To build for .NET 6.0 or .NET 8.0, ensure that the [.NET 8.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) (or later) is installed and included in your `PATH`. Then, run the following commands from command prompt, Powershell, Terminal, or shell:
|
||||
|
||||
**MPF UI (Windows only):**
|
||||
|
||||
```bash
|
||||
dotnet build MPF/MPF.csproj --framework [net6.0-windows|net8.0-windows] --runtime win-x64
|
||||
```
|
||||
|
||||
Choose one of `[win-x64|linux-x64|osx-x64]` depending on the machine you are targeting.
|
||||
**MPF.Check (Windows, OSX, Linux):**
|
||||
|
||||
```bash
|
||||
dotnet build MPF.Check/MPF.Check.csproj --framework [net6.0|net8.0] --runtime [win-x64|linux-x64|osx-x64]
|
||||
```
|
||||
|
||||
Choose one of `win-x64`, `linux-x64`, or `osx-x64` depending on the machine you are targeting.
|
||||
|
||||
### Build Scripts
|
||||
|
||||
Windows users may run `publish-win.ps1` and Linux users may run `publish-nix.sh` to perform a full release build.
|
||||
|
||||
- `publish-win.ps1` will build and package all variants of MPF UI and MPF.Check
|
||||
- The script requires [7-zip commandline](https://www.7-zip.org/download.html) and [Git for Windows](https://git-scm.com/downloads) to be installed and in `PATH`
|
||||
- `publish-nix.sh` will _only_ build and package all variants of MPF.Check
|
||||
- The script requires `zip` and `git` to be installed and in `PATH`
|
||||
|
||||
## Information
|
||||
|
||||
@@ -81,8 +79,7 @@ A list of all changes in each stable release and current WIP builds can now be f
|
||||
|
||||
MPF uses some external libraries to assist with additional information gathering after the dumping process.
|
||||
|
||||
- **BurnOutSharp** - Protection scanning - [GitHub](https://github.com/mnadareski/BurnOutSharp)
|
||||
- **UnshieldSharp** - Protection scanning - [GitHub](https://github.com/mnadareski/UnshieldSharp)
|
||||
- **BinaryObjectScanner** - Protection scanning - [GitHub](https://github.com/SabreTools/BinaryObjectScanner)
|
||||
- **WPFCustomMessageBox.thabse** - Custom message boxes in UI - [GitHub](https://github.com/thabse/WPFCustomMessageBox)
|
||||
|
||||
## Contributors
|
||||
|
||||
70
appveyor.yml
70
appveyor.yml
@@ -1,5 +1,5 @@
|
||||
# version format
|
||||
version: 2.7.1-{build}
|
||||
version: 3.0.3-{build}
|
||||
|
||||
# pull request template
|
||||
pull_requests:
|
||||
@@ -12,14 +12,6 @@ image: Visual Studio 2022
|
||||
build_script:
|
||||
- dotnet restore
|
||||
|
||||
# .NET Framework 4.8 Debug
|
||||
- dotnet publish MPF\MPF.csproj -f net48 -r win7-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT%
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net48 -r win7-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT%
|
||||
|
||||
# .NET Framework 4.8 Release
|
||||
- dotnet publish MPF\MPF.csproj -f net48 -r win7-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:DebugType=None -p:DebugSymbols=false
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net48 -r win7-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:DebugType=None -p:DebugSymbols=false
|
||||
|
||||
# .NET 6.0 Debug
|
||||
- dotnet publish MPF\MPF.csproj -f net6.0-windows -r win-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net6.0 -r win-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true
|
||||
@@ -32,44 +24,44 @@ build_script:
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net6.0 -r linux-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net6.0 -r osx-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
|
||||
# .NET 7.0 Debug
|
||||
- dotnet publish MPF\MPF.csproj -f net7.0-windows -r win-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r win-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r linux-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r osx-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true
|
||||
# .NET 8.0 Debug
|
||||
- dotnet publish MPF\MPF.csproj -f net8.0-windows -r win-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r win-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r linux-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r osx-x64 -c Debug --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true
|
||||
|
||||
# .NET 7.0 Release
|
||||
- dotnet publish MPF\MPF.csproj -f net7.0-windows -r win-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r win-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r linux-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r osx-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
# .NET 8.0 Release
|
||||
- dotnet publish MPF\MPF.csproj -f net8.0-windows -r win-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r win-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r linux-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
- dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r osx-x64 -c Release --self-contained true --version-suffix %APPVEYOR_REPO_COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
|
||||
# post-build step
|
||||
after_build:
|
||||
|
||||
# Aaru
|
||||
- ps: appveyor DownloadFile https://github.com/aaru-dps/Aaru/releases/download/v5.3.2/aaru-5.3.2_windows_x64.zip
|
||||
- 7z x aaru-5.3.2_windows_x64.zip -oMPF\bin\Debug\net6.0-windows\win-x64\publish\Programs\Aaru *
|
||||
- 7z x aaru-5.3.2_windows_x64.zip -oMPF\bin\Debug\net8.0-windows\win-x64\publish\Programs\Aaru *
|
||||
|
||||
# DiscImageCreator
|
||||
- ps: appveyor DownloadFile https://github.com/saramibreak/DiscImageCreator/files/11660558/DiscImageCreator_20230606.zip
|
||||
- 7z e DiscImageCreator_20230606.zip -oMPF\bin\Debug\net6.0-windows\win-x64\publish\Programs\Creator Release_ANSI\*
|
||||
- 7z e DiscImageCreator_20230606.zip -oMPF\bin\Debug\net8.0-windows\win-x64\publish\Programs\Creator Release_ANSI\*
|
||||
|
||||
# Redumper
|
||||
- ps: appveyor DownloadFile https://github.com/superg/redumper/releases/download/build_221/redumper-2023.10.02_build221-win64.zip
|
||||
- 7z e redumper-2023.10.02_build221-win64.zip -oMPF\bin\Debug\net6.0-windows\win-x64\publish\Programs\Redumper redumper-2023.10.02_build221-win64\bin\*
|
||||
- ps: appveyor DownloadFile https://github.com/superg/redumper/releases/download/build_271/redumper-2023.11.30_build271-win64.zip
|
||||
- 7z e redumper-2023.11.30_build271-win64.zip -oMPF\bin\Debug\net8.0-windows\win-x64\publish\Programs\Redumper redumper-2023.11.30_build271-win64\bin\*
|
||||
|
||||
# Create MPF Debug archives
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\MPF\bin\Debug\net6.0-windows\win-x64\publish\
|
||||
- 7z a -tzip %APPVEYOR_BUILD_FOLDER%\MPF_%APPVEYOR_BUILD_NUMBER%_net6.0_win-x64_debug.zip *
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\MPF\bin\Debug\net8.0-windows\win-x64\publish\
|
||||
- 7z a -tzip %APPVEYOR_BUILD_FOLDER%\MPF_%APPVEYOR_BUILD_NUMBER%_net8.0_win-x64_debug.zip *
|
||||
|
||||
# Create MPF.Check Debug archives
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\MPF.Check\bin\Debug\net6.0\win-x64\publish\
|
||||
- 7z a -tzip %APPVEYOR_BUILD_FOLDER%\MPF.Check_%APPVEYOR_BUILD_NUMBER%_net6.0_win-x64_debug.zip *
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\MPF.Check\bin\Debug\net6.0\linux-x64\publish\
|
||||
- 7z a -tzip %APPVEYOR_BUILD_FOLDER%\MPF.Check_%APPVEYOR_BUILD_NUMBER%_net6.0_linux-x64_debug.zip *
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\MPF.Check\bin\Debug\net6.0\osx-x64\publish\
|
||||
- 7z a -tzip %APPVEYOR_BUILD_FOLDER%\MPF.Check_%APPVEYOR_BUILD_NUMBER%_net6.0_osx-x64_debug.zip *
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\MPF.Check\bin\Debug\net8.0\win-x64\publish\
|
||||
- 7z a -tzip %APPVEYOR_BUILD_FOLDER%\MPF.Check_%APPVEYOR_BUILD_NUMBER%_net8.0_win-x64_debug.zip *
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\MPF.Check\bin\Debug\net8.0\linux-x64\publish\
|
||||
- 7z a -tzip %APPVEYOR_BUILD_FOLDER%\MPF.Check_%APPVEYOR_BUILD_NUMBER%_net8.0_linux-x64_debug.zip *
|
||||
- cd %APPVEYOR_BUILD_FOLDER%\MPF.Check\bin\Debug\net8.0\osx-x64\publish\
|
||||
- 7z a -tzip %APPVEYOR_BUILD_FOLDER%\MPF.Check_%APPVEYOR_BUILD_NUMBER%_net8.0_osx-x64_debug.zip *
|
||||
|
||||
# success/failure tracking
|
||||
on_success:
|
||||
@@ -81,12 +73,12 @@ on_failure:
|
||||
|
||||
# artifact linking
|
||||
artifacts:
|
||||
- path: MPF_%APPVEYOR_BUILD_NUMBER%_net6.0_win-x64_debug.zip
|
||||
name: MPF (.NET 6.0, Debug, Windows x64)
|
||||
- path: MPF_%APPVEYOR_BUILD_NUMBER%_net8.0_win-x64_debug.zip
|
||||
name: MPF (.NET 8.0, Debug, Windows x64)
|
||||
|
||||
- path: MPF.Check_%APPVEYOR_BUILD_NUMBER%_net6.0_win-x64_debug.zip
|
||||
name: MPF.Check (.NET 6.0, Debug, Windows x64)
|
||||
- path: MPF.Check_%APPVEYOR_BUILD_NUMBER%_net6.0_linux-x64_debug.zip
|
||||
name: MPF.Check (.NET 6.0, Debug, Linux x64)
|
||||
- path: MPF.Check_%APPVEYOR_BUILD_NUMBER%_net6.0_osx-x64_debug.zip
|
||||
name: MPF.Check (.NET 6.0, Debug, OSX x64)
|
||||
- path: MPF.Check_%APPVEYOR_BUILD_NUMBER%_net8.0_win-x64_debug.zip
|
||||
name: MPF.Check (.NET 8.0, Debug, Windows x64)
|
||||
- path: MPF.Check_%APPVEYOR_BUILD_NUMBER%_net8.0_linux-x64_debug.zip
|
||||
name: MPF.Check (.NET 8.0, Debug, Linux x64)
|
||||
- path: MPF.Check_%APPVEYOR_BUILD_NUMBER%_net8.0_osx-x64_debug.zip
|
||||
name: MPF.Check (.NET 8.0, Debug, OSX x64)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#! /bin/bash
|
||||
|
||||
# This batch file assumes the following:
|
||||
# - .NET 7.0 (or newer) SDK is installed and in PATH
|
||||
# - .NET 8.0 (or newer) SDK is installed and in PATH
|
||||
# - zip is installed and in PATH
|
||||
# - Git is installed and in PATH
|
||||
# - The relevant commandline programs are already downloaded
|
||||
@@ -37,31 +37,31 @@ dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r win-x64 -c Release --self
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r linux-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r osx-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
|
||||
|
||||
# .NET 7.0 Debug
|
||||
echo "Building .NET 7.0 debug"
|
||||
#dotnet publish MPF/MPF.csproj -f net7.0-windows -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net7.0 -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net7.0 -r linux-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net7.0 -r osx-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
# .NET 8.0 Debug
|
||||
echo "Building .NET 8.0 debug"
|
||||
#dotnet publish MPF/MPF.csproj -f net8.0-windows -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r linux-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r osx-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
|
||||
# .NET 7.0 Release
|
||||
echo "Building .NET 7.0 release"
|
||||
#dotnet publish MPF/MPF.csproj -f net7.0-windows -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net7.0 -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net7.0 -r linux-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net7.0 -r osx-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
|
||||
# .NET 8.0 Release
|
||||
echo "Building .NET 8.0 release"
|
||||
#dotnet publish MPF/MPF.csproj -f net8.0-windows -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r linux-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r osx-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
|
||||
|
||||
# Create MPF Debug archives
|
||||
#cd $BUILD_FOLDER/MPF/bin/Debug/net6.0-windows/win-x64/publish/
|
||||
#zip -r $BUILD_FOLDER/MPF_net6.0_win-x64_debug.zip .
|
||||
#cd $BUILD_FOLDER/MPF/bin/Debug/net7.0-windows/win-x64/publish/
|
||||
#zip -r $BUILD_FOLDER/MPF_net7.0_win-x64_debug.zip .
|
||||
#cd $BUILD_FOLDER/MPF/bin/Debug/net8.0-windows/win-x64/publish/
|
||||
#zip -r $BUILD_FOLDER/MPF_net8.0_win-x64_debug.zip .
|
||||
|
||||
# Create MPF Release archives
|
||||
#cd $BUILD_FOLDER/MPF/bin/Release/net6.0-windows/win-x64/publish/
|
||||
#zip -r $BUILD_FOLDER/MPF_net6.0_win-x64_release.zip .
|
||||
#cd $BUILD_FOLDER/MPF/bin/Release/net7.0-windows/win-x64/publish/
|
||||
#zip -r $BUILD_FOLDER/MPF_net7.0_win-x64_release.zip .
|
||||
#cd $BUILD_FOLDER/MPF/bin/Release/net8.0-windows/win-x64/publish/
|
||||
#zip -r $BUILD_FOLDER/MPF_net8.0_win-x64_release.zip .
|
||||
|
||||
# Create MPF.Check Debug archives
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net6.0/win-x64/publish/
|
||||
@@ -70,12 +70,12 @@ cd $BUILD_FOLDER/MPF.Check/bin/Debug/net6.0/linux-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net6.0_linux-x64_debug.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net6.0/osx-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net6.0_osx-x64_debug.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net7.0/win-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net7.0_win-x64_debug.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net7.0/linux-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net7.0_linux-x64_debug.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net7.0/osx-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net7.0_osx-x64_debug.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net8.0/win-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net8.0_win-x64_debug.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net8.0/linux-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net8.0_linux-x64_debug.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Debug/net8.0/osx-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net8.0_osx-x64_debug.zip .
|
||||
|
||||
# Create MPF.Check Release archives
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Release/net6.0/win-x64/publish/
|
||||
@@ -84,9 +84,9 @@ cd $BUILD_FOLDER/MPF.Check/bin/Release/net6.0/linux-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net6.0_linux-x64_release.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Release/net6.0/osx-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net6.0_osx-x64_release.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Release/net7.0/win-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net7.0_win-x64_release.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Release/net7.0/linux-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net7.0_linux-x64_release.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Release/net7.0/osx-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net7.0_osx-x64_release.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Release/net8.0/win-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net8.0_win-x64_release.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Release/net8.0/linux-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net8.0_linux-x64_release.zip .
|
||||
cd $BUILD_FOLDER/MPF.Check/bin/Release/net8.0/osx-x64/publish/
|
||||
zip -r $BUILD_FOLDER/MPF.Check_net8.0_osx-x64_release.zip .
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
@echo OFF
|
||||
|
||||
REM This batch file assumes the following:
|
||||
REM - .NET Framework 4.8 SDK is installed and in PATH
|
||||
REM - .NET 7.0 (or newer) SDK is installed and in PATH
|
||||
REM - .NET 8.0 (or newer) SDK is installed and in PATH
|
||||
REM - 7-zip commandline (7z.exe) is installed and in PATH
|
||||
REM - Git for Windows is installed and in PATH
|
||||
REM - The relevant commandline programs are already downloaded
|
||||
@@ -21,16 +20,6 @@ REM Restore Nuget packages for all builds
|
||||
echo Restoring Nuget packages
|
||||
dotnet restore
|
||||
|
||||
REM .NET Framework 4.8 Debug
|
||||
echo Building .NET Framework 4.8 debug
|
||||
dotnet publish MPF\MPF.csproj -f net48 -r win7-x64 -c Debug --self-contained true --version-suffix %COMMIT%
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net48 -r win7-x64 -c Debug --self-contained true --version-suffix %COMMIT%
|
||||
|
||||
REM .NET Framework 4.8 Release
|
||||
echo Building .NET Framework 4.8 release
|
||||
dotnet publish MPF\MPF.csproj -f net48 -r win7-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net48 -r win7-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:DebugType=None -p:DebugSymbols=false
|
||||
|
||||
REM .NET 6.0 Debug
|
||||
echo Building .NET 6.0 debug
|
||||
dotnet publish MPF\MPF.csproj -f net6.0-windows -r win-x64 -c Debug --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true
|
||||
@@ -45,64 +34,56 @@ dotnet publish MPF.Check\MPF.Check.csproj -f net6.0 -r win-x64 -c Release --self
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net6.0 -r linux-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net6.0 -r osx-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
|
||||
REM .NET 7.0 Debug
|
||||
echo Building .NET 7.0 debug
|
||||
dotnet publish MPF\MPF.csproj -f net7.0-windows -r win-x64 -c Debug --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r win-x64 -c Debug --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r linux-x64 -c Debug --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r osx-x64 -c Debug --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true
|
||||
REM .NET 8.0 Debug
|
||||
echo Building .NET 8.0 debug
|
||||
dotnet publish MPF\MPF.csproj -f net8.0-windows -r win-x64 -c Debug --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r win-x64 -c Debug --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r linux-x64 -c Debug --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r osx-x64 -c Debug --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true
|
||||
|
||||
REM .NET 7.0 Release
|
||||
echo Building .NET 7.0 release
|
||||
dotnet publish MPF\MPF.csproj -f net7.0-windows -r win-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r win-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r linux-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net7.0 -r osx-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
REM .NET 8.0 Release
|
||||
echo Building .NET 8.0 release
|
||||
dotnet publish MPF\MPF.csproj -f net8.0-windows -r win-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r win-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r linux-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f net8.0 -r osx-x64 -c Release --self-contained true --version-suffix %COMMIT% -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
|
||||
REM Create MPF Debug archives
|
||||
cd %BUILD_FOLDER%\MPF\bin\Debug\net48\win7-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF_net48_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF\bin\Debug\net6.0-windows\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF_net6.0_win-x64_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF\bin\Debug\net7.0-windows\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF_net7.0_win-x64_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF\bin\Debug\net8.0-windows\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF_net8.0_win-x64_debug.zip *
|
||||
|
||||
REM Create MPF Release archives
|
||||
cd %BUILD_FOLDER%\MPF\bin\Release\net48\win7-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF_net48_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF\bin\Release\net6.0-windows\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF_net6.0_win-x64_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF\bin\Release\net7.0-windows\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF_net7.0_win-x64_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF\bin\Release\net8.0-windows\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF_net8.0_win-x64_release.zip *
|
||||
|
||||
REM Create MPF.Check Debug archives
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Debug\net48\win7-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net48_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Debug\net6.0\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net6.0_win-x64_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Debug\net6.0\linux-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net6.0_linux-x64_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Debug\net6.0\osx-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net6.0_osx-x64_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Debug\net7.0\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net7.0_win-x64_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Debug\net7.0\linux-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net7.0_linux-x64_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Debug\net7.0\osx-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net7.0_osx-x64_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Debug\net8.0\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net8.0_win-x64_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Debug\net8.0\linux-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net8.0_linux-x64_debug.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Debug\net8.0\osx-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net8.0_osx-x64_debug.zip *
|
||||
|
||||
REM Create MPF.Check Release archives
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Release\net48\win7-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net48_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Release\net6.0\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net6.0_win-x64_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Release\net6.0\linux-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net6.0_linux-x64_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Release\net6.0\osx-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net6.0_osx-x64_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Release\net7.0\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net7.0_win-x64_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Release\net7.0\linux-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net7.0_linux-x64_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Release\net7.0\osx-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net7.0_osx-x64_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Release\net8.0\win-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net8.0_win-x64_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Release\net8.0\linux-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net8.0_linux-x64_release.zip *
|
||||
cd %BUILD_FOLDER%\MPF.Check\bin\Release\net8.0\osx-x64\publish\
|
||||
7z a -tzip %BUILD_FOLDER%\MPF.Check_net8.0_osx-x64_release.zip *
|
||||
|
||||
157
publish-win.ps1
Normal file
157
publish-win.ps1
Normal file
@@ -0,0 +1,157 @@
|
||||
# This batch file assumes the following:
|
||||
# - .NET 8.0 (or newer) SDK is installed and in PATH
|
||||
# - 7-zip commandline (7z.exe) is installed and in PATH
|
||||
# - Git for Windows is installed and in PATH
|
||||
# - The relevant commandline programs are already downloaded
|
||||
# and put into their respective folders
|
||||
#
|
||||
# If any of these are not satisfied, the operation may fail
|
||||
# in an unpredictable way and result in an incomplete output.
|
||||
|
||||
# Optional parameters
|
||||
param(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[Alias("UseAll")]
|
||||
[switch]$USE_ALL,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[Alias("IncludePrograms")]
|
||||
[switch]$INCLUDE_PROGRAMS,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[Alias("NoBuild")]
|
||||
[switch]$NO_BUILD,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[Alias("NoArchive")]
|
||||
[switch]$NO_ARCHIVE
|
||||
)
|
||||
|
||||
# Set the current directory as a variable
|
||||
$BUILD_FOLDER = $PSScriptRoot
|
||||
|
||||
# Set the current commit hash
|
||||
$COMMIT = git log --pretty=format:"%H" -1
|
||||
|
||||
# Create the build matrix arrays
|
||||
$UI_FRAMEWORKS = @('net6.0-windows', 'net8.0-windows')
|
||||
$UI_RUNTIMES = @('win-x64')
|
||||
$CHECK_FRAMEWORKS = @('net6.0', 'net8.0')
|
||||
$CHECK_RUNTIMES = @('win-x64', 'linux-x64', 'osx-x64')
|
||||
|
||||
# Use expanded lists, if requested
|
||||
if ($USE_ALL.IsPresent)
|
||||
{
|
||||
$UI_FRAMEWORKS = @('net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0-windows', 'net6.0-windows', 'net7.0-windows', 'net8.0-windows')
|
||||
$UI_RUNTIMES = @('win-x86', 'win-x64')
|
||||
$CHECK_FRAMEWORKS = @('net20', 'net35', 'net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0')
|
||||
$CHECK_RUNTIMES = @('win-x86', 'win-x64', 'win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64')
|
||||
}
|
||||
|
||||
# Create the filter arrays
|
||||
$SINGLE_FILE_CAPABLE = @('net5.0', 'net5.0-windows', 'net6.0', 'net6.0-windows', 'net7.0', 'net7.0-windows', 'net8.0', 'net8.0-windows')
|
||||
$VALID_CROSS_PLATFORM_FRAMEWORKS = @('netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0')
|
||||
$VALID_CROSS_PLATFORM_RUNTIMES = @('win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64')
|
||||
|
||||
# Only build if requested
|
||||
if (!$NO_BUILD.IsPresent)
|
||||
{
|
||||
# Restore Nuget packages for all builds
|
||||
Write-Host "Restoring Nuget packages"
|
||||
dotnet restore
|
||||
|
||||
# Build UI
|
||||
foreach ($FRAMEWORK in $UI_FRAMEWORKS)
|
||||
{
|
||||
foreach ($RUNTIME in $UI_RUNTIMES)
|
||||
{
|
||||
# Only .NET 5 and above can publish to a single file
|
||||
if ($SINGLE_FILE_CAPABLE -contains $FRAMEWORK)
|
||||
{
|
||||
dotnet publish MPF\MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
dotnet publish MPF\MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
}
|
||||
else
|
||||
{
|
||||
dotnet publish MPF\MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT
|
||||
dotnet publish MPF\MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Build Check
|
||||
foreach ($FRAMEWORK in $CHECK_FRAMEWORKS)
|
||||
{
|
||||
foreach ($RUNTIME in $CHECK_RUNTIMES)
|
||||
{
|
||||
# If we have an invalid combination of framework and runtime
|
||||
if ($VALID_CROSS_PLATFORM_FRAMEWORKS -notcontains $FRAMEWORK -and $VALID_CROSS_PLATFORM_RUNTIMES -contains $RUNTIME)
|
||||
{
|
||||
continue
|
||||
}
|
||||
|
||||
# Only .NET 5 and above can publish to a single file
|
||||
if ($SINGLE_FILE_CAPABLE -contains $FRAMEWORK)
|
||||
{
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
|
||||
}
|
||||
else
|
||||
{
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT
|
||||
dotnet publish MPF.Check\MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Only create archives if requested
|
||||
if (!$NO_ARCHIVE.IsPresent)
|
||||
{
|
||||
# Create UI archives
|
||||
foreach ($FRAMEWORK in $UI_FRAMEWORKS)
|
||||
{
|
||||
foreach ($RUNTIME in $UI_RUNTIMES)
|
||||
{
|
||||
Set-Location -Path $BUILD_FOLDER\MPF\bin\Debug\$FRAMEWORK\$RUNTIME\publish\
|
||||
if ($INCLUDE_PROGRAMS.IsPresent)
|
||||
{
|
||||
7z a -tzip $BUILD_FOLDER\MPF_${FRAMEWORK}_${RUNTIME}_debug.zip *
|
||||
}
|
||||
else
|
||||
{
|
||||
7z a -tzip -x!Programs\* $BUILD_FOLDER\MPF_${FRAMEWORK}_${RUNTIME}_debug.zip *
|
||||
}
|
||||
Set-Location -Path $BUILD_FOLDER\MPF\bin\Release\$FRAMEWORK\$RUNTIME\publish\
|
||||
if ($INCLUDE_PROGRAMS.IsPresent)
|
||||
{
|
||||
7z a -tzip $BUILD_FOLDER\MPF_${FRAMEWORK}_${RUNTIME}_release.zip *
|
||||
}
|
||||
else
|
||||
{
|
||||
7z a -tzip -x!Programs\* $BUILD_FOLDER\MPF_${FRAMEWORK}_${RUNTIME}_release.zip *
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Create Check archives
|
||||
foreach ($FRAMEWORK in $CHECK_FRAMEWORKS)
|
||||
{
|
||||
foreach ($RUNTIME in $CHECK_RUNTIMES)
|
||||
{
|
||||
# If we have an invalid combination of framework and runtime
|
||||
if ($VALID_CROSS_PLATFORM_FRAMEWORKS -notcontains $FRAMEWORK -and $VALID_CROSS_PLATFORM_RUNTIMES -contains $RUNTIME)
|
||||
{
|
||||
continue
|
||||
}
|
||||
|
||||
Set-Location -Path $BUILD_FOLDER\MPF.Check\bin\Debug\$FRAMEWORK\$RUNTIME\publish\
|
||||
7z a -tzip $BUILD_FOLDER\MPF.Check_${FRAMEWORK}_${RUNTIME}_debug.zip *
|
||||
Set-Location -Path $BUILD_FOLDER\MPF.Check\bin\Release\$FRAMEWORK\${RUNTIME}\publish\
|
||||
7z a -tzip $BUILD_FOLDER\MPF.Check_${FRAMEWORK}_${RUNTIME}_release.zip *
|
||||
}
|
||||
}
|
||||
|
||||
# Reset the directory
|
||||
Set-Location -Path $PSScriptRoot
|
||||
}
|
||||
Reference in New Issue
Block a user