Samples.csproj: add WebkitGtkSharp - sample
This commit is contained in:
parent
4790ecaa9b
commit
6d40ae2437
2 changed files with 62 additions and 0 deletions
|
@ -28,5 +28,6 @@
|
||||||
<ProjectReference Include="..\Libs\GtkSharp\GtkSharp.csproj" />
|
<ProjectReference Include="..\Libs\GtkSharp\GtkSharp.csproj" />
|
||||||
<ProjectReference Include="..\Libs\PangoSharp\PangoSharp.csproj" />
|
<ProjectReference Include="..\Libs\PangoSharp\PangoSharp.csproj" />
|
||||||
<ProjectReference Include="..\Libs\GtkSourceSharp\GtkSourceSharp.csproj" />
|
<ProjectReference Include="..\Libs\GtkSourceSharp\GtkSourceSharp.csproj" />
|
||||||
|
<ProjectReference Include="..\Libs\WebkitGtkSharp\WebkitGtkSharp.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
61
Source/Samples/Sections/Widgets/WebviewSection.cs
Normal file
61
Source/Samples/Sections/Widgets/WebviewSection.cs
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
// This is free and unencumbered software released into the public domain.
|
||||||
|
// Happy coding!!! - GtkSharp Team
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using Atk;
|
||||||
|
using Gdk;
|
||||||
|
using Gtk;
|
||||||
|
using WebKit;
|
||||||
|
|
||||||
|
namespace Samples
|
||||||
|
{
|
||||||
|
|
||||||
|
[Section(ContentType = typeof(WebView), Category = Category.Widgets)]
|
||||||
|
class WebviewSection : ListSection
|
||||||
|
{
|
||||||
|
|
||||||
|
public WebviewSection()
|
||||||
|
{
|
||||||
|
AddItem(ShowHtml());
|
||||||
|
AddItem(ShowUri());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public (string, Widget) ShowHtml()
|
||||||
|
{
|
||||||
|
var webView = new WebView {
|
||||||
|
HeightRequest = 100,
|
||||||
|
Hexpand = true
|
||||||
|
};
|
||||||
|
|
||||||
|
webView.LoadString(
|
||||||
|
$"This is a <b>{nameof(WebView)}</b> showing html text",
|
||||||
|
"text/html", "UTF-8", null
|
||||||
|
);
|
||||||
|
|
||||||
|
return ($"{nameof(WebView)} show html text:", webView);
|
||||||
|
}
|
||||||
|
|
||||||
|
public (string, Widget) ShowUri()
|
||||||
|
{
|
||||||
|
var webView = new WebView {ViewMode = WebViewViewMode.Floating};
|
||||||
|
|
||||||
|
var scroll = new ScrolledWindow {
|
||||||
|
Child = webView,
|
||||||
|
Vexpand = true,
|
||||||
|
Hexpand = true,
|
||||||
|
PropagateNaturalHeight = true,
|
||||||
|
PropagateNaturalWidth = true
|
||||||
|
};
|
||||||
|
|
||||||
|
webView.LoadUri("https://github.com/GtkSharp/GtkSharp#readme");
|
||||||
|
|
||||||
|
return ($"{nameof(WebView)} show uri:", scroll);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue