Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 9d562fa

Browse files
committed
Added MT.D walkthrough examples
1 parent f31d0dc commit 9d562fa

34 files changed

+1000
-0
lines changed

MTDJsonDemo/AppDelegate.cs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
using MonoTouch.Foundation;
6+
using MonoTouch.UIKit;
7+
using MonoTouch.Dialog;
8+
9+
namespace MTDJsonDemo
10+
{
11+
[Register ("AppDelegate")]
12+
public partial class AppDelegate : UIApplicationDelegate
13+
{
14+
UIWindow _window;
15+
UINavigationController _nav;
16+
DialogViewController _rootVC;
17+
RootElement _rootElement;
18+
UIBarButtonItem _addButton;
19+
int n = 0;
20+
21+
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
22+
{
23+
_window = new UIWindow (UIScreen.MainScreen.Bounds);
24+
25+
_rootElement = new RootElement ("Json Example"){
26+
new Section ("Demo Json"){
27+
JsonElement.FromFile ("sample.json"),
28+
new JsonElement ("Load from url", "http://localhost/sample.json")
29+
},
30+
new Section ("Tasks Sample")
31+
};
32+
33+
_rootVC = new DialogViewController (_rootElement);
34+
_nav = new UINavigationController (_rootVC);
35+
36+
_addButton = new UIBarButtonItem (UIBarButtonSystemItem.Add);
37+
_rootVC.NavigationItem.RightBarButtonItem = _addButton;
38+
39+
_addButton.Clicked += (sender, e) => {
40+
41+
++n;
42+
43+
var task = new Task{Name = "task " + n, DueDate = DateTime.Now};
44+
45+
var taskElement = JsonElement.FromFile ("task.json");
46+
47+
taskElement.Caption = task.Name;
48+
49+
var description = taskElement ["task-description"] as EntryElement;
50+
51+
if (description != null) {
52+
description.Caption = task.Name;
53+
description.Value = task.Description;
54+
}
55+
56+
var duedate = taskElement ["task-duedate"] as DateElement;
57+
58+
if (duedate != null) {
59+
duedate.DateValue = task.DueDate;
60+
}
61+
62+
_rootElement [1].Add (taskElement);
63+
};
64+
65+
_window.RootViewController = _nav;
66+
_window.MakeKeyAndVisible ();
67+
68+
return true;
69+
}
70+
}
71+
}
72+

MTDJsonDemo/Info.plist

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>UIDeviceFamily</key>
6+
<array>
7+
<integer>1</integer>
8+
</array>
9+
<key>UISupportedInterfaceOrientations~ipad</key>
10+
<array>
11+
<string>UIInterfaceOrientationPortrait</string>
12+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
13+
<string>UIInterfaceOrientationLandscapeLeft</string>
14+
<string>UIInterfaceOrientationLandscapeRight</string>
15+
</array>
16+
</dict>
17+
</plist>

MTDJsonDemo/MTDJsonDemo.csproj

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
6+
<ProductVersion>10.0.0</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{CEBCEAD4-1FBD-41B0-82A0-1694E9978AFE}</ProjectGuid>
9+
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
10+
<OutputType>Exe</OutputType>
11+
<RootNamespace>MTDJsonDemo</RootNamespace>
12+
<AssemblyName>MTDJsonDemo</AssemblyName>
13+
</PropertyGroup>
14+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
15+
<DebugSymbols>true</DebugSymbols>
16+
<DebugType>full</DebugType>
17+
<Optimize>false</Optimize>
18+
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
19+
<DefineConstants>DEBUG;</DefineConstants>
20+
<ErrorReport>prompt</ErrorReport>
21+
<WarningLevel>4</WarningLevel>
22+
<ConsolePause>false</ConsolePause>
23+
<MtouchDebug>true</MtouchDebug>
24+
<MtouchProfiling>true</MtouchProfiling>
25+
<MtouchLink>None</MtouchLink>
26+
<MtouchI18n />
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
29+
<DebugType>none</DebugType>
30+
<Optimize>false</Optimize>
31+
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
<ConsolePause>false</ConsolePause>
35+
<MtouchLink>None</MtouchLink>
36+
</PropertyGroup>
37+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
38+
<DebugSymbols>true</DebugSymbols>
39+
<DebugType>full</DebugType>
40+
<Optimize>false</Optimize>
41+
<OutputPath>bin\iPhone\Debug</OutputPath>
42+
<DefineConstants>DEBUG;</DefineConstants>
43+
<ErrorReport>prompt</ErrorReport>
44+
<WarningLevel>4</WarningLevel>
45+
<ConsolePause>false</ConsolePause>
46+
<CodesignKey>iPhone Developer</CodesignKey>
47+
<MtouchDebug>true</MtouchDebug>
48+
<MtouchProfiling>true</MtouchProfiling>
49+
</PropertyGroup>
50+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
51+
<DebugType>none</DebugType>
52+
<Optimize>false</Optimize>
53+
<OutputPath>bin\iPhone\Release</OutputPath>
54+
<ErrorReport>prompt</ErrorReport>
55+
<WarningLevel>4</WarningLevel>
56+
<ConsolePause>false</ConsolePause>
57+
<CodesignKey>iPhone Developer</CodesignKey>
58+
</PropertyGroup>
59+
<ItemGroup>
60+
<Reference Include="System" />
61+
<Reference Include="System.Xml" />
62+
<Reference Include="System.Core" />
63+
<Reference Include="monotouch" />
64+
<Reference Include="MonoTouch.Dialog-1" />
65+
</ItemGroup>
66+
<ItemGroup>
67+
<None Include="Info.plist" />
68+
</ItemGroup>
69+
<ItemGroup>
70+
<Compile Include="Main.cs" />
71+
<Compile Include="AppDelegate.cs" />
72+
<Compile Include="Task.cs" />
73+
</ItemGroup>
74+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
75+
<ItemGroup>
76+
<Content Include="sample.json" />
77+
<Content Include="background.png" />
78+
<Content Include="caltemplate.png" />
79+
<Content Include="favorite.png" />
80+
<Content Include="favorited.png" />
81+
<Content Include="jakub-calendar.png" />
82+
<Content Include="task.json" />
83+
</ItemGroup>
84+
<ProjectExtensions>
85+
<MonoDevelop>
86+
<Properties>
87+
<Policies>
88+
<TextStylePolicy FileWidth="120" TabWidth="4" inheritsSet="Mono" inheritsScope="text/plain" scope="text/x-csharp" />
89+
<CSharpFormattingPolicy inheritsSet="Mono" inheritsScope="text/x-csharp" scope="text/x-csharp" />
90+
<TextStylePolicy FileWidth="120" TabWidth="4" inheritsSet="Mono" inheritsScope="text/plain" scope="text/plain" />
91+
<TextStylePolicy FileWidth="120" TabWidth="4" inheritsSet="Mono" inheritsScope="text/plain" scope="application/json" />
92+
</Policies>
93+
</Properties>
94+
</MonoDevelop>
95+
</ProjectExtensions>
96+
</Project>

