Browse Source

Project template for Silverlight application.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4004 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Ivan Shumilin 16 years ago
parent
commit
4526da55b2
  1. 192
      data/templates/project/CSharp/SilverlightApplication.xpt
  2. 23
      src/Main/Base/Project/Src/Project/CompilableProject.cs
  3. 1
      src/Setup/Files.wxs

192
data/templates/project/CSharp/SilverlightApplication.xpt

@ -0,0 +1,192 @@ @@ -0,0 +1,192 @@
<Template originator = "Ivan Shumilin" created = "20/04/2009">
<!-- Template Header -->
<TemplateConfiguration>
<Name>Silverlight Application</Name>
<Category>C#</Category>
<Subcategory>Silverlight</Subcategory>
<Icon>C#.Project.Form</Icon>
<Description>Default Silverlight 3.0 Application</Description>
</TemplateConfiguration>
<!-- Actions -->
<Actions>
<Open filename = "MainPage.xaml"/>
</Actions>
<Project language = "C#">
<ProjectItems>
<Reference Include="System.Windows" />
<Reference Include="mscorlib" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
<Reference Include="System.Windows.Browser" />
</ProjectItems>
<PropertyGroup>
<ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>${StandardNamespace}</RootNamespace>
<AssemblyName>${StandardNamespace}</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>${StandardNamespace}.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>${StandardNamespace}.App</SilverlightAppEntry>
<TestPageFileName>TestPage.html</TestPageFileName>
<CreateTestPage>true</CreateTestPage>
<ValidateXaml>true</ValidateXaml>
<UsePlatformExtensions>false</UsePlatformExtensions>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
</PropertyGroup>
<PropertyGroup configuration="Debug" escapeValue="false">
<DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
</PropertyGroup>
<PropertyGroup configuration="Release" escapeValue="false">
<DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
</PropertyGroup>
<Imports clear="True">
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.CSharp.targets" />
</Imports>
<Files>
<File name="App.xaml" buildAction="ApplicationDefinition" language="XML"><![CDATA[<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="${StandardNamespace}.App"
>
<Application.Resources>
</Application.Resources>
</Application>]]></File>
<File name="App.xaml.cs" SubType="Code" DependentUpon="App.xaml"><![CDATA[using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace ${StandardNamespace}
{
public partial class App : Application
{
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
}
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
}
private void Application_Exit(object sender, EventArgs e)
{
}
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
// If the app is running outside of the debugger then report the exception using
// the browser's exception mechanism. On IE this will display it a yellow alert
// icon in the status bar and Firefox will display a script error.
if (!System.Diagnostics.Debugger.IsAttached) {
// NOTE: This will allow the application to continue running after an exception has been thrown
// but not handled.
// For production applications this error handling should be replaced with something that will
// report the error to the website and stop the application.
e.Handled = true;
Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
}
}
private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
{
try {
string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");
System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
}
catch (Exception) {
}
}
}
}]]></File>
<File name="MainPage.xaml" buildAction="Page" language="XML"><![CDATA[<UserControl x:Class="${StandardNamespace}.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
</Grid>
</UserControl>]]></File>
<File name="MainPage.xaml.cs" SubType="Code" DependentUpon="MainPage.xaml"><![CDATA[using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace ${StandardNamespace}
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
}
}]]></File>
<File name="Properties\AppManifest.xml"><![CDATA[<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Deployment.Parts>
</Deployment.Parts>
<!-- Uncomment the markup and update the fields below to make your application offline enabled
<Deployment.ApplicationIdentity>
<ApplicationIdentity
ShortName="Out of Browser Silverlight Application"
Title="Window Title of Your Silverlight Application">
<ApplicationIdentity.Blurb>Description of your Silverlight application</ApplicationIdentity.Blurb>
</ApplicationIdentity>
</Deployment.ApplicationIdentity>
-->
</Deployment>]]></File>
<File name="Properties\AssemblyInfo.cs" src="DefaultAssemblyInfo.cs" />
</Files>
</Project>
</Template>

23
src/Main/Base/Project/Src/Project/CompilableProject.cs

@ -207,6 +207,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -207,6 +207,9 @@ namespace ICSharpCode.SharpDevelop.Project
#region Starting (debugging)
public override bool IsStartable {
get {
if (IsSilverlightProject) {
return TestPageFileName.Length > 0;
}
switch (this.StartAction) {
case StartAction.Project:
return OutputType == OutputType.Exe || OutputType == OutputType.WinExe;
@ -282,6 +285,10 @@ namespace ICSharpCode.SharpDevelop.Project @@ -282,6 +285,10 @@ namespace ICSharpCode.SharpDevelop.Project
public override ProcessStartInfo CreateStartInfo()
{
if (IsSilverlightProject) {
string pagePath = "file:///" + Path.Combine(OutputFullPath, TestPageFileName);
return new ProcessStartInfo(pagePath);
}
switch (this.StartAction) {
case StartAction.Project:
return CreateStartInfo(this.OutputAssemblyFullPath);
@ -350,6 +357,22 @@ namespace ICSharpCode.SharpDevelop.Project @@ -350,6 +357,22 @@ namespace ICSharpCode.SharpDevelop.Project
SetProperty("StartWorkingDirectory", string.IsNullOrEmpty(value) ? null : value);
}
}
public bool IsSilverlightProject {
get {
string guids = GetEvaluatedProperty("ProjectTypeGuids") ?? "";
return guids.Contains("A1591282-1198-4647-A2B1-27E5FF5F6F3B");
}
}
public string TestPageFileName {
get {
return GetEvaluatedProperty("TestPageFileName") ?? "";
}
set {
SetProperty("TestPageFileName", string.IsNullOrEmpty(value) ? null : value);
}
}
#endregion
protected override void OnActiveConfigurationChanged(EventArgs e)

1
src/Setup/Files.wxs

@ -1020,6 +1020,7 @@ @@ -1020,6 +1020,7 @@
<File Source="..\..\data\templates\project\CSharp\SharpDevelopMacro.xpt" Id="CSharpSharpDevelopMacro.xpt" Name="SharpDevelopMacro.xpt" />
<File Source="..\..\data\templates\project\CSharp\WebpageProject.xpt" Id="CSharpWebpageProject.xpt" Name="WebpageProject.xpt" />
<File Source="..\..\data\templates\project\CSharp\WPFApplication.xpt" Id="CSharpWPFApplication.xpt" Name="WPFApplication.xpt" />
<File Source="..\..\data\templates\project\CSharp\SilverlightApplication.xpt" Id="CSharpSilverlightApplication.xpt" Name="SilverlightApplication.xpt" />
</Component>
<Component Guid="9D156515-C54F-4DAB-AD66-40E44C28E56C" Id="CSharpProjectSharpDevelopCustomToolTemplates" DiskId="1">
<File Source="..\..\data\templates\project\CSharp\SharpDevelopCustomTool.xpt" Id="SharpDevelopCustomTool.xpt" Name="SharpDevelopCustomTool.xpt" />

Loading…
Cancel
Save