Skip to content

Commit

Permalink
adding more sample projects
Browse files Browse the repository at this point in the history
  • Loading branch information
gshackles committed Jan 24, 2011
1 parent 1b41b02 commit 73b36dc
Show file tree
Hide file tree
Showing 125 changed files with 6,668 additions and 0 deletions.
19 changes: 19 additions & 0 deletions MonoDroid/IoCDemo/Assets/AboutAssets.txt
@@ -0,0 +1,19 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories) and given a Build Action of "AndroidAsset".

These files will be deployed with you package and will be accessible using Android's
AssetManager, like this:

public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

InputStream input = Assets.Open ("my_asset.txt");
}
}

Additionally, some Android functions will automatically load asset files:

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
33 changes: 33 additions & 0 deletions MonoDroid/IoCDemo/DemoActivity.cs
@@ -0,0 +1,33 @@
using Android.App;
using Android.OS;
using Android.Widget;
using IoCDemo.Quotes;

namespace IoCDemo
{
[Activity(Label = "IoC Demo", MainLauncher = true)]
public class DemoActivity : Activity
{
private IMovieQuoteProvider _quoteProvider;
private Button _generateButton;
private TextView _quoteText;

protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

_quoteProvider = ((DemoApplication)Application).FunqContainer.Resolve<IMovieQuoteProvider>();
//_quoteProvider = TinyIoC.TinyIoCContainer.Current.Resolve<IMovieQuoteProvider>();

SetContentView(Resource.Layout.main);
_generateButton = FindViewById<Button>(Resource.Id.generate);
_quoteText = FindViewById<TextView>(Resource.Id.quote);

_generateButton.Click += delegate
{
_quoteText.Text = _quoteProvider.GetQuote();
};
}
}
}

39 changes: 39 additions & 0 deletions MonoDroid/IoCDemo/DemoApplication.cs
@@ -0,0 +1,39 @@
using System;
using Android.App;
using Funq;
using IoCDemo.Quotes;
using TinyIoC;

namespace IoCDemo
{
[Application]
public class DemoApplication : Application
{
public Container FunqContainer { get; private set; }

public DemoApplication(IntPtr handle)
: base(handle)
{
}

public override void OnCreate()
{
base.OnCreate();

initTinyIoC();
initFunq();
}

private void initTinyIoC()
{
TinyIoCContainer.Current.Register<IMovieQuoteProvider>(new TheBigLebowskiQuoteProvider());
}

private void initFunq()
{
FunqContainer = new Container();

FunqContainer.Register<IMovieQuoteProvider>(new SpaceballsQuoteProvider());
}
}
}
78 changes: 78 additions & 0 deletions MonoDroid/IoCDemo/IoCDemo.csproj
@@ -0,0 +1,78 @@
<?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>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9E66E12B-395B-48B5-AD76-0A531735EA95}</ProjectGuid>
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IoCDemo</RootNamespace>
<AssemblyName>IoCDemo</AssemblyName>
<FileAlignment>512</FileAlignment>
<AndroidApplication>true</AndroidApplication>
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</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="Funq">
<HintPath>lib\Funq.dll</HintPath>
</Reference>
<Reference Include="Mono.Android" />
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DemoActivity.cs" />
<Compile Include="DemoApplication.cs" />
<Compile Include="Quotes\IMovieQuoteProvider.cs" />
<Compile Include="Quotes\SpaceballsQuoteProvider.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Quotes\TheBigLebowskiQuoteProvider.cs" />
<Compile Include="TinyIoC.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
<None Include="Assets\AboutAssets.txt" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\layout\main.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\values\strings.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\drawable\icon.png" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.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>
22 changes: 22 additions & 0 deletions MonoDroid/IoCDemo/IoCDemo.sln
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoCDemo", "IoCDemo.csproj", "{9E66E12B-395B-48B5-AD76-0A531735EA95}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9E66E12B-395B-48B5-AD76-0A531735EA95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E66E12B-395B-48B5-AD76-0A531735EA95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E66E12B-395B-48B5-AD76-0A531735EA95}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{9E66E12B-395B-48B5-AD76-0A531735EA95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E66E12B-395B-48B5-AD76-0A531735EA95}.Release|Any CPU.Build.0 = Release|Any CPU
{9E66E12B-395B-48B5-AD76-0A531735EA95}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Binary file added MonoDroid/IoCDemo/IoCDemo.suo
Binary file not shown.
36 changes: 36 additions & 0 deletions MonoDroid/IoCDemo/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// 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("IoCDemo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("IoCDemo")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[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("a557ce8c-9dbe-4b93-8fc4-95ffc126cf14")]

