-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b1ac77
commit 2e47ceb
Showing
7 changed files
with
130 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System.Diagnostics; | ||
using CoreWindowsWrapper; | ||
using Diga.NativeControls.WebBrowser; | ||
using Diga.WebView2.Wrapper.EventArguments; | ||
|
||
namespace DigaWinFormsTest | ||
{ | ||
class BrowserWindow : NativeWindow | ||
{ | ||
private NativeWebBrowser _Browser; | ||
protected override void InitControls() | ||
{ | ||
this.Text = "WebBrowser"; | ||
this.Name = "BrowserWindow"; | ||
this.StatusBar = true; | ||
this.IconFile = "Browser.ico"; | ||
this.Width = 800; | ||
this.Height = 600; | ||
this.StartUpPosition = WindowsStartupPosition.CenterScreen; | ||
|
||
|
||
this._Browser = new NativeWebBrowser() | ||
{ | ||
Width = this.Width, | ||
Height = this.Height, | ||
Url = "http://localhost:1", | ||
IsStatusBarEnabled = true, | ||
DefaultContextMenusEnabled = false, | ||
DevToolsEnabled = false, | ||
EnableMonitoring = true, | ||
MonitoringFolder = ".\\wwwroot", | ||
MonitoringUrl = "http://localhost:1/" | ||
}; | ||
this._Browser.DocumentTitleChanged += OnDocumentTitleChanged; | ||
this._Browser.NavigationStart += OnNavigationStart; | ||
this._Browser.NavigationCompleted += OnNaviationCompleted; | ||
this._Browser.WebResourceRequested += OnWebResourceRequested; | ||
this.Controls.Add(this._Browser); | ||
} | ||
private void OnWebResourceRequested(object sender, WebResourceRequestedEventArgs e) | ||
{ | ||
Debug.Print(e.Request.Uri); | ||
} | ||
|
||
private void OnNaviationCompleted(object sender, NavigationCompletedEventArgs e) | ||
{ | ||
if (e.IsSuccess) | ||
this.Text = e.IsSuccess + "->" + this._Browser.DocumentTitle; | ||
else | ||
this.Text = "Navigation-Error=>" + e.GetErrorText(); | ||
|
||
} | ||
private void OnNavigationStart(object sender, NavigationStartingEventArgs e) | ||
{ | ||
|
||
this.Text = "Start-Navigate" + e.Uri; | ||
} | ||
private void OnDocumentTitleChanged(object sender, WebView2EventArgs e) | ||
{ | ||
this.Text = this._Browser.DocumentTitle; | ||
} | ||
|
||
protected override void OnSize(SizeEventArgs e) | ||
{ | ||
if (e.Width == 0) return; | ||
base.OnSize(e); | ||
this._Browser.Left = e.X; | ||
this._Browser.Top = e.Y; | ||
this._Browser.Width = e.Width; | ||
this._Browser.Height = e.Height; | ||
this._Browser.DoDock(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="CoreWindowsWrapper" version="1.0.41" targetFramework="net472" /> | ||
<package id="Diga.Core.Api.Win32" version="1.0.19" targetFramework="net472" developmentDependency="true" /> | ||
<package id="Diga.NativeControls.WebBrowser" version="1.0.0" targetFramework="net472" /> | ||
<package id="Diga.WebView2.Interop" version="2.0.4" targetFramework="net472" /> | ||
<package id="Diga.WebView2.Wrapper" version="2.0.4" targetFramework="net472" /> | ||
<package id="MimeTypeExtension" version="1.0.1" targetFramework="net472" /> | ||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" /> | ||
</packages> |