MTDJsonDemo/MTDJsonDemo.sln

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MTDJsonDemo", "MTDJsonDemo.csproj", "{CEBCEAD4-1FBD-41B0-82A0-1694E9978AFE}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|iPhoneSimulator = Debug|iPhoneSimulator
9+
Release|iPhoneSimulator = Release|iPhoneSimulator
10+
Debug|iPhone = Debug|iPhone
11+
Release|iPhone = Release|iPhone
12+
AdHoc|iPhoneSimulator = AdHoc|iPhoneSimulator
13+
AppStore|iPhoneSimulator = AppStore|iPhoneSimulator
14+
AdHoc|iPhone = AdHoc|iPhone
15+
AppStore|iPhone = AppStore|iPhone
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{CEBCEAD4-1FBD-41B0-82A0-1694E9978AFE}.Debug|iPhone.ActiveCfg = Debug|iPhone
19+
{CEBCEAD4-1FBD-41B0-82A0-1694E9978AFE}.Debug|iPhone.Build.0 = Debug|iPhone
20+
{CEBCEAD4-1FBD-41B0-82A0-1694E9978AFE}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
21+
{CEBCEAD4-1FBD-41B0-82A0-1694E9978AFE}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
22+
{CEBCEAD4-1FBD-41B0-82A0-1694E9978AFE}.Release|iPhone.ActiveCfg = Release|iPhone
23+
{CEBCEAD4-1FBD-41B0-82A0-1694E9978AFE}.Release|iPhone.Build.0 = Release|iPhone
24+
{CEBCEAD4-1FBD-41B0-82A0-1694E9978AFE}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
25+
{CEBCEAD4-1FBD-41B0-82A0-1694E9978AFE}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
26+
EndGlobalSection
27+
GlobalSection(MonoDevelopProperties) = preSolution
28+
StartupItem = MTDJsonDemo.csproj
29+
EndGlobalSection
30+
EndGlobal

MTDJsonDemo/Main.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
using MonoTouch.Foundation;
6+
using MonoTouch.UIKit;
7+
8+
namespace MTDJsonDemo
9+
{
10+
public class Application
11+
{
12+
// This is the main entry point of the application.
13+
static void Main (string[] args)
14+
{
15+
// if you want to use a different Application Delegate class from "AppDelegate"
16+
// you can specify it here.
17+
UIApplication.Main (args, null, "AppDelegate");
18+
}
19+
}
20+
}

MTDJsonDemo/Metadata.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<SampleMetadata>
3+
<ID>5dbad834-4427-4ed1-831c-a5642b384f24</ID>
4+
<IsFullApplication>false</IsFullApplication>
5+
<Level>Beginning</Level>
6+
<Tags>User Interface</Tags>
7+
</SampleMetadata>

MTDJsonDemo/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MonoTouch.Dialog JSON Walkthrough
2+
=================================
3+
4+
This sample demonstrates how to use the JSON API with MonoTouch.Dialog
130 KB
Loading

MTDJsonDemo/Task.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
3+
namespace MTDJsonDemo
4+
{
5+
public class Task
6+
{
7+
public Task ()
8+
{
9+
}
10+
11+
public string Name { get; set; }
12+
13+
public string Description { get; set; }
14+
15+
public DateTime DueDate { get; set; }
16+
}
17+
}

MTDJsonDemo/background.png

117 KB
Loading

MTDJsonDemo/caltemplate.png

566 Bytes
Loading

MTDJsonDemo/favorite.png

573 Bytes
Loading

MTDJsonDemo/favorited.png

793 Bytes
Loading

MTDJsonDemo/jakub-calendar.png

912 Bytes
Loading

0 commit comments

Comments
 (0)