Revert "migrate to wpf"

This reverts commit 97a4dbf4d3.

# Conflicts:
#	MainWindow.xaml.cs
#	html/src/index.pug
This commit is contained in:
pypy
2021-03-08 20:58:56 +09:00
parent 395cb6c8a0
commit 291169fce0
13 changed files with 1886 additions and 2380 deletions

View File

@@ -1,9 +0,0 @@
<Application x:Class="VRCX.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:VRCX"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace VRCX
{
public partial class App : Application
{
}
}

View File

@@ -15,7 +15,6 @@ using System.IO;
using System.Net;
using Windows.UI.Notifications;
using Windows.Data.Xml.Dom;
using System.Windows;
namespace VRCX
{
@@ -28,59 +27,9 @@ namespace VRCX
Instance = new AppApi();
}
public void CloseMainWindow()
{
try
{
MainWindow.Instance.Dispatcher.BeginInvoke(new MethodInvoker(() =>
{
MainWindow.Instance.Close();
}));
}
catch
{
}
}
public void MinimizeMainWindow()
{
try
{
MainWindow.Instance.Dispatcher.BeginInvoke(new MethodInvoker(() =>
{
MainWindow.Instance.WindowState = WindowState.Minimized;
}));
}
catch
{
}
}
public void ToggleMaximizeMainWindow()
{
try
{
MainWindow.Instance.Dispatcher.BeginInvoke(new MethodInvoker(() =>
{
var mainWindow = MainWindow.Instance;
if (mainWindow.WindowState == WindowState.Maximized)
{
mainWindow.WindowState = WindowState.Normal;
}
else
{
mainWindow.WindowState = WindowState.Maximized;
}
}));
}
catch
{
}
}
public void ShowDevTools()
{
MainWindow.Instance.Browser.ShowDevTools();
MainForm.Instance.Browser.ShowDevTools();
}
public void DeleteAllCookies()
@@ -196,13 +145,13 @@ namespace VRCX
{
try
{
/*MainForm.Instance.BeginInvoke(new MethodInvoker(() =>
MainForm.Instance.BeginInvoke(new MethodInvoker(() =>
{
if (VRForm.Instance == null)
{
new VRForm().Show();
}
}));*/
}));
}
catch
{
@@ -266,7 +215,7 @@ namespace VRCX
{
if (enabled == true)
{
var path = System.Reflection.Assembly.GetExecutingAssembly().Location;
var path = Application.ExecutablePath;
key.SetValue("VRCX", $"\"{path}\" --startup");
}
else

View File

@@ -1,5 +1,5 @@
using CefSharp;
using CefSharp.Wpf;
using CefSharp.WinForms;
using System;
using System.IO;
@@ -16,8 +16,6 @@ namespace VRCX
internal void Init()
{
AppContext.SetSwitch("Switch.System.Windows.Input.Stylus.EnablePointerSupport", true);
var cefSettings = new CefSettings
{
CachePath = Path.Combine(Program.BaseDirectory, "cache"),
@@ -36,7 +34,6 @@ namespace VRCX
SchemeHandlerFactory = new FolderSchemeHandlerFactory(Application.StartupPath + "/../../../html")
});*/
cefSettings.CefCommandLineArgs.Add("disable-threaded-scrolling");
cefSettings.CefCommandLineArgs.Add("ignore-certificate-errors");
cefSettings.CefCommandLineArgs.Add("disable-plugins");
cefSettings.CefCommandLineArgs.Add("disable-spell-checking");

View File

@@ -1,73 +0,0 @@
// Copyright(c) 2019 pypy. All rights reserved.
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
using System;
using System.Collections.Generic;
using System.Drawing;
using CefSharp;
using CefSharp.Enums;
namespace VRCX
{
public class DragHandler : IDragHandler
{
public event Action<Region> RegionsChanged;
public void Dispose()
{
RegionsChanged = null;
}
bool IDragHandler.OnDragEnter(IWebBrowser chromiumWebBrowser, IBrowser browser, IDragData dragData, DragOperationsMask mask)
{
return false;
}
void IDragHandler.OnDraggableRegionsChanged(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IList<DraggableRegion> regions)
{
//By default popup browers are native windows in WPF so we cannot handle their drag using this method
if (browser.IsPopup == false)
{
//NOTE: I haven't tested with dynamically adding removing regions so this may need some tweaking
Region draggableRegion = null;
if (regions.Count > 0)
{
//Take the individual Region and construct a complex Region that represents them all.
foreach (var region in regions)
{
var rect = new Rectangle(region.X, region.Y, region.Width, region.Height);
if (draggableRegion == null)
{
draggableRegion = new Region(rect);
}
else
{
if (region.Draggable)
{
draggableRegion.Union(rect);
}
else
{
//In the scenario where we have an outer region, that is draggable and it has
// an inner region that's not, we must exclude the non draggable.
// Not all scenarios are covered in this example.
draggableRegion.Exclude(rect);
}
}
}
}
var handler = RegionsChanged;
if (handler != null)
{
handler(draggableRegion);
}
}
}
}
}

View File

@@ -1,25 +0,0 @@
<Window x:Class="VRCX.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VRCX"
mc:Ignorable="d"
Title="VRCX"
Width="800"
Height="450"
MinWidth="320"
MinHeight="240"
WindowStyle="None"
WindowStartupLocation="CenterScreen"
Loaded="Window_Loaded"
Closed="Window_Closed"
Closing="Window_Closing"
LocationChanged="Window_LocationChanged"
SizeChanged="Window_SizeChanged">
<WindowChrome.WindowChrome>
<WindowChrome
CaptionHeight="0"
ResizeBorderThickness="5"/>
</WindowChrome.WindowChrome>
</Window>

View File

@@ -1,244 +0,0 @@
using CefSharp;
using CefSharp.Wpf;
using System;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
namespace VRCX
{
public partial class MainWindow : Window
{
public static MainWindow Instance;
public ChromiumWebBrowser Browser;
// Store draggable region if we have one - used for hit testing
private Region Region_;
private NotifyIcon NotifyIcon_;
private bool Quit_;
private int LastLocationX;
private int LastLocationY;
private int LastSizeWidth;
private int LastSizeHeight;
public MainWindow()
{
Instance = this;
InitializeComponent();
DoTrayIcon();
var dragHandler = new DragHandler();
dragHandler.RegionsChanged += (region) =>
{
if (region != null)
{
// Only wire up event handler once
if (Region_ == null)
{
Browser.PreviewMouseLeftButtonDown += (sender, e) =>
{
var point = e.GetPosition(Browser);
if (Region_.IsVisible((float)point.X, (float)point.Y))
{
var window = GetWindow(this);
window.DragMove();
e.Handled = true;
}
};
}
Region_ = region;
}
};
Browser = new ChromiumWebBrowser(
Path.Combine(Program.BaseDirectory, "html/index.html")
)
{
DragHandler = dragHandler,
MenuHandler = new NoopMenuHandler(),
BrowserSettings =
{
DefaultEncoding = "UTF-8",
}
};
Browser.IsBrowserInitializedChanged += (A, B) =>
{
if (Browser.IsDisposed == false)
{
// Browser.ShowDevTools();
}
};
Util.ApplyJavascriptBindings(Browser.JavascriptObjectRepository);
Content = Browser;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
// restore last window location and size
try
{
int.TryParse(VRCXStorage.Instance.Get("VRCX_LocationX"), out LastLocationX);
int.TryParse(VRCXStorage.Instance.Get("VRCX_LocationY"), out LastLocationY);
int.TryParse(VRCXStorage.Instance.Get("VRCX_SizeWidth"), out LastSizeWidth);
int.TryParse(VRCXStorage.Instance.Get("VRCX_SizeHeight"), out LastSizeHeight);
var location = new System.Drawing.Point(LastLocationX, LastLocationY);
var size = new System.Drawing.Size(LastSizeWidth, LastSizeHeight);
var screen = Screen.FromPoint(location);
if (screen.Bounds.Contains(location.X, location.Y) == true)
{
Left = location.X;
Top = location.Y;
}
if (size.Width > 0 && size.Height > 0)
{
Width = size.Width;
Height = size.Height;
}
}
catch
{
}
// restore last window state
try
{
var state = WindowState;
if ("true".Equals(VRCXStorage.Instance.Get("VRCX_StartAsMinimizedState")))
{
state = WindowState.Minimized;
}
else
{
if (int.TryParse(VRCXStorage.Instance.Get("VRCX_WindowState"), out int v))
{
state = (WindowState)v;
}
if (state == WindowState.Minimized)
{
state = WindowState.Normal;
}
}
WindowState = state;
}
catch
{
}
}
private void Window_Closed(object sender, EventArgs e)
{
try
{
VRCXStorage.Instance.Set("VRCX_LocationX", LastLocationX.ToString());
VRCXStorage.Instance.Set("VRCX_LocationY", LastLocationY.ToString());
VRCXStorage.Instance.Set("VRCX_SizeWidth", LastSizeWidth.ToString());
VRCXStorage.Instance.Set("VRCX_SizeHeight", LastSizeHeight.ToString());
VRCXStorage.Instance.Set("VRCX_WindowState", ((int)WindowState).ToString());
}
catch
{
}
if (NotifyIcon_ != null)
{
NotifyIcon_.Visible = false;
}
Content = null;
}
private void DoTrayIcon()
{
var contextMenu = new ContextMenu();
contextMenu.MenuItems.Add("Open", (sender, e) =>
{
if (WindowState == WindowState.Minimized)
{
WindowState = WindowState.Normal;
}
Show();
Focus();
});
contextMenu.MenuItems.Add("-");
contextMenu.MenuItems.Add("Quit VRCX", (sender, e) =>
{
Quit_ = true;
Close();
});
NotifyIcon_ = new NotifyIcon();
try
{
var location = Assembly.GetExecutingAssembly().Location;
NotifyIcon_.Icon = System.Drawing.Icon.ExtractAssociatedIcon(location);
}
catch
{
}
NotifyIcon_.ContextMenu = contextMenu;
NotifyIcon_.Text = "VRCX";
NotifyIcon_.DoubleClick += (sender, e) =>
{
if (WindowState == WindowState.Minimized)
{
WindowState = WindowState.Normal;
}
Show();
Focus();
};
NotifyIcon_.Visible = true;
}
private void Window_Closing(object sender, CancelEventArgs e)
{
try
{
if (Quit_ == false &&
"true".Equals(SharedVariable.Instance.Get("config:vrcx_closetotray")) == true)
{
e.Cancel = true;
Hide();
}
}
catch
{
}
}
private void Window_LocationChanged(object sender, EventArgs e)
{
if (WindowState == WindowState.Normal)
{
LastLocationX = (int)Left;
LastLocationY = (int)Top;
}
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (WindowState == WindowState.Normal)
{
LastSizeWidth = (int)Width;
LastSizeHeight = (int)Height;
}
}
}
}

View File

@@ -1,31 +0,0 @@
// Copyright(c) 2019 pypy. All rights reserved.
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
using CefSharp;
namespace VRCX
{
public class NoopMenuHandler : IContextMenuHandler
{
public void OnBeforeContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
{
model.Clear();
}
public bool OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
{
return false;
}
public void OnContextMenuDismissed(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame)
{
}
public bool RunContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback)
{
return false;
}
}
}

View File

@@ -45,11 +45,7 @@ namespace VRCX
CefService.Instance.Init();
VRCXVR.Instance.Init();
var app = new App();
app.InitializeComponent();
app.Run();
Application.Run(new MainForm());
WebApi.Instance.SaveCookies();
VRCXVR.Instance.Exit();
CefService.Instance.Exit();

View File

@@ -10,7 +10,6 @@
<AssemblyName>VRCX</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
@@ -78,12 +77,9 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -93,26 +89,29 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="CefService.cs" />
<Compile Include="Discord.cs" />
<Compile Include="CpuMonitor.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="DragHandler.cs" />
<Compile Include="NoopMenuHandler.cs" />
<Compile Include="OffScreenBrowser.cs" />
<Compile Include="NoopDragHandler.cs" />
<Compile Include="WebApi.cs" />
<Compile Include="SQLite.cs" />
<Compile Include="SharedVariable.cs" />
<Compile Include="Util.cs" />
<Compile Include="VRForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="VRForm.Designer.cs">
<DependentUpon>VRForm.cs</DependentUpon>
</Compile>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="VRCXVR.cs" />
<Compile Include="openvr_api.cs" />
<Compile Include="Program.cs" />
@@ -123,6 +122,12 @@
<Compile Include="VRCXStorage.cs" />
<Compile Include="JsonSerializer.cs" />
<Compile Include="WinApi.cs" />
<EmbeddedResource Include="VRForm.resx">
<DependentUpon>VRForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -167,7 +172,7 @@
<PackageReference Include="CefSharp.OffScreen">
<Version>86.0.241</Version>
</PackageReference>
<PackageReference Include="CefSharp.Wpf">
<PackageReference Include="CefSharp.WinForms">
<Version>86.0.241</Version>
</PackageReference>
<PackageReference Include="DiscordRichPresence">
@@ -198,15 +203,5 @@
<Version>1.0.113.7</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Page Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -3524,18 +3524,6 @@ speechSynthesis.getVoices();
}
};
$app.methods.minimizeWindow = function () {
AppApi.MinimizeMainWindow();
};
$app.methods.toggleMaximizeWindow = function () {
AppApi.ToggleMaximizeMainWindow();
};
$app.methods.closeWindow = function () {
AppApi.CloseMainWindow();
};
$app.methods.openExternalLink = function (link) {
this.$confirm(`${link}`, 'Open External Link', {
confirmButtonText: 'Confirm',

View File

@@ -138,24 +138,10 @@ a {
.x-app {
position: absolute;
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
overflow: hidden;
}
.x-title-bar {
display: flex;
width: 100%;
height: 30px;
}
.x-wrap {
position: relative;
display: flex;
width: 100%;
height: calc(100% - 30px);
overflow: hidden auto;
cursor: default;
}
.x-container {
@@ -170,10 +156,10 @@ a {
position: absolute;
// modal 시작이 2000이라서
z-index: 1999;
display: flex;
width: 100%;
height: 100%;
background: #fff;
overflow: hidden scroll;
}
.x-menu-container {

File diff suppressed because it is too large Load Diff