예제 #1
0
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                nuint row = (nuint)indexPath.Row;

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

                sampleDict = new NSDictionary();
                sampleDict = NSDictionary.FromFile(sampleListPathString);

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

                for (nuint i = 0; i < dictArray.Count; i++)
                {
                    NSDictionary dict = dictArray.GetItem <NSDictionary> (i);
                    sampArray.Add(dict.ValueForKey(new NSString("SampleName")));
                }


                SampleViewController sampleController = new SampleViewController();

                sampleController.selectedControl       = ctrl.name;
                sampleController.sampleDictionaryArray = dictArray;
                sampleController.sampleArray           = sampArray;

                controller.NavigationController.PushViewController(sampleController, true);
            }
예제 #2
0
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                nuint    row            = (nuint)indexPath.Row;
                NSString selectedSample = sampleArray.GetItem <NSString> (row);

                // Load selected sample
                this.controller.LoadSample(selectedSample);
                this.controller.menuVisible = false;
                this.controller.HideMenu();
            }
예제 #3
0
        /// <summary>
        /// Import the specified certificate and its associated private key.
        /// </summary>
        /// <param name="certificate">The certificate and key, in PKCS12 format.</param>
        /// <param name="passphrase">The passphrase that protects the private key.</param>
        public void Import(byte[] certificate, string passphrase)
        {
            NSDictionary opt;

            if (string.IsNullOrEmpty(passphrase))
            {
                opt = new NSDictionary();
            }
            else
            {
                opt = NSDictionary.FromObjectAndKey(new NSString(passphrase), SecImportExport.Passphrase);
            }

            var status = SecImportExport.ImportPkcs12(certificate, opt, out NSDictionary[] array);

            if (status == SecStatusCode.Success)
            {
                var              identity = new SecIdentity(array[0]["identity"].Handle);
                NSArray          chain    = array[0]["chain"] as NSArray;
                SecCertificate[] certs    = new SecCertificate[chain.Count];
                for (System.nuint i = 0; i < chain.Count; i++)
                {
                    certs[i] = chain.GetItem <SecCertificate>(i);
                }
                Credential = new NSUrlCredential(identity, certs, NSUrlCredentialPersistence.ForSession);
            }
        }
예제 #4
0
 private static object NormalizeDicValue(NSObject value)
 {
     if (value == null)
     {
         return(null);
     }
     else if (value is NSDictionary)
     {
         return(From((NSDictionary)value));
     }
     else if (value is NSString)
     {
         return(((NSString)value).ToString());
     }
     else if (value is NSNumber)
     {
         return(((NSNumber)value).DoubleValue);
     }
     else if (value is NSArray)
     {
         List <object> list       = new List <object>();
         NSArray       nativeList = (NSArray)value;
         for (nuint i = 0; i < nativeList.Count; i++)
         {
             NSObject listObject = nativeList.GetItem <NSObject>(i);
             list.Add(NormalizeDicValue(listObject));
         }
         return(list);
     }
     return(null);
 }
예제 #5
0
        UIImage DrawFaces(UIImage srcImage, NSArray arrFaces)
        {
            UIGraphics.BeginImageContext(srcImage.Size);
            CGContext context = UIGraphics.GetCurrentContext();

            //draw src image
            srcImage.Draw(new CGRect(0, 0, srcImage.Size.Width, srcImage.Size.Height));

            //draw faces
            for (nuint i = 0; i < arrFaces.Count; i++)
            {
                NSValue valRect = arrFaces.GetItem <NSValue>(i);
                CGRect  rect    = valRect.CGRectValue;

                //draw
                context.SetStrokeColor(UIColor.Red.CGColor);
                context.SetLineWidth(2);
                context.StrokeRect(rect);
            }

            UIImage dstImage = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            return(dstImage);
        }
예제 #6
0
        public static List <StockDataPoint> LoadStockPoints(int maxItems)
        {
            List <StockDataPoint> stockPoints = new List <StockDataPoint> ();

            string          filePath  = NSBundle.MainBundle.PathForResource("AppleStockPrices", "json");
            NSData          json      = NSData.FromFile(filePath);
            NSError         error     = new NSError();
            NSArray         data      = (NSArray)NSJsonSerialization.Deserialize(json, NSJsonReadingOptions.AllowFragments, out error);
            NSDateFormatter formatter = new NSDateFormatter();

            formatter.DateFormat = "dd-MM-yyyy";

            for (int i = 0; i < (int)data.Count; i++)
            {
                if (i == maxItems)
                {
                    break;
                }
                NSDictionary   jsonPoint = data.GetItem <NSDictionary> ((nuint)i);
                StockDataPoint dataPoint = new StockDataPoint();
                dataPoint.DataXValue = formatter.Parse((NSString)jsonPoint ["date"]);
                dataPoint.Open       = (NSNumber)jsonPoint ["open"];
                dataPoint.Low        = (NSNumber)jsonPoint ["low"];
                dataPoint.Close      = (NSNumber)jsonPoint ["close"];
                dataPoint.Volume     = (NSNumber)jsonPoint ["volume"];
                dataPoint.High       = (NSNumber)jsonPoint ["high"];
                stockPoints.Add(dataPoint);
            }

            return(stockPoints);
        }
예제 #7
0
        internal static void DumpAccessibilityTree(NSObject obj = null, int indentLevel = 0)
        {
            if (obj == null)
            {
                obj = NSApplication.SharedApplication;
            }

            string desc = obj.Description;

            desc = desc.PadLeft(desc.Length + indentLevel, ' ');
            Console.WriteLine($"{desc}");

            if (!obj.RespondsToSelector(new Selector("accessibilityChildren")))
            {
                string notAccessible = "Not accessible";
                Console.WriteLine($"{notAccessible.PadLeft (notAccessible.Length + indentLevel + 2, ' ')}");
                return;
            }

            NSArray children = (NSArray)obj.PerformSelector(new Selector("accessibilityChildren"));

            if (children == null)
            {
                return;
            }

            for (nuint i = 0; i < children.Count; i++)
            {
                DumpAccessibilityTree(children.GetItem <NSObject> (i), indentLevel + 2);
            }
        }
예제 #8
0
        public bool LoadMesh()
        {
            NSInputStream inputStream = NSInputStream.FromFile(mMeshPath);

            if (inputStream != null)
            {
                inputStream.Open();
                NSError error;
                try {
                    var jsonMesh = NSJsonSerialization.Deserialize(inputStream, new NSJsonReadingOptions(), out error);
                    if (error == null)
                    {
                        NSArray      values = null;
                        nuint        i;
                        NSDictionary dictVertices;
                        NSDictionary dictTriangles;

                        NSArray  arrayVertices = (jsonMesh as NSDictionary)["vertices"] as NSArray;
                        NSArray  arrayTriangles = (jsonMesh as NSDictionary)["connectivity"] as NSArray;
                        NSString nameVertices, nameTriangles;
                        for (i = 0; i < arrayVertices.Count; i++)
                        {
                            dictVertices = arrayVertices.GetItem <NSDictionary>(i);
                            values       = dictVertices["values"] as NSArray;
                            nameVertices = dictVertices["name"] as NSString;
                            if (nameVertices == "position_buffer")
                            {
                                mVertices = VerticesToFloat(values);
                            }
                            else if (nameVertices == "normal_buffer")
                            {
                                mNormals = ToFloatArray(values);
                            }
                            else if (nameVertices == "texcoord_buffer")
                            {
                                mTexCoords = ToFloatArray(values);
                            }
                        }

                        for (i = 0; i < arrayTriangles.Count; i++)
                        {
                            dictTriangles = arrayTriangles.GetItem <NSDictionary>(i);
                            nameTriangles = dictTriangles["name"] as NSString;
                            if (nameTriangles == "triangles")
                            {
                                values          = dictTriangles["indices"] as NSArray;
                                mIndices_Number = (int)values.Count;
                                mIndex          = ToShortIntArray(values);
                            }
                        }
                    }
                } catch (Exception ee) {
                    Console.WriteLine("Errore durante LoadMesh {0}", ee.Message);
                    inputStream.Close();
                    return(false);
                }
                inputStream.Close();
            }
            return(true);
        }
예제 #9
0
        public void Search(string searchText, EventHandler handler)
        {
            NSUrl url = GetUrl(searchText);
            NSUrlSessionDataTask dataTask = session.CreateDataTask(url, (data, response, error) =>
            {
                NSError er;
                NSDictionary dict = (NSDictionary)NSJsonSerialization.Deserialize(data, NSJsonReadingOptions.AllowFragments, out er);

                string status = dict["stat"].ToString();
                Console.WriteLine("stat = " + dict["stat"]);
                NSArray arr = (NSArray)((NSDictionary)dict["photos"])["photo"];
                List <FlickrPhoto> photosList = new List <FlickrPhoto>();
                for (nuint i = 0; i < arr.Count; i++)
                {
                    //Console.WriteLine(arr.GetItem<NSDictionary>(i));
                    NSDictionary elemt = arr.GetItem <NSDictionary>(i);
                    FlickrPhoto photo  = new FlickrPhoto(elemt["id"].ToString(), elemt["farm"].ToString(), elemt["server"].ToString(), elemt["secret"].ToString(), elemt["title"].ToString());
                    photosList.Add(photo);
                }
                //Console.WriteLine("photos = " + ((NSDictionary)dict["photos"])["photo"]);
                var arg        = new PhotosDounloadEventArg();
                arg.PhotosList = photosList;
                //FinishHandler(this, arg);
                handler(this, arg);

                Console.WriteLine("dict = " + dict);
                Console.WriteLine("data = " + data);
                Console.WriteLine("error = " + error);
            });

            dataTask.Resume();
        }
예제 #10
0
        public static InstagramAuthTopBar Create()
        {
            NSArray             arr  = NSBundle.MainBundle.LoadNib("InstagramAuthTopBar", null, null);
            InstagramAuthTopBar view = arr.GetItem <InstagramAuthTopBar>(0);

            return(view);
        }
예제 #11
0
        /// <summary>
        /// Deserializa tareas.
        /// </summary>
        /// <param name="json">JSON con datos.</param>
        /// <returns>Tareas.</returns>
        public static Tarea[] DeserializeTareas(string json)
        {
            // Tareas
            List <Tarea> tareas = null;

            // Deserializo JSON
            NSArray data = (NSArray)NSJsonSerialization.Deserialize(json, 0, out NSError e);

            // Compruebo datos
            if (data != null)
            {
                // Inicializo lista
                tareas = new List <Tarea>();

                // Recorro tareas
                for (uint i = 0; i < data.Count; i++)
                {
                    // Creo y añado
                    tareas.Add(new Tarea(data.GetItem <NSDictionary>(i)));
                }
            }

            // Devuelvo datos
            return(tareas.ToArray());
        }
예제 #12
0
		public override void DrawRect(CGRect dirtyRect)
		{
			CGRect nameRect = CGRect.Empty;
			CGRect raiseRect = CGRect.Empty;
			raiseRect.Size = nameRect.Size = new CGSize(0.0f, lineHeight);

			nameRect.Location = new CGPoint(pageRect.Location.X, nameRect.Location.X);
			nameRect.Size = new CGSize(200.0f, nameRect.Size.Height);
			raiseRect.Location = new CGPoint(nameRect.GetMaxX(), raiseRect.Location.Y);
			raiseRect.Size = new CGSize(100.0f, raiseRect.Size.Height);

			nuint emptyRows = 2;
			for (nuint i = 0; i < employeeLinesPerPage; i++) {
				nuint index = (currentPage * employeeLinesPerPage) + i;
				if (index >= people.Count) {
					emptyRows = totalLinesPerPage - i;
					break;
				}
				Person p = people.GetItem<Person>(index);

				// Draw index and name
				nameRect.Location = new CGPoint(nameRect.Location.X, pageRect.Location.Y + (i * lineHeight));
				NSString nameString = new NSString(String.Format("{0:D2}: {1}", index+1, p.Name));
				nameString.DrawInRect(nameRect, attributes);

				raiseRect.Location = new CGPoint(raiseRect.Location.X, nameRect.Location.Y);
				NSString raiseString = new NSString(String.Format("{0:P1}", p.ExpectedRaise));
				raiseString.DrawInRect(raiseRect, attributes);
			}
			NSString printPageNumber = new NSString(String.Format("Page {0}", currentPage + 1));
			printPageNumber.DrawInRect(new CGRect(nameRect.Location.X, nameRect.Location.Y + nameRect.Size.Height * emptyRows, 200.0f, nameRect.Size.Height), attributes);

		}
