Beispiel #1
0
        public override void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath)
        {
            nuint row = (nuint)indexPath.Row;

            Control      ctrl = Controller.Controls.GetItem <Control>(row);
            string       sampleListPathString = NSBundle.MainBundle.BundlePath + "/plist/SampleList.plist";
            NSDictionary sampleDict           = new NSDictionary();

            sampleDict = NSDictionary.FromFile(sampleListPathString);

            NSMutableArray dictArray   = sampleDict.ValueForKey(new NSString(ctrl.Name)) as NSMutableArray;
            NSMutableArray collections = new NSMutableArray();
            Control        contrl      = Controller.Controls.GetItem <Control>((nuint)indexPath.Row);

            for (nuint i = 0; i < dictArray.Count; i++)
            {
                NSDictionary dict    = dictArray.GetItem <NSDictionary>(i);
                Control      control = new Control
                {
                    ControlName = ctrl.Name,
                    Name        = (NSString)dict.ValueForKey(new NSString("SampleName")),
                    Description = (NSString)dict.ValueForKey(new NSString("Description"))
                };

                NSString imageToLoad = (NSString)dict.ValueForKey(new NSString("Image"));
                if (imageToLoad != null)
                {
                    control.Image = UIImage.FromBundle(imageToLoad);
                }

                if (dict.ValueForKey(new NSString("IsNew")) != null && dict.ValueForKey(new NSString("IsNew")).ToString() == "YES")
                {
                    control.Tag = new NSString("NEW");
                }
                else if (dict.ValueForKey(new NSString("IsUpdated")) != null && dict.ValueForKey(new NSString("IsUpdated")).ToString() == "YES")
                {
                    control.Tag = new NSString("UPDATED");
                }
                else if (dict.ValueForKey(new NSString("IsPreview")) != null && dict.ValueForKey(new NSString("IsPreview")).ToString() == "YES")
                {
                    control.Tag = new NSString("PREVIEW");
                }
                else
                {
                    control.Tag = new NSString(string.Empty);
                }

                if (dict.ValueForKey(new NSString("DisplayName")) != null)
                {
                    control.DisplayName = dict.ValueForKey(new NSString("DisplayName")) as NSString;
                }
                else
                {
                    control.DisplayName = new NSString(string.Empty);
                }

                collections.Add(control);
            }

            this.Controller.NavigationItem.BackBarButtonItem = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, null);

            if (ctrl.Name == "Chart")
            {
                ChartSamplesViewController sampleController = new ChartSamplesViewController
                {
                    FeaturesCollections = collections,
                    ControlName         = contrl.Name,
                    Types    = contrl.Type1,
                    Features = contrl.Type2
                };

                Controller.NavigationController.PushViewController(sampleController, true);
            }
            else
            {
                indexPath = NSIndexPath.FromRowSection(0, 0);
                SampleViewController controller = new SampleViewController(indexPath)
                {
                    SamplesCollection = collections,
                    ControlName       = contrl.Name
                };

                Controller.NavigationController.PushViewController(controller, true);
            }
        }
 public TypeSamplesDataSource(NSMutableArray collections, ChartSamplesViewController controller)
 {
     samplesCollections = collections;
     this.controller    = controller;
 }
Beispiel #3
0
        public override void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath)
        {
            nuint row = (nuint)indexPath.Row;

            Control      ctrl = controller.controls.GetItem <Control>(row);
            string       sampleListPathString = NSBundle.MainBundle.BundlePath + "/plist/SampleList.plist";
            NSDictionary sampleDict           = new NSDictionary();

            sampleDict = NSDictionary.FromFile(sampleListPathString);

            //NSMutableArray samplesArray = new NSMutableArray();
            NSMutableArray dictArray = sampleDict.ValueForKey(new NSString(ctrl.name)) as NSMutableArray;

            NSMutableArray collections = new NSMutableArray();
            Control        contrl      = controller.controls.GetItem <Control>((nuint)indexPath.Row);

            for (nuint i = 0; i < dictArray.Count; i++)
            {
                NSDictionary dict = dictArray.GetItem <NSDictionary>(i);

                //samplesArray.Add(dict.ValueForKey(new NSString("SampleName")));

                Control control = new Control();
                control.ControlName = ctrl.name;
                control.name        = (NSString)dict.ValueForKey(new NSString("SampleName"));
                control.description = (NSString)dict.ValueForKey(new NSString("Description"));
                NSString imageToLoad = (NSString)dict.ValueForKey(new NSString("Image"));
                if (imageToLoad != null)
                {
                    control.image = UIImage.FromBundle(imageToLoad);
                }

                if (dict.ValueForKey(new NSString("IsNew")) != null && dict.ValueForKey(new NSString("IsNew")).ToString() == "YES")
                {
                    control.tag = new NSString("NEW");
                }
                else if (dict.ValueForKey(new NSString("IsUpdated")) != null && dict.ValueForKey(new NSString("IsUpdated")).ToString() == "YES")
                {
                    control.tag = new NSString("UPDATED");
                }
                else if (dict.ValueForKey(new NSString("IsPreview")) != null && dict.ValueForKey(new NSString("IsPreview")).ToString() == "YES")
                {
                    control.tag = new NSString("PREVIEW");
                }
                else
                {
                    control.tag = new NSString("");
                }

                if (dict.ValueForKey(new NSString("DisplayName")) != null)
                {
                    control.dispName = dict.ValueForKey(new NSString("DisplayName")) as NSString;
                }
                else
                {
                    control.dispName = new NSString("");
                }

                collections.Add(control);
            }

            if (ctrl.name == "Chart")
            {
                ChartSamplesViewController sampleController = new ChartSamplesViewController();
                sampleController.FeaturesCollections = collections;
                sampleController.ControlName         = contrl.name;
                sampleController.Types    = contrl.Type1;
                sampleController.Features = contrl.Type2;

                controller.NavigationController.PushViewController(sampleController, true);
            }
            //Go directly to sample page for controls having sample less than or equat to 4
            else
            {
                indexPath = NSIndexPath.FromRowSection(0, 0);
                SampleViewController _controller = new SampleViewController(indexPath);
                _controller.SamplesCollection = collections;
                _controller.ControlName       = contrl.name;
                //_controller.DisplayNameCollection = dispNames;

                controller.NavigationController.PushViewController(_controller, true);
            }
        }