ios-samples/MonoDevelopTouchCells/Main.cs

73 строки
1.8 KiB
C#
Исходник Постоянная ссылка Обычный вид История

2009-11-11 02:08:09 +03:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
2015-01-19 18:09:40 +03:00
using Foundation;
using UIKit;
2009-11-11 02:08:09 +03:00
namespace MonoDevelopTouchCells
{
public class Application
{
static void Main (string[] args)
{
UIApplication.Main (args);
}
}
// The name AppDelegate is referenced in the MainWindow.xib file.
public partial class AppDelegate : UIApplicationDelegate
{
2015-01-19 18:09:40 +03:00
DetailViewController detailViewController = new DetailViewController ();
2009-11-11 02:08:09 +03:00
// This method is invoked when the application has loaded its UI and its ready to run
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
2015-01-19 18:09:40 +03:00
this.InitializeTableData ();
navigationController.NavigationBar.Translucent = false;
2009-11-11 02:08:09 +03:00
// If you have defined a view, add it here:
// window.AddSubview (navigationController.View);
2015-01-19 18:09:40 +03:00
window.AddSubview (this.navigationController.View);
2009-11-11 02:08:09 +03:00
window.MakeKeyAndVisible ();
return true;
}
// This method is required in iPhoneOS 3.0
public override void OnActivated (UIApplication application)
{
}
2015-01-19 18:09:40 +03:00
public void ShowDetail (CustomCell cell)
{
this.detailViewController.ShowDetail (cell);
this.navigationController.PushViewController (
2009-11-11 02:08:09 +03:00
this.detailViewController, true);
}
2015-01-19 18:09:40 +03:00
void InitializeTableData ()
{
string source = Path.Combine (Directory.GetCurrentDirectory (), "data.xml");
2009-11-11 02:08:09 +03:00
source = "file://" + source;
2015-01-19 18:09:40 +03:00
XDocument xdoc = XDocument.Load (source);//Path.Combine(Directory.GetCurrentDirectory(), "data.xml"));
var items = from c in xdoc.Descendants ("item")
select new Item {
Title = (string)c.Element ("title"),
Checked = (bool)c.Element ("checked"),
};
myTableView.Delegate = new TableViewDelegate ();
2009-11-11 02:08:09 +03:00
myTableView.InvokeOnMainThread (delegate {
2015-01-19 18:09:40 +03:00
myTableView.DataSource = new DataSource (items);
2009-11-11 02:08:09 +03:00
});
}
}
}