Permalink
Browse files

Merge pull request #34 from purplecabbage/master

Removed t4 templating, and added WSH scripting
  • Loading branch information...
2 parents ef2479a + 70431c6 commit ac517cbf1524c72aa68f9edb4c41dc41a394f0d1 Jesse MacFadyen committed Oct 20, 2011
View
Binary file not shown.
@@ -11,15 +11,10 @@
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True" d:DesignHeight="768" d:DesignWidth="480" xmlns:my="clr-namespace:WP7GapClassLib;assembly=WP7GapClassLib">
- <Grid>
+ <Grid x:Name="LayoutRoot" >
<my:PGView Name="pGView1" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"></my:PGView>
- <!--<phone:WebBrowser x:Name="GapBrowser"
- Loaded="GapBrowser_Loaded"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"
- IsScriptEnabled="True" />-->
</Grid>
@@ -4,7 +4,7 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=9" />
- <meta name="Viewport" content="width=480" />
+ <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<title>PhoneGap - WP7 : Proof of concept</title>
<link rel="stylesheet" type="text/css" href="master.css"/>
@@ -1,198 +0,0 @@
-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.Diagnostics;
-using System.Runtime.Serialization;
-using WP7GapClassLib.PhoneGap.UI;
-using Microsoft.Phone.Shell;
-
-namespace WP7GapClassLib.PhoneGap.Commands
-{
- [DataContract]
- public class BrowserOptions
- {
- [DataMember]
- public string url;
-
- [DataMember]
- public bool isGeolocationEnabled;
- }
-
- public class ChildBrowserCommand : BaseCommand
- {
-
- private static WebBrowser browser;
- private static ApplicationBarIconButton backButton;
- private static ApplicationBarIconButton fwdButton;
-
- // Display an inderminate progress indicator
- public void showWebPage(string options)
- {
- BrowserOptions opts = JSON.JsonHelper.Deserialize<BrowserOptions>(options);
-
- Uri loc = new Uri(opts.url);
-
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- if (browser != null)
- {
- browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
- browser.Navigate(loc);
- }
- else
- {
- PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
- if (frame != null)
- {
- PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
- if (page != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- browser = new WebBrowser();
- browser.Navigate(loc);
-
- browser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted);
-
- browser.Navigating += new EventHandler<NavigatingEventArgs>(browser_Navigating);
- browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed);
- browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(browser_Navigated);
- browser.IsScriptEnabled = true;
- browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
- grid.Children.Add(browser);
- }
-
- ApplicationBar bar = new ApplicationBar();
- bar.BackgroundColor = Colors.Black;
- bar.IsMenuEnabled = false;
-
- backButton = new ApplicationBarIconButton();
- backButton.Text = "Back";
- backButton.IconUri = new Uri("/Images/appbar.back.rest.png", UriKind.Relative);
- backButton.Click += new EventHandler(backButton_Click);
- backButton.IsEnabled = false;
- bar.Buttons.Add(backButton);
-
-
- fwdButton = new ApplicationBarIconButton();
- fwdButton.Text = "Forward";
- fwdButton.IconUri = new Uri("/Images/appbar.next.rest.png", UriKind.Relative);
- fwdButton.Click += new EventHandler(fwdButton_Click);
- fwdButton.IsEnabled = false;
- bar.Buttons.Add(fwdButton);
-
- ApplicationBarIconButton closeBtn = new ApplicationBarIconButton();
- closeBtn.Text = "Close";
- closeBtn.IconUri = new Uri("/Images/appbar.close.rest.png", UriKind.Relative);
- closeBtn.Click += new EventHandler(closeBtn_Click);
- bar.Buttons.Add(closeBtn);
-
- page.ApplicationBar = bar;
- }
-
- }
- }
- });
- }
-
- void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
- {
-
- }
-
- void fwdButton_Click(object sender, EventArgs e)
- {
- if (browser != null)
- {
- try
- {
- browser.InvokeScript("execScript", "history.forward();");
- }
- catch(Exception)
- {
-
- }
- }
- }
-
- void backButton_Click(object sender, EventArgs e)
- {
- if (browser != null)
- {
- try
- {
- browser.InvokeScript("execScript", "history.back();");
- }
- catch (Exception)
- {
-
- }
- }
- }
-
- void closeBtn_Click(object sender, EventArgs e)
- {
- this.close();
- }
-
-
- public void close(string options="")
- {
- if (browser != null)
- {
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
- if (frame != null)
- {
- PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
- if (page != null)
- {
- Grid grid = page.FindName("LayoutRoot") as Grid;
- if (grid != null)
- {
- grid.Children.Remove(browser);
- }
- page.ApplicationBar = null;
- }
- }
- browser = null;
- });
- }
- }
-
- void browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
- {
- string message = "{type:\"locationChanged\",location:\"" + e.Uri.AbsoluteUri + "\"}";
- PluginResult result = new PluginResult(PluginResult.Status.OK, message);
- result.KeepCallback = true;
- this.DispatchCommandResult(result);
- }
-
- void browser_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e)
- {
- string message = "{type:\"navigationError\",location:\"" + e.Uri.AbsoluteUri + "\"}";
- PluginResult result = new PluginResult(PluginResult.Status.ERROR, message);
- result.KeepCallback = true;
- this.DispatchCommandResult(result);
- }
-
- void browser_Navigating(object sender, NavigatingEventArgs e)
- {
- string message = "{type:\"locationAboutToChange\",location:\"" + e.Uri.AbsoluteUri + "\"}";
- PluginResult result = new PluginResult(PluginResult.Status.OK, message);
- result.KeepCallback = true;
- this.DispatchCommandResult(result);
- }
-
- }
-}
@@ -58,7 +58,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="PhoneGap\Commands\AudioPlayer.cs" />
- <Compile Include="PhoneGap\Commands\ChildBrowserCommand.cs" />
<Compile Include="PhoneGap\Commands\Compass.cs" />
<Compile Include="PhoneGap\Commands\Media.cs" />
<Compile Include="PhoneGap\DOMStorageHelper.cs" />
@@ -78,20 +78,13 @@
</ItemGroup>
<ItemGroup>
<Content Include="GapLib\WP7GapClassLib.dll" />
- <Content Include="GapSourceDictionary.xml">
- <AutoGen>True</AutoGen>
- <DesignTime>True</DesignTime>
- <DependentUpon>GapSourceDictionary.tt</DependentUpon>
- </Content>
+ <Content Include="GapSourceDictionary.xml" />
+ <Content Include="ManifestProcessor.js" />
<Content Include="www\index.html">
<SubType>Designer</SubType>
</Content>
<Content Include="www\master.css" />
<Content Include="www\phonegap-1.1.0.js" />
- <None Include="GapSourceDictionary.tt">
- <Generator>TextTemplatingFileGenerator</Generator>
- <LastGenOutput>GapSourceDictionary.xml</LastGenOutput>
- </None>
<None Include="Properties\AppManifest.xml">
<SubType>Designer</SubType>
</None>
@@ -125,9 +118,10 @@
-->
<ProjectExtensions />
<PropertyGroup>
- <PreBuildEvent>@echo about to build GapExample</PreBuildEvent>
+ <PreBuildEvent>CScript "$(ProjectDir)/ManifestProcessor.js"</PreBuildEvent>
</PropertyGroup>
<PropertyGroup>
- <PostBuildEvent>@echo done GapExample</PostBuildEvent>
+ <PostBuildEvent>
+ </PostBuildEvent>
</PropertyGroup>
</Project>
Binary file not shown.
@@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010 Express for Windows Phone
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GapAppProj", "GapAppProj.csproj", "{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WP7GapClassLib", "..\framework\WP7GapClassLib.csproj", "{FC6A1A70-892D-46AD-9E4A-9793F72AF780}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -17,10 +15,6 @@ Global
{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|Any CPU.Build.0 = Release|Any CPU
{3677C1B7-D68B-4CF9-BF8A-E869D437A6DF}.Release|Any CPU.Deploy.0 = Release|Any CPU
- {FC6A1A70-892D-46AD-9E4A-9793F72AF780}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1,35 +0,0 @@
-<#@ template language="C#" hostspecific="True" #>
-<#@ Output Extension=".xml" #>
-<#@ assembly name="System.Core" #>
-<#@ assembly name="System.Xml" #>
-<#@ assembly name="System.Xml.Linq" #>
-<#@ import namespace="System" #>
-<#@ import namespace="System.CodeDom" #>
-<#@ import namespace="System.CodeDom.Compiler" #>
-<#@ import namespace="System.Collections.Generic" #>
-<#@ import namespace="System.IO" #>
-<#@ import namespace="System.Linq" #>
-<#@ import namespace="System.Reflection" #>
-<#@ import namespace="System.Text" #>
-<#@ import namespace="System.Xml.Linq" #>
-<#@ import namespace="Microsoft.VisualStudio.TextTemplating" #>
-<?xml version="1.0" encoding="utf-8"?>
-<GapSourceDictionary>
-<#
-var currentDirectory = Path.GetDirectoryName(Host.TemplateFile);
-var jsFiles = Directory.GetFiles(String.Format(@"{0}{1}www", currentDirectory, System.IO.Path.DirectorySeparatorChar), "*", SearchOption.AllDirectories);
-#>
-<# foreach(var jsFile in jsFiles) { #>
- <FilePath Value="<#= GetRelativeFilePath(jsFile) #>"/>
-<# } #>
-</GapSourceDictionary>
-
-<#+
-public string GetRelativeFilePath(string path) {
- var currentDirectory = Path.GetDirectoryName(Host.TemplateFile) + System.IO.Path.DirectorySeparatorChar;
- if (path.IndexOf(currentDirectory) == 0) {
- return path.Substring(currentDirectory.Length);
- }
- return path;
-}
-#>
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
+<!-- This file is auto-generated, do not edit! -jm -->
<GapSourceDictionary>
- <FilePath Value="www\index.html"/>
- <FilePath Value="www\master.css"/>
- <FilePath Value="www\phonegap-1.1.0.js"/>
+ <FilePath Value="www\index.html"/>
+ <FilePath Value="www\master.css"/>
+ <FilePath Value="www\phonegap-1.1.0.js"/>
</GapSourceDictionary>
-
@@ -11,16 +11,14 @@
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True" d:DesignHeight="768" d:DesignWidth="480" xmlns:my="clr-namespace:WP7GapClassLib;assembly=WP7GapClassLib">
- <Grid>
-
- <my:PGView Name="pGView1" HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"></my:PGView>
- <!--<phone:WebBrowser x:Name="GapBrowser"
- Loaded="GapBrowser_Loaded"
- HorizontalAlignment="Stretch"
- VerticalAlignment="Stretch"
- IsScriptEnabled="True" />-->
-
+ <Grid x:Name="LayoutRoot" Background="Transparent" HorizontalAlignment="Stretch">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="*"/>
+ </Grid.RowDefinitions>
+ <my:PGView HorizontalAlignment="Stretch"
+ Margin="0,0,0,0"
+ Name="PGView"
+ VerticalAlignment="Stretch" />
</Grid>
</phone:PhoneApplicationPage>
Oops, something went wrong.

0 comments on commit ac517cb

Please sign in to comment.