windows: Remove CefSharp from build and use WPF WebBrowser instead

This commit is contained in:
Hylke Bons 2012-03-10 02:56:09 +00:00
parent 98e01c2ebb
commit a578979147
16 changed files with 35 additions and 415 deletions

View file

@ -1,62 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CefSharp;
using System.IO;
namespace SparkleShare {
class ApplicationSchemeHandler : ISchemeHandler {
#region ISchemeHandler Members
public bool ProcessRequest (IRequest request, ref string mimeType, ref Stream stream)
{
if (request.Url.EndsWith (".png")) {
System.Drawing.Bitmap Image=null;
if (request.Url.EndsWith ("avatar-default-32.png"))
Image = Icons.avatar_default_32;
else if (request.Url.EndsWith ("document-added-12.png"))
Image = Icons.document_added_12;
else if (request.Url.EndsWith ("document-edited-12.png"))
Image = Icons.document_edited_12;
else if (request.Url.EndsWith ("document-deleted-12.png"))
Image = Icons.document_deleted_12;
else if (request.Url.EndsWith ("document-moved-12.png"))
Image = Icons.document_moved_12;
if (Image != null) {
stream = new MemoryStream ();
Image.Save (stream, System.Drawing.Imaging.ImageFormat.Png);
stream.Seek (0, SeekOrigin.Begin);
mimeType = "image/png";
return true;
}
} else if (request.Url.EndsWith (".js")) {
string Text = null;
if (request.Url.EndsWith ("jquery.js"))
Text = Properties.Resources.jquery_js;
if (Text != null) {
stream = new MemoryStream (Encoding.UTF8.GetPreamble ().Concat (Encoding.UTF8.GetBytes (Text)).ToArray ());
mimeType = "application/javascript";
return true;
}
}
return false;
}
#endregion
}
public class ApplicationSchemeHandlerFactory : ISchemeHandlerFactory {
public ISchemeHandler Create ()
{
return new ApplicationSchemeHandler ();
}
}
}

View file

@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CefSharp;
using System.IO;
namespace SparkleShare {
class FileSchemeHandler : ISchemeHandler {
#region ISchemeHandler Members
public bool ProcessRequest (IRequest request, ref string mimeType, ref Stream stream)
{
return false;
}
#endregion
}
public class FileSchemeHandlerFactory : ISchemeHandlerFactory {
public ISchemeHandler Create ()
{
return new FileSchemeHandler ();
}
}
}

View file

