예제 #1
0
        public override bool Reload(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }
            var pool = new NSAutoreleasePool();

            SuppressChangeEvents = true;
            try {
                list.Clear();
                var nsa = NSArray.FromFile(fileName);
                if (nsa != null)
                {
                    var arr = NSArray.ArrayFromHandle <NSObject> (nsa.Handle);
                    foreach (var f in arr)
                    {
                        Add(PDictionary.FromNSObject(f));
                    }
                }
                else
                {
                    return(false);
                }
            } finally {
                SuppressChangeEvents = false;
                pool.Dispose();
            }
            OnChanged(EventArgs.Empty);
            return(true);
        }
예제 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var path        = NSBundle.MainBundle.PathForResource("CityList", "plist");
            var citiesArray = NSArray.FromFile(path);

            foreach (var city in NSArray.FromArray <NSDictionary>(citiesArray))
            {
                cities.Add(new WorldCity(city[(NSString)"cityNameKey"].ToString(),
                                         double.Parse(city[(NSString)"latitudeKey"].ToString()),
                                         double.Parse(city[(NSString)"longitudeKey"].ToString())));
            }
        }
        void FetchAvailableFilters()
        {
            // Load the available filters
            string plist          = NSBundle.MainBundle.PathForResource("Filters", "plist");
            var    rawFiltersData = NSArray.FromFile(plist);

            int count = (int)rawFiltersData.Count;

            availableFilterInfos = new FilterInfo[count];

            for (int i = 0; i < count; i++)
            {
                availableFilterInfos [i] = new FilterInfo(rawFiltersData.GetItem <NSDictionary> (i));
            }
        }
        public MatchesViewController()
        {
            string  path = NSBundle.MainBundle.PathForResource("matches", "plist");
            NSArray serializedMatches = NSArray.FromFile(path);

            matches = new List <Person> ();

            for (nuint i = 0; i < serializedMatches.Count; i++)
            {
                var    sMatch = serializedMatches.GetItem <NSDictionary> (i);
                Person match  = Person.PersonFromDictionary(sMatch);
                matches.Add(match);
            }

            Title = "Matches".LocalizedString("Title of the matches page");

            BackgroundImage = UIImage.FromBundle("dessert.jpg");
        }
예제 #5
0
        static void LoadQuakeData(out CLLocation[] locations, out double[] weights)
        {
            var     data      = NSBundle.MainBundle.PathForResource("quake", "plist");
            NSArray quakeData = NSArray.FromFile(data);

            locations = new CLLocation[quakeData.Count];
            weights   = new double[quakeData.Count];
            for (uint i = 0; i < quakeData.Count; i++)
            {
                NSDictionary dic = quakeData.GetItem <NSDictionary>(i);

                var latitude  = (NSNumber)dic.ObjectForKey(new NSString("latitude"));
                var longitude = (NSNumber)dic.ObjectForKey(new NSString("longitude"));
                var magnitude = ((NSNumber)dic.ObjectForKey(new NSString("magnitude")));
                var location  = new CLLocation(latitude.DoubleValue, longitude.DoubleValue);
                locations[i] = location;
                weights[i]   = magnitude.DoubleValue * 10;
            }
        }
예제 #6
0
        public override void Draw(CGRect mainrect)
        {
            myDictionary = new Dictionary <nint, List <Pair> >();
            myItems      = new List <UIImageView>();
            nint        key   = 0;
            List <Pair> array = null;

            currentItem     = 0;
            currentItemText = 0;
            nextTextTime    = 1.25f;

            string filePath = pagePath + "/index";

            filePath = NSBundle.MainBundle.PathForResource(filePath, "plist");



            NSArray contentsArray = NSArray.FromFile(filePath);
            nint    itemCount     = 0;

            for (nuint i = 0; i < contentsArray.Count; i++)
            {
                NSDictionary item      = contentsArray.GetItem <NSDictionary>(i);
                NSString     animation = item.ValueForKey(new NSString("animationLayer")) as NSString;
                if (animation != null)
                {
                    this.animationLayerIndex = (nuint)itemCount + 2;
                }
                NSString frame = item.ValueForKey(new NSString("frame")) as NSString;
                NSString file  = item.ValueForKey(new NSString("image")) as NSString;
                NSString file2 = new NSString(pagePath.ToString() + "/" + file.ToString());

                CGRect rect = CGRectFromString(frame);

                NSString hfile = new NSString(file.ToString().Replace(".png", "-old.png"));
                hfile = new NSString(pagePath + "/" + hfile);

                UIImageView subview = new UIImageView(rect);
                subview.HighlightedImage = new UIImage(file2);
                //subview.Image = new UIImage(hfile);
                subview.Highlighted            = _highlighted;
                subview.UserInteractionEnabled = true;
                subview.MultipleTouchEnabled   = true;
                subview.Tag = itemCount;
                this.InsertSubview(subview, itemCount);
                itemCount++;


                if (array != null)
                {
                    myDictionary.Add(key, array);
                }
                array = new List <Pair>();
                key   = subview.Tag;
                myItems.Add(subview);

                NSArray childrenArray = item.ObjectForKey(new NSString("children")) as NSArray;

                if (childrenArray != null)
                {
                    for (nuint j = 0; j < childrenArray.Count; j++)
                    {
                        NSDictionary child = childrenArray.GetItem <NSDictionary> (j);

                        frame = child.ObjectForKey(new NSString("frame")) as NSString;
                        file  = child.ObjectForKey(new NSString("image")) as NSString;

                        file = new NSString(pagePath + "/" + file);

                        rect = CGRectFromString(frame);

                        subview = new UIImageView(rect);

                        subview.Image = new UIImage(file);
                        subview.UserInteractionEnabled = true;
                        subview.MultipleTouchEnabled   = true;
                        this.AddSubview(subview);

                        subview.Transform = CGAffineTransform.MakeScale(1.00f, 1.00f);

                        subview.Alpha = 0.0f;

                        UITapGestureRecognizer tap = new UITapGestureRecognizer(t => {
                            handleTapGestureText(t);
                        });

                        subview.AddGestureRecognizer(tap);

                        Pair pair = new Pair();
                        pair.view       = subview;
                        pair.glosary    = child.ObjectForKey(new NSString("glosary")) as NSArray;
                        pair.currentKey = 0;

                        array.Add(pair);
                    }
                }
            }
            if (array != null)
            {
                myDictionary.Add(key, array);
            }

            NSString    sepiaFile  = new NSString(pagePath + "/medium.jpg");
            UIImageView sepiaImage = new UIImageView(new CGRect(0, 0, 1024, 646));

            sepiaImage.Image = new UIImage(sepiaFile);

            this.InsertSubview(sepiaImage, 0);

            UITapGestureRecognizer gestureRe = new UITapGestureRecognizer(t => {
                handleTapGesture(t);
            });

            this.AddGestureRecognizer(gestureRe);


            base.Draw(mainrect);
            // Perform any additional setup after loading the view, typically from a nib.
        }