mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
add CefService
This commit is contained in:
@@ -0,0 +1,60 @@
|
|||||||
|
using CefSharp;
|
||||||
|
using CefSharp.WinForms;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace VRCX
|
||||||
|
{
|
||||||
|
public static class CefService
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var cefSettings = new CefSettings
|
||||||
|
{
|
||||||
|
CachePath = Path.Combine(Program.BaseDirectory, "cache"),
|
||||||
|
UserDataPath = Path.Combine(Program.BaseDirectory, "userdata"),
|
||||||
|
IgnoreCertificateErrors = true,
|
||||||
|
LogSeverity = LogSeverity.Disable,
|
||||||
|
WindowlessRenderingEnabled = true,
|
||||||
|
PersistSessionCookies = true,
|
||||||
|
PersistUserPreferences = true
|
||||||
|
};
|
||||||
|
|
||||||
|
/*cefSettings.RegisterScheme(new CefCustomScheme
|
||||||
|
{
|
||||||
|
SchemeName = "vrcx",
|
||||||
|
DomainName = "app",
|
||||||
|
SchemeHandlerFactory = new FolderSchemeHandlerFactory(Application.StartupPath + "/../../../html")
|
||||||
|
});*/
|
||||||
|
|
||||||
|
cefSettings.CefCommandLineArgs.Add("ignore-certificate-errors");
|
||||||
|
cefSettings.CefCommandLineArgs.Add("disable-plugins");
|
||||||
|
cefSettings.CefCommandLineArgs.Add("disable-spell-checking");
|
||||||
|
cefSettings.CefCommandLineArgs.Add("disable-pdf-extension");
|
||||||
|
cefSettings.CefCommandLineArgs.Add("disable-extensions");
|
||||||
|
// cefSettings.CefCommandLineArgs.Add("allow-universal-access-from-files");
|
||||||
|
// cefSettings.CefCommandLineArgs.Add("disable-web-security");
|
||||||
|
cefSettings.CefCommandLineArgs.Add("disable-gpu");
|
||||||
|
cefSettings.CefCommandLineArgs.Add("disable-gpu-compositing");
|
||||||
|
cefSettings.CefCommandLineArgs.Add("disable-webgl");
|
||||||
|
cefSettings.DisableGpuAcceleration();
|
||||||
|
cefSettings.SetOffScreenRenderingBestPerformanceArgs();
|
||||||
|
|
||||||
|
CefSharpSettings.WcfEnabled = true; // TOOD: REMOVE THIS LINE YO
|
||||||
|
CefSharpSettings.ShutdownOnExit = false;
|
||||||
|
|
||||||
|
// Enable High-DPI support on Windows 7 or newer
|
||||||
|
Cef.EnableHighDPISupport();
|
||||||
|
|
||||||
|
if (Cef.Initialize(cefSettings) == false)
|
||||||
|
{
|
||||||
|
throw new Exception("Cef.Initialize()");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Exit()
|
||||||
|
{
|
||||||
|
Cef.Shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+29
-59
@@ -3,10 +3,8 @@
|
|||||||
// This work is licensed under the terms of the MIT license.
|
// This work is licensed under the terms of the MIT license.
|
||||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||||
|
|
||||||
using CefSharp;
|
using CefSharp.DevTools.Runtime;
|
||||||
using CefSharp.WinForms;
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace VRCX
|
namespace VRCX
|
||||||
@@ -21,65 +19,11 @@ namespace VRCX
|
|||||||
}
|
}
|
||||||
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main()
|
private static void Main()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var settings = new CefSettings
|
Run();
|
||||||
{
|
|
||||||
CachePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "cache"),
|
|
||||||
IgnoreCertificateErrors = true,
|
|
||||||
LogSeverity = LogSeverity.Disable,
|
|
||||||
PersistUserPreferences = true,
|
|
||||||
WindowlessRenderingEnabled = true,
|
|
||||||
PersistSessionCookies = true
|
|
||||||
};
|
|
||||||
settings.CefCommandLineArgs.Add("ignore-certificate-errors");
|
|
||||||
// settings.CefCommandLineArgs.Add("no-proxy-server");
|
|
||||||
// settings.CefCommandLineArgs.Add("disable-web-security");
|
|
||||||
settings.CefCommandLineArgs.Add("allow-universal-access-from-files");
|
|
||||||
settings.CefCommandLineArgs.Add("disable-extensions");
|
|
||||||
settings.CefCommandLineArgs.Add("disable-plugins");
|
|
||||||
settings.CefCommandLineArgs.Add("disable-pdf-extension");
|
|
||||||
settings.CefCommandLineArgs.Add("disable-spell-checking");
|
|
||||||
settings.CefCommandLineArgs.Add("disable-gpu");
|
|
||||||
settings.CefCommandLineArgs.Add("disable-gpu-vsync");
|
|
||||||
settings.DisableGpuAcceleration();
|
|
||||||
/*settings.RegisterScheme(new CefCustomScheme
|
|
||||||
{
|
|
||||||
SchemeName = "vrcx",
|
|
||||||
DomainName = "app",
|
|
||||||
SchemeHandlerFactory = new FolderSchemeHandlerFactory(Application.StartupPath + "/../../../html")
|
|
||||||
});*/
|
|
||||||
|
|
||||||
// MUST TURN ON (Error when creating a browser on certain systems.)
|
|
||||||
CefSharpSettings.WcfEnabled = true;
|
|
||||||
CefSharpSettings.ShutdownOnExit = false;
|
|
||||||
CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
|
|
||||||
|
|
||||||
Cef.EnableHighDPISupport();
|
|
||||||
|
|
||||||
if (Cef.Initialize(settings, true, browserProcessHandler: null))
|
|
||||||
{
|
|
||||||
Application.EnableVisualStyles();
|
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
|
||||||
VRCXStorage.Load();
|
|
||||||
CpuMonitor.Instance.Init();
|
|
||||||
Discord.Instance.Init();
|
|
||||||
SQLite.Instance.Init();
|
|
||||||
WebApi.Instance.Init();
|
|
||||||
LogWatcher.Instance.Init();
|
|
||||||
VRCXVR.Init();
|
|
||||||
Application.Run(new MainForm());
|
|
||||||
VRCXVR.Exit();
|
|
||||||
LogWatcher.Instance.Exit();
|
|
||||||
WebApi.Instance.Exit();
|
|
||||||
SQLite.Instance.Exit();
|
|
||||||
Discord.Instance.Exit();
|
|
||||||
CpuMonitor.Instance.Exit();
|
|
||||||
VRCXStorage.Save();
|
|
||||||
Cef.Shutdown();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -87,5 +31,31 @@ namespace VRCX
|
|||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void Run()
|
||||||
|
{
|
||||||
|
Application.EnableVisualStyles();
|
||||||
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
|
VRCXStorage.Load();
|
||||||
|
CpuMonitor.Instance.Init();
|
||||||
|
Discord.Instance.Init();
|
||||||
|
SQLite.Instance.Init();
|
||||||
|
WebApi.Instance.Init();
|
||||||
|
LogWatcher.Instance.Init();
|
||||||
|
|
||||||
|
CefService.Init();
|
||||||
|
VRCXVR.Init();
|
||||||
|
Application.Run(new MainForm());
|
||||||
|
VRCXVR.Exit();
|
||||||
|
CefService.Exit();
|
||||||
|
|
||||||
|
LogWatcher.Instance.Exit();
|
||||||
|
WebApi.Instance.Exit();
|
||||||
|
SQLite.Instance.Exit();
|
||||||
|
Discord.Instance.Exit();
|
||||||
|
CpuMonitor.Instance.Exit();
|
||||||
|
VRCXStorage.Save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,6 +125,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="CefService.cs" />
|
||||||
<Compile Include="Discord.cs" />
|
<Compile Include="Discord.cs" />
|
||||||
<Compile Include="CpuMonitor.cs" />
|
<Compile Include="CpuMonitor.cs" />
|
||||||
<Compile Include="Browser.cs" />
|
<Compile Include="Browser.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user