public void TableViewWillDisplayCell(NSTableView aView, Id aCell, NSTableColumn aTableColumn, int aRow) { NSString identifier = aTableColumn.Identifier.CastTo <NSString>(); if (identifier.Compare(NSString.StringWithUTF8String("standby")) == NSComparisonResult.NSOrderedSame) { NSButtonCell cell = aCell.CastTo <NSButtonCell>(); Room r = iModel.Items[aRow]; cell.Image = r.Standby ? Properties.Resources.IconStandby : Properties.Resources.IconStandbyOn; cell.AlternateImage = r.Standby ? Properties.Resources.IconStandby : Properties.Resources.IconStandbyOn; cell.IsEnabled = !r.Standby; } if (identifier.Compare(NSString.StringWithUTF8String("selected")) == NSComparisonResult.NSOrderedSame) { NSImageCell cell = aCell.CastTo <NSImageCell>(); if (aRow == SelectedIndex) { cell.Image = Properties.Resources.IconTick; cell.IsEnabled = true; } else { cell.Image = null; cell.IsEnabled = false; } } }
public void Compare() { using (NSString s1 = new NSString("Sebastien")) using (NSString s2 = new NSString("Sébastien")) { Assert.That(s1.Compare(s1), Is.EqualTo(NSComparisonResult.Same), "Same"); Assert.That(s1.Compare(s2), Is.EqualTo(NSComparisonResult.Ascending), "Ascending"); Assert.That(s2.Compare(s1), Is.EqualTo(NSComparisonResult.Descending), "Descending"); } }
public void Compare_Locale() { using (NSString s1 = new NSString("sebastien")) using (NSString s2 = new NSString("Sébastien")) { NSStringCompareOptions options = NSStringCompareOptions.DiacriticInsensitiveSearch | NSStringCompareOptions.CaseInsensitiveSearch; NSRange r = new NSRange(0, s2.Length); Assert.That(s1.Compare(s2, options, r, null), Is.EqualTo(NSComparisonResult.Same), "null"); Assert.That(s1.Compare(s2, options, r, NSLocale.SystemLocale), Is.EqualTo(NSComparisonResult.Same), "SystemLocale"); } }
public void Compare_Options() { using (NSString s1 = new NSString("Sebastien")) using (NSString s2 = new NSString("Sébastien")) { Assert.That(s1.Compare(s2, NSStringCompareOptions.DiacriticInsensitiveSearch), Is.EqualTo(NSComparisonResult.Same), "DiacriticInsensitiveSearch"); } }
public void Compare_Range() { using (NSString s1 = new NSString("Bastien")) using (NSString s2 = new NSString("Sébastien")) { NSRange r = new NSRange(2, s2.Length - 2); Assert.That(s2.Compare(s1, NSStringCompareOptions.CaseInsensitiveSearch, r), Is.EqualTo(NSComparisonResult.Same), "skip accent"); } }
// requested in http://bugzilla.xamarin.com/show_bug.cgi?id=1870 public void Replace_Range() { using (NSString s1 = new NSString("Sebastien")) using (NSString s2 = new NSString("é")) using (NSString s3 = new NSString("sébastien")) using (NSString result = s1.Replace(new NSRange(1, 1), s2)) { NSStringCompareOptions options = NSStringCompareOptions.CaseInsensitiveSearch; Assert.That(result.Compare(s3, options), Is.EqualTo(NSComparisonResult.Same), "Replace"); } }
public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation) { if (url.Scheme.Equals("iosParking") || url.Scheme.Equals("iosparking")) { string[] paramters = url.Query.Split(new char[] { '&' }, 1000); NSMutableDictionary urlParamters = new NSMutableDictionary(); foreach (string paramterValuePair in paramters) { string[] arr = paramterValuePair.Split(new char[] { '=' }, 1000); urlParamters.SetValueForKey(new NSString(arr [1]), new NSString(arr [0])); } NSString value = (NSString)urlParamters.ObjectForKey(new NSString("response")); if (value.Compare(new NSString("ok")) == NSComparisonResult.Same) { //Show messaage saying that the payment was ok Console.WriteLine("Payment OK"); } else if (value.Compare(new NSString("cancel")) == NSComparisonResult.Same) { //Show messaage saying that the payment was rejected by the user Console.WriteLine("Payment Cancelled"); } else { //Here an error ocurred proccessing the payment Console.WriteLine("Payment Error"); } return(true); } else { return(false); } }
public void Equality() { using (var s1 = new NSString("\u00f6")) // o-umlaut using (var s2 = new NSString("o\u0308")) { // o + combining diaeresis // since ObjC thinks it's different Assert.That(s1.GetHashCode(), Is.Not.EqualTo(s2.GetHashCode()), "GetHashCode"); // then it's "correct" to return false for equality Assert.False(s1.Equals((object)s2), "Equal(object)"); Assert.False(s1.Equals((NSObject)s2), "Equal(NSObject)"); Assert.False(s1.Equals((NSString)s2), "Equal(NSString)"); Assert.False(NSString.Equals(s1, s2), "static"); // and people need to call compare Assert.That(s1.Compare(s2), Is.EqualTo(NSComparisonResult.Same), "Same"); } }
public static void OpenInMaps(Place place ) { bool canDoIOS6Maps = false; using (NSString curVer = new NSString (UIDevice.CurrentDevice.SystemVersion)) { using (NSString targetVar = new NSString ("6.0")) { canDoIOS6Maps = curVer.Compare ( targetVar, NSStringCompareOptions.NumericSearch) != NSComparisonResult.Ascending; } } if (canDoIOS6Maps) OpenIOSMap (place); else OpenGoogleMap (place); }
public void TableViewWillDisplayCell(NSTableView aView, NSCell aCell, NSTableColumn aTableColumn, int aRow) { NSString identifier = aTableColumn.Identifier.CastTo <NSString>(); if (identifier.Compare(NSString.StringWithUTF8String("selected")) == NSComparisonResult.NSOrderedSame) { NSImageCell cell = aCell.CastTo <NSImageCell>(); if (aRow == SelectedIndex) { cell.Image = Properties.Resources.IconTick; cell.IsEnabled = true; } else { cell.Image = null; cell.IsEnabled = false; } } else { aCell.RepresentedObject = iSources.ObjectAtIndex((uint)aRow); } }
public void Compare_Null() { using (NSString s = new NSString("s")) { s.Compare(null); } }
public void Compare_Null() { using (NSString s = new NSString("s")) { Assert.Throws <ArgumentNullException> (() => s.Compare(null)); } }
public void Initialize() { CAEAGLLayer eaglLayer = (CAEAGLLayer)Layer; eaglLayer.Opaque = true; eaglLayer.DrawableProperties = NSDictionary.FromObjectsAndKeys( new object[] { NSNumber.FromBoolean(false), EAGLColorFormat.RGBA8 }, new object[] { EAGLDrawableProperty.RetainedBacking, EAGLDrawableProperty.ColorFormat }); m_context = new EAGLContext(EAGLRenderingAPI.OpenGLES2); if(m_context == null || !EAGLContext.SetCurrentContext(m_context)) { throw new ApplicationException("Could not create/set EAGLContext"); } m_renderer = new ES2Renderer(); m_renderer.InitWithContext(m_context, (CAEAGLLayer)Layer); Animating = false; displayLinkSupported = false; animationFrameInterval = 1; displayLink = null; animationTimer = null; // A system version of 3.1 or greater is required to use CADisplayLink. The NSTimer // class is used as fallback when it isn't available. var reqSysVer = new NSString("3.1"); var currSysVer = new NSString(UIDevice.CurrentDevice.SystemVersion); if(currSysVer.Compare(reqSysVer, NSStringCompareOptions.NumericSearch) != NSComparisonResult.Ascending) displayLinkSupported = true; }