protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); HookCrashLogger(); // // Create the view // _worldView = new WorldView(this, Resource.Drawable.MissingTile) { ShowSun = false }; // // Add a layer of tiles // var tiles = new TileRenderer(); var sourceIndex = 0; tiles.Source = _tileSources[sourceIndex]; _worldView.AddDrawable(tiles); // // Add a button to toggle tile sources // var toggle = new Button(this); toggle.Text = _tileSources[0].Name; toggle.Click += delegate { sourceIndex = (sourceIndex + 1) % _tileSources.Length; toggle.Text = _tileSources[sourceIndex].Name; tiles.Source = _tileSources[sourceIndex]; }; var root = new LinearLayout(this); root.LayoutParameters = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent); root.Orientation = Orientation.Vertical; root.AddView(_worldView); root.AddView(toggle); this.SetContentView(root); _worldView.Run(4); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { _rootViewController = new UIViewController(); // // Create the root view // _worldView = new WorldView (window.Bounds) { ShowSun = false, }; _rootViewController.View.AddSubview (_worldView); window.RootViewController = _rootViewController; _worldView.Run (4); // // Add a layer of tiles // var tiles = new TileRenderer(); var sourceIndex = 0; tiles.Source = _tileSources[sourceIndex]; _worldView.AddDrawable(tiles); // // Add a button to toggle tile sources // var toggle = new UIButton(new RectangleF(0,450,120,30)); toggle.Font = UIFont.BoldSystemFontOfSize(14); toggle.SetTitle(_tileSources[0].Name, UIControlState.Normal); toggle.SetTitleColor(UIColor.Black, UIControlState.Normal); toggle.TouchUpInside += delegate { sourceIndex = (sourceIndex + 1) % _tileSources.Length; toggle.SetTitle(_tileSources[sourceIndex].Name, UIControlState.Normal); tiles.Source = _tileSources[sourceIndex]; }; window.AddSubview(toggle); window.MakeKeyAndVisible (); return true; }