Add files via upload
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<Project>
|
||||
<Import Project="Global.csproj" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows10.0.17763.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
BIN
Valorant Hyper V Driver/Valorant Hyper V Driver/BOOT/BOOTx64.efi
Normal file
BIN
Valorant Hyper V Driver/Valorant Hyper V Driver/BOOT/BOOTx64.efi
Normal file
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
<%@ Application Codebehind="Global.asax.cs" Inherits="HyperVAdmin.MvcApplication" Language="C#" %>
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Optimization;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace HyperVAdmin
|
||||
{
|
||||
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
|
||||
// visit http://go.microsoft.com/?LinkId=9394801
|
||||
|
||||
#pragma warning disable 1591
|
||||
public class MvcApplication : System.Web.HttpApplication
|
||||
{
|
||||
protected void Application_Start()
|
||||
{
|
||||
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
||||
BundleConfig.RegisterBundles(BundleTable.Bundles);
|
||||
|
||||
// Removing all the view engines
|
||||
ViewEngines.Engines.Clear();
|
||||
|
||||
//Add Razor Engine (which we are using)
|
||||
ViewEngines.Engines.Add(new ViewEngine());
|
||||
|
||||
MvcHandler.DisableMvcResponseHeader = true;
|
||||
}
|
||||
|
||||
protected void Application_EndRequest()
|
||||
{
|
||||
// removing excessive headers. They don't need to see this.
|
||||
Response.Headers.Remove("Server");
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>1.0.0</Version>
|
||||
<Company>André Zammit</Company>
|
||||
<Copyright>André Zammit 2021</Copyright>
|
||||
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<BaseOutputPath>..\..\Bin\</BaseOutputPath>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,3 @@
|
||||
<Project>
|
||||
<Import Project="Global.csproj" />
|
||||
</Project>
|
||||
@@ -0,0 +1,125 @@
|
||||
using Microsoft.Web.Administration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace HyperVAdmin.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// The Model representing a site.
|
||||
/// </summary>
|
||||
public class SiteModel
|
||||
{
|
||||
/// <summary>
|
||||
/// IIS ServerManager used to retrieve sites and info.
|
||||
/// </summary>
|
||||
public static ServerManager Manager = new ServerManager();
|
||||
|
||||
/// <summary>
|
||||
/// The name of the Site.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The fullpath of the site's location.
|
||||
/// </summary>
|
||||
public string PhysicalPath { get; set; }
|
||||
|
||||
private Dictionary<string, string> _bindings = new Dictionary<string, string>();
|
||||
/// <summary>
|
||||
/// The bindings of the Site.
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Bindings
|
||||
{
|
||||
get
|
||||
{
|
||||
return _bindings;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current state of the Site, such as stopped, started etc.
|
||||
/// </summary>
|
||||
public ObjectState State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The web applications defined for a site.
|
||||
/// </summary>
|
||||
public List<Application> Applications { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a list of SiteModels.
|
||||
/// </summary>
|
||||
/// <returns>A list of SiteModels</returns>
|
||||
public static List<SiteModel> GetSites()
|
||||
{
|
||||
ServerManager manager = new ServerManager();
|
||||
List<SiteModel> models = new List<SiteModel>();
|
||||
|
||||
foreach (Site site in manager.Sites)
|
||||
{
|
||||
SiteModel model = new SiteModel
|
||||
{
|
||||
Name = site.Name,
|
||||
PhysicalPath = site.Applications[0].VirtualDirectories[0].PhysicalPath,
|
||||
State = site.State,
|
||||
Applications = site.Applications.Where(app => app.Path != "/").ToList()
|
||||
};
|
||||
|
||||
foreach (Binding binding in site.Bindings.OrderBy(b => b.Protocol))
|
||||
{
|
||||
if (binding.Protocol.ToLowerInvariant() == "http" || binding.Protocol.ToLowerInvariant() == "https")
|
||||
{
|
||||
string url = binding.Protocol + "://" + (binding.Host != string.Empty ? binding.Host : Environment.MachineName);
|
||||
|
||||
if (binding.EndPoint != null &&
|
||||
!(binding.EndPoint.Port == 80 && binding.Protocol == "http") &&
|
||||
!(binding.EndPoint.Port == 443 && binding.Protocol == "https"))
|
||||
{
|
||||
url += ":" + binding.EndPoint.Port;
|
||||
}
|
||||
|
||||
if (!model.Bindings.ContainsKey(binding.Protocol))
|
||||
{
|
||||
model.Bindings.Add(binding.Protocol, url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
models.Add(model);
|
||||
}
|
||||
|
||||
models = models.OrderBy(s => s.Name).ToList();
|
||||
|
||||
return models;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops an IIS website.
|
||||
/// </summary>
|
||||
/// <param name="sitename">The site to stop.</param>
|
||||
public static void StopSite(string sitename)
|
||||
{
|
||||
Site site = Manager.Sites.FirstOrDefault(s => s.Name == sitename);
|
||||
|
||||
if (site != null)
|
||||
{
|
||||
site.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts an IIS website.
|
||||
/// </summary>
|
||||
/// <param name="sitename">The site to start.</param>
|
||||
public static void StartSite(string sitename)
|
||||
{
|
||||
Site site = Manager.Sites.FirstOrDefault(s => s.Name == sitename);
|
||||
|
||||
if (site != null)
|
||||
{
|
||||
site.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
using HyperVAdmin.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace HyperVAdmin.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// The model representing a VirtualMachine
|
||||
/// </summary>
|
||||
public class VirtualMachineModel
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the VM.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The description of the VM.
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The total Virtual Memory available for this VM.
|
||||
/// </summary>
|
||||
public UInt64 MemoryTotal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The units of virtual memory allocation as a string (such as MB).
|
||||
/// </summary>
|
||||
public string MemoryAllocationUnits { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The current state of the VM. Such as start, stop etc.
|
||||
/// </summary>
|
||||
public VirtualMachineState State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The amounts of virtual cores associated with this VM.
|
||||
/// </summary>
|
||||
public ushort CoresAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The MAC address of the virtual network switch adapter.
|
||||
/// </summary>
|
||||
public string MAC { get; set; }
|
||||
|
||||
private UInt16 _cpuLoad = 0;
|
||||
/// <summary>
|
||||
/// The CPULoad retrieved from WMI.
|
||||
/// </summary>
|
||||
public UInt16? CPULoad
|
||||
{
|
||||
get
|
||||
{
|
||||
return _cpuLoad;
|
||||
}
|
||||
set
|
||||
{
|
||||
_cpuLoad = value == null ? (UInt16)0 : (UInt16)value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The last time the VirtualMachineState was changed.
|
||||
/// </summary>
|
||||
public DateTime TimeOfLastStateChange { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time in ms inidicating how long the VM has been running. Will be 0 when off.
|
||||
/// </summary>
|
||||
public UInt64 OnTimeInMilliseconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A human readable string of the last time the VirtualMachineState was changed.
|
||||
/// </summary>
|
||||
public string TimeOfLastStateChangeFormatted
|
||||
{
|
||||
get
|
||||
{
|
||||
return TimeOfLastStateChange.ToString("dd-MM-yyyy HH:mm:ss");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A TimeSpan inidicating how long the VM has been running.
|
||||
/// </summary>
|
||||
public TimeSpan GetOnTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return TimeSpan.FromMilliseconds(OnTimeInMilliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A human readable represantation of the time the VM has been running.
|
||||
/// </summary>
|
||||
public string GetOnTimeFormatted
|
||||
{
|
||||
get
|
||||
{
|
||||
return TimeSpan.FromMilliseconds(OnTimeInMilliseconds).ToString(@"dd\.hh\:mm\:ss");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of VirtualMachinesModels.
|
||||
/// </summary>
|
||||
/// <returns>A list of VirtualMachineModels.</returns>
|
||||
public static List<VirtualMachineModel> GetVMList()
|
||||
{
|
||||
ManagementScope scope = GetVMScope();
|
||||
|
||||
// define the information we want to query - in this case, just grab all properties of the object
|
||||
ObjectQuery queryObj = new ObjectQuery(ConfigurationManager.AppSettings["HyperVQueryVMs"].ToString());
|
||||
|
||||
// connect and set up our search
|
||||
ManagementObjectSearcher vmSearcher = new ManagementObjectSearcher(scope, queryObj);
|
||||
List<ManagementObject> vmCollection = vmSearcher.Get().Cast<ManagementObject>().OrderBy(vm => vm["ElementName"]).ToList();
|
||||
List<VirtualMachineModel> vms = new List<VirtualMachineModel>();
|
||||
|
||||
foreach (ManagementObject vm in vmCollection)
|
||||
{
|
||||
ManagementObject settings = vm.GetRelated("Msvm_VirtualSystemSettingData").Cast<ManagementObject>().ToList().FirstOrDefault();
|
||||
ManagementObject memorySettings = settings.GetRelated("Msvm_MemorySettingData").Cast<ManagementObject>().ToList().FirstOrDefault();
|
||||
ManagementObject ethernet = settings.GetRelated("Msvm_SyntheticEthernetPortSettingData").Cast<ManagementObject>().ToList().FirstOrDefault();
|
||||
ManagementObject information = vm.GetRelated("Msvm_SummaryInformation").Cast<ManagementObject>().ToList().FirstOrDefault();
|
||||
|
||||
string mac = string.Empty;
|
||||
if (ethernet == null)
|
||||
{
|
||||
ethernet = settings.GetRelated("Msvm_EmulatedEthernetPortSettingData").Cast<ManagementObject>().ToList().FirstOrDefault();
|
||||
}
|
||||
|
||||
if(ethernet != null)
|
||||
{
|
||||
mac = Regex.Replace(ethernet["Address"].ToString(), ".{2}", "$0:");
|
||||
}
|
||||
|
||||
vms.Add(new VirtualMachineModel
|
||||
{
|
||||
Name = vm["ElementName"].ToString(),
|
||||
Description = vm["Description"].ToString(),
|
||||
State = (VirtualMachineState)(UInt16)vm["EnabledState"],
|
||||
MemoryTotal = (UInt64)memorySettings["VirtualQuantity"],
|
||||
MemoryAllocationUnits = memorySettings["AllocationUnits"].ToString() == "byte * 2^20" ? "MB" : memorySettings["AllocationUnits"].ToString(),
|
||||
CoresAmount = information != null ? (ushort)information["NumberOfProcessors"] : (ushort)0,
|
||||
CPULoad = information != null ? (UInt16?)information["ProcessorLoad"] : null,
|
||||
MAC = string.IsNullOrWhiteSpace(mac) ? mac : mac.Substring(0, mac.Length - 1),
|
||||
TimeOfLastStateChange = ManagementDateTimeConverter.ToDateTime(vm["TimeOfLastStateChange"].ToString()),
|
||||
OnTimeInMilliseconds = (UInt64)vm["OnTimeInMilliseconds"]
|
||||
});
|
||||
}
|
||||
|
||||
return vms;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggles the state of the VM. The vmName is used to target the VM and the state is used to set the state of the VM.
|
||||
/// </summary>
|
||||
/// <param name="vmName">Which VM to toggle.</param>
|
||||
/// <param name="state">What VirtualMachineState to set the VM to.</param>
|
||||
/// <returns>A string indicating success of the action.</returns>
|
||||
public static string ToggleState(string vmName, VirtualMachineState state)
|
||||
{
|
||||
ManagementScope scope = GetVMScope();
|
||||
ManagementObject vm = HyperVUtility.GetTargetComputer(vmName, scope);
|
||||
ManagementBaseObject inParams = vm.GetMethodParameters("RequestStateChange");
|
||||
inParams["RequestedState"] = state;
|
||||
|
||||
ManagementBaseObject outParams = vm.InvokeMethod("RequestStateChange", inParams, null);
|
||||
|
||||
string returnValue = string.Empty;
|
||||
|
||||
if ((UInt32)outParams["ReturnValue"] == ReturnCode.Started)
|
||||
{
|
||||
if (HyperVUtility.JobCompleted(outParams, scope))
|
||||
{
|
||||
returnValue = string.Format("VM '{0}' state was changed successfully.", vmName);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = "Failed to change virtual system state";
|
||||
}
|
||||
}
|
||||
else if ((UInt32)outParams["ReturnValue"] == ReturnCode.Completed)
|
||||
{
|
||||
returnValue = string.Format("VM '{0}' state was changed successfully.", vmName);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = string.Format("Change virtual system state failed with error {0}.", outParams["ReturnValue"]);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to retrieve the VirtualMachineModel List by GetVMList.
|
||||
/// </summary>
|
||||
/// <returns>The ManagementScope object to use to build the VM List.</returns>
|
||||
public static ManagementScope GetVMScope()
|
||||
{
|
||||
return new ManagementScope(ConfigurationManager.AppSettings["HyperVManagementPath"].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The used VirtualMachineStates used internally by WMI. Only supported states for this application are present.</summary>
|
||||
public enum VirtualMachineState
|
||||
{
|
||||
/// <summary>
|
||||
/// The on state
|
||||
/// </summary>
|
||||
Enabled = 2,
|
||||
/// <summary>
|
||||
/// The off state
|
||||
/// </summary>
|
||||
Disabled = 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Diagnostics;
|
||||
using System.Web;
|
||||
|
||||
namespace HyperVAdmin.Modules
|
||||
{
|
||||
/// <summary>
|
||||
/// A HTTPModule to keep trak of duration of page lifecycle
|
||||
/// </summary>
|
||||
public class TimingModule : IHttpModule
|
||||
{
|
||||
/// <summary>
|
||||
/// Disposes this module
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bind BeginRequest eventhandler
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public void Init(HttpApplication context)
|
||||
{
|
||||
context.BeginRequest += OnBeginRequest;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start a stopwatch at the beginning of the request to calculate duration of lifecycle
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void OnBeginRequest(object sender, System.EventArgs e)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
HttpContext.Current.Items["Stopwatch"] = stopwatch;
|
||||
stopwatch.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Valorant Hyper V Driver/Valorant Hyper V Driver/Program.cs
Normal file
22
Valorant Hyper V Driver/Valorant Hyper V Driver/Program.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace HyperVAdmin
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom viewengine, to optimize view resolving.
|
||||
/// </summary>
|
||||
public class ViewEngine : RazorViewEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// The cosntructor overrides the default view locations and extensions to minimize the paths to look in
|
||||
/// when MVC needs to find a view.
|
||||
/// </summary>
|
||||
public ViewEngine()
|
||||
{
|
||||
ViewLocationFormats = new string[] { "~/Views/{1}/{0}.cshtml" };
|
||||
MasterLocationFormats = new string[] { "~/Views/Shared/{0}.cshtml" };
|
||||
PartialViewLocationFormats = new string[] { "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" };
|
||||
FileExtensions = new string[] { "cshtml" };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyCopyright("Copyright © 2016 - 2019 Jos Nienhuis")]
|
||||
@@ -0,0 +1,5 @@
|
||||
<#@ template language="C#" #>
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyCopyright("Copyright © 2016 - <#=DateTime.Now.Year#> Jos Nienhuis")]
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("HyperVAdmin")]
|
||||
[assembly: AssemblyDescription("A simple website to manage your Hyper-V VMs")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("GotGeeks.nl")]
|
||||
[assembly: AssemblyProduct("HyperVAdmin")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("en")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("c4f74d63-9e2f-4b15-8dc4-c36d153e5053")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.5")]
|
||||
[assembly: AssemblyFileVersion("1.5")]
|
||||
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Worker">
|
||||
|
||||
<Import Project="..\..\Misc\Shared Project Files\App.csproj" />
|
||||
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>dotnet-HyperVLauncher.Services.Monitor-0EF1C2E7-463D-47EE-8AA1-301B9B48A2F6</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Providers\HyperVLauncher.Providers.Common\HyperVLauncher.Providers.Common.csproj" />
|
||||
<ProjectReference Include="..\..\Providers\HyperVLauncher.Providers.HyperV\HyperVLauncher.Providers.HyperV.csproj" />
|
||||
<ProjectReference Include="..\..\Providers\HyperVLauncher.Providers.Ipc\HyperVLauncher.Providers.Ipc.csproj" />
|
||||
<ProjectReference Include="..\..\Providers\HyperVLauncher.Providers.Settings\HyperVLauncher.Providers.Settings.csproj" />
|
||||
<ProjectReference Include="..\..\Providers\HyperVLauncher.Providers.Shortcut\HyperVLauncher.Providers.Shortcut.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,110 @@
|
||||
using HyperVLauncher.Contracts.Models;
|
||||
using HyperVLauncher.Contracts.Interfaces;
|
||||
|
||||
using HyperVLauncher.Providers.Tracing;
|
||||
|
||||
namespace HyperVLauncher.Services.Monitor
|
||||
{
|
||||
public class MonitorService
|
||||
{
|
||||
private readonly IHyperVProvider _hyperVProvider;
|
||||
private readonly ITrayIpcProvider _trayIpcProvider;
|
||||
private readonly IShortcutProvider _shortcutProvider;
|
||||
private readonly ISettingsProvider _settingsProvider;
|
||||
private readonly CancellationToken _cancellationToken;
|
||||
|
||||
public MonitorService(
|
||||
IHyperVProvider hyperVProvider,
|
||||
ITrayIpcProvider trayIpcProvider,
|
||||
ISettingsProvider settingsProvider,
|
||||
IShortcutProvider shortcutProvider,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
_hyperVProvider = hyperVProvider;
|
||||
_trayIpcProvider = trayIpcProvider;
|
||||
_shortcutProvider = shortcutProvider;
|
||||
_settingsProvider = settingsProvider;
|
||||
_cancellationToken = cancellationToken;
|
||||
}
|
||||
|
||||
public async Task Run()
|
||||
{
|
||||
await CheckForInvalidShortcuts();
|
||||
|
||||
_hyperVProvider.StartVirtualMachineCreatedMonitor(_cancellationToken);
|
||||
_hyperVProvider.StartVirtualMachineDeletedMonitor(_cancellationToken);
|
||||
|
||||
_hyperVProvider.OnVirtualMachineCreated = OnVirtualMachineCreated;
|
||||
_hyperVProvider.OnVirtualMachineDeleted = OnVirtualMachineDeleted;
|
||||
}
|
||||
|
||||
private async Task CheckForInvalidShortcuts()
|
||||
{
|
||||
var appSettings = await _settingsProvider.Get(true);
|
||||
|
||||
if (!appSettings.AutoDeleteShortcuts)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Tracer.Info("Checking for invalid shortcuts...");
|
||||
|
||||
var vmList = _hyperVProvider.GetVirtualMachineList().ToList();
|
||||
|
||||
var vmIdsToDelete = new HashSet<string>();
|
||||
|
||||
foreach (var shortcut in appSettings.Shortcuts)
|
||||
{
|
||||
if (vmList.FirstOrDefault(x => x.Id == shortcut.VmId) is null)
|
||||
{
|
||||
vmIdsToDelete.Add(shortcut.VmId);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var vmIdToDelete in vmIdsToDelete)
|
||||
{
|
||||
await _settingsProvider.DeleteVirtualMachineShortcuts(
|
||||
vmIdToDelete,
|
||||
_trayIpcProvider,
|
||||
_shortcutProvider);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OnVirtualMachineCreated(VirtualMachine vm)
|
||||
{
|
||||
Tracer.Info($"New Virtual Machine detected: {vm.Id} - {vm.Name}");
|
||||
|
||||
var appSettings = await _settingsProvider.Get(true);
|
||||
|
||||
if (appSettings.AutoCreateShortcuts)
|
||||
{
|
||||
await _settingsProvider.ProcessCreateShortcut(
|
||||
vm.Id,
|
||||
vm.Name,
|
||||
_trayIpcProvider,
|
||||
_shortcutProvider);
|
||||
}
|
||||
else if (appSettings.NotifyOnNewVm)
|
||||
{
|
||||
await _trayIpcProvider.SendShowShortcutPromptNotif(
|
||||
vm.Id,
|
||||
vm.Name);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OnVirtualMachineDeleted(VirtualMachine vm)
|
||||
{
|
||||
Tracer.Info($"Deleted Virtual Machine detected: {vm.Id} - {vm.Name}");
|
||||
|
||||
var appSettings = await _settingsProvider.Get(true);
|
||||
|
||||
if (appSettings.AutoDeleteShortcuts)
|
||||
{
|
||||
await _settingsProvider.DeleteVirtualMachineShortcuts(
|
||||
vm.Id,
|
||||
_trayIpcProvider,
|
||||
_shortcutProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using HyperVLauncher.Contracts.Constants;
|
||||
using HyperVLauncher.Contracts.Interfaces;
|
||||
|
||||
using HyperVLauncher.Providers.Ipc;
|
||||
using HyperVLauncher.Providers.Path;
|
||||
using HyperVLauncher.Providers.HyperV;
|
||||
using HyperVLauncher.Providers.Tracing;
|
||||
using HyperVLauncher.Providers.Settings;
|
||||
using HyperVLauncher.Providers.Shortcut;
|
||||
|
||||
using HyperVLauncher.Services.Monitor;
|
||||
|
||||
var pathProvider = new PathProvider(GeneralConstants.ProfileName);
|
||||
pathProvider.CreateDirectories();
|
||||
|
||||
TracingProvider.Init(pathProvider.GetTracingPath(), "Monitor");
|
||||
|
||||
Tracer.Info("Starting Virtual Machine monitor service...");
|
||||
|
||||
var hostBuilder = Host.CreateDefaultBuilder(args)
|
||||
.ConfigureServices(services =>
|
||||
{
|
||||
services.AddHostedService<Worker>();
|
||||
services.AddSingleton<IHyperVProvider, HyperVProvider>();
|
||||
services.AddSingleton<ISettingsProvider, SettingsProvider>();
|
||||
services.AddSingleton<IShortcutProvider, ShortcutProvider>();
|
||||
|
||||
services.AddSingleton<IPathProvider>(provider => pathProvider);
|
||||
services.AddSingleton<ITrayIpcProvider>(provider => new IpcProvider(GeneralConstants.TrayIpcPipeName));
|
||||
});
|
||||
|
||||
if (Environment.UserInteractive)
|
||||
{
|
||||
await hostBuilder
|
||||
.RunConsoleAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await hostBuilder
|
||||
.UseWindowsService()
|
||||
.Build()
|
||||
.RunAsync();
|
||||
}
|
||||
|
||||
Tracer.Info("Stopped Virtual Machine monitor service.");
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
namespace HyperVLauncher.Services.Monitor
|
||||
{
|
||||
public class Worker : BackgroundService
|
||||
{
|
||||
private Task? _monitorTask;
|
||||
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public Worker(IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
protected override Task ExecuteAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_monitorTask = Task.Run(async () =>
|
||||
{
|
||||
var monitorService = ActivatorUtilities
|
||||
.CreateInstance<MonitorService>(
|
||||
_serviceProvider,
|
||||
cancellationToken);
|
||||
|
||||
await monitorService.Run();
|
||||
}, cancellationToken);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await base.StopAsync(cancellationToken);
|
||||
|
||||
if (_monitorTask is not null)
|
||||
{
|
||||
await _monitorTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Web.Hosting;
|
||||
|
||||
namespace HyperVAdmin.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// A utility class to help with HTML related tasks.
|
||||
/// </summary>
|
||||
public static class HtmlUtility
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves the VirtualDirectory/Path (also for "IIS Applications") when not hosted in the root of the domain
|
||||
/// </summary>
|
||||
/// <returns>Either the VirtualDirectory/Path (with trailing slash) or "/" when hosted in the domain</returns>
|
||||
public static string GetVirtualApplicationPath()
|
||||
{
|
||||
string path = HostingEnvironment.ApplicationVirtualPath;
|
||||
|
||||
if (path.Substring(path.Length - 1) != "/")
|
||||
{
|
||||
path += "/";
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
using System;
|
||||
using System.Management;
|
||||
|
||||
#pragma warning disable 1591
|
||||
namespace HyperVAdmin.Utilities
|
||||
{
|
||||
public static class ResourceType
|
||||
{
|
||||
public const UInt16 Other = 1;
|
||||
public const UInt16 ComputerSystem = 2;
|
||||
public const UInt16 Processor = 3;
|
||||
public const UInt16 Memory = 4;
|
||||
public const UInt16 IDEController = 5;
|
||||
public const UInt16 ParallelSCSIHBA = 6;
|
||||
public const UInt16 FCHBA = 7;
|
||||
public const UInt16 iSCSIHBA = 8;
|
||||
public const UInt16 IBHCA = 9;
|
||||
public const UInt16 EthernetAdapter = 10;
|
||||
public const UInt16 OtherNetworkAdapter = 11;
|
||||
public const UInt16 IOSlot = 12;
|
||||
public const UInt16 IODevice = 13;
|
||||
public const UInt16 FloppyDrive = 14;
|
||||
public const UInt16 CDDrive = 15;
|
||||
public const UInt16 DVDdrive = 16;
|
||||
public const UInt16 Serialport = 17;
|
||||
public const UInt16 Parallelport = 18;
|
||||
public const UInt16 USBController = 19;
|
||||
public const UInt16 GraphicsController = 20;
|
||||
public const UInt16 StorageExtent = 21;
|
||||
public const UInt16 Disk = 22;
|
||||
public const UInt16 Tape = 23;
|
||||
public const UInt16 OtherStorageDevice = 24;
|
||||
public const UInt16 FirewireController = 25;
|
||||
public const UInt16 PartitionableUnit = 26;
|
||||
public const UInt16 BasePartitionableUnit = 27;
|
||||
public const UInt16 PowerSupply = 28;
|
||||
public const UInt16 CoolingDevice = 29;
|
||||
public const UInt16 DisketteController = 1;
|
||||
}
|
||||
|
||||
public static class ResourceSubType
|
||||
{
|
||||
public const string DisketteController = null;
|
||||
public const string DisketteDrive = "Microsoft Synthetic Diskette Drive";
|
||||
public const string ParallelSCSIHBA = "Microsoft Synthetic SCSI Controller";
|
||||
public const string IDEController = "Microsoft Emulated IDE Controller";
|
||||
public const string DiskSynthetic = "Microsoft Synthetic Disk Drive";
|
||||
public const string DiskPhysical = "Microsoft Physical Disk Drive";
|
||||
public const string DVDPhysical = "Microsoft Physical DVD Drive";
|
||||
public const string DVDSynthetic = "Microsoft Synthetic DVD Drive";
|
||||
public const string CDROMPhysical = "Microsoft Physical CD Drive";
|
||||
public const string CDROMSynthetic = "Microsoft Synthetic CD Drive";
|
||||
public const string EthernetSynthetic = "Microsoft Synthetic Ethernet Port";
|
||||
|
||||
//logical drive
|
||||
public const string DVDLogical = "Microsoft Virtual CD/DVD Disk";
|
||||
public const string ISOImage = "Microsoft ISO Image";
|
||||
public const string VHD = "Microsoft Virtual Hard Disk";
|
||||
public const string DVD = "Microsoft Virtual DVD Disk";
|
||||
public const string VFD = "Microsoft Virtual Floppy Disk";
|
||||
public const string videoSynthetic = "Microsoft Synthetic Display Controller";
|
||||
}
|
||||
|
||||
public static class OtherResourceType
|
||||
{
|
||||
public const string DisketteController = "Microsoft Virtual Diskette Controller";
|
||||
|
||||
}
|
||||
public static class ReturnCode
|
||||
{
|
||||
public const UInt32 Completed = 0;
|
||||
public const UInt32 Started = 4096;
|
||||
public const UInt32 Failed = 32768;
|
||||
public const UInt32 AccessDenied = 32769;
|
||||
public const UInt32 NotSupported = 32770;
|
||||
public const UInt32 Unknown = 32771;
|
||||
public const UInt32 Timeout = 32772;
|
||||
public const UInt32 InvalidParameter = 32773;
|
||||
public const UInt32 SystemInUse = 32774;
|
||||
public const UInt32 InvalidState = 32775;
|
||||
public const UInt32 IncorrectDataType = 32776;
|
||||
public const UInt32 SystemNotAvailable = 32777;
|
||||
public const UInt32 OutofMemory = 32778;
|
||||
}
|
||||
|
||||
public class HyperVUtility
|
||||
{
|
||||
static class JobState
|
||||
{
|
||||
public const UInt16 New = 2;
|
||||
public const UInt16 Starting = 3;
|
||||
public const UInt16 Running = 4;
|
||||
public const UInt16 Suspended = 5;
|
||||
public const UInt16 ShuttingDown = 6;
|
||||
public const UInt16 Completed = 7;
|
||||
public const UInt16 Terminated = 8;
|
||||
public const UInt16 Killed = 9;
|
||||
public const UInt16 Exception = 10;
|
||||
public const UInt16 Service = 11;
|
||||
}
|
||||
/// <summary>
|
||||
/// Common utility function to get a service object
|
||||
/// </summary>
|
||||
/// <param name="scope"></param>
|
||||
/// <param name="serviceName"></param>
|
||||
/// <returns></returns>
|
||||
public static ManagementObject GetServiceObject(ManagementScope scope, string serviceName)
|
||||
{
|
||||
scope.Connect();
|
||||
ManagementPath wmiPath = new ManagementPath(serviceName);
|
||||
ManagementClass serviceClass = new ManagementClass(scope, wmiPath, null);
|
||||
ManagementObjectCollection services = serviceClass.GetInstances();
|
||||
|
||||
ManagementObject serviceObject = null;
|
||||
|
||||
foreach (ManagementObject service in services)
|
||||
{
|
||||
serviceObject = service;
|
||||
}
|
||||
return serviceObject;
|
||||
}
|
||||
|
||||
public static ManagementObject GetHostSystemDevice(string deviceClassName, string deviceObjectElementName, ManagementScope scope)
|
||||
{
|
||||
string hostName = System.Environment.MachineName;
|
||||
ManagementObject systemDevice = GetSystemDevice(deviceClassName, deviceObjectElementName, hostName, scope);
|
||||
return systemDevice;
|
||||
}
|
||||
|
||||
|
||||
public static ManagementObject GetSystemDevice(string deviceClassName, string deviceObjectElementName, string vmName, ManagementScope scope)
|
||||
{
|
||||
ManagementObject systemDevice = null;
|
||||
ManagementObject computerSystem = HyperVUtility.GetTargetComputer(vmName, scope);
|
||||
|
||||
ManagementObjectCollection systemDevices = computerSystem.GetRelated
|
||||
(
|
||||
deviceClassName,
|
||||
"Msvm_SystemDevice",
|
||||
null,
|
||||
null,
|
||||
"PartComponent",
|
||||
"GroupComponent",
|
||||
false,
|
||||
null
|
||||
);
|
||||
|
||||
foreach (ManagementObject device in systemDevices)
|
||||
{
|
||||
if (device["ElementName"].ToString().ToLower() == deviceObjectElementName.ToLower())
|
||||
{
|
||||
systemDevice = device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return systemDevice;
|
||||
}
|
||||
|
||||
public static bool JobCompleted(ManagementBaseObject outParams, ManagementScope scope)
|
||||
{
|
||||
bool jobCompleted = true;
|
||||
|
||||
//Retrieve msvc_StorageJob path. This is a full wmi path
|
||||
string JobPath = (string)outParams["Job"];
|
||||
ManagementObject Job = new ManagementObject(scope, new ManagementPath(JobPath), null);
|
||||
//Try to get storage job information
|
||||
Job.Get();
|
||||
while ((UInt16)Job["JobState"] == JobState.Starting
|
||||
|| (UInt16)Job["JobState"] == JobState.Running)
|
||||
{
|
||||
Console.WriteLine("In progress... {0}% completed.", Job["PercentComplete"]);
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
Job.Get();
|
||||
}
|
||||
|
||||
//Figure out if job failed
|
||||
UInt16 jobState = (UInt16)Job["JobState"];
|
||||
if (jobState != JobState.Completed)
|
||||
{
|
||||
UInt16 jobErrorCode = (UInt16)Job["ErrorCode"];
|
||||
Console.WriteLine("Error Code:{0}", jobErrorCode);
|
||||
Console.WriteLine("ErrorDescription: {0}", (string)Job["ErrorDescription"]);
|
||||
jobCompleted = false;
|
||||
}
|
||||
return jobCompleted;
|
||||
}
|
||||
|
||||
public static ManagementObject GetTargetComputer(string vmElementName, ManagementScope scope)
|
||||
{
|
||||
string query = string.Format("select * from Msvm_ComputerSystem Where ElementName = '{0}'", vmElementName);
|
||||
|
||||
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, new ObjectQuery(query));
|
||||
|
||||
ManagementObjectCollection computers = searcher.Get();
|
||||
|
||||
ManagementObject computer = null;
|
||||
|
||||
foreach (ManagementObject instance in computers)
|
||||
{
|
||||
computer = instance;
|
||||
break;
|
||||
}
|
||||
return computer;
|
||||
}
|
||||
|
||||
public static ManagementObject GetVirtualSystemSettingData(ManagementObject vm)
|
||||
{
|
||||
ManagementObject vmSetting = null;
|
||||
ManagementObjectCollection vmSettings = vm.GetRelated
|
||||
(
|
||||
"Msvm_VirtualSystemSettingData",
|
||||
"Msvm_SettingsDefineState",
|
||||
null,
|
||||
null,
|
||||
"SettingData",
|
||||
"ManagedElement",
|
||||
false,
|
||||
null
|
||||
);
|
||||
|
||||
if (vmSettings.Count != 1)
|
||||
{
|
||||
throw new Exception(String.Format("{0} instance of Msvm_VirtualSystemSettingData was found", vmSettings.Count));
|
||||
}
|
||||
|
||||
foreach (ManagementObject instance in vmSettings)
|
||||
{
|
||||
vmSetting = instance;
|
||||
break;
|
||||
}
|
||||
|
||||
return vmSetting;
|
||||
}
|
||||
|
||||
enum ValueRole
|
||||
{
|
||||
Default = 0,
|
||||
Minimum = 1,
|
||||
Maximum = 2,
|
||||
Increment = 3
|
||||
}
|
||||
|
||||
enum ValueRange
|
||||
{
|
||||
Default = 0,
|
||||
Minimum = 1,
|
||||
Maximum = 2,
|
||||
Increment = 3
|
||||
}
|
||||
|
||||
//
|
||||
// Get RASD definitions
|
||||
//
|
||||
public static ManagementObject GetResourceAllocationsettingDataDefault(ManagementScope scope, UInt16 resourceType, string resourceSubType, string otherResourceType)
|
||||
{
|
||||
ManagementObject RASD = null;
|
||||
|
||||
string query = String.Format("select * from Msvm_ResourcePool where ResourceType = '{0}' and ResourceSubType ='{1}' and OtherResourceType = '{2}'",
|
||||
resourceType, resourceSubType, otherResourceType);
|
||||
|
||||
if (resourceType == ResourceType.Other)
|
||||
{
|
||||
query = String.Format("select * from Msvm_ResourcePool where ResourceType = '{0}' and ResourceSubType = null and OtherResourceType = {1}",
|
||||
resourceType, otherResourceType);
|
||||
}
|
||||
else
|
||||
{
|
||||
query = String.Format("select * from Msvm_ResourcePool where ResourceType = '{0}' and ResourceSubType ='{1}' and OtherResourceType = null",
|
||||
resourceType, resourceSubType);
|
||||
}
|
||||
|
||||
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, new ObjectQuery(query));
|
||||
|
||||
ManagementObjectCollection poolResources = searcher.Get();
|
||||
|
||||
//Get pool resource allocation ability
|
||||
if (poolResources.Count == 1)
|
||||
{
|
||||
foreach (ManagementObject poolResource in poolResources)
|
||||
{
|
||||
ManagementObjectCollection allocationCapabilities = poolResource.GetRelated("Msvm_AllocationCapabilities");
|
||||
foreach (ManagementObject allocationCapability in allocationCapabilities)
|
||||
{
|
||||
ManagementObjectCollection settingDatas = allocationCapability.GetRelationships("Msvm_SettingsDefineCapabilities");
|
||||
foreach (ManagementObject settingData in settingDatas)
|
||||
{
|
||||
|
||||
if (Convert.ToInt16(settingData["ValueRole"]) == (UInt16)ValueRole.Default)
|
||||
{
|
||||
RASD = new ManagementObject(settingData["PartComponent"].ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return RASD;
|
||||
}
|
||||
|
||||
public static ManagementObject GetResourceAllocationsettingData(ManagementObject vm, UInt16 resourceType, string resourceSubType, string otherResourceType)
|
||||
{
|
||||
//vm->vmsettings->RASD for IDE controller
|
||||
ManagementObject RASD = null;
|
||||
ManagementObjectCollection settingDatas = vm.GetRelated("Msvm_VirtualSystemsettingData");
|
||||
foreach (ManagementObject settingData in settingDatas)
|
||||
{
|
||||
//retrieve the rasd
|
||||
ManagementObjectCollection RASDs = settingData.GetRelated("Msvm_ResourceAllocationsettingData");
|
||||
foreach (ManagementObject rasdInstance in RASDs)
|
||||
{
|
||||
if (Convert.ToUInt16(rasdInstance["ResourceType"]) == resourceType)
|
||||
{
|
||||
//found the matching type
|
||||
if (resourceType == ResourceType.Other)
|
||||
{
|
||||
if (rasdInstance["OtherResourceType"].ToString() == otherResourceType)
|
||||
{
|
||||
RASD = rasdInstance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rasdInstance["ResourceSubType"].ToString() == resourceSubType)
|
||||
{
|
||||
RASD = rasdInstance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return RASD;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
[
|
||||
//HyperVAdmin CSS
|
||||
{
|
||||
"includeInProject": true,
|
||||
"options": { "sourceMap": true },
|
||||
"outputFile": "Content/Styles/default.css",
|
||||
"inputFile": "Content/Styles/default.scss"
|
||||
},
|
||||
{
|
||||
"includeInProject": true,
|
||||
"minify": { "enabled": true },
|
||||
"outputFile": "Content/Styles/Default.min.css",
|
||||
"inputFile": "Content/Styles/Default.scss"
|
||||
}
|
||||
]
|
||||
49
Valorant Hyper V Driver/Valorant Hyper V Driver/libman.json
Normal file
49
Valorant Hyper V Driver/Valorant Hyper V Driver/libman.json
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"defaultProvider": "cdnjs",
|
||||
"libraries": [
|
||||
{
|
||||
"library": "jquery@3.6.0",
|
||||
"destination": "Content/Vendor/jquery/"
|
||||
},
|
||||
{
|
||||
"library": "fancybox@3.5.7",
|
||||
"destination": "Content/Vendor/fancybox/"
|
||||
},
|
||||
{
|
||||
"library": "jquery-fullscreen-plugin@1.1.5",
|
||||
"destination": "Content/Vendor/jquery-fullscreen-plugin/"
|
||||
},
|
||||
{
|
||||
"provider": "unpkg",
|
||||
"library": "@fortawesome/fontawesome-free@5.14.0",
|
||||
"destination": "Content/Vendor/fortawesome/",
|
||||
"files": [
|
||||
"scss/_variables.scss",
|
||||
"scss/_mixins.scss",
|
||||
"scss/_core.scss",
|
||||
"scss/_animated.scss"
|
||||
]
|
||||
},
|
||||
{
|
||||
"provider": "unpkg",
|
||||
"library": "bootstrap@5.1.3",
|
||||
"destination": "Content/Vendor/bootstrap/"
|
||||
},
|
||||
{
|
||||
"provider": "filesystem",
|
||||
"library": "https://raw.githubusercontent.com/joszz/is-loading/master/jquery.isloading.js",
|
||||
"destination": "Content/Vendor/jquery.isloading/"
|
||||
},
|
||||
{
|
||||
"provider": "filesystem",
|
||||
"library": "https://raw.githubusercontent.com/Illyism/jquery.vibrate.js/master/build/jquery/jquery.vibrate.js",
|
||||
"destination": "Content/Vendor/jquery.vibrate/"
|
||||
},
|
||||
{
|
||||
"provider": "filesystem",
|
||||
"library": "https://raw.githubusercontent.com/joszz/sorttable/master/sorttable.js",
|
||||
"destination": "Content/Vendor/sorttable/"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
|
||||
<package id="IIS.Microsoft.Web.Administration" version="8.5.9600.17042" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="5.0.0" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net472" />
|
||||
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net472" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
|
||||
<package id="Microsoft.Web.LibraryManager.Build" version="2.1.161" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
|
||||
</packages>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
105
Valorant Hyper V Driver/Valorant Hyper V Driver/visual_hyperinterval/Form1.Designer.cs
generated
Normal file
105
Valorant Hyper V Driver/Valorant Hyper V Driver/visual_hyperinterval/Form1.Designer.cs
generated
Normal file
@@ -0,0 +1,105 @@
|
||||
|
||||
namespace visual_hyperinterval
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором форм Windows
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.build = new System.Windows.Forms.Button();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
|
||||
this.pictureBox1.Location = new System.Drawing.Point(56, 13);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(649, 649);
|
||||
this.pictureBox1.TabIndex = 0;
|
||||
this.pictureBox1.TabStop = false;
|
||||
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
|
||||
this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
|
||||
//
|
||||
// build
|
||||
//
|
||||
this.build.Location = new System.Drawing.Point(733, 341);
|
||||
this.build.Name = "build";
|
||||
this.build.Size = new System.Drawing.Size(75, 23);
|
||||
this.build.TabIndex = 1;
|
||||
this.build.Text = "Построить";
|
||||
this.build.UseVisualStyleBackColor = true;
|
||||
this.build.Click += new System.EventHandler(this.build_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(693, 665);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(12, 13);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "x";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(38, 13);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(12, 13);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "y";
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(833, 687);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.build);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Визуализация генерации точек";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Button build;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace visual_hyperinterval
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private double MAX_EXPONENT_THREE = 3486784401.0;
|
||||
private List<uint> Points = new List<uint>();
|
||||
private List<uint> PointsHyp = new List<uint>();
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void build_Click(object sender, EventArgs e)
|
||||
{
|
||||
string path1 = @"D:\materials\projects\visual_hyperinterval\points.txt";
|
||||
string path2 = @"D:\materials\projects\visual_hyperinterval\hyp.txt";
|
||||
|
||||
using (StreamReader sr1 = new StreamReader(path1, System.Text.Encoding.Default))
|
||||
{
|
||||
string line1;
|
||||
while ((line1 = sr1.ReadLine()) != null)
|
||||
{
|
||||
Points.Add(uint.Parse(line1));
|
||||
}
|
||||
}
|
||||
|
||||
using (StreamReader sr2 = new StreamReader(path2, System.Text.Encoding.Default))
|
||||
{
|
||||
string line2;
|
||||
while ((line2 = sr2.ReadLine()) != null)
|
||||
{
|
||||
PointsHyp.Add(uint.Parse(line2));
|
||||
}
|
||||
}
|
||||
|
||||
pictureBox1.Invalidate();
|
||||
}
|
||||
|
||||
private void pictureBox1_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void pictureBox1_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
Graphics gr = e.Graphics;
|
||||
System.Drawing.Rectangle rect;
|
||||
rect = new Rectangle(0, 0, pictureBox1.Width - 1, pictureBox1.Height - 1);
|
||||
SolidBrush whiteBrush = new SolidBrush(Color.White);
|
||||
SolidBrush redBrush = new SolidBrush(Color.Red);
|
||||
Pen blackPen = new Pen(Color.Black);
|
||||
Pen blackPen2 = new Pen(Color.Black, 1);
|
||||
Pen bluePen = new Pen(Color.Blue);
|
||||
Pen bluePen2 = new Pen(Color.DarkBlue, 2);
|
||||
gr.DrawRectangle(blackPen, rect);
|
||||
|
||||
int u1 = 0;
|
||||
int u2 = 0;
|
||||
int v1 = 0;
|
||||
int v2 = 0;
|
||||
|
||||
for (int i = 0; i < PointsHyp.Count - 3; i += 4)
|
||||
{
|
||||
// считываем точку из списка и приводим её к координатам pictureBox1
|
||||
u1 = (int)((double)PointsHyp[i] / MAX_EXPONENT_THREE * (pictureBox1.Width - 1));
|
||||
u2 = (int)((double)PointsHyp[i + 1] / MAX_EXPONENT_THREE * (pictureBox1.Height - 1));
|
||||
v1 = (int)((double)PointsHyp[i + 2] / MAX_EXPONENT_THREE * (pictureBox1.Width - 1));
|
||||
v2 = (int)((double)PointsHyp[i + 3] / MAX_EXPONENT_THREE * (pictureBox1.Height - 1));
|
||||
|
||||
// выполняем преобразование поворота и сдвиг
|
||||
u2 = (pictureBox1.Height - 1) - u2;
|
||||
v2 = (pictureBox1.Height - 1) - v2;
|
||||
|
||||
if ((u1 < v1) && (u2 < v2))
|
||||
{
|
||||
rect = new Rectangle(u1, u2, v1 - u1, v2 - u2);
|
||||
gr.DrawRectangle(blackPen, rect);
|
||||
}
|
||||
else if ((v1 < u1) && (v2 < u2))
|
||||
{
|
||||
rect = new Rectangle(v1, v2, u1 - v1, u2 - v2);
|
||||
gr.DrawRectangle(blackPen, rect);
|
||||
}
|
||||
else if ((u1 < v1) && (u2 > v2))
|
||||
{
|
||||
int tmp = u1;
|
||||
u1 = v1;
|
||||
v1 = tmp;
|
||||
|
||||
rect = new Rectangle(v1, v2, u1 - v1, u2 - v2);
|
||||
gr.DrawRectangle(blackPen, rect);
|
||||
}
|
||||
else if ((u1 > v1) && (u2 < v2))
|
||||
{
|
||||
int tmp = u1;
|
||||
u1 = v1;
|
||||
v1 = tmp;
|
||||
|
||||
rect = new Rectangle(u1, u2, v1 - u1, v2 - u2);
|
||||
gr.DrawRectangle(blackPen, rect);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < Points.Count - 1; i += 2)
|
||||
{
|
||||
// считываем точку из списка и приводим её к координатам pictureBox1
|
||||
u1 = (int)((double)Points[i] / MAX_EXPONENT_THREE * (pictureBox1.Width - 1));
|
||||
u2 = (int)((double)Points[i + 1] / MAX_EXPONENT_THREE * (pictureBox1.Height - 1));
|
||||
|
||||
// выполняем преобразование поворота и сдвиг
|
||||
u2 = (pictureBox1.Height - 1) - u2;
|
||||
|
||||
//gr.FillEllipse(redBrush, u1 - 3.0f, u2 - 3.0f, 3.0f * 2, 3.0f * 2);
|
||||
//gr.DrawEllipse(bluePen2, u1 - 3.0f, u2 - 3.0f, 3.0f * 2, 3.0f * 2);
|
||||
|
||||
gr.FillEllipse(redBrush, u1 - 2.5f, u2 - 2.5f, 2.5f * 2, 2.5f * 2);
|
||||
gr.DrawEllipse(blackPen2, u1 - 2.5f, u2 - 2.5f, 2.5f * 2, 2.5f * 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
8069502011d0681850e57a53d5a1673222f430a6
|
||||
@@ -0,0 +1,11 @@
|
||||
D:\materials\projects\visual_hyperinterval\visual_hyperinterval\bin\Debug\visual_hyperinterval.exe.config
|
||||
D:\materials\projects\visual_hyperinterval\visual_hyperinterval\bin\Debug\visual_hyperinterval.exe
|
||||
D:\materials\projects\visual_hyperinterval\visual_hyperinterval\bin\Debug\visual_hyperinterval.pdb
|
||||
D:\materials\projects\visual_hyperinterval\visual_hyperinterval\obj\Debug\visual_hyperinterval.csproj.AssemblyReference.cache
|
||||
D:\materials\projects\visual_hyperinterval\visual_hyperinterval\obj\Debug\visual_hyperinterval.Form1.resources
|
||||
D:\materials\projects\visual_hyperinterval\visual_hyperinterval\obj\Debug\visual_hyperinterval.Properties.Resources.resources
|
||||
D:\materials\projects\visual_hyperinterval\visual_hyperinterval\obj\Debug\visual_hyperinterval.csproj.GenerateResource.cache
|
||||
D:\materials\projects\visual_hyperinterval\visual_hyperinterval\obj\Debug\visual_hyperinterval.csproj.CoreCompileInputs.cache
|
||||
D:\materials\projects\visual_hyperinterval\visual_hyperinterval\obj\Debug\visual_hyperinterval.exe
|
||||
D:\materials\projects\visual_hyperinterval\visual_hyperinterval\obj\Debug\visual_hyperinterval.pdb
|
||||
D:\materials\projects\visual_hyperinterval\visual_hyperinterval\obj\Debug\visual_hyperinterval.csproj.SuggestedBindingRedirects.cache
|
||||
Binary file not shown.
Reference in New Issue
Block a user