예제 #13
0
        public static RankInfoView Create()
        {
            NSArray      arr  = NSBundle.MainBundle.LoadNib("RankInfoView", null, null);
            RankInfoView view = arr.GetItem <RankInfoView>(0);

            return(view);
        }
예제 #14
0
        partial void btnCreateCar(Foundation.NSObject sender)
        {
            NSWindow w = tableView.Window;

            // try to end any editing that is taking place
            bool editingEnded = w.MakeFirstResponder(w);

            if (!editingEnded)
            {
                Console.WriteLine("Unable to end editing");
                return;
            }

            NSUndoManager undo = this.UndoManager;

            // Has an edit occurred already in this event?
            if (undo.GroupingLevel > 0)
            {
                // Close the last group
                undo.EndUndoGrouping();
                // Open a new group
                undo.BeginUndoGrouping();
            }

            // Create the object
            // Should be able to do arrayController.NewObject, but it returns an NSObjectController
            // not an NSObject and also causes an InvalidCastException
            // BUG: https://bugzilla.xamarin.com/show_bug.cgi?id=25620
//			var c = arrayController.NewObject;
            // Workaround - not available in Unified API... due to protection level.
//			Car c = (Car)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend(arrayController.Handle, Selector.GetHandle ("newObject")));
            // Plus I can't figure out how to get the Car object from NSObjectController. Ah, this is due to above bug.
            // Creating my own Person object instead
            Car c = new Car();

            // Add it to the content array of arrayController
            arrayController.AddObject(c);

            // Re-sort (in case the user has sorted a column)
            arrayController.RearrangeObjects();

            // Get the sorted array
            NSArray a = NSArray.FromNSObjects(arrayController.ArrangedObjects());

            // Find the object just added
            nint row = -1;

            for (nuint i = 0; i < a.Count; i++)
            {
                if (c == a.GetItem <Car>(i))
                {
                    row = (nint)i;
                    break;
                }
            }
            Console.WriteLine("Starting edit of {0} in row {1}", c, row);

            // Begin the edit of the first column
            tableView.EditColumn(0, row, null, true);
        }
예제 #15
0
 static IEnumerable <T> ConvertToIEnumerable <T> (NSArray array) where T : class, ObjCRuntime.INativeObject
 {
     for (nuint i = 0; i < array.Count; i++)
     {
         yield return(array.GetItem <T> (i));
     }
 }
예제 #16
0
        private static void ProcessSubtitle(
            this AVPlayerViewController controller,
            CMTime time)
        {
            NSString text = NSString.Empty;

            NSArray payload = controller.Payload();

            for (nuint i = 0; i < payload.Count; ++i)
            {
                NSDictionary item = payload.GetItem <NSDictionary>(i);
                NSNumber     from = item.ObjectForKey(new NSString("from")) as NSNumber;
                NSNumber     to   = item.ObjectForKey(new NSString("to")) as NSNumber;
                if (time.Seconds >= from.FloatValue &&
                    time.Seconds < to.FloatValue)
                {
                    text = item.ObjectForKey(new NSString("text")) as NSString;
                    break;
                }
            }

            UILabel subtitleLabel = controller.SubtitleLabel();

            subtitleLabel.Text = text;
            var attributes = new UIStringAttributes();

            attributes.Font = subtitleLabel.Font;
            CGRect rect = text.GetBoundingRect(
                new CGSize(subtitleLabel.Bounds.Width, nfloat.MaxValue),
                NSStringDrawingOptions.UsesLineFragmentOrigin,
                attributes, null
                );

            controller.SubtitleConstranint().Constant = rect.Size.Height + 5;
        }
