Exemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Round current = Rounds[currenRound];

            answers.Add(current.correct);

            options.Add(current.correct.title, current.correct);
            options.Add(current.fake1.title, current.fake1);
            options.Add(current.fake2.title, current.fake2);
            options.Add(current.fake3.title, current.fake3);


            //handle image for round
            //add scaling stuff ??
            GameImage.Image = UIImage.FromFile(current.image);

            List <Option> shuffledOptions = new List <Option> {
                current.correct, current.fake1, current.fake2, current.fake3
            };

            shuffledOptions = Option.RandomizeOptionList(shuffledOptions);

            GameOptions.RegisterClassForCellReuse(typeof(UITableViewCell), "TableCell");
            GameOptions.Source = new TableSource(shuffledOptions, GameMap);


            //handle map stuff
            GameMap.MapType       = MapKit.MKMapType.Satellite;//Hybrid;
            GameMap.ZoomEnabled   = true;
            GameMap.ScrollEnabled = true;
            GameMap.Delegate      = new MapActions(GameOptions);

            double avglat = 0;
            double avglon = 0;

            foreach (KeyValuePair <string, Option> curOpt in options)
            {
                avglat += curOpt.Value.location.Latitude;
                avglon += curOpt.Value.location.Longitude;
                GameMap.AddAnnotations(new MapKit.MKPointAnnotation()
                {
                    Title = curOpt.Key, Coordinate = new CoreLocation.CLLocationCoordinate2D(curOpt.Value.location.Latitude, curOpt.Value.location.Longitude)
                });

                //pin annotaition code, need to override function
                //NSObject temp2 = new NSObject();
                //temp2.Equals(curOpt);
                //NSCoder temp = new NSCoder();
                //temp.Encode(0 , curOpt.title);
                //GameMap.AddAnnotations(new MapKit.MKPinAnnotationView(temp); //{Title=curOpt.title, Coordinate= new CoreLocation.CLLocationCoordinate2D(curOpt.location.Latitude, curOpt.location.Longitude) });
            }


            GameMap.SetRegion(new MapKit.MKCoordinateRegion(new CoreLocation.CLLocationCoordinate2D(avglat / 4, avglon / 4), new MapKit.MKCoordinateSpan(180, 360)), true);
        }