Skip to content
This repository
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 107 lines (96 sloc) 3.631 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.Dialog;
using System.IO;
using System.Drawing;

namespace Sample
{
public class Application
{
static void Main (string[] args)
{
UIApplication.Main (args, null, "AppDelegate");
}
}

// The name AppDelegate is referenced in the MainWindow.xib file.
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
UINavigationController navigation;
UIWindow window;
const string footer =
"These show the two sets of APIs\n" +
"available in MonoTouch.Dialogs";

// This method is invoked when the application has loaded its UI and its ready to run
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
JsonElement sampleJson;
var Last = new DateTime (2010, 10, 7);
Console.WriteLine (Last);

var p = Path.GetFullPath ("background.png");

var menu = new RootElement ("Demos"){
new Section ("Element API"){
new StringElement ("iPhone Settings Sample", DemoElementApi),
new StringElement ("Dynamically load data", DemoDynamic),
new StringElement ("Add/Remove demo", DemoAddRemove),
new StringElement ("Assorted cells", DemoDate),
new StyledStringElement ("Styled Elements", DemoStyled) { BackgroundUri = new Uri ("file://" + p) },
new StringElement ("Load More Sample", DemoLoadMore),
new StringElement ("Row Editing Support", DemoEditing),
new StringElement ("Advanced Editing Support", DemoAdvancedEditing),
new StringElement ("Owner Drawn Element", DemoOwnerDrawnElement),
new StringElement ("UIViewElement insets", DemoInsets),
},
new Section ("Container features"){
new StringElement ("Pull to Refresh", DemoRefresh),
new StringElement ("Headers and Footers", DemoHeadersFooters),
new StringElement ("Root Style", DemoContainerStyle),
new StringElement ("Index sample", DemoIndex),
},
new Section ("Json") {
(sampleJson = JsonElement.FromFile ("sample.json")),
// Notice what happens when I close the paranthesis at the end, in the next line:
new JsonElement ("Load from URL", "file://" + Path.GetFullPath ("sample.json"))
},
new Section ("Auto-mapped", footer){
new StringElement ("Reflection API", DemoReflectionApi)
},
};

//
// Lookup elements by ID:
//
var jsonSection = sampleJson ["section-1"] as Section;
Console.WriteLine ("The section has {0} elements", jsonSection.Count);
var booleanElement = sampleJson ["first-boolean"] as BooleanElement;
Console.WriteLine ("The state of the first-boolean value is {0}", booleanElement.Value);

//
// Create our UI and add it to the current toplevel navigation controller
// this will allow us to have nice navigation animations.
//
var dv = new DialogViewController (menu) {
Autorotate = true
};
navigation = new UINavigationController ();
navigation.PushViewController (dv, true);

// On iOS5 we use the new window.RootViewController, on older versions, we add the subview
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.MakeKeyAndVisible ();
            if (UIDevice.CurrentDevice.CheckSystemVersion (5, 0))
window.RootViewController = navigation;
else
window.AddSubview (navigation.View);

return true;
}

static void JsonCallback (object data)
{
Console.WriteLine ("Invoked");
}

// This method is required in iPhoneOS 3.0
public override void OnActivated (UIApplication application)
{
}
}
}
Something went wrong with that request. Please try again.