예제 #17
0
 private static object ConvertValue(NSObject value, Type type)
 {
     if (value != null && value is NSArray)
     {
         if (type.GenericTypeArguments.Length > 1)
         {
             throw new Exception("Not Support Type:" + type);
         }
         IList result = null;
         if (type.GenericTypeArguments[0].Equals(typeof(Name)))
         {
             result = new List <Name>();
         }
         else if (type.GenericTypeArguments[0].Equals(typeof(string)))
         {
             result = new List <string>();
         }
         else if (type.GenericTypeArguments[0].Equals(typeof(int)))
         {
             result = new List <int>();
         }
         else
         {
             throw new Exception("Not Support Type:" + type);
         }
         NSArray nestedlist = (NSArray)value;
         for (uint i = 0; i < nestedlist.Count; i++)
         {
             result.Add(ConvertValue(nestedlist.GetItem <NSObject>((System.nuint)i), type.GenericTypeArguments[0]));
         }
         return(result);
     }
     else if (type.Equals(typeof(Name)))
     {
         var value2 = value as NSMutableDictionary;
         var tmp    = new NSMutableDictionary <NSString, NSObject>();
         for (uint i = 0; i < value2.Count; i++)
         {
             tmp.SetValueForKey(value2.Values[i], value2.Keys[i] as NSString);
         }
         return(LoadSaveData <Name>(new NSDictionary <NSString, NSObject>(tmp.Keys, tmp.Values)));
     }
     else if (type.Equals(typeof(int)))
     {
         return(((NSNumber)value).Int32Value);
     }
     else if (type.Equals(typeof(bool)))
     {
         return(((NSNumber)value).BoolValue);
     }
     else if (type.Equals(typeof(string)))
     {
         return(((NSString)value).ToString());
     }
     else
     {
         return(null);
     }
 }
예제 #18
0
        public override void ViewDidLoad()
        {
            colors = NSArray.FromNSObjects(UIColor.Red, UIColor.Orange, UIColor.Yellow,
                                           UIColor.Green, UIColor.Blue, UIColor.Purple);

            View.BackgroundColor = colors.GetItem <UIColor> (colorIndex);
            colorIndex           = (colorIndex + 1) % colors.Count;
        }
예제 #19
0
 void SetLayoutIdentifierForArray(NSString identifier, NSArray constraintsArray)
 {
     for (nuint i = 0; i < constraintsArray.Count; i++)
     {
         var constraint = constraintsArray.GetItem <NSLayoutConstraint> (i);
         constraint.SetIdentifier(identifier);
     }
 }
예제 #20
0
        public override void ViewDidLoad()
        {
            colors = NSArray.FromNSObjects (UIColor.Red, UIColor.Orange, UIColor.Yellow,
                                            UIColor.Green, UIColor.Blue, UIColor.Purple);

            View.BackgroundColor = colors.GetItem<UIColor> (colorIndex);
            colorIndex = (colorIndex + 1) % colors.Count;
        }
