示例#1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            #region load data from XML
            RogetHierarchy hierarchy;
            using (TextReader reader = new StreamReader("roget15aHierarchy.xml"))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(RogetHierarchy));
                hierarchy = (RogetHierarchy)serializer.Deserialize(reader);
                // HACK: makes Divisions synonymous with Sections, makes navigation easier
                foreach (var h in hierarchy.Classes)
                {
                    foreach (RogetDivision d in h.Divisions)
                    {
                        h.Sections.Add(new RogetSection {
                            Name = d.Name, Sections = d.Sections
                        });
                    }
                }
            }
            Classes = hierarchy.Classes;

            using (TextReader reader = new StreamReader("roget15aCategories.xml"))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(RogetCategories));
                Categories = (RogetCategories)serializer.Deserialize(reader);
            }
            #endregion

            // no XIB !
            tableView = new UITableView()
            {
                Source = new TableViewSource(Classes, this),
                //Delegate = new TableViewDelegate(Classes, this),
                //DataSource = new TableViewDataSource(Classes, this),
                AutoresizingMask = UIViewAutoresizing.FlexibleHeight |
                                   UIViewAutoresizing.FlexibleWidth,
                BackgroundColor = UIColor.White,
            };

            // Set the table view to fit the width of the app.
            tableView.SizeToFit();

            // Reposition and resize the receiver
            tableView.Frame = new RectangleF(
                0, 0, this.View.Frame.Width, this.View.Frame.Height);

            // Add the table view as a subview
            this.View.AddSubview(tableView);

            Console.WriteLine("Is you're using the simulator, switch to it now.");
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            #region load data from XML
            RogetHierarchy hierarchy;
            using (TextReader reader = new StreamReader("roget15aHierarchy.xml"))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(RogetHierarchy));
                hierarchy = (RogetHierarchy)serializer.Deserialize(reader);
                // HACK: makes Divisions synonymous with Sections, makes navigation easier
                foreach (var h in hierarchy.Classes)
                {
                    foreach (RogetDivision d in h.Divisions)
                    {
                        h.Sections.Add(new RogetSection{Name=d.Name, Sections = d.Sections});
                    }
                }
            }
            Classes = hierarchy.Classes;

            using (TextReader reader = new StreamReader("roget15aCategories.xml"))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(RogetCategories));
                Categories = (RogetCategories)serializer.Deserialize(reader);
            }
            #endregion

            // no XIB !
            tableView = new UITableView()
            {
                Source = new TableViewSource (Classes, this),
                //Delegate = new TableViewDelegate(Classes, this),
                //DataSource = new TableViewDataSource(Classes, this),
                AutoresizingMask = UIViewAutoresizing.FlexibleHeight|
                                   UIViewAutoresizing.FlexibleWidth,
                BackgroundColor = UIColor.White,
            };

            // Set the table view to fit the width of the app.
            tableView.SizeToFit();

            // Reposition and resize the receiver
            tableView.Frame = new RectangleF (
                0, 0, this.View.Frame.Width, this.View.Frame.Height);

            // Add the table view as a subview
            this.View.AddSubview(tableView);

            Console.WriteLine("Is you're using the simulator, switch to it now.");
        }