public override void ViewDidLoad() { base.ViewDidLoad (); var r = new Random (); var generator = new LoremIpsumGenerator (); items = new NSMutableArray (); for (int i = 0; i < 20; i++) { items.Add (new NSString(generator.GenerateString (2 + r.Next (30)))); } dataSource = new TKDataSource (items); dataSource.Settings.ListView.DefaultCellClass = new ObjCRuntime.Class (typeof(ListViewVariableSizeCell)); dataSource.Settings.ListView.InitCell ((TKListView listView, NSIndexPath indexPath, TKListViewCell cell, NSObject item) => { var myCell = cell as ListViewVariableSizeCell; myCell.label.Text = item.Description; }); var list = new TKListView (this.View.Bounds); list.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; list.WeakDataSource = dataSource; this.View.AddSubview (list); var layout = list.Layout as TKListViewLinearLayout; layout.DynamicItemSize = true; }
public RatingControl () { Rating = AAPLRatingControlMinimumRating; var blurredEffect = UIBlurEffect.FromStyle (UIBlurEffectStyle.Light); backgroundView = new UIVisualEffectView (blurredEffect); backgroundView.ContentView.BackgroundColor = UIColor.FromWhiteAlpha (0.7f, 0.3f); Add (backgroundView); var imageViews = new NSMutableArray (); for (nint rating = AAPLRatingControlMinimumRating; rating <= AAPLRatingControlMaximumRating; rating++) { UIImageView imageView = new UIImageView (); imageView.UserInteractionEnabled = true; imageView.Image = UIImage.FromBundle ("ratingInactive"); imageView.HighlightedImage = UIImage.FromBundle ("ratingActive"); imageView.HighlightedImage = imageView.HighlightedImage.ImageWithRenderingMode (UIImageRenderingMode.AlwaysTemplate); imageView.AccessibilityLabel = string.Format ("{0} stars", rating + 1); Add (imageView); imageViews.Add (imageView); } ImageViews = imageViews; UpdateImageViews (); SetupConstraints (); }
public static void SaveToDictionary(this IStateBundle state, NSMutableDictionary bundle) { var formatter = new BinaryFormatter(); foreach (var kv in state.Data.Where(x => x.Value != null)) { var value = kv.Value; if (value.GetType().IsSerializable) { using (var stream = new MemoryStream()) { formatter.Serialize(stream, value); stream.Position = 0; var bytes = stream.ToArray(); var array = new NSMutableArray(); foreach (var b in bytes) { array.Add(NSNumber.FromByte(b)); } bundle.Add(new NSString(kv.Key), array); } } } }
public override void SetupSlide (PresentationViewController presentationViewController) { // Create a node to own the "sign" model, make it to be close to the camera, rotate by 90 degree because it's oriented with z as the up axis var intermediateNode = SCNNode.Create (); intermediateNode.Position = new SCNVector3 (0, 0, 7); intermediateNode.Rotation = new SCNVector4 (1, 0, 0, -(float)(Math.PI / 2)); GroundNode.AddChildNode (intermediateNode); // Load the "sign" model var signNode = Utils.SCAddChildNode (intermediateNode, "sign", "Scenes/intersection/intersection", 30); signNode.Position = new SCNVector3 (4, -2, 0.05f); // Re-parent every node that holds a camera otherwise they would inherit the scale from the "sign" model. // This is not a problem except that the scale affects the zRange of cameras and so it would be harder to get the transition from one camera to another right var cameraNodes = new NSMutableArray (); foreach (SCNNode child in signNode) { if (child.Camera != null) cameraNodes.Add (child); } for (nuint i = 0; i < cameraNodes.Count; i++) { var cameraNode = new SCNNode (cameraNodes.ValueAt ((uint)i)); var previousWorldTransform = cameraNode.WorldTransform; intermediateNode.AddChildNode (cameraNode); // re-parent cameraNode.Transform = intermediateNode.ConvertTransformFromNode (previousWorldTransform, null); cameraNode.Scale = new SCNVector3 (1, 1, 1); } }
private NSMutableArray ReadRectanglesXml(PinboardData.RectangleInfo screenRectangle) { var list = new NSMutableArray(); // Read <Rectangles> reader.ReadStartElement(rectanglesAtom); reader.MoveToContent(); while (true) { if (String.ReferenceEquals(reader.Name, rectanglesAtom)) { reader.ReadEndElement(); reader.MoveToContent(); break; } var rectInfo = ReadRectangleXml(); // Flip the rectangle top to bottom relative to the screen rectangle rectInfo.Y = screenRectangle.Height - rectInfo.Y - rectInfo.Height; list.Add(rectInfo); } return list; }
public NSMutableArray GetMountedVolumes() { NSMutableArray volumeList = new NSMutableArray(); NSArray volKeys = NSArray.FromNSObjects( NSUrl.VolumeLocalizedNameKey, NSUrl.VolumeTotalCapacityKey, NSUrl.VolumeAvailableCapacityKey, NSUrl.VolumeIsBrowsableKey, NSUrl.VolumeURLKey, NSUrl.VolumeUUIDStringKey ); NSFileManager fileManager = new NSFileManager(); NSUrl[] volumeUrls = fileManager.GetMountedVolumes(volKeys, NSVolumeEnumerationOptions.None); NSByteCountFormatter byteFormatter = new NSByteCountFormatter(); byteFormatter.CountStyle = NSByteCountFormatterCountStyle.File; foreach(NSUrl volumeUrl in volumeUrls) { NSError volUrlError; NSObject volName; NSObject volIdentifer; NSObject volBrowsable; NSObject volBytesAvailable; NSObject volBytesTotal; volumeUrl.TryGetResource(NSUrl.VolumeLocalizedNameKey, out volName, out volUrlError); volumeUrl.TryGetResource(NSUrl.VolumeURLKey, out volIdentifer, out volUrlError); volumeUrl.TryGetResource(NSUrl.VolumeIsBrowsableKey, out volBrowsable, out volUrlError); volumeUrl.TryGetResource(NSUrl.VolumeAvailableCapacityKey, out volBytesAvailable, out volUrlError); volumeUrl.TryGetResource(NSUrl.VolumeTotalCapacityKey, out volBytesTotal, out volUrlError); NSNumber volBytesAvailableNum = (NSNumber)volBytesAvailable; NSNumber volBytesTotalNum = (NSNumber)volBytesTotal; byteFormatter.IncludesUnit = false; byteFormatter.IncludesCount = true; var volBytesAvailableCount = byteFormatter.Format(volBytesAvailableNum.LongValue); var volBytesTotalCount = byteFormatter.Format(volBytesTotalNum.LongValue); byteFormatter.IncludesUnit = true; byteFormatter.IncludesCount = false; var volBytesAvailableUnit = byteFormatter.Format(volBytesAvailableNum.LongValue); var volBytesTotalUnit = byteFormatter.Format(volBytesTotalNum.LongValue); NSNumber browsable = (NSNumber)volBrowsable; if (browsable.BoolValue) { volumeList.Add(new NSDictionary( "name", volName, "id", volIdentifer, "bytesAvailableCount", volBytesAvailableCount, "bytesAvailableUnit", volBytesAvailableUnit, "bytesTotalCount", volBytesTotalCount, "bytesTotalUnit", volBytesTotalUnit )); } } return volumeList; }
public override void ViewDidLoad() { AddOption ("TKChart", useChart); AddOption ("TKCalendar", useCalendar); AddOption ("UITableView", useTableView); AddOption ("UICollectionView", useCollectionView); AddOption ("TKListView", useListView); base.ViewDidLoad (); string[] imageNames = new string[] {"CENTCM.jpg", "FAMIAF.jpg", "CHOPSF.jpg", "DUMONF.jpg", "ERNSHM.jpg", "FOLIGF.jpg"}; string[] names = new string[] { "John", "Abby", "Phill", "Saly", "Robert", "Donna" }; NSMutableArray array = new NSMutableArray (); Random r = new Random (); for (int i = 0; i < imageNames.Length; i++) { UIImage image = new UIImage (imageNames [i]); this.AddItem (array, names [i], r.Next (100), r.Next (100) > 50 ? "two" : "one", r.Next (10), image); } this.dataSource.DisplayKey = "Name"; this.dataSource.ValueKey = "Value"; this.dataSource.ItemSource = array; this.useChart (this, EventArgs.Empty); }
public GettingStarted () { view = new UIView (); label = new UILabel (); label.Text = "Getting Started"; label.Frame=new CGRect(0,0,300,30); //view.AddSubview (label); tree = new SFTreeMap (); tree.LeafItemSettings = new SFLeafItemSetting (); tree.LeafItemSettings.LabelStyle = new SFStyle () { Font = UIFont.SystemFontOfSize (12), Color = UIColor.White }; tree.LeafItemSettings.LabelPath = (NSString)"Label"; tree.LeafItemSettings.ShowLabels = true; tree.LeafItemSettings.Gap = 2; tree.LeafItemSettings.BorderColor=UIColor.Gray; tree.LeafItemSettings.BorderWidth = 1; NSMutableArray ranges = new NSMutableArray (); ranges.Add (new SFRange () { LegendLabel = (NSString)"1 % Growth", From = 0, To = 1, Color = UIColor.FromRGB (0x77, 0xD8, 0xD8) }); ranges.Add (new SFRange () { LegendLabel = (NSString)"2 % Growth", From = 0, To = 2, Color = UIColor.FromRGB (0xAE, 0xD9, 0x60) }); ranges.Add (new SFRange () { LegendLabel = (NSString)"3 % Growth", From = 0, To = 3, Color = UIColor.FromRGB (0xFF, 0xAF, 0x51) }); ranges.Add (new SFRange () { LegendLabel = (NSString)"4 % Growth", From = 0, To = 4, Color = UIColor.FromRGB (0xF3, 0xD2, 0x40) }); tree.LeafItemColorMapping = new SFRangeColorMapping () { Ranges = ranges }; CGSize legendSize = new CGSize (this.Frame.Size.Width, 60); CGSize iconSize = new CGSize (17, 17); UIColor legendColor = UIColor.Gray; tree.LegendSettings = new SFLegendSetting () { LabelStyle = new SFStyle () { Font = UIFont.SystemFontOfSize (12), Color = legendColor }, IconSize = iconSize, ShowLegend = true, Size = legendSize }; GetPopulationData (); tree.Items = PopulationDetails; AddSubview (view); control = this; }
public override Id Init() { this.NativePointer = this.SendMessageSuper<IntPtr>(AppControllerClass, "init"); this._data = new NSMutableArray().Retain<NSMutableArray>(); return this; }
void AccessGrantedForContactStore () { string plistPath = NSBundle.MainBundle.PathForResource ("Menu", "plist"); menuArray = NSMutableArray.FromFile (plistPath); TableView.ReloadData (); }
public override void ViewDidLoad () { base.ViewDidLoad (); dataSource = new TKDataSource (); dataSource.AddFilterDescriptor (new TKDataSourceFilterDescriptor ("NOT (Name like 'John')")); dataSource.AddSortDescriptor (new TKDataSourceSortDescriptor ("Name", true)); dataSource.AddGroupDescriptor (new TKDataSourceGroupDescriptor ("Group")); var array = new NSMutableArray (); array.Add (new DSItem () { Name = "John", Value = 22.0f, Group = "one" }); array.Add (new DSItem () { Name = "Peter", Value = 15.0f, Group = "one" }); array.Add (new DSItem () { Name = "Abby", Value = 47.0f, Group = "one" }); array.Add (new DSItem () { Name = "Robert", Value = 45.0f, Group = "two" }); array.Add (new DSItem () { Name = "Alan", Value = 17.0f, Group = "two" }); array.Add (new DSItem () { Name = "Saly", Value = 33.0f, Group = "two" }); dataSource.DisplayKey = "Name"; dataSource.ValueKey = "Value"; dataSource.ItemSource = array; var tableView = new UITableView (this.View.Bounds); tableView.DataSource = dataSource; this.View.AddSubview (tableView); }
private UIButton[] LeftButtons() { var leftUtilityButtons = new NSMutableArray(); leftUtilityButtons.AddUtilityButton(UIColor.FromRGB(242, 38, 19), UIImage.FromBundle("delete_big.png")); leftUtilityButtons.AddUtilityButton(UIColor.FromRGB(30, 130, 76), UIImage.FromBundle("share_big.png")); return NSArray.FromArray<UIButton>(leftUtilityButtons); }
public AAPLRatingControl() { Rating = AAPLRatingControlMinimumRating; var blurredEffect = UIBlurEffect.FromStyle(UIBlurEffectStyle.Light); backgroundView = new UIVisualEffectView(blurredEffect); backgroundView.ContentView.BackgroundColor = UIColor.FromWhiteAlpha(0.7f, 0.2f); Add(backgroundView); var append = ""; var imageViews = new NSMutableArray(); for (int rating = AAPLRatingControlMinimumRating; rating <= AAPLRatingControlMaximumRating; rating++) { var imageView = new UIImageView { UserInteractionEnabled = true, Image = UIImage.FromBundle("ratingInactive" + append), HighlightedImage = UIImage.FromBundle("ratingActive" + append).ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal), AccessibilityLabel = string.Format("{0} bananas", rating + 1) }; imageView.HighlightedImage = imageView.HighlightedImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); Add(imageView); imageViews.Add(imageView); } ImageViews = imageViews; UpdateImageViews(); SetupConstraints(); }
public ChartSemiPieDataSource () { DataPoints = new NSMutableArray (); AddDataPointsForChart("Product A", 14); AddDataPointsForChart("Product B", 54); AddDataPointsForChart("Product C", 23); AddDataPointsForChart("Product D", 53); }
public override void ViewDidLoad () { base.ViewDidLoad (); FoodItems = new NSMutableArray (); if(HealthStore != null) UpdateJournal (null, null); UIApplication.Notifications.ObserveDidBecomeActive (UpdateJournal); }
public ChartSplineAreaDataSource () { DataPoints = new NSMutableArray (); AddDataPointsForChart("2010", 54); AddDataPointsForChart("2011", 34); AddDataPointsForChart("2012", 53); AddDataPointsForChart("2013", 63); AddDataPointsForChart("2014", 35); }
public ChartNumericalSource () { DataPoints = new NSMutableArray (); AddDataPointsForChart(1, 54); AddDataPointsForChart(2, 24); AddDataPointsForChart(3, 53); AddDataPointsForChart(4, 63); AddDataPointsForChart(5, 35); }
public ChartSplineDataSource () { DataPoints = new NSMutableArray (); AddDataPointsForChart("2010", 45); AddDataPointsForChart("2011", 89); AddDataPointsForChart("2012", 23); AddDataPointsForChart("2013", 43); AddDataPointsForChart("2014", 54); }
public override void ViewDidLoad () { base.ViewDidLoad (); Title = "QuickContacts"; menuArray = new NSMutableArray (0); CheckContactStore (); }
public ChartZoomPanDataSource () { DataPoints = new NSMutableArray (); AddDataPointsForChart("Bentley" , 54); AddDataPointsForChart("Audi", 24); AddDataPointsForChart("BMW", 53); AddDataPointsForChart("Jaguar", 63); AddDataPointsForChart("Skoda", 35); }
public void ApplicationDidFinishLaunching(NSNotification notification) { this.textView.Font = NSFont.FontWithNameSize("Courier", 24.0f); this.deviceList = new NSMutableArray(DRDevice.Devices.Count); DRNotificationCenter.CurrentRunLoopCenter.AddObserverSelectorNameObject(this, ObjectiveCRuntime.Selector("deviceDisappeared:"), DRDevice.DRDeviceDisappearedNotification, null); DRNotificationCenter.CurrentRunLoopCenter.AddObserverSelectorNameObject(this, ObjectiveCRuntime.Selector("deviceAppeared:"), DRDevice.DRDeviceAppearedNotification, null); }
public void saveNotes(Collection<string> notes) { NSMutableArray arrayNotes = new NSMutableArray (); for (int i = 0; i < notes.Count; i++) { arrayNotes.Add (new NSString (notes [i])); } NSUserDefaults.StandardUserDefaults.SetValueForKey (arrayNotes, new NSString (NOTES)); NSUserDefaults.StandardUserDefaults.Synchronize (); }
public ChartPieDataSource () { DataPoints = new NSMutableArray (); AddDataPointsForChart("2010", 8000); AddDataPointsForChart("2011", 8100); AddDataPointsForChart("2012", 8250); AddDataPointsForChart("2013", 8600); AddDataPointsForChart("2014", 8700); }
public ChartPyramidDataSource () { DataPoints = new NSMutableArray (); AddDataPointsForChart("Bentley", 800); AddDataPointsForChart("Audi", 810); AddDataPointsForChart("BMW", 825); AddDataPointsForChart("Jaguar", 860); AddDataPointsForChart("Skoda", 870); }
public ChartCandleDataSource () { DataPoints = new NSMutableArray (); AddDataPointsForChart("2010", 873.8, 878.85, 855.5, 860.5); AddDataPointsForChart("2011", 861, 868.4, 835.2, 843.45); AddDataPointsForChart("2012", 846.15, 853, 838.5, 847.5); AddDataPointsForChart("2013", 846, 860.75, 841, 855); AddDataPointsForChart("2014", 841, 845, 827.85, 838.65); }
public ChartRangeColumnDataSource () { DataPoints = new NSMutableArray (); AddDataPointsForChart("Jan", 35, 17); AddDataPointsForChart("Feb", 42,-11); AddDataPointsForChart("Mar", 25, 5); AddDataPointsForChart("Apr", 32, 10); AddDataPointsForChart("May", 20, 3); AddDataPointsForChart("Jun", 41, 30); }
public MultipleAxisDataSource () { DataPoints = new NSMutableArray (); DataPoints1 = new NSMutableArray (); AddDataPointsForChart("2010", 8000,6); AddDataPointsForChart("2011", 8100,15); AddDataPointsForChart("2012", 8250,35); AddDataPointsForChart("2013", 8600,65); AddDataPointsForChart("2014", 8700,75); }
public ChartLineChartDataSource () { DataPoints = new NSMutableArray (); AddDataPointsForChart ("2010", 45.68); AddDataPointsForChart ("2011", 89.25); AddDataPointsForChart ("2012", 23.73); AddDataPointsForChart ("2013", 43.5); AddDataPointsForChart ("2014", 54.92); }
// Shared initialization code void Initialize () { repeatCount = 1; categoryArray = new NSMutableArray (); categories = TestSuite.Categories; foreach (var category in categories) { categoryArray.Add ((NSString)category.Name); } }
// Load stored scores from disk public void loadStoredScores () { NSArray unarchivedObj = (NSArray)NSKeyedUnarchiver.UnarchiveFile (this.storedScoresFilename); if (unarchivedObj != null) { storedScores = (NSMutableArray)unarchivedObj; this.resubmitSotredScores (); } else { storedScores = new NSMutableArray (); } }
NSMutableArray CreateAppointments() { NSDate today = new NSDate(); setColors(); setSubjects(); NSMutableArray appCollection = new NSMutableArray(); NSCalendar calendar = NSCalendar.CurrentCalendar; // Get the year, month, day from the date NSDateComponents components = calendar.Components( NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second components.Hour = 10; components.Minute = 0; components.Second = 0; // Get the year, month, day from the date NSDateComponents endDateComponents = calendar.Components(NSCalendarUnit.Year | NSCalendarUnit.Month | NSCalendarUnit.Day, today); // Set the hour, minute, second endDateComponents.Hour = 12; endDateComponents.Minute = 0; endDateComponents.Second = 0; Random randomNumber = new Random(); for (int i = 0; i < 10; i++) { components.Hour = randomNumber.Next(10, 16); endDateComponents.Hour = components.Hour + randomNumber.Next(1, 3); NSDate startDate = calendar.DateFromComponents(components); NSDate endDate = calendar.DateFromComponents(endDateComponents); ScheduleAppointment appointment = new ScheduleAppointment(); appointment.StartTime = startDate; appointment.EndTime = endDate; components.Day = components.Day + 1; endDateComponents.Day = endDateComponents.Day + 1; appointment.Subject = (NSString)subjectCollection[i]; appointment.AppointmentBackground = colorCollection[i]; appCollection.Add(appointment); } return(appCollection); }
public override void ViewDidLoad() { base.ViewDidLoad(); groups = new NSMutableArray(); groups.Add(NSArray.FromStrings(new string[] { "John", "Abby" })); groups.Add(NSArray.FromStrings(new string[] { "Smith", "Peter", "Paula" })); TKListView listView = new TKListView(new CGRect(20, 20, this.View.Bounds.Size.Width - 40, this.View.Bounds.Size.Height - 40)); listView.RegisterClassForCell(new Class(typeof(TKListViewCell)), "cell"); listView.RegisterClassForSupplementaryView(new Class(typeof(TKListViewHeaderCell)), TKListViewElementKindSectionKey.Header, new NSString("header")); listView.DataSource = new ListViewDataSource(this); TKListViewLinearLayout layout = (TKListViewLinearLayout)listView.Layout; layout.HeaderReferenceSize = new CGSize(200, 22); this.View.AddSubview(listView); }
public void ReplaceObjectTest() { var v1 = (NSString)"1"; var v2 = (NSString)"2"; var v3 = (NSString)"3"; using (var arr = new NSMutableArray <NSString> (v1, v3)) { Assert.AreEqual(2, arr.Count, "ReplaceObject 1"); Assert.AreSame(v1, arr [0], "a [0]"); Assert.AreSame(v3, arr [1], "a [1]"); Assert.Throws <ArgumentNullException> (() => arr.ReplaceObject(0, null), "Insert ANE"); Assert.Throws <IndexOutOfRangeException> (() => arr.ReplaceObject(-1, v2), "Insert AOORE 1"); Assert.Throws <IndexOutOfRangeException> (() => arr.ReplaceObject(3, v2), "Insert AOORE 2"); arr.ReplaceObject(1, v2); Assert.AreEqual(2, arr.Count, "ReplaceObject 2"); Assert.AreSame(v1, arr [0], "b [0]"); Assert.AreSame(v2, arr [1], "b [1]"); } }
public ChartLineDataSource() { DataPoints = new NSMutableArray(); AddDataPointsForChart("2010", 45); AddDataPointsForChart("2011", 86); AddDataPointsForChart("2012", 23); AddDataPointsForChart("2013", 43); AddDataPointsForChart("2014", 54); AddDataPointsForChart("2010", 48); AddDataPointsForChart("2011", 68); AddDataPointsForChart("2012", 20); AddDataPointsForChart("2013", 56); AddDataPointsForChart("2014", 53); AddDataPointsForChart("2010", 48); AddDataPointsForChart("2011", 61); AddDataPointsForChart("2012", 13); AddDataPointsForChart("2013", 76); AddDataPointsForChart("2014", 04); }
public override void ViewDidLoad() { base.ViewDidLoad(); // >> datasource-displaykey-cs NSMutableArray items = new NSMutableArray(); items.Add(new DSItem() { Name = "John", Value = 50, Group = "A" }); items.Add(new DSItem() { Name = "Abby", Value = 33, Group = "A" }); items.Add(new DSItem() { Name = "Smith", Value = 42, Group = "B" }); items.Add(new DSItem() { Name = "Peter", Value = 28, Group = "B" }); items.Add(new DSItem() { Name = "Paula", Value = 25, Group = "B" }); this.dataSource = new TKDataSource(); this.dataSource.ItemSource = items; this.dataSource.DisplayKey = "Name"; // << datasource-displaykey-cs this.dataSource.FilterWithQuery("Value > 30"); this.dataSource.SortWithKey("Value", true); this.dataSource.GroupWithKey("Group"); UITableView tableView = new UITableView(this.View.Bounds); tableView.DataSource = this.dataSource; this.View.AddSubview(tableView); }
static void PlatformTrackError(Exception exception, IDictionary <string, string> properties, ErrorAttachmentLog[] attachments) { NSDictionary propertyDictionary = properties != null?StringDictToNSDict(properties) : new NSDictionary(); NSMutableArray attachmentArray = new NSMutableArray(); foreach (var attachment in attachments) { if (attachment?.internalAttachment != null) { attachmentArray.Add(attachment.internalAttachment); } else { AppCenterLog.Warn(LogTag, "Skipping null ErrorAttachmentLog in Crashes.TrackError."); } } MSWrapperCrashesHelper.TrackModelException(GenerateiOSException(exception, false), propertyDictionary, attachmentArray); }
void Initialize() { serverModeArray = new NSMutableArray(); if (MacUI.AppDelegate.HasBuiltinFramework) { serverModeArray.Add(new ServerModeModel(ServerMode.Builtin, "Builtin test framework")); } else { serverModeArray.Add(new ServerModeModel(ServerMode.WaitForConnection, "Wait for connection")); serverModeArray.Add(new ServerModeModel(ServerMode.Local, "Run locally")); serverModeArray.Add(new ServerModeModel(ServerMode.Android, "Connect to Android")); serverModeArray.Add(new ServerModeModel(ServerMode.iOS, "Connect to iOS")); } string currentMode; if (!SettingsBag.TryGetValue("ServerMode", out currentMode)) { currentMode = MacUI.AppDelegate.HasBuiltinFramework ? "Builtin" : "WaitForConnection"; } SettingsBag.DisableTimeouts = SettingsBag.LogLevel > SettingsBag.DisableTimeoutsAtLogLevel; for (nuint i = 0; i < serverModeArray.Count; i++) { var model = serverModeArray.GetItem <ServerModeModel> (i); if (currentServerMode == null || model.Mode.ToString().Equals(currentMode)) { currentServerMode = model; } } testCategoriesArray = new NSMutableArray(); allCategory = new TestCategoryModel(TestCategory.All); globalCategory = new TestCategoryModel(TestCategory.Global); currentCategory = allCategory; testCategoriesArray.Add(allCategory); testCategoriesArray.Add(globalCategory); testFeaturesArray = new NSMutableArray(); }
private static NSArray ParseSubtitles(NSUrl url) { var subtitles = new NSMutableArray(); try { NSData data = NSData.FromUrl(url); var parser = new SubParser(); byte[] bytes = data.ToArray(); using (MemoryStream stream = new MemoryStream(bytes)) { foreach (var item in parser.ParseStream(stream)) { var subtitle = new NSMutableDictionary(); subtitle.Add( new NSString("from"), NSNumber.FromFloat(item.StartTime / 1000.0f) ); subtitle.Add( new NSString("to"), NSNumber.FromFloat(item.EndTime / 1000.0f) ); string content = string.Empty; item.Lines.ForEach(l => content += (l + "\n")); content = content.Trim('\n'); subtitle.Add( new NSString("text"), new NSString(content) ); subtitles.Add( subtitle ); } } return(subtitles); } catch (Exception e) { Console.WriteLine("Error parsing subtitles: " + e.Message); return(new NSArray()); } }
public override void ViewDidLoad() { base.ViewDidLoad(); // >> listview-feed-cs simpleArrayOfStrings = new NSMutableArray(); simpleArrayOfStrings.Add(new NSString("Kristina Wolfe")); simpleArrayOfStrings.Add(new NSString("Freda Curtis")); simpleArrayOfStrings.Add(new NSString("Eva Lawson")); simpleArrayOfStrings.Add(new NSString("Emmett Santos")); simpleArrayOfStrings.Add(new NSString("Theresa Bryan")); simpleArrayOfStrings.Add(new NSString("Jenny Fuller")); simpleArrayOfStrings.Add(new NSString("Terrell Norris")); simpleArrayOfStrings.Add(new NSString("Eric Wheeler")); simpleArrayOfStrings.Add(new NSString("Julius Clayton")); simpleArrayOfStrings.Add(new NSString("Harry Douglas")); simpleArrayOfStrings.Add(new NSString("Eduardo Thomas")); simpleArrayOfStrings.Add(new NSString("Orlando Mathis")); simpleArrayOfStrings.Add(new NSString("Alfredo Thornton")); // << listview-feed-cs // >> listview-feed-ds-cs dataSource.ItemSource = simpleArrayOfStrings; // << listview-feed-ds-cs // >> listview-init-cs TKListView listView = new TKListView(); listView.Frame = new CGRect(0, 0, this.View.Bounds.Size.Width, this.View.Bounds.Size.Height - 20); listView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; listView.WeakDataSource = dataSource; this.View.AddSubview(listView); // << listview-init-cs // >> listview-init-selec-cs listView.AllowsMultipleSelection = true; // << listview-init-selec-cs // >> listview-init-reorder-cs listView.AllowsCellReorder = true; // << listview-init-reorder-cs }
// // Load support: // Override one of ReadFromData, ReadFromFileWrapper or ReadFromUrl // public override bool ReadFromData(NSData data, string typeName, out NSError outError) { outError = null; Console.WriteLine("About to read data of type {0}", typeName); NSMutableArray newArray = null; try { newArray = (NSMutableArray)NSKeyedUnarchiver.UnarchiveObject(data); } catch (Exception ex) { Console.WriteLine("Error loading file: Exception: {0}", ex.Message); NSDictionary d = NSDictionary.FromObjectAndKey(new NSString(NSBundle.MainBundle.LocalizedString("DATA_CORRUPTED", null)), NSError.LocalizedFailureReasonErrorKey); outError = NSError.FromDomain(NSError.OsStatusErrorDomain, -4, d); return(false); } Ovals = NSArray.FromArray <Oval>(newArray).ToList <Oval>(); return(true); }
public static User UserWithDictionary(NSDictionary dictionary) { string name = (NSString)dictionary.ObjectForKey(new NSString("name")); var conversationDictionaries = (NSArray)dictionary.ObjectForKey(new NSString("conversations")); var conversations = new NSMutableArray(conversationDictionaries.Count); for (nuint i = 0; i < conversationDictionaries.Count; i++) { var conversation = Conversation.ConversationWithDictionary(conversationDictionaries.GetItem <NSDictionary> (i)); conversations.Add(conversation); } var lastPhotoDictionary = NSDictionary.FromDictionary((NSDictionary)dictionary.ObjectForKey(new NSString("lastPhoto"))); return(new User { Name = name, Conversations = conversations, LastPhoto = Photo.PhotoWithDictionary(lastPhotoDictionary) }); }
void GetPopulationData() { PopulationDetails = new NSMutableArray(); PopulationDetails.Add(new SFTreeMapItem() { Label = (NSString)"Indonesia", ColorWeight = 3, Weight = 237641326 }); PopulationDetails.Add(new SFTreeMapItem() { Label = (NSString)"Russia", ColorWeight = 2, Weight = 152518015 }); PopulationDetails.Add(new SFTreeMapItem() { Label = (NSString)"United States", ColorWeight = 4, Weight = 315645000 }); PopulationDetails.Add(new SFTreeMapItem() { Label = (NSString)"Mexico", ColorWeight = 2, Weight = 112336538 }); PopulationDetails.Add(new SFTreeMapItem() { Label = (NSString)"Nigeria", ColorWeight = 2, Weight = 170901000 }); PopulationDetails.Add(new SFTreeMapItem() { Label = (NSString)"Egypt", ColorWeight = 1, Weight = 83661000 }); PopulationDetails.Add(new SFTreeMapItem() { Label = (NSString)"Germany", ColorWeight = 1, Weight = 81993000 }); PopulationDetails.Add(new SFTreeMapItem() { Label = (NSString)"France", ColorWeight = 1, Weight = 65605000 }); PopulationDetails.Add(new SFTreeMapItem() { Label = (NSString)"UK", ColorWeight = 1, Weight = 63181775 }); }
public void ReloadData(TKAutoCompleteTextView autocomplete) { NSMutableArray suggestions = new NSMutableArray(); if (airports == null) { NSUrl url = new NSUrl(urlStr); NSUrlRequest req = new NSUrlRequest(url); NSUrlResponse res; NSData dataVal = new NSData(); NSDictionary jsonResult = new NSDictionary(); NSError error; NSError errorReq; dataVal = NSUrlConnection.SendSynchronousRequest(req, out res, out errorReq); if (dataVal != null) { jsonResult = (NSDictionary)NSJsonSerialization.Deserialize(dataVal, NSJsonReadingOptions.MutableContainers, out error); if (error == null) { airports = (NSArray)jsonResult.ObjectForKey(new NSString("airports")); } for (nuint i = 0; i < airports.Count; i++) { NSDictionary item = airports.GetItem <NSDictionary> (i); NSString name = (NSString)item.ValueForKey(new NSString("FIELD2")); NSString shortName = (NSString)item.ValueForKey(new NSString("FIELD5")); string result = String.Format("{0}, {1}", name.ToString(), shortName.ToString()); if (result.ToUpper().StartsWith(prefix.ToUpper())) { suggestions.Add(new TKAutoCompleteToken(new NSString(result))); } } } DispatchQueue queue = DispatchQueue.MainQueue; queue.DispatchAfter(DispatchTime.Now, delegate { autocomplete.CompleteSuggestionViewPopulation(suggestions); }); } }
public static NSArray ToNSArray(this IList list) { var nsArray = new NSMutableArray(); var arrayType = list.GetType(); bool isArrayOfDictionaries = arrayType.IsGenericType && arrayType.GetGenericArguments()[0].GetTypeInfo().ImplementedInterfaces.Contains(typeof(IDictionary)); foreach (var item in list) { NSObject nsItem = null; if (isArrayOfDictionaries) { nsItem = ((IDictionary)item).ToNSDictionary(); } else { nsItem = NSObject.FromObject(item); } nsArray.Add(nsItem); } return(nsArray); }
public override void ViewDidLoad() { base.ViewDidLoad(); string[] imageNames = new string[] { "CENTCM.jpg", "FAMIAF.jpg", "CHOPSF.jpg", "DUMONF.jpg", "ERNSHM.jpg", "FOLIGF.jpg" }; string[] names = new string[] { "John", "Abby", "Phill", "Saly", "Robert", "Donna" }; NSMutableArray array = new NSMutableArray(); Random r = new Random(); for (int i = 0; i < imageNames.Length; i++) { UIImage image = new UIImage(imageNames [i]); this.AddItem(array, names [i], r.Next(100), r.Next(100) > 50 ? "two" : "one", r.Next(10), image); } this.dataSource.DisplayKey = "Name"; this.dataSource.ValueKey = "Value"; this.dataSource.ItemSource = array; this.useChart(this, EventArgs.Empty); }
public Rotator_Mobile() { array = new NSMutableArray(); getRotatorItem(); //Control Initialization rotator = new SFRotator(); rotator.DataSource = array; rotator.EnableLooping = true; rotator.NavigationStripMode = SFRotatorNavigationStripMode.Dots; rotator.SelectedIndex = 0; rotator.NavigationDelay = 2; getPropertiesInitialization(); this.AddSubview(main_view); this.BackgroundColor = UIColor.White; main_view.BringSubviewToFront(navigationModePicker); main_view.BringSubviewToFront(navigationDirectionPicker); main_view.BringSubviewToFront(tabStripPicker); main_view.BringSubviewToFront(doneButton); }
private void ModelChanged(object sender, EventArgs e) { // clear existing source list iSources.Release(); iSources = new NSMutableArray(); // add current list of sources foreach (Linn.Kinsky.Source source in iModel.Items) { SourceData data = new SourceData(source); iSources.AddObject(data); data.Release(); } // notify that there has been a change in the source list **before** the change in selection WillChangeValueForKey(NSString.StringWithUTF8String("sources")); DidChangeValueForKey(NSString.StringWithUTF8String("sources")); WillChangeValueForKey(NSString.StringWithUTF8String("selectionIndices")); DidChangeValueForKey(NSString.StringWithUTF8String("selectionIndices")); }
public UICaptureDrawView(CGRect frame, bool needBaseLine = true) : base(frame) { _paths = new NSMutableArray <CustomUIBezierPath>(); NeedBaseLine = needBaseLine; if (NeedBaseLine) { var signatureBaseLine = new CustomUIBezierPath { LineWidth = 1, LineColor = UIColor.Black, LineJoinStyle = CGLineJoin.Round }; _baseLineStart = new CGPoint(0, frame.Height - frame.Height / 32); _baseLineEnd = new CGPoint(frame.Width, frame.Height - frame.Height / 32); signatureBaseLine.MoveTo(_baseLineStart); signatureBaseLine.AddLineTo(_baseLineEnd); signatureBaseLine.Stroke(); _paths.Add(signatureBaseLine); } }
private void CharacteristicsOnCollectionChanged(object sender, NotifyCollectionChangedEventArgs notifyCollectionChangedEventArgs) { foreach (ICharacteristic newItem in notifyCollectionChangedEventArgs.NewItems) { switch (notifyCollectionChangedEventArgs.Action) { case NotifyCollectionChangedAction.Add: var nativeService = (CBMutableService)NativeService; NSMutableArray <CBCharacteristic> characteristics; if (NativeService.Characteristics == null) { characteristics = new NSMutableArray <CBCharacteristic>(); } else { characteristics = new NSMutableArray <CBCharacteristic>(NativeService.Characteristics); } characteristics.Add((CBCharacteristic)newItem.NativeCharacteristic); nativeService.Characteristics = characteristics.ToArray(); break; case NotifyCollectionChangedAction.Remove: // remove characteristic break; case NotifyCollectionChangedAction.Replace: // create & remove break; case NotifyCollectionChangedAction.Reset: // Remove all break; case NotifyCollectionChangedAction.Move: default: break; } } }
// // Save support: // Override one of GetAsData, GetAsFileWrapper, or WriteToUrl. // // This method should store the contents of the document using the given typeName // on the return NSData value. public override NSData GetAsData(string typeName, out NSError outError) { outError = null; // End editing tableView.Window.EndEditingFor(null); NSMutableArray array = new NSMutableArray(); foreach (Person p in Employees) { array.Add(p); } // Create an NSData object from the employees array NSData data = NSKeyedArchiver.ArchivedDataWithRootObject(array); return(data); // Default template code // outError = NSError.FromDomain(NSError.OsStatusErrorDomain, -4); // return null; }
public override void ViewDidLoad() { base.ViewDidLoad(); controls = new NSMutableArray(); // Fetching data from plist files string controlListPathString = NSBundle.MainBundle.BundlePath + "/ControlList.plist"; controlDict = new NSDictionary(); controlDict = NSDictionary.FromFile(controlListPathString); NSString controlDictKey = new NSString("Control"); controlDictArray = controlDict.ValueForKey(controlDictKey) as NSArray; this.PrepareControlList(); // Register the TableView's data source TableView.Source = new AllControlsViewSource(this); }
public void setSlider(NSMutableArray imageArray) { int width = (int)scrollView.Frame.Size.Width; int height = (int)scrollView.Frame.Size.Height; int count = 0; if (imageArray != null) { count = (int)imageArray.Count; } scrollView.ContentSize = new CoreGraphics.CGSize(width * count, height); pageControl.CurrentPage = 0; pageControl.Pages = count; scrollView.PagingEnabled = true; scrollView.Delegate = new ImageScrollDelegate(this); for (int i = 0; i < count; i++) { UIImageView imageView = new UIImageView(new CoreGraphics.CGRect(width * i, 0, width, height)); imageView.Image = imageArray.GetItem <UIImage>((System.nuint)i); scrollView.AddSubview(imageView); } }
ArrayList ChangedChildRecordsForParentRecord(UPCRMRecord parentRecord, bool userChangesOnly) { ArrayList childRecords = this.ParticipantsControl.ChangedRepParticipantAcceptanceRecords(); if (!userChangesOnly && this.ParticipantsControl.RepAcceptanceInfoAreaId.Length && !parentRecord.IsNew) { UPCRMRecord sync = new UPCRMRecord(this.ParticipantsControl.RepAcceptanceInfoAreaId, "Sync"); sync.AddLink(new UPCRMLink(parentRecord, this.ParticipantsControl.RepAcceptanceLinkId)); if (childRecords) { return(childRecords.ArrayByAddingObject(sync)); } else { return(NSMutableArray.ArrayWithObject(sync)); } } else { return(childRecords); } }
public void InsertTest() { var v1 = (NSString)"1"; var v2 = (NSString)"2"; var v3 = (NSString)"3"; using (var arr = new NSMutableArray <NSString> (v1, v3)) { Assert.AreEqual(2, arr.Count, "Insert 1"); Assert.Throws <ArgumentNullException> (() => arr.Insert(null, 0), "Insert ANE"); Assert.Throws <IndexOutOfRangeException> (() => arr.Insert(v2, -1), "Insert AOORE 1"); Assert.Throws <IndexOutOfRangeException> (() => arr.Insert(v2, 3), "Insert AOORE 2"); arr.Insert(v2, 1); Assert.AreEqual(3, arr.Count, "Insert 2"); Assert.AreSame(v1, arr [0], "[0]"); Assert.AreSame(v2, arr [1], "[1]"); Assert.AreSame(v3, arr [2], "[2]"); } using (var arr = new NSMutableArray <NSString>()) { Assert.DoesNotThrow(() => arr.Insert(v1, 0), "Insert into empty array"); } }
public void IEnumerable1Test() { const int C = 16 * 2 + 3; // NSFastEnumerator has a array of size 16, use more than that, and not an exact multiple. using (var arr = new NSMutableArray <NSString> ()) { for (int i = 0; i < C; i++) { arr.Add((NSString)i.ToString()); } Assert.AreEqual(C, arr.Count, "Count 1"); var lst = new List <NSString> (); foreach (var a in (IEnumerable <NSString>)arr) { Assert.IsNotNull(a, "null item iterator"); Assert.IsFalse(lst.Contains(a), "duplicated item iterator"); Assert.AreEqual(lst.Count.ToString(), (string)a, "#" + lst.Count.ToString()); lst.Add(a); } Assert.AreEqual(C, lst.Count, "iterator count"); } }
static NSMutableArray GetArrayFromList(List <PSPDFDrawingPoint []> lines) { if (lines == null || lines.Count == 0) { return(new NSMutableArray()); } var mainArray = new NSMutableArray((nuint)lines.Count); for (nuint i = 0; i < mainArray.Count; i++) { var points = lines [(int)i]; var innerArr = new NSMutableArray((nuint)points.Length); for (int j = 0; j < points.Length; j++) { innerArr.Insert((null as NSValue).FromPSPDFDrawingPoint(points[j]), j); } mainArray.Insert(innerArr, (nint)i); } return(mainArray); }
private void PrepareSamplesList() { NSMutableArray typesCollections = new NSMutableArray(); NSMutableArray featuresCollections = new NSMutableArray(); for (nuint i = 0; i < FeaturesCollections.Count; i++) { Control control = FeaturesCollections.GetItem <Control>(i); if (typeSamples.Contains(control.Name)) { typesCollections.Add(control); } else if (featureSamples.Contains(control.Name)) { featuresCollections.Add(control); } } TypesCollections = typesCollections; FeaturesCollections = featuresCollections; }
public void XForY_Autorelease() { using (var k = new NSString("keyz")) using (var v = new NSString("valuez")) { var k1 = k.RetainCount; if (k1 >= int.MaxValue) { Assert.Ignore("RetainCount unusable for testing"); } var k2 = k1; Assert.That(k.RetainCount, Is.EqualTo((nint)1), "Key.RetainCount-a"); var v1 = v.RetainCount; var v2 = v1; Assert.That(v.RetainCount, Is.EqualTo((nint)1), "Value.RetainCount-a"); using (var d = new NSMutableDictionary <NSString, NSString> (k, v)) { k2 = k.RetainCount; Assert.That(k2, Is.GreaterThan(k1), "Key.RetainCount-b"); v2 = v.RetainCount; Assert.That(v2, Is.GreaterThan(v1), "Value.RetainCount-b"); var x = d.KeysForObject(v); Assert.That(x [0], Is.SameAs(k), "KeysForObject"); var y = d.ObjectForKey(k); Assert.NotNull(y, "ObjectForKey"); using (var a = new NSMutableArray()) { a.Add(k); var z = d.ObjectsForKeys(a, k); Assert.That(z [0], Is.SameAs(v), "ObjectsForKeys"); } Assert.That(k.RetainCount, Is.EqualTo(k2), "Key.RetainCount-c"); Assert.That(v.RetainCount, Is.EqualTo(v2), "Value.RetainCount-c"); } Assert.That(k.RetainCount, Is.LessThan(k2), "Key.RetainCount-d"); Assert.That(v.RetainCount, Is.LessThan(v2), "Value.RetainCount-d"); } }
public void AddObjectsTest() { var v1 = (NSString)"1"; var v2 = (NSString)"2"; var v3 = (NSString)"3"; using (var arr = new NSMutableArray <NSString> ()) { Assert.Throws <ArgumentNullException> (() => arr.AddObjects((NSString[])null), "AddObjects ANE 1"); Assert.AreEqual(0, arr.Count, "Count 1"); Assert.Throws <ArgumentNullException> (() => arr.AddObjects(new NSString [] { null }), "AddObjects ANE 2"); Assert.AreEqual(0, arr.Count, "Count 2"); Assert.Throws <ArgumentNullException> (() => arr.AddObjects(new NSString [] { v1, null, v3 }), "AddObjects ANE 3"); Assert.AreEqual(0, arr.Count, "Count 3"); arr.AddObjects(v1, v2); Assert.AreEqual(2, arr.Count, "AddObjects 1"); Assert.AreSame(v1, arr [0], "a [0]"); Assert.AreSame(v2, arr [1], "a [1]"); } }
void SetupTour() { var tour = Tour.Instance; if (tour.IsEnabled) { if (tour.Step == 3) { productTour = new ProductTour(); productTour.Frame = new RectangleF(0, 0, View.Bounds.Width, View.Bounds.Height); var bubble = new Bubble(queueButton, "VERSES QUEUE", "Click to reveal\nunmemorized verses.", ArrowPosition.Top, null); bubble.FontName = "SourceSansPro-Bold"; var bubbleArray = new NSMutableArray(1); bubbleArray.Add(bubble); productTour.Bubbles = bubbleArray; Add(productTour); } } }