예제 #21
0
        //
        // Inspect our selected objects (user double-clicked them).
        //
        // Note: this method will not get called until you make all columns in the table
        // as "non-editable".  So long as they are editable, double clicking a row will
        // cause the current cell to be editied.
        //
        partial void inspect(NSArray sender)
        {
            NSArray selectedObjects = sender;

            Console.WriteLine("inspect");

            int  index;
            uint numItems = (uint)selectedObjects.Count;

            for (index = 0; index < numItems; index++)
            {
                NSDictionary objectDict = selectedObjects.GetItem <NSDictionary> (0);

                if (objectDict != null)
                {
                    Console.WriteLine(string.Format("inspector item: [ {0} {1}, {2} ]",
                                                    (NSString)objectDict[FIRST_NAME].ToString(),
                                                    (NSString)objectDict[LAST_NAME].ToString(),
                                                    (NSString)objectDict[PHONE].ToString()));
                }

                // setup the edit sheet controller if one hasn't been setup already
                if (myEditController == null)
                {
                    myEditController = new EditController();
                }

                // remember which selection index we are changing
                nint savedSelectionIndex = (nint)myContentArray.SelectionIndex;

                NSDictionary editItem = selectedObjects.GetItem <NSDictionary> (0);

                // get the current selected object and start the edit sheet
                NSMutableDictionary newValues = myEditController.edit(editItem, this);

                if (!myEditController.Cancelled)
                {
                    // remove the current selection and replace it with the newly edited one
                    var currentObjects = myContentArray.SelectedObjects;
                    myContentArray.Remove(currentObjects);

                    // make sure to add the new entry at the same selection location as before
                    myContentArray.Insert(newValues, savedSelectionIndex);
                }
            }
        }
        private void ParseControlsPlist()
        {
            string       controlListPathString = NSBundle.MainBundle.BundlePath + "/plist/ControlList.plist";
            NSDictionary controlDict           = new NSDictionary();

            controlDict = NSDictionary.FromFile(controlListPathString);
            NSString controlDictKey   = new NSString("Control");
            NSArray  controlDictArray = controlDict.ValueForKey(controlDictKey) as NSArray;

            Controls = new NSMutableArray();

            if (controlDictArray.Count > 0)
            {
                for (nuint i = 0; i < controlDictArray.Count; i++)
                {
                    NSDictionary dict  = controlDictArray.GetItem <NSDictionary>(i);
                    string       image = dict.ValueForKey(new NSString("ControlName")).ToString();
                    image = "Controls/" + image;
                    Control control = new Control
                    {
                        Name        = new NSString(dict.ValueForKey(new NSString("ControlName")).ToString()),
                        Description = new NSString(dict.ValueForKey(new NSString("Description")).ToString()),
                        Image       = UIImage.FromBundle(image)
                    };

                    if (!UIDevice.CurrentDevice.CheckSystemVersion(9, 0) && control.Name == "PDFViewer")
                    {
                        continue;
                    }

                    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("Type1")) != null)
                    {
                        control.IsMultipleSampleView = true;
                        control.Type1 = new NSString(dict.ValueForKey(new NSString("Type1")).ToString());
                        control.Type2 = new NSString(dict.ValueForKey(new NSString("Type2")).ToString());
                    }

                    Controls.Add(control);
                }
            }
        }
예제 #23
0
        private void InitView()
        {
            NSArray array = NSBundle.MainBundle.LoadNib("UserListCell", this, null);
            var     view  = array.GetItem <UIView>(0);

            this.AddSubview(view);
            view.Frame            = this.Bounds;
            view.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
        }
        private ServiceUuid[] ExtractServiceUuids(NSArray array)
        {
            var res = new ServiceUuid[array.Count];

            for (int i = 0; i < res.Length; i++)
            {
                res[i] = array.GetItem <CBUUID>((nuint)i).ToUuid();
            }
            return(res);
        }
예제 #25
0
 protected override void OnElementChanged(ElementChangedEventArgs <ItemsView> e)
 {
     base.OnElementChanged(e);
     if (Control != null)
     {
         NSArray          s = Control.ValueForKey(new NSString("_subviewCache")) as NSMutableArray;
         UICollectionView c = s.GetItem <UICollectionView>(0);
         c.ShowsHorizontalScrollIndicator = false;
     }
 }
        public static IList ToList(this NSArray @this, Type targetType)
        {
            var list = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(targetType));

            for (nuint i = 0; i < @this.Count; i++)
            {
                list.Add(@this.GetItem <NSObject>(i).ToObject(targetType));
            }
            return(list);
        }
예제 #27
0
        private void inspect(NSArray selectedObjects)
        {
            var objectDict = selectedObjects.GetItem <NSDictionary> (0);

            if (objectDict != null)
            {
                NSString sss = new NSString("url");
                NSUrl    url = new NSUrl(objectDict.ValueForKey(sss).ToString());
                NSWorkspace.SharedWorkspace.OpenUrl(url);
            }
        }
예제 #28
0
 static IEnumerable <object> GetItems(NSArray items)
 {
     for (nnuint i = 0; i < items.Count; i++)
     {
         var item = items.GetItem <EtoTreeItem>(i);
         if (item != null)
         {
             yield return(item.Item);
         }
     }
 }
예제 #29
0
        protected override void OnElementChanged(ElementChangedEventArgs <GroupableItemsView> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                NSArray          views          = Control.ValueForKey(new NSString("_subviewCache")) as NSMutableArray;
                UICollectionView collectionView = views.GetItem <UICollectionView>(0);
                collectionView.Delegate = new MyCollectionViewDelegate((CustomCollectionView)Element);
            }
        }