// 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 Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
7 changes: 7 additions & 0 deletions MonoDroid/IoCDemo/Quotes/IMovieQuoteProvider.cs
@@ -0,0 +1,7 @@
namespace IoCDemo.Quotes
{
public interface IMovieQuoteProvider
{
string GetQuote();
}
}
30 changes: 30 additions & 0 deletions MonoDroid/IoCDemo/Quotes/SpaceballsQuoteProvider.cs
@@ -0,0 +1,30 @@
using System;
using System.Linq;

namespace IoCDemo.Quotes
{
public class SpaceballsQuoteProvider : IMovieQuoteProvider
{
private Random _randomNumberGenerator;

public SpaceballsQuoteProvider()
{
_randomNumberGenerator = new Random();
}

private string[] _quotes =
{
"You have the ring, and I see your Schwartz is as big as mine. Now let's see how well you handle it.",
"Look your highness, it's not that we're afraid, far from it. It's just that we've got this thing about death; it's not us.",
"Out of order?! Even in the future, nothing works!",
"Or else Pizza is gonna send out for you.",
"So, at last we meet for the first time for the last time.",
"So, Lone Starr, now you see that evil will always triumph, because good is dumb."
};

public string GetQuote()
{
return _quotes[_randomNumberGenerator.Next(0, _quotes.Count() - 1)];
}
}
}
30 changes: 30 additions & 0 deletions MonoDroid/IoCDemo/Quotes/TheBigLebowskiQuoteProvider.cs
@@ -0,0 +1,30 @@
using System;
using System.Linq;

namespace IoCDemo.Quotes
{
public class TheBigLebowskiQuoteProvider : IMovieQuoteProvider
{
private Random _randomNumberGenerator;

public TheBigLebowskiQuoteProvider()
{
_randomNumberGenerator = new Random();
}

private string[] _quotes =
{
"You want a toe? I can get you a toe, believe me. There are ways, Dude. You don't wanna know about it, believe me.",
"That rug really tied the room together.",
"Let me explain something to you. Um, I am not \"Mr. Lebowski\". You're Mr. Lebowski. I'm the Dude. So that's what you call me. You know, that or, uh, His Dudeness, or uh, Duder, or El Duderino if you're not into the whole brevity thing.",
"Hey, nice marmot!",
"Jackie Treehorn treats objects like women, man.",
"Mark it, Dude."
};

public string GetQuote()
{
return _quotes[_randomNumberGenerator.Next(0, _quotes.Count() - 1)];
}
}
}
50 changes: 50 additions & 0 deletions MonoDroid/IoCDemo/Resources/AboutResources.txt
@@ -0,0 +1,50 @@
Images, layout descriptions, binary blobs and string dictionaries can be included
in your application as resource files. Various Android APIs are designed to
operate on the resource IDs instead of dealing with images, strings or binary blobs
directly.

For example, a sample Android app that contains a user interface layout (main.xml),
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
would keep its resources in the "Resources" directory of the application:

Resources/
drawable-hdpi/
icon.png

drawable-ldpi/
icon.png

drawable-mdpi/
icon.png

layout/
main.xml

values/
strings.xml

In order to get the build system to recognize Android resources, set the build action to
"AndroidResource". The native Android APIs do not operate directly with filenames, but
instead operate on resource IDs. When you compile an Android application that uses resources,
the build system will package the resources for distribution and generate a class called
"Resource" that contains the tokens for each one of the resources included. For example,
for the above Resources layout, this is what the Resource class would expose:

public class Resource {
public class drawable {
public const int icon = 0x123;
}

public class layout {
public const int main = 0x456;
}

public class strings {
public const int first_string = 0xabc;
public const int second_string = 0xbcd;
}
}

You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
string in the dictionary file values/strings.xml.

0 comments on commit 73b36dc

Please sign in to comment.