add CefSharp.Example to house shared code

This commit is contained in:
anthony taranto
2012-02-23 15:08:50 -08:00
parent d165d56a40
commit 417f01fd59
11 changed files with 293 additions and 24 deletions
+58
View File
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A4394E7B-1155-43A6-989E-8AB72DDDC9E4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CefSharp.Example</RootNamespace>
<AssemblyName>CefSharp.Example</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ExamplePresenter.cs" />
<Compile Include="IExampleView.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CefSharp\CefSharp.vcproj">
<Project>{7B495581-2271-4F41-9476-ACB86E8C864F}</Project>
<Name>CefSharp</Name>
</ProjectReference>
</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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+81
View File
@@ -0,0 +1,81 @@
using System;
using System.ComponentModel;
namespace CefSharp.Example
{
public class ExamplePresenter
{
private readonly IWebBrowser model;
private readonly IExampleView view;
private readonly Action<Action> gui_invoke;
public ExamplePresenter(IWebBrowser model, IExampleView view,
Action<Action> gui_invoke)
{
this.model = model;
this.view = view;
this.gui_invoke = gui_invoke;
this.model.PropertyChanged += model_PropertyChanged;
this.view.ExitActivated += view_ExitActivated;
this.view.ForwardActivated += view_ForwardActivated;
this.view.BackActivated += view_BackActivated;
this.view.UrlActivated += view_UrlActivated;
}
private void model_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
string @string;
bool @bool;
switch (e.PropertyName)
{
case "Title":
@string = model.Title;
gui_invoke(() => view.SetTitle(@string));
break;
case "Tooltip":
@string = model.Tooltip;
gui_invoke(() => view.SetTooltip(@string));
break;
case "Address":
@string = model.Address;
gui_invoke(() => view.SetAddress(@string));
break;
case "CanGoBack":
@bool = model.CanGoBack;
gui_invoke(() => view.SetCanGoBack(@bool));
break;
case "CanGoForward":
@bool = model.CanGoForward;
gui_invoke(() => view.SetCanGoForward(@bool));
break;
case "IsLoading":
@bool = model.IsLoading;
gui_invoke(() => view.SetIsLoading(@bool));
break;
}
}
private void view_UrlActivated(object sender, string url)
{
model.Load(url);
}
private void view_BackActivated(object sender, EventArgs e)
{
model.Back();
}
private void view_ForwardActivated(object sender, EventArgs e)
{
model.Forward();
}
private void view_ExitActivated(object sender, EventArgs e)
{
throw new NotImplementedException();
}
}
}
+19
View File
@@ -0,0 +1,19 @@
using System;
namespace CefSharp.Example
{
public interface IExampleView
{
event Action<object, string> UrlActivated;
event EventHandler BackActivated;
event EventHandler ForwardActivated;
event EventHandler ExitActivated;
void SetTitle(string title);
void SetTooltip(string tooltip);
void SetAddress(string address);
void SetCanGoBack(bool can_go_back);
void SetCanGoForward(bool can_go_forward);
void SetIsLoading(bool is_loading);
}
}
@@ -0,0 +1,11 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("CefSharp.Example")]
[assembly: AssemblyCompany("Anthony Taranto")]
[assembly: AssemblyProduct("CefSharp.Example")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyVersion("0.9.*")]
[assembly: ComVisible(false)]