예제 #30
0
        public static nuint [] GetNUintArray(NSArray nsArray)
        {
            var items = new nuint [nsArray.Count];

            for (nuint i = 0; (int)i < items.Length; i++)
            {
                items [i] = nsArray.GetItem <NSNumber> (i).NUIntValue;
            }

            return(items);
        }
예제 #31
0
        MediaItem [] ProcessMediaItems(NSArray json)
        {
            var mediaItems = new MediaItem [json.Count];

            for (nuint i = 0; i < json.Count; i++)
            {
                mediaItems [i] = MediaItem.From(json.GetItem <NSDictionary> (i));
            }

            return(mediaItems);
        }
		static Dictionary<string, NSObject>[] ParseShortcuts (NSArray items)
		{
			var count = (int)items.Count;
			var result = new Dictionary<string, NSObject>[count];
			for (int i = 0; i < count; i++) {
				var nDict = items.GetItem<NSDictionary> ((nuint)i);
				var dict = result [i] = new Dictionary<string, NSObject> ();
				foreach (var kvp in nDict)
					dict [(NSString)kvp.Key] = kvp.Value;
			}

			return result;
		}
예제 #33
0
 public MPMediaItem GetItem(xint index)
 {
     using (var array = new NSArray (Messaging.IntPtr_objc_msgSend (Handle, Selector.GetHandle ("items"))))
         return array.GetItem<MPMediaItem> (index);
 }
예제 #34
0
 public MPMediaQuerySection GetSection(xint index)
 {
     using (var array = new NSArray (Messaging.IntPtr_objc_msgSend (Handle, Selector.GetHandle ("itemSections"))))
         return array.GetItem<MPMediaQuerySection> (index);
 }
예제 #35
0
		private void inspect (NSArray selectedObjects)
		{
			var objectDict = selectedObjects.GetItem<NSDictionary> (0);
			
			if (objectDict != null) {
				NSString sss = new NSString ("url");
				NSUrl url = new NSUrl (objectDict.ValueForKey (sss).ToString ());
				NSWorkspace.SharedWorkspace.OpenUrl (url);                      
			}
		}
        protected void Initialize()
        {
            log ("Initialize view");
            this.ShowSplashScreenOnStartupTime( UIApplication.SharedApplication.StatusBarOrientation);

            NSObject supportedOrientationsObj = NSBundle.MainBundle.ObjectForInfoDictionary ("CustomUISupportedInterfaceOrientations");
            if (supportedOrientationsObj != null) {
                if (supportedOrientationsObj is NSArray) {
                    supportedOrientations = (NSArray)supportedOrientationsObj;

                    for (uint index = 0; index < supportedOrientations.Count; index++) {
                        NSString mySupportedOrientation = new NSString (supportedOrientations.GetItem<NSString>(index));
                        if (("UIInterfaceOrientation" + UIInterfaceOrientation.Portrait.ToString ()) == mySupportedOrientation.ToString ()) {
                            orientationSupportedPortrait = true;
                        }
                        if (("UIInterfaceOrientation" + UIInterfaceOrientation.PortraitUpsideDown.ToString ()) == mySupportedOrientation.ToString ()) {
                            orientationSupportedPortraitUpsideDown = true;
                        }
                        if (("UIInterfaceOrientation" + UIInterfaceOrientation.LandscapeLeft.ToString ()) == mySupportedOrientation.ToString ()) {
                            orientationSupportedLandscapeLeft = true;
                        }
                        if (("UIInterfaceOrientation" + UIInterfaceOrientation.LandscapeRight.ToString ()) == mySupportedOrientation.ToString ()) {
                            orientationSupportedLandscapeRight = true;
                        }
                    }

                }
                log ("custom supported orientations: "
                    + orientationSupportedPortrait + " | " + orientationSupportedPortraitUpsideDown  + " | " +
                    orientationSupportedLandscapeLeft + " | " + orientationSupportedLandscapeRight);
            }
        }
        void SetLayoutIdentifierForArray (NSString identifier, NSArray constraintsArray)
		{
			for (nuint i = 0; i < constraintsArray.Count; i++) {
				var constraint = constraintsArray.GetItem<NSLayoutConstraint> (i);
				constraint.SetIdentifier (identifier);
			}
        }