@ -1,150 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SparkleShare.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("SparkleShare.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 &lt;div class=&apos;day-entry&apos;&gt;
/// &lt;div class=&apos;day-entry-header&apos;&gt;
/// &lt;!-- $day-entry-header --&gt;
/// &lt;/div&gt;
/// &lt;div class=&apos;day-entry-content&apos;&gt;
/// &lt;!-- $day-entry-content --&gt;
/// &lt;/div&gt;
///&lt;/div&gt;
///.
/// </summary>
internal static string day_entry_html {
get {
return ResourceManager.GetString("day_entry_html", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;div class=&apos;event-entry&apos; style=&apos;background-image: url(&quot;&lt;!-- $event-avatar-url --&gt;&quot;);&apos;&gt;
/// &lt;div class=&apos;event-user-name&apos;&gt;&lt;!-- $event-user-name --&gt;&lt;/div&gt;
/// &lt;div class=&apos;event-folder&apos;&gt;&lt;!-- $event-folder --&gt;&lt;/div&gt;
///
/// &lt;!-- $event-entry-content --&gt;
///
/// &lt;div class=&quot;clearer&quot;&gt;&lt;/div&gt;
/// &lt;div class=&quot;event-timestamp&quot;&gt;&lt;!-- $event-time --&gt;&lt;/div&gt;
/// &lt;div class=&quot;action note&quot;&gt;Add note&lt;/div&gt;
/// &lt;div class=&quot;action show&quot;&gt;Show all&lt;/div&gt;
///
/// &lt;div class=&quot;clearer&quot;&gt;&lt;/div&gt;
///
/// &lt;div class=&quot;comments-section&quot;&gt;
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string event_entry_html {
get {
return ResourceManager.GetString("event_entry_html", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;!doctype html&gt;
///&lt;html&gt;
/// &lt;head&gt;
/// &lt;title&gt;SparkleShare Event Log&lt;/title&gt;
/// &lt;script type=&quot;text/javascript&quot; src=&quot;&lt;!-- $jquery-url --&gt;&quot;&gt;&lt;/script&gt;
/// &lt;script type=&quot;text/javascript&quot;&gt;
/// $(document).ready(function () {
/// $(&apos;.comments-section&apos;).each (function () {
/// if ($(this).find (&apos;.comments&apos;).children ().size () &lt; 1) {
/// $(this).hide ();
/// }
/// });
///
/// $(&apos;.buddy-icon&apos;).each (function () {
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string event_log_html {
get {
return ResourceManager.GetString("event_log_html", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to /*!
/// * jQuery JavaScript Library v1.6.1
/// * http://jquery.com/
/// *
/// * Copyright 2011, John Resig
/// * Dual licensed under the MIT or GPL Version 2 licenses.
/// * http://jquery.org/license
/// *
/// * Includes Sizzle.js
/// * http://sizzlejs.com/
/// * Copyright 2011, The Dojo Foundation
/// * Released under the MIT, BSD, and GPL Licenses.
/// *
/// * Date: Thu May 12 15:04:36 2011 -0400
/// */
///(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!cj[a]){var [rest of string was truncated]&quot;;.
/// </summary>
internal static string jquery_js {
get {
return ResourceManager.GetString("jquery_js", resourceCulture);
}
}
}
}

View file

@ -1,133 +0,0 @@
<?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="day_entry_html" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\..\data\html\day-entry.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="event_entry_html" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\..\data\html\event-entry.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="event_log_html" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\..\data\html\event-log.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="jquery_js" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\..\..\data\html\jquery.js;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
</root>

View file

@ -26,7 +26,6 @@ using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using CefSharp;
using Microsoft.Win32;
using SparkleLib;
@ -55,20 +54,6 @@ namespace SparkleShare {
public override void Initialize ()
{
Settings settings = new Settings ();
BrowserSettings browser_settings = new BrowserSettings ();
if (!CEF.Initialize (settings, browser_settings)) {
Console.WriteLine ("Could not initialise CEF");
return;
}
CEF.RegisterScheme ("application", "sparkleshare", new ApplicationSchemeHandlerFactory ());
CEF.RegisterScheme ("application", "file", new FileSchemeHandlerFactory ());
Application.EnableVisualStyles ();
Application.SetCompatibleTextRenderingDefault (false);
// Add msysgit to path, as we cannot asume it is added to the path
// Asume it is installed in @"<exec dir>\msysgit\bin"
string executable_dir = Path.GetDirectoryName (Application.ExecutablePath);
@ -94,8 +79,9 @@ namespace SparkleShare {
public override string EventLogHTML
{
get {
string html = Properties.Resources.event_log_html;
html = html.Replace ("<!-- $jquery-url -->", "application://sparkleshare/jquery.js");
string html = SparkleUIHelpers.GetHTML ("event-log.html");
html = html.Replace ("<!-- $jquery -->", SparkleUIHelpers.GetHTML ("jquery.js"));
return html;
}
}
@ -104,7 +90,7 @@ namespace SparkleShare {
public override string DayEntryHTML
{
get {
return Properties.Resources.day_entry_html;
return SparkleUIHelpers.GetHTML ("day-entry.html");
}
}
@ -112,7 +98,7 @@ namespace SparkleShare {
public override string EventEntryHTML
{
get {
return Properties.Resources.event_entry_html;
return SparkleUIHelpers.GetHTML ("event-entry.html");
}
}

View file

@ -52,6 +52,8 @@ namespace SparkleShare {
Width = 480;
ResizeMode = ResizeMode.NoResize;
Background = new SolidColorBrush (Color.FromRgb (240, 240, 240));
AllowsTransparency = false;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
@ -97,11 +99,11 @@ namespace SparkleShare {
Height = Height - 36 - 12
};
this.web_browser.Navigating += delegate (object sender, NavigatingCancelEventArgs e) {
/*this.web_browser.Navigating += delegate (object sender, NavigatingCancelEventArgs e) {
string url = e.Uri.ToString ();
Controller.LinkClicked (url);
};
*/
this.canvas = new Canvas ();
Content = this.canvas;
@ -258,9 +260,8 @@ namespace SparkleShare {
Dispatcher.Invoke ((Action) delegate {
//if (this.progress_indicator.Superview == ContentView) TODO: spinner
// this.progress_indicator.RemoveFromSuperview ();
this.web_browser.NavigateToString (html);
this.web_browser.NavigateToString (html);
//MessageBox.Show (html);
if (!this.canvas.Children.Contains (this.web_browser)) {
this.canvas.Children.Add (this.web_browser);
Canvas.SetLeft (this.web_browser, 0);

View file

@ -70,9 +70,6 @@
<HintPath>..\..\bin\Gettext.Cs.dll</HintPath>
</Reference>
<Reference Include="WindowsFormsIntegration" />
<Reference Include="CefSharp">
<HintPath>..\..\bin\CefSharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\SparkleLib\windows\GlobalAssemblyInfo.cs">
@ -102,19 +99,12 @@
<Compile Include="..\SparkleStatusIconController.cs">
<Link>SparkleStatusIconController.cs</Link>
</Compile>
<Compile Include="ApplicationSchemeHandler.cs" />
<Compile Include="AssemblyInfo.cs" />
<Compile Include="FileSchemeHandler.cs" />
<Compile Include="Icons.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Icons.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="..\SparkleSetupController.cs" />
<Compile Include="SparkleUI.cs" />
<Compile Include="..\SparkleAboutController.cs" />
@ -201,11 +191,6 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Icons.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\about.png">
<Link>Pixmaps\about.png</Link>
</EmbeddedResource>
@ -252,6 +237,18 @@
<EmbeddedResource Include="..\..\data\icons\folder-windows-16.png">
<Link>Pixmaps\folder-windows-16.png</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\html\day-entry.html">
<Link>HTML\day-entry.html</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\html\event-entry.html">
<Link>HTML\event-entry.html</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\html\event-log.html">
<Link>HTML\event-log.html</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\..\data\html\jquery.js">
<Link>HTML\jquery.js</Link>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Icons.tt">
@ -424,5 +421,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Pixmaps\" />
<Folder Include="HTML\" />
</ItemGroup>
</Project>

View file

@ -22,6 +22,7 @@ using System.Windows;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using Forms = System.Windows.Forms;
namespace SparkleShare {
@ -52,7 +53,7 @@ namespace SparkleShare {
public SparkleStatusIcon ()
{
{
AnimationFrames = CreateAnimationFrames ();
Animation = CreateAnimation ();
ErrorIcon = SparkleUIHelpers.GetBitmap ("sparkleshare-syncing-error-windows");

View file

@ -44,6 +44,15 @@ namespace SparkleShare {
Assembly assembly = Assembly.GetExecutingAssembly ();
Stream image_stream = assembly.GetManifestResourceStream ("SparkleShare.Pixmaps." + name + ".png");
return (Bitmap) Bitmap.FromStream (image_stream);
}
public static string GetHTML (string name)
{
Assembly assembly = Assembly.GetExecutingAssembly ();
StreamReader html_reader = new StreamReader (
assembly.GetManifestResourceStream ("SparkleShare.HTML." + name));
return html_reader.ReadToEnd ();
}
}
}

View file

@ -7,9 +7,6 @@ set msbuild="%WinDirNet%\v3.5\msbuild.exe"
if not exist %msbuild% set msbuild="%WinDirNet%\v4.0.30319\msbuild.exe"
set wixBinDir=%WIX%\bin
cd lib
copy * ..\..\..\bin
cd ..
copy ..\..\data\icons\sparkleshare.ico ..\..\bin

Binary file not shown.

Binary file not shown.