diff --git a/CefSharp.Example/BoundObject.cs b/CefSharp.Example/BoundObject.cs new file mode 100644 index 000000000..3ae3f13ca --- /dev/null +++ b/CefSharp.Example/BoundObject.cs @@ -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; + } + } +} diff --git a/CefSharp.Example/CefSharp.Example.csproj b/CefSharp.Example/CefSharp.Example.csproj index 6fa330117..e8dca92f3 100644 --- a/CefSharp.Example/CefSharp.Example.csproj +++ b/CefSharp.Example/CefSharp.Example.csproj @@ -35,11 +35,20 @@ 3.5 + + + + + True + True + Resources.resx + + @@ -47,6 +56,18 @@ CefSharp + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\BindingTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + + ..\Resources\PopupTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + + ..\Resources\SchemeTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + + ..\Resources\TooltipTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + \ No newline at end of file diff --git a/CefSharp.Example/Resources/BindingTest.html b/CefSharp.Example/Resources/BindingTest.html new file mode 100644 index 000000000..92f5ade6f --- /dev/null +++ b/CefSharp.Example/Resources/BindingTest.html @@ -0,0 +1,32 @@ + + + + Binding Test + + +

+ Result of calling bound.Repeat("hi ", 5) = + +

+ + Methods on bound object 'bound':
+
    + +
+ + \ No newline at end of file diff --git a/CefSharp.Example/Resources/PopupTest.html b/CefSharp.Example/Resources/PopupTest.html new file mode 100644 index 000000000..3bc0a7f06 --- /dev/null +++ b/CefSharp.Example/Resources/PopupTest.html @@ -0,0 +1,11 @@ + + + + Popup Test + + + target=_blank +
+ window.open() + + diff --git a/CefSharp.Example/Resources/SchemeTest.html b/CefSharp.Example/Resources/SchemeTest.html new file mode 100644 index 000000000..c2c143d86 --- /dev/null +++ b/CefSharp.Example/Resources/SchemeTest.html @@ -0,0 +1,10 @@ + + + + Scheme Handler Test + + +

Success

+

Scheme Handler Functioned Correctly

+ + \ No newline at end of file diff --git a/CefSharp.Example/Resources/TooltipTest.html b/CefSharp.Example/Resources/TooltipTest.html new file mode 100644 index 000000000..b5b7497c1 --- /dev/null +++ b/CefSharp.Example/Resources/TooltipTest.html @@ -0,0 +1,13 @@ + + + + Scheme Handler Test + + +
+ + + +
+ + \ No newline at end of file diff --git a/CefSharp.Example/SchemeHandler.cs b/CefSharp.Example/SchemeHandler.cs new file mode 100644 index 000000000..ae606e13a --- /dev/null +++ b/CefSharp.Example/SchemeHandler.cs @@ -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 resources; + + public SchemeHandler() + { + resources = new Dictionary + { + { "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; + } + } +} diff --git a/CefSharp.WinForms.Example/BoundObject.cs b/CefSharp.WinForms.Example/BoundObject.cs index 186d4ed90..12d3c68d3 100644 --- a/CefSharp.WinForms.Example/BoundObject.cs +++ b/CefSharp.WinForms.Example/BoundObject.cs @@ -6,9 +6,7 @@ namespace CefSharp.WinForms.Example { public string Repeat(string str, int n) { - Console.WriteLine("In bound object method"); - - string result = ""; + string result = String.Empty; for (int i = 0; i < n; i++) { result += str; diff --git a/CefSharp.WinForms.Example/Browser.cs b/CefSharp.WinForms.Example/Browser.cs index af77efddd..d0eeed8f5 100644 --- a/CefSharp.WinForms.Example/Browser.cs +++ b/CefSharp.WinForms.Example/Browser.cs @@ -3,8 +3,6 @@ using System.ComponentModel; using System.IO; using System.Text; using System.Windows.Forms; -using CefSharp; -using CefSharp.WinForms; namespace CefSharp.WinForms.Example { diff --git a/CefSharp.Wpf.Example/App.xaml.cs b/CefSharp.Wpf.Example/App.xaml.cs index cf33fa0bb..a44df3d68 100644 --- a/CefSharp.Wpf.Example/App.xaml.cs +++ b/CefSharp.Wpf.Example/App.xaml.cs @@ -1,9 +1,13 @@ using System.Windows; +using CefSharp.Example; namespace CefSharp.Wpf.Example { public partial class App : Application { - + private App() + { + ExamplePresenter.Init(); + } } } \ No newline at end of file diff --git a/CefSharp.Wpf.Example/MainWindow.xaml b/CefSharp.Wpf.Example/MainWindow.xaml index 40c8a7206..995b5660a 100644 --- a/CefSharp.Wpf.Example/MainWindow.xaml +++ b/CefSharp.Wpf.Example/MainWindow.xaml @@ -6,16 +6,15 @@ - + - - - - - - - + + + + + + @@ -23,8 +22,8 @@ - - + + @@ -33,6 +32,7 @@ +