Permalink
Browse files

simplified ui, added auto-generated id

  • Loading branch information...
1 parent 6f1d342 commit 181eec875fe4d4259ba7f461c093eebf46551bf4 @sgrebnov committed Sep 24, 2012
View
@@ -1 +1,4 @@
/*.suo
+obj
+bin
+*.csproj.user
View
@@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE.Debug.Core", "Libraries\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WP7CordovaClassLib", "Libraries\cordovalib\WP7CordovaClassLib.csproj", "{FC6A1A70-892D-46AD-9E4A-9793F72AF780}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IE.Debug.Weinre", "Libraries\IE.Debug.Weinre\IE.Debug.Weinre.csproj", "{18AFA051-F01B-458E-B64A-4E3B495881D4}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +35,10 @@ Global
{FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Release|Any CPU.Build.0 = Release|Any CPU
+ {18AFA051-F01B-458E-B64A-4E3B495881D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {18AFA051-F01B-458E-B64A-4E3B495881D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {18AFA051-F01B-458E-B64A-4E3B495881D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {18AFA051-F01B-458E-B64A-4E3B495881D4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1,14 +1,5 @@
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using Support;
+using Support;
+using System;
namespace IE.Debug.Core
{
@@ -1,37 +1,26 @@
-using System;
-using System.Net;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Documents;
-using System.Windows.Ink;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Animation;
-using System.Windows.Shapes;
-using Microsoft.Phone.Controls;
-using System.IO.IsolatedStorage;
-using System.IO;
+using Microsoft.Phone.Controls;
using Support;
+using System;
namespace IE.Debug.Core
{
public static class WebPageDebugger
{
- private static WebBrowser browser;
+ private static WebBrowser Browser {get; set;}
- public static string pageHtml
+ public static string PageHtml
{
- get { return browser.SaveToString(); }
+ get { return Browser.SaveToString(); }
}
- public static string pageUri
+ public static string PageUri
{
get { return String.Empty; }
}
public static void Initialize(WebBrowser browser)
{
- WebPageDebugger.browser = browser;
+ WebPageDebugger.Browser = browser;
}
public static void InstallDebugConsole()
@@ -40,10 +29,10 @@ public static void InstallDebugConsole()
{
string nativeReady = "(function(){ cordova.require('cordova/channel').onNativeReady.fire()})();";
- browser.InvokeScript("eval", new string[] { Scripting.PhoneGapInjectScript });
- browser.InvokeScript("eval", new string[] { FileUtils.ReadFileContent("app/www/js/wpHtmlDebugger.js") });
+ Browser.InvokeScript("eval", new string[] { Scripting.PhoneGapInjectScript });
+ Browser.InvokeScript("eval", new string[] { FileUtils.ReadFileContent("app/www/js/wpHtmlDebugger.js") });
- browser.InvokeScript("execScript", new string[] { nativeReady });
+ Browser.InvokeScript("execScript", new string[] { nativeReady });
}
catch (Exception ex)
{
@@ -52,36 +41,15 @@ public static void InstallDebugConsole()
//browser.InvokeScript("eval", new string[] { Scripting.BuilInjectScript(@"http://mshare.akvelon.net:8184/cordova-init.js")});
}
- public static void ConnectWeinerDebugger()
- {
- try
- {
- // install cross domain request wrapper
- browser.InvokeScript("eval", new string[] { @"window.wpHtmlDebugger.applyXSSpatch()" });
-
- browser.InvokeScript("eval", new string[] { @"window.WeinreServerId='wp7'" });
- browser.InvokeScript("eval", new string[] { @"window.WeinreServerURL='http://debug.shadow.adobe.com:8080'" });
-
- browser.InvokeScript("eval", new string[] { FileUtils.ReadFileContent(@"app/www/wp-hacks.js") });
- browser.InvokeScript("eval", new string[] { FileUtils.ReadFileContent(@"app/www/target-script-min.js") });
-
- MessageBox.Show("Debugger connected to the following endpoint: http://debug.shadow.adobe.com:8080/client/#wp7");
- }
- catch (Exception ex)
- {
- Support.Messages.ShowError("Sorry, an error occured. " + ex.Message);
- }
- }
-
public static void InstallFirebug()
{
- browser.InvokeScript("eval", new string[] { Scripting.FirebugInjectScript });
+ Browser.InvokeScript("eval", new string[] { Scripting.FirebugInjectScript });
//(@"function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F[i+'NS']&&F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new%20Image;E[r]('src',I+L);})(document,'createElement','setAttribute','getElementsByTagName','FirebugLite','4','firebug-lite.js','releases/lite/latest/skin/xp/sprite.png','https://getfirebug.com/','#startOpened')();");
}
public static void ExecuteCustomScript(string script)
{
- browser.InvokeScript("eval", new string[] { script});
+ Browser.InvokeScript("eval", new string[] { script});
}
}
}
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.20506</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{18AFA051-F01B-458E-B64A-4E3B495881D4}</ProjectGuid>
+ <ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>IE.Debug.Weinre</RootNamespace>
+ <AssemblyName>IE.Debug.Weinre</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
+ <TargetFrameworkProfile>WindowsPhone71</TargetFrameworkProfile>
+ <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
+ <SilverlightApplication>false</SilverlightApplication>
+ <ValidateXaml>true</ValidateXaml>
+ <ThrowErrorsInValidation>true</ThrowErrorsInValidation>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>Bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <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;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
+ <NoStdLib>true</NoStdLib>
+ <NoConfig>true</NoConfig>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System.Windows" />
+ <Reference Include="system" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Net" />
+ <Reference Include="mscorlib.extensions" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="WeinreDebugger.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\IE.Debug.Core\IE.Debug.Core.csproj">
+ <Project>{435B81A7-D555-4D9E-BE2D-0DCEE4D6050E}</Project>
+ <Name>IE.Debug.Core</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Support\Support.csproj">
+ <Project>{5F99E641-C43E-49A2-A771-06FC091BE010}</Project>
+ <Name>Support</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
+ <ProjectExtensions />
+ <!-- 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>
@@ -0,0 +1,37 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Resources;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("IE.Debug.Weinre")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("IE.Debug.Weinre")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("18afa051-f01b-458e-b64a-4e3b495881d4")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: NeutralResourcesLanguageAttribute("en-US")]
@@ -0,0 +1,75 @@
+using IE.Debug.Core;
+using Support;
+using System;
+using System.IO.IsolatedStorage;
+using System.Windows;
+
+namespace IE.Debug.Weinre
+{
+ /// <summary>
+ /// Implements weinre debugger injection functionality
+ /// </summary>
+ public static class WeinreDebugger
+ {
+ /// <summary>
+ /// Weinre server
+ /// </summary>
+ private static readonly string WeinreServerURL = @"http://debug.shadow.adobe.com:8080";
+
+ /// <summary>
+ /// Injects weinre debugger script to the page
+ /// </summary>
+ public static void RegisterTarget()
+ {
+ try
+ {
+ // install cross domain request wrapper
+ WebPageDebugger.ExecuteCustomScript(@"window.wpHtmlDebugger.applyXSSpatch()");
+
+ // weinre settings
+ WebPageDebugger.ExecuteCustomScript(String.Format(@"window.WeinreServerId='{0}'", WeinreId));
+ WebPageDebugger.ExecuteCustomScript(String.Format(@"window.WeinreServerURL='{0}'", WeinreServerURL));
+
+ // run weinre script
+ WebPageDebugger.ExecuteCustomScript(FileUtils.ReadFileContent(@"app/www/wp-hacks.js"));
+ WebPageDebugger.ExecuteCustomScript(FileUtils.ReadFileContent(@"app/www/target-script-min.js"));
+
+ MessageBox.Show(String.Format("Successfully connected! Use the following uri in desktop browser: {0}/client/#{1}", WeinreServerURL, WeinreId));
+ }
+ catch (Exception ex)
+ {
+ Support.Messages.ShowError("Sorry, an error occured. " + ex.Message);
+ }
+ }
+
+ /// <summary>
+ /// Gets unique identifier for this device.
+ /// </summary>
+ private static string WeinreId
+ {
+ get
+ {
+
+ var settings = IsolatedStorageSettings.ApplicationSettings;
+
+ if (!settings.Contains("WeinreId"))
+ {
+ settings["WeinreId"] = GenerateWeinreId();
+ settings.Save();
+ }
+
+ return settings["WeinreId"] as string;
+
+ }
+ }
+
+ /// <summary>
+ /// Generates unique id for target device
+ /// </summary>
+ /// <returns></returns>
+ private static string GenerateWeinreId()
+ {
+ return Guid.NewGuid().ToString().Substring(0, 4);
+ }
+ }
+}
@@ -9,15 +9,23 @@
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480"
xmlns:my="clr-namespace:WP7CordovaClassLib;assembly=WP7CordovaClassLib">
-
- <Grid x:Name="LayoutRoot">
+
+ <Grid x:Name="LayoutRoot" Margin="0,0,0,0">
<Grid>
- <my:CordovaView HorizontalAlignment="Stretch"
- Margin="0,64,0,0"
+ <Grid.RowDefinitions>
+ <RowDefinition Height="72"></RowDefinition>
+ <RowDefinition Height="*"></RowDefinition>
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*"></ColumnDefinition>
+ <ColumnDefinition Width="Auto"></ColumnDefinition>
+ </Grid.ColumnDefinitions>
+
+ <my:CordovaView Grid.Row="1" Margin="0,0,0,0" Grid.ColumnSpan="2" HorizontalAlignment="Stretch"
Name="PGView"
VerticalAlignment="Stretch" StartPageUri="http://microsoft.com" />
- <TextBox Height="72" HorizontalAlignment="Left" Name="txtUrl" Text="http://microsoft.com" VerticalAlignment="Top" Width="414" Margin="-10,-3,0,0" />
- <Button Content="go" Height="72" HorizontalAlignment="Left" Margin="384,-1,0,0" Name="btnNavigate" VerticalAlignment="Top" Width="82" Click="btnNavigate_Click" />
+ <TextBox Grid.Row="0" Grid.Column="0" Name="txtUrl" Text="http://m.microsoft.com" Margin="-10,0" Padding="0,2,2,2" />
+ <Button Grid.Row="0" Grid.Column="1" Content="debug" Name="btnNavigate" Click="btnNavigate_Click" Padding="0,3,0,5" Margin="0,0,-10,0" />
</Grid>
</Grid>
@@ -25,20 +25,26 @@ public PageHostControl()
{
InitializeComponent();
- PGView.StartPageUri = new Uri(txtUrl.Text, UriKind.RelativeOrAbsolute);
-
this.Loaded += (arg1, arg2) => {
txtUrl.InputScope = new InputScope { Names = { new InputScopeName { NameValue = InputScopeNameValue.Url } } };
WebPageDebugger.Initialize(this.Browser);
- PGView.Browser.NavigationFailed += (s, ex) =>
+ Browser.NavigationFailed += (s, ex) =>
{
if (ex.Exception != null) {
Messages.ShowError(ex.Exception.Message);
}
};
+
+ Browser.LoadCompleted += (s, ex) =>
+ {
+ WebPageDebugger.InstallDebugConsole();
+ Weinre.WeinreDebugger.RegisterTarget();
+ };
+
+ Browser.Navigate(new Uri(txtUrl.Text, UriKind.RelativeOrAbsolute));
};
}
Oops, something went wrong.

0 comments on commit 181eec8

Please sign in to comment.