mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-05 11:42:36 +00:00
move test logic into CefSharp.Example, run all example tests in wpf
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
|
||||
namespace CefSharp.Example
|
||||
{
|
||||
class BoundObject
|
||||
{
|
||||
public string Repeat(string str, int n)
|
||||
{
|
||||
string result = String.Empty;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
result += str;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void EchoVoid()
|
||||
{
|
||||
}
|
||||
|
||||
public Boolean EchoBoolean(Boolean arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Boolean? EchoNullableBoolean(Boolean? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public SByte EchoSByte(SByte arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public SByte? EchoNullableSByte(SByte? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Int16 EchoInt16(Int16 arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Int16? EchoNullableInt16(Int16? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Int32 EchoInt32(Int32 arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Int32? EchoNullableInt32(Int32? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Int64 EchoInt64(Int64 arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Int64? EchoNullableInt64(Int64? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Byte EchoByte(Byte arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Byte? EchoNullableByte(Byte? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public UInt16 EchoUInt16(UInt16 arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public UInt16? EchoNullableUInt16(UInt16? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public UInt32 EchoUInt32(UInt32 arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public UInt32? EchoNullableUInt32(UInt32? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public UInt64 EchoUInt64(UInt64 arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public UInt64? EchoNullableUInt64(UInt64? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Single EchoSingle(Single arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Single? EchoNullableSingle(Single? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Double EchoDouble(Double arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Double? EchoNullableDouble(Double? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Char EchoChar(Char arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Char? EchoNullableChar(Char? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public DateTime EchoDateTime(DateTime arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public DateTime? EchoNullableDateTime(DateTime? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Decimal EchoDecimal(Decimal arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public Decimal? EchoNullableDecimal(Decimal? arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
|
||||
public String EchoString(String arg0)
|
||||
{
|
||||
return arg0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,11 +35,20 @@
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BoundObject.cs" />
|
||||
<Compile Include="ExamplePresenter.cs" />
|
||||
<Compile Include="IExampleView.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="SchemeHandler.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CefSharp\CefSharp.vcproj">
|
||||
@@ -47,6 +56,18 @@
|
||||
<Name>CefSharp</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\BindingTest.html" />
|
||||
<Content Include="Resources\PopupTest.html" />
|
||||
<Content Include="Resources\SchemeTest.html" />
|
||||
<Content Include="Resources\TooltipTest.html" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -1,10 +1,34 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace CefSharp.Example
|
||||
{
|
||||
public class ExamplePresenter
|
||||
public class ExamplePresenter : IBeforeResourceLoad
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
Settings settings = new Settings();
|
||||
if (CEF.Initialize(settings))
|
||||
{
|
||||
CEF.RegisterScheme("test", new SchemeHandlerFactory());
|
||||
CEF.RegisterJsObject("bound", new BoundObject());
|
||||
}
|
||||
}
|
||||
|
||||
private const string resource_url = "http://test/resource/load";
|
||||
private const string scheme_url = "test://test/SchemeTest.html";
|
||||
private const string bind_url = "test://test/BindingTest.html";
|
||||
|
||||
private int color_index = 0;
|
||||
private readonly string[] colors =
|
||||
{
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
};
|
||||
|
||||
private readonly IWebBrowser model;
|
||||
private readonly IExampleView view;
|
||||
private readonly Action<Action> gui_invoke;
|
||||
@@ -18,16 +42,22 @@ namespace CefSharp.Example
|
||||
|
||||
this.model.PropertyChanged += model_PropertyChanged;
|
||||
|
||||
this.view.ExitActivated += view_ExitActivated;
|
||||
this.view.UrlActivated += view_UrlActivated;
|
||||
this.view.ForwardActivated += view_ForwardActivated;
|
||||
this.view.BackActivated += view_BackActivated;
|
||||
this.view.UrlActivated += view_UrlActivated;
|
||||
this.view.TestResourceLoadActivated += view_TestResourceLoadActivated;
|
||||
this.view.TestSchemeLoadActivated += view_TestSchemeLoadActivated;
|
||||
this.view.TestExecuteScriptActivated += view_TestExecuteScriptActivated;
|
||||
this.view.TestEvaluateScriptActivated += view_TestEvaluateScriptActivated;
|
||||
this.view.TestBindActivated += view_TestBindActivated;
|
||||
this.view.TestConsoleMessageActivated += view_TestConsoleMessageActivated;
|
||||
this.view.ExitActivated += view_ExitActivated;
|
||||
}
|
||||
|
||||
private void model_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
string @string;
|
||||
bool @bool;
|
||||
string @string = null;
|
||||
bool @bool = false;
|
||||
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
@@ -73,9 +103,68 @@ namespace CefSharp.Example
|
||||
model.Forward();
|
||||
}
|
||||
|
||||
private void view_TestResourceLoadActivated(object sender, EventArgs e)
|
||||
{
|
||||
model.Load(resource_url);
|
||||
}
|
||||
|
||||
private void view_TestSchemeLoadActivated(object sender, EventArgs e)
|
||||
{
|
||||
model.Load(scheme_url);
|
||||
}
|
||||
|
||||
private void view_TestExecuteScriptActivated(object sender, EventArgs e)
|
||||
{
|
||||
var script = String.Format("document.body.style.background = '{0}'",
|
||||
colors[color_index++]);
|
||||
if (color_index >= colors.Length)
|
||||
{
|
||||
color_index = 0;
|
||||
}
|
||||
|
||||
view.ExecuteScript(script);
|
||||
}
|
||||
|
||||
private void view_TestEvaluateScriptActivated(object sender, EventArgs e)
|
||||
{
|
||||
var rand = new Random();
|
||||
var x = rand.Next(1, 10);
|
||||
var y = rand.Next(1, 10);
|
||||
|
||||
var script = String.Format("{0} + {1}", x, y);
|
||||
var result = view.EvaluateScript(script);
|
||||
var output = String.Format("{0} => {1}", script, result);
|
||||
|
||||
gui_invoke(() => view.DisplayOutput(output));
|
||||
}
|
||||
|
||||
private void view_TestBindActivated(object sender, EventArgs e)
|
||||
{
|
||||
model.Load(bind_url);
|
||||
}
|
||||
|
||||
private void view_TestConsoleMessageActivated(object sender, EventArgs e)
|
||||
{
|
||||
var script = "console.log('Hello, world!')";
|
||||
view.ExecuteScript(script);
|
||||
}
|
||||
|
||||
private void view_ExitActivated(object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
CEF.Shutdown();
|
||||
System.Environment.Exit(0);
|
||||
}
|
||||
|
||||
void IBeforeResourceLoad.HandleBeforeResourceLoad(IWebBrowser browserControl,
|
||||
IRequestResponse requestResponse)
|
||||
{
|
||||
IRequest request = requestResponse.Request;
|
||||
if (request.Url.StartsWith(resource_url))
|
||||
{
|
||||
Stream resourceStream = new MemoryStream(Encoding.UTF8.GetBytes(
|
||||
"<html><body><h1>Success</h1><p>This document is loaded from a System.IO.Stream</p></body></html>"));
|
||||
requestResponse.RespondWith(resourceStream, "text/html");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,12 @@ namespace CefSharp.Example
|
||||
event Action<object, string> UrlActivated;
|
||||
event EventHandler BackActivated;
|
||||
event EventHandler ForwardActivated;
|
||||
event EventHandler TestResourceLoadActivated;
|
||||
event EventHandler TestSchemeLoadActivated;
|
||||
event EventHandler TestExecuteScriptActivated;
|
||||
event EventHandler TestEvaluateScriptActivated;
|
||||
event EventHandler TestBindActivated;
|
||||
event EventHandler TestConsoleMessageActivated;
|
||||
event EventHandler ExitActivated;
|
||||
|
||||
void SetTitle(string title);
|
||||
@@ -15,5 +21,9 @@ namespace CefSharp.Example
|
||||
void SetCanGoBack(bool can_go_back);
|
||||
void SetCanGoForward(bool can_go_forward);
|
||||
void SetIsLoading(bool is_loading);
|
||||
|
||||
void ExecuteScript(string script);
|
||||
object EvaluateScript(string script);
|
||||
void DisplayOutput(string output);
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.5448
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace CefSharp.Example.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CefSharp.Example.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
///<html>
|
||||
/// <head>
|
||||
/// <title>Binding Test</title>
|
||||
/// </head>
|
||||
/// <body>
|
||||
/// <p>
|
||||
/// Result of calling bound.Repeat("hi ", 5) =
|
||||
/// <script type="text/javascript">
|
||||
/// var result = bound.Repeat("hi ", 5);
|
||||
/// document.write('"' + result + '"');
|
||||
/// if(result == "hi hi hi hi hi ")
|
||||
/// {
|
||||
/// document.write(" SUCCESS");
|
||||
/// }
|
||||
/// else
|
||||
/// {
|
||||
/// document.write(" FAIL!");
|
||||
/// }
|
||||
/// [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string BindingTest {
|
||||
get {
|
||||
return ResourceManager.GetString("BindingTest", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
///<html>
|
||||
/// <head>
|
||||
/// <title>Popup Test</title>
|
||||
/// </head>
|
||||
/// <body>
|
||||
/// <a href="https://github.com/ataranto/CefSharp" target="_blank">target=_blank</a>
|
||||
/// <br />
|
||||
/// <a href="#" onclick="window.open('https://github.com/ataranto/CefSharp')">window.open()</a>
|
||||
/// </body>
|
||||
///</html>
|
||||
///.
|
||||
/// </summary>
|
||||
internal static string PopupTest {
|
||||
get {
|
||||
return ResourceManager.GetString("PopupTest", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
///<html>
|
||||
/// <head>
|
||||
/// <title>Scheme Handler Test</title>
|
||||
/// </head>
|
||||
/// <body>
|
||||
/// <h1>Success</h1>
|
||||
/// <p>Scheme Handler Functioned Correctly</p>
|
||||
/// </body>
|
||||
///</html>.
|
||||
/// </summary>
|
||||
internal static string SchemeTest {
|
||||
get {
|
||||
return ResourceManager.GetString("SchemeTest", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
///<html>
|
||||
/// <head>
|
||||
/// <title>Scheme Handler Test</title>
|
||||
/// </head>
|
||||
/// <body>
|
||||
/// <form>
|
||||
/// <input type="text" size=25 title="This is the first tooltip">
|
||||
/// <input type="text" size=25 title="This is the second tooltip">
|
||||
/// <input type="button" value="Submit">
|
||||
/// </form>
|
||||
/// </body>
|
||||
///</html>.
|
||||
/// </summary>
|
||||
internal static string TooltipTest {
|
||||
get {
|
||||
return ResourceManager.GetString("TooltipTest", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="BindingTest" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\BindingTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
<data name="PopupTest" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\PopupTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
<data name="SchemeTest" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\SchemeTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
|
||||
</data>
|
||||
<data name="TooltipTest" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\TooltipTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Binding Test</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Result of calling bound.Repeat("hi ", 5) =
|
||||
<script type="text/javascript">
|
||||
var result = bound.Repeat("hi ", 5);
|
||||
document.write('"' + result + '"');
|
||||
if(result == "hi hi hi hi hi ")
|
||||
{
|
||||
document.write(" SUCCESS");
|
||||
}
|
||||
else
|
||||
{
|
||||
document.write(" FAIL!");
|
||||
}
|
||||
</script>
|
||||
</p>
|
||||
|
||||
Methods on bound object 'bound':<br />
|
||||
<ul>
|
||||
<script type="text/javascript">
|
||||
for(var name in bound) {
|
||||
document.write("<li>" + name + "</li>");
|
||||
}
|
||||
</script>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Popup Test</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/ataranto/CefSharp" target="_blank">target=_blank</a>
|
||||
<br />
|
||||
<a href="#" onclick="window.open('https://github.com/ataranto/CefSharp')">window.open()</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Scheme Handler Test</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Success</h1>
|
||||
<p>Scheme Handler Functioned Correctly</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Scheme Handler Test</title>
|
||||
</head>
|
||||
<body>
|
||||
<form>
|
||||
<input type="text" size=25 title="This is the first tooltip">
|
||||
<input type="text" size=25 title="This is the second tooltip">
|
||||
<input type="button" value="Submit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using CefSharp.Example.Properties;
|
||||
|
||||
namespace CefSharp.Example
|
||||
{
|
||||
class SchemeHandlerFactory : ISchemeHandlerFactory
|
||||
{
|
||||
public ISchemeHandler Create()
|
||||
{
|
||||
return new SchemeHandler();
|
||||
}
|
||||
}
|
||||
|
||||
class SchemeHandler: ISchemeHandler
|
||||
{
|
||||
private readonly IDictionary<string, string> resources;
|
||||
|
||||
public SchemeHandler()
|
||||
{
|
||||
resources = new Dictionary<string, string>
|
||||
{
|
||||
{ "BindingTest.html", Resources.BindingTest },
|
||||
{ "PopupTest.html", Resources.PopupTest },
|
||||
{ "SchemeTest.html", Resources.SchemeTest },
|
||||
{ "TooltipTest.html", Resources.TooltipTest },
|
||||
};
|
||||
}
|
||||
|
||||
public bool ProcessRequest(IRequest request, ref string mimeType, ref Stream stream)
|
||||
{
|
||||
var uri = new Uri(request.Url);
|
||||
var segments = uri.Segments;
|
||||
var file = segments[segments.Length - 1];
|
||||
|
||||
string resource;
|
||||
if (resources.TryGetValue(file, out resource) &&
|
||||
!String.IsNullOrEmpty(resource))
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(resource);
|
||||
stream = new MemoryStream(bytes);
|
||||
mimeType = "text/html";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user