initial commit
This commit is contained in:
59
Form1.cs
Normal file
59
Form1.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Web.WebView2.WinForms;
|
||||
using Microsoft.Owin.Hosting;
|
||||
using VNCServerList.Web;
|
||||
|
||||
namespace VNCServerList
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private WebView2 webView;
|
||||
private IDisposable webApp;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
StartWebServer();
|
||||
InitializeWebView();
|
||||
|
||||
}
|
||||
|
||||
private async void InitializeWebView()
|
||||
{
|
||||
webView = new WebView2();
|
||||
webView.Dock = DockStyle.Fill;
|
||||
this.Controls.Add(webView);
|
||||
|
||||
try
|
||||
{
|
||||
await webView.EnsureCoreWebView2Async(null);
|
||||
webView.CoreWebView2.Navigate("http://localhost:8080");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"WebView2 초기화 중 오류가 발생했습니다: {ex.Message}", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void StartWebServer()
|
||||
{
|
||||
try
|
||||
{
|
||||
var options = new StartOptions("http://localhost:8080");
|
||||
|
||||
webApp = WebApp.Start<Startup>(options);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"웹 서버 시작 중 오류가 발생했습니다: {ex.Message}", "오류", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
webApp?.Dispose();
|
||||
base.OnFormClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user