public static CFHTTPMessage CreateRequest(Uri uri, string method, Version version) { if (uri == null) { throw new ArgumentNullException("uri"); } CFUrl urlRef = null; NSString methodRef = null; var escaped = Uri.EscapeUriString(uri.ToString()); try { urlRef = CFUrl.FromUrlString(escaped, null); if (urlRef == null) { throw new ArgumentException("Invalid URL."); } methodRef = new NSString(method); return(CreateRequest(urlRef, methodRef, version)); } finally { if (urlRef != null) { urlRef.Dispose(); } if (methodRef != null) { methodRef.Dispose(); } } }
public static MonoTouch.UIKit.UIView GetHook(string hook, int x, int y, MonoTouch.UIKit.UIView view, bool attachToView, string orientation, string canvasOrientation, bool refresh, bool canvasAnimated, string rewardMessage, NSDictionary userCookies) { if (hook == null) throw new ArgumentNullException ("hook"); if (view == null) throw new ArgumentNullException ("view"); if (orientation == null) throw new ArgumentNullException ("orientation"); if (canvasOrientation == null) throw new ArgumentNullException ("canvasOrientation"); if (rewardMessage == null) throw new ArgumentNullException ("rewardMessage"); if (userCookies == null) throw new ArgumentNullException ("userCookies"); var nshook = new NSString (hook); var nsorientation = new NSString (orientation); var nscanvasOrientation = new NSString (canvasOrientation); var nsrewardMessage = new NSString (rewardMessage); MonoTouch.UIKit.UIView ret; ret = (MonoTouch.UIKit.UIView) Runtime.GetNSObject (Messaging.IntPtr_objc_msgSend_IntPtr_int_int_IntPtr_bool_IntPtr_IntPtr_bool_bool_IntPtr_IntPtr (class_ptr, selGetHookXLocYLocViewAttachToViewOrientationCanvasOrientationAutoRefreshCanvasAnimatedRewardMessageUserCookies, nshook.Handle, x, y, view.Handle, attachToView, nsorientation.Handle, nscanvasOrientation.Handle, refresh, canvasAnimated, nsrewardMessage.Handle, userCookies.Handle)); nshook.Dispose (); nsorientation.Dispose (); nscanvasOrientation.Dispose (); nsrewardMessage.Dispose (); return ret; }
void ProcessNotificationActions(NSDictionary userInfo) { if (userInfo == null) { return; } NSString actionKey = null; NSString actionValue = null; try { actionValue = userInfo.ObjectForKey(actionKey = new NSString("action")) as NSString; if (!string.IsNullOrWhiteSpace(actionValue?.Description)) { NotificationActionService.TriggerAction(actionValue.Description); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { actionKey?.Dispose(); actionValue?.Dispose(); } }
public override Xamarin.Forms.Size Measure(string text, double fontSize, string fontName) { UIFont font = this.getFont(fontName, fontSize); UIStringAttributes attributes = new UIStringAttributes(); attributes.Font = font; SizeF boundSize = new SizeF(float.PositiveInfinity, float.PositiveInfinity); NSStringDrawingOptions options = NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin; NSString nsText = new NSString(text); CGSize resultSize = nsText.GetBoundingRect( boundSize, options, attributes, null).Size; nsText.Dispose(); return(new Xamarin.Forms.Size( Math.Ceiling((double)resultSize.Width), Math.Ceiling((double)resultSize.Height))); }
////public override NSObject Annotation ////{ //// get //// { //// return base.Annotation; //// } //// set //// { //// base.Annotation = value; //// this.Redraw(); //// } ////} ////private void Redraw() ////{ //// this.Draw(this.Frame); ////} public override void Draw(CGRect rect) { base.Draw(rect); var annotation = this.Annotation as ClusterMapAnnotation; if (annotation == null) { return; } using (var context = UIGraphics.GetCurrentContext()) { context.SetLineWidth(1.0f); context.SetFillColor(this.color1); context.SetAlpha(0.5f); context.FillEllipseInRect(new RectangleF(0f, 0f, this.Diameter, this.Diameter)); context.SetFillColor(this.color2); context.SetAlpha(1.0f); context.FillEllipseInRect(new RectangleF((this.Diameter - this.diameter2) / 2, (this.Diameter - this.diameter2) / 2, this.diameter2, this.diameter2)); context.SetFillColor(this.Color.CGColor); context.SetAlpha(1.0f); context.FillEllipseInRect(new RectangleF((this.Diameter - this.diameter3) / 2, (this.Diameter - this.diameter3) / 2, this.diameter3, this.diameter3)); NSString titleString = new NSString(annotation.Title); UIColor.White.SetColor(); UIFont font = UIFont.BoldSystemFontOfSize(10.0f); titleString.DrawString(new RectangleF(((float)this.CenterOffset.X) / 2, ((float)this.CenterOffset.Y) / 2, this.diameter3, this.diameter3), font); titleString.Dispose(); } }
public static void OpenTakeover(string hook, string orientation, MonoTouch.UIKit.UIImage image, string message, NSDictionary userCookies) { if (hook == null) { throw new ArgumentNullException("hook"); } if (orientation == null) { throw new ArgumentNullException("orientation"); } if (image == null) { throw new ArgumentNullException("image"); } if (message == null) { throw new ArgumentNullException("message"); } if (userCookies == null) { throw new ArgumentNullException("userCookies"); } var nshook = new NSString(hook); var nsorientation = new NSString(orientation); var nsmessage = new NSString(message); Messaging.void_objc_msgSend_IntPtr_IntPtr_IntPtr_IntPtr_IntPtr(class_ptr, selOpenTakeoverOrientationRewardImageRewardMessageUserCookies, nshook.Handle, nsorientation.Handle, image.Handle, nsmessage.Handle, userCookies.Handle); nshook.Dispose(); nsorientation.Dispose(); nsmessage.Dispose(); }
public void Dispose() { Debug.Assert(!_disposed); _disposed = true; _native.Dispose(); GC.SuppressFinalize(this); }
public override void DrawFooterForPage(int index, RectangleF footerRect) { NSString footer = new NSString(string.Format("Page {0} of {1}", index - pageRange.Location + 1, pageRange.Length)); footer.DrawString(footerRect, SystemFont, UILineBreakMode.Clip, UITextAlignment.Center); footer.Dispose(); }
public override void DrawFooterForPage(nint index, CGRect footerRect) { var item = printItem [index].First(); NSString footer = new NSString(item.Key.ToString()); footer.DrawString(footerRect, eBriefingAppearance.ThemeRegularFont(10f), UILineBreakMode.Clip, UITextAlignment.Center); footer.Dispose(); }
public void SetString(string value, string defaultName) { NSString str = new NSString(value); SetObjectForKey(str, defaultName); str.Dispose(); }
public void SetString (string value, string defaultName) { NSString str = new NSString (value); SetObjectForKey (str, defaultName); str.Dispose (); }
public override void Draw(RectangleF rect) { WeatherForecastAnnotation annotation; CGPath path; base.Draw(rect); annotation = Annotation as WeatherForecastAnnotation; if (annotation == null) { return; } // Get the current graphics context CGContext context = UIGraphics.GetCurrentContext(); context.SetLineWidth(1.0f); // Draw the gray pointed shape: path = new CGPath(); path.MoveToPoint(14.0f, 0.0f); path.AddLineToPoint(0.0f, 0.0f); path.AddLineToPoint(55.0f, 50.0f); context.AddPath(path); context.SetFillColor(UIColor.LightGray.CGColor); context.SetStrokeColor(UIColor.Gray.CGColor); context.DrawPath(CGPathDrawingMode.FillStroke); // Draw the cyan rounded box path = new CGPath(); path.MoveToPoint(15.0f, 0.5f); path.AddArcToPoint(59.5f, 00.5f, 59.5f, 05.0f, 5.0f); path.AddArcToPoint(59.5f, 69.5f, 55.5f, 69.5f, 5.0f); path.AddArcToPoint(10.5f, 69.5f, 10.5f, 64.0f, 5.0f); path.AddArcToPoint(10.5f, 00.5f, 15.5f, 00.5f, 5.0f); context.AddPath(path); context.SetFillColor(UIColor.Cyan.CGColor); context.SetStrokeColor(UIColor.Blue.CGColor); context.DrawPath(CGPathDrawingMode.FillStroke); // Create the location & temperature string WeatherForecast forecast = annotation.Forecast; NSString temperature = new NSString(string.Format("{0}\n{1} / {2}", forecast.Place, forecast.High, forecast.Low)); // Draw the text in black UIColor.Black.SetColor(); temperature.DrawString(new RectangleF(15.0f, 5.0f, 50.0f, 40.0f), UIFont.SystemFontOfSize(11.0f)); temperature.Dispose(); // Draw the icon for the weather condition string imageName = string.Format("WeatherMap.WeatherIcons.{0}.png", forecast.Condition); UIImage image = UIImage.FromResource(typeof(WeatherAnnotationView).Assembly, imageName); image.Draw(new RectangleF(12.5f, 28.0f, 45.0f, 45.0f)); image.Dispose(); }
public void AddAnimation(CAAnimation animation, string key = null) { NSString nskey = key == null ? null : new NSString(key); AddAnimation(animation, nskey); if (nskey != null) { nskey.Dispose(); } }
protected override void Dispose(bool disposing) { if (disposing && CellId != null) { CellId.Dispose(); CellId = null; } base.Dispose(disposing); }
public static void RemoveLoginItem(string path) { if (path == null) { throw new ArgumentNullException("path"); } var nspath = new NSString(path); MonoMac.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr(class_ptr, selRemoveLoginItem, nspath.Handle); nspath.Dispose(); }
protected override void Dispose(bool disposing) { if (disposing) { if (CellResuse != null) { CellResuse.Dispose(); } } base.Dispose(disposing); }
static public SecPolicy CreateSslPolicy(bool server, string hostName) { NSString host = hostName == null ? null : new NSString(hostName); IntPtr handle = host == null ? IntPtr.Zero : host.Handle; SecPolicy policy = new SecPolicy(SecPolicyCreateSSL(server, handle), true); if (host != null) { host.Dispose(); } return(policy); }
// Custom UIPrintPageRenderer's may override this class to draw a custom print page header. // To illustrate that, this class sets the date in the header. public override void DrawHeaderForPage(int index, RectangleF headerRect) { NSDateFormatter dateFormatter = new NSDateFormatter(); dateFormatter.DateFormat = "MMMM d, yyyy 'at' h:mm a"; NSString dateString = new NSString(dateFormatter.ToString(NSDate.Now)); dateFormatter.Dispose(); dateString.DrawString(headerRect, SystemFont, UILineBreakMode.Clip, UITextAlignment.Right); dateString.Dispose(); }
public void SetHeaderFieldValue(string name, string value) { NSString nstr = (NSString)name; NSString vstr = value != null ? (NSString)value : null; IntPtr vptr = vstr != null ? vstr.Handle : IntPtr.Zero; CFHTTPMessageSetHeaderFieldValue(Handle, nstr.Handle, vptr); nstr.Dispose(); if (vstr != null) { vstr.Dispose(); } }
static AccessoryInfo[] ExtractAccessoryInfo (IntPtr ptr, NSString id, NSString description) { using (var array = new CFArray (ptr)) { var res = new AccessoryInfo [array.Count]; for (int i = 0; i < res.Length; ++i) { var dict = array.GetValue (i); var n = new NSNumber (CFDictionary.GetValue (dict, id.Handle)); var desc = CFString.FetchString (CFDictionary.GetValue (dict, description.Handle)); res [i] = new AccessoryInfo ((int) n, desc); id.Dispose (); } return res; } }
public static string Echo(string message) { if (message == null) { throw new ArgumentNullException("message"); } var nsmessage = new NSString(message); string ret; ret = NSString.FromHandle(MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr(class_ptr, selEcho_, nsmessage.Handle)); nsmessage.Dispose(); return(ret); }
public virtual void CustomizeViewWithText(string message) { if (message == null) { throw new ArgumentNullException("message"); } var nsmessage = new NSString(message); if (IsDirectBinding) { MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr(this.Handle, selCustomizeViewWithText_, nsmessage.Handle); } else { MonoTouch.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr(this.SuperHandle, selCustomizeViewWithText_, nsmessage.Handle); } nsmessage.Dispose(); }
protected override void Dispose(bool disposing) { if (disposing) { if (MemberData != null) { MemberData.Dispose(); MemberData = null; } if (CellId != null) { CellId.Dispose(); } if (NavigationView != null) { var disposable = NavigationView as IDisposable; if (disposable != null) { disposable.Dispose(); NavigationView = null; } } if (NavigationSource != null) { NavigationSource.Dispose(); NavigationSource = null; } //TODO: Should this be disposed here?? foreach (var section in Sections.Values) { var disposable = section.DataContext as IDisposable; if (disposable != null) { disposable.Dispose(); } } } base.Dispose(disposing); }
static string NSObjectToJSON(NSObject obj) { NSError err; NSData jsonData = NSJsonSerialization.Serialize(obj, 0, out err); if (err != null) { return(string.Empty); } NSString myString = NSString.FromData(jsonData, NSStringEncoding.UTF8); jsonData.Dispose(); var json = myString.ToString(); myString.Dispose(); return(json); }
public void SetHeaderFieldValue(string name, string value) { if (name == null) { throw new ArgumentNullException("name"); } NSString nstr = (NSString)name; NSString vstr = value != null ? (NSString)value : null; IntPtr vptr = vstr != null ? vstr.Handle : IntPtr.Zero; CFHTTPMessageSetHeaderFieldValue(Handle, nstr.Handle, vptr); nstr.Dispose(); if (vstr != null) { vstr.Dispose(); } }
public Xamarin.Forms.Size GetTextSize( string text, double maxWidth, double fontSize = 0, string fontName = null) { if (fontSize <= 0) { fontSize = UIFont.SystemFontSize; } UIFont font = null; if (string.IsNullOrEmpty(fontName)) { font = UIFont.SystemFontOfSize((nfloat)fontSize); } else { font = UIFont.FromName(fontName, (nfloat)fontSize); } var attributes = new UIStringAttributes { Font = font }; var boundSize = new SizeF((float)maxWidth, float.MaxValue); var options = NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin; var nsText = new NSString(text); var resultSize = nsText.GetBoundingRect( boundSize, options, attributes, null).Size; font.Dispose(); nsText.Dispose(); return(new Xamarin.Forms.Size( Math.Ceiling((double)resultSize.Width), Math.Ceiling((double)resultSize.Height))); }
public static void OpenTakeover(string hook, string orientation, MonoTouch.UIKit.UIImage image, string message, NSDictionary userCookies) { if (hook == null) throw new ArgumentNullException ("hook"); if (orientation == null) throw new ArgumentNullException ("orientation"); if (image == null) throw new ArgumentNullException ("image"); if (message == null) throw new ArgumentNullException ("message"); if (userCookies == null) throw new ArgumentNullException ("userCookies"); var nshook = new NSString (hook); var nsorientation = new NSString (orientation); var nsmessage = new NSString (message); Messaging.void_objc_msgSend_IntPtr_IntPtr_IntPtr_IntPtr_IntPtr (class_ptr, selOpenTakeoverOrientationRewardImageRewardMessageUserCookies, nshook.Handle, nsorientation.Handle, image.Handle, nsmessage.Handle, userCookies.Handle); nshook.Dispose (); nsorientation.Dispose (); nsmessage.Dispose (); }
public static MonoTouch.UIKit.UIView GetHook(string hook, int x, int y, MonoTouch.UIKit.UIView view, bool attachToView, string orientation, string canvasOrientation, bool refresh, bool canvasAnimated, string rewardMessage, NSDictionary userCookies) { if (hook == null) { throw new ArgumentNullException("hook"); } if (view == null) { throw new ArgumentNullException("view"); } if (orientation == null) { throw new ArgumentNullException("orientation"); } if (canvasOrientation == null) { throw new ArgumentNullException("canvasOrientation"); } if (rewardMessage == null) { throw new ArgumentNullException("rewardMessage"); } if (userCookies == null) { throw new ArgumentNullException("userCookies"); } var nshook = new NSString(hook); var nsorientation = new NSString(orientation); var nscanvasOrientation = new NSString(canvasOrientation); var nsrewardMessage = new NSString(rewardMessage); MonoTouch.UIKit.UIView ret; ret = (MonoTouch.UIKit.UIView)Runtime.GetNSObject(Messaging.IntPtr_objc_msgSend_IntPtr_int_int_IntPtr_bool_IntPtr_IntPtr_bool_bool_IntPtr_IntPtr(class_ptr, selGetHookXLocYLocViewAttachToViewOrientationCanvasOrientationAutoRefreshCanvasAnimatedRewardMessageUserCookies, nshook.Handle, x, y, view.Handle, attachToView, nsorientation.Handle, nscanvasOrientation.Handle, refresh, canvasAnimated, nsrewardMessage.Handle, userCookies.Handle)); nshook.Dispose(); nsorientation.Dispose(); nscanvasOrientation.Dispose(); nsrewardMessage.Dispose(); return(ret); }
public virtual string Hello(string name) { if (name == null) { throw new ArgumentNullException("name"); } var nsname = new NSString(name); string ret; if (IsDirectBinding) { ret = NSString.FromHandle(MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr(this.Handle, selHello_, nsname.Handle)); } else { ret = NSString.FromHandle(MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_IntPtr(this.SuperHandle, selHello_, nsname.Handle)); } nsname.Dispose(); return(ret); }
public static CFHTTPMessage CreateRequest(Uri uri, string method, Version version) { if (uri == null) { throw new ArgumentNullException("uri"); } CFUrl urlRef = null; NSString methodRef = null; // the method is obsolete, but EscapeDataString does not work the same way. We could get the components // of the Uri and then EscapeDataString, but this might introduce bugs, so for now we will ignore the warning #pragma warning disable SYSLIB0013 var escaped = Uri.EscapeUriString(uri.ToString()); #pragma warning restore SYSLIB0013 try { urlRef = CFUrl.FromUrlString(escaped, null); if (urlRef == null) { throw new ArgumentException("Invalid URL."); } methodRef = new NSString(method); return(CreateRequest(urlRef, methodRef, version)); } finally { if (urlRef != null) { urlRef.Dispose(); } if (methodRef != null) { methodRef.Dispose(); } } }
public override void DrawHeaderForPage(nint index, CoreGraphics.CGRect headerRect) { xPoint = paperWidth / 1.7f; yPoint = 36f; var item = printItem [index].First(); var printContent = item.Value; string headerText = ""; if (printContent.PdfImage == null) { headerText = String.Format("Notes Continued (pg {0})", item.Key.ToString()); } else if (printContent.PdfImage != null && printContent.Note != null) { headerText = String.Format("{0} Notes (pg {1})", printContent.NoteCount.ToString(), item.Key.ToString()); } var pageNumberString = new NSString(headerText); pageNumberString.DrawString(headerRect, eBriefingAppearance.ThemeRegularFont(12f), UILineBreakMode.Clip, UITextAlignment.Center); pageNumberString.Dispose(); }
public override void Draw (CGRect rect) { WeatherForecastAnnotation annotation; CGPath path; base.Draw (rect); annotation = Annotation as WeatherForecastAnnotation; if (annotation == null) return; // Get the current graphics context using (var context = UIGraphics.GetCurrentContext ()) { context.SetLineWidth (1.0f); // Draw the gray pointed shape: path = new CGPath (); path.MoveToPoint (14.0f, 0.0f); path.AddLineToPoint (0.0f, 0.0f); path.AddLineToPoint (55.0f, 50.0f); context.AddPath (path); context.SetFillColor (UIColor.LightGray.CGColor); context.SetStrokeColor (UIColor.Gray.CGColor); context.DrawPath (CGPathDrawingMode.FillStroke); // Draw the cyan rounded box path = new CGPath (); path.MoveToPoint (15.0f, 0.5f); path.AddArcToPoint (59.5f, 00.5f, 59.5f, 05.0f, 5.0f); path.AddArcToPoint (59.5f, 69.5f, 55.5f, 69.5f, 5.0f); path.AddArcToPoint (10.5f, 69.5f, 10.5f, 64.0f, 5.0f); path.AddArcToPoint (10.5f, 00.5f, 15.5f, 00.5f, 5.0f); context.AddPath (path); context.SetFillColor (UIColor.Cyan.CGColor); context.SetStrokeColor (UIColor.Blue.CGColor); context.DrawPath (CGPathDrawingMode.FillStroke); // Create the location & temperature string WeatherForecast forecast = annotation.Forecast; NSString temperature = new NSString (string.Format ("{0}\n{1} / {2}", forecast.Place, forecast.High, forecast.Low)); // Draw the text in black UIColor.Black.SetColor (); temperature.DrawString (new CGRect (15.0f, 5.0f, 50.0f, 40.0f), UIFont.SystemFontOfSize (11.0f)); temperature.Dispose (); // Draw the icon for the weather condition string imageName = string.Format ("WeatherMap.WeatherIcons.{0}.png", forecast.Condition); UIImage image = UIImage.FromResource (typeof(WeatherAnnotationView).Assembly, imageName); image.Draw (new CGRect (12.5f, 28.0f, 45.0f, 45.0f)); image.Dispose (); } }
public override void Draw(CGRect rect) { base.Draw(rect); if (_Annotation == null) { return; } using (var context = UIGraphics.GetCurrentContext()) { // Line1, FLight, Hex and Last seen CGRect trect = new CGRect(rect.X + 5, rect.Y, rect.Width, 9); NSString text = new NSString( string.Format("Flight: {0}", (_Annotation._Flight.Length == 0) ? "N/A" : _Annotation._Flight) ); UIColor.White.SetColor(); text.DrawString(trect, UIFont.BoldSystemFontOfSize(9.0f)); text.Dispose(); trect = new CGRect(rect.Width / 2, rect.Y, rect.Width, 9); text = new NSString( string.Format("Hex: {0}", (_Annotation._Hex.Length == 0) ? "N/A" : _Annotation._Hex) ); UIColor.White.SetColor(); text.DrawString(trect, UIFont.BoldSystemFontOfSize(9.0f)); text.Dispose(); /*Planes.PlaneDetails pd = Planes.PlanesList.Find (p => p._Hex == _Annotation._Hex); * if (pd != null) { * TimeSpan ts = DateTime.Now - pd._LastSeen; * trect = new CGRect (170, rect.Y, rect.Width, 9); * text = new NSString ( * string.Format ("({0:00}:{1:00})", ts.TotalMinutes, ts.TotalSeconds) * ); * UIColor.White.SetColor (); * text.DrawString (trect, UIFont.BoldSystemFontOfSize (9.0f)); * text.Dispose (); * }*/ // Line2, Callsign and Type trect = new CGRect(rect.X + 5, rect.Y + 9, rect.Width, 9); text = new NSString( string.Format("Callsign: {0}", (_Annotation._PCode.Length == 0) ? "N/A" : _Annotation._PCode) ); UIColor.White.SetColor(); text.DrawString(trect, UIFont.BoldSystemFontOfSize(9.0f)); text.Dispose(); trect = new CGRect(rect.Width / 2, rect.Y + 9, rect.Width, 9); text = new NSString( string.Format("Type: {0}", (_Annotation._PType.Length == 0) ? "N/A" : _Annotation._PType) ); UIColor.White.SetColor(); text.DrawString(trect, UIFont.BoldSystemFontOfSize(9.0f)); text.Dispose(); // Line3, Altitude, Picture trect = new CGRect(rect.X + 5, rect.Y + 18, rect.Width, 9); text = new NSString( string.Format("Altitude: {0}ft", _Annotation._Level.ToString()) ); if (_Annotation._ChangingElevation == PlaneAnnotation.ChangingElevation.Climbing) { UIColor.Green.SetColor(); } else if (_Annotation._ChangingElevation == PlaneAnnotation.ChangingElevation.Descending) { UIColor.Orange.SetColor(); } else { UIColor.White.SetColor(); } text.DrawString(trect, UIFont.BoldSystemFontOfSize(9.0f)); text.Dispose(); if (File.Exists(_cachePicture)) { _PlaneImageView.Image = UIImage.FromFile(_cachePicture); } else { _PlaneImageView.Image = null; } // Line 4, Heading trect = new CGRect(rect.X + 5, rect.Y + 27, rect.Width, 9); text = new NSString( string.Format("Heading: {0}°", _Annotation._Heading.ToString()) ); UIColor.White.SetColor(); text.DrawString(trect, UIFont.BoldSystemFontOfSize(9.0f)); text.Dispose(); // Line 5, Speed trect = new CGRect(rect.X + 5, rect.Y + 36, rect.Width, 9); text = new NSString( string.Format("Speed: {0:0.0}km/h", _Annotation._Speed * 1.852 ) ); if (_Annotation._ChangingSpeed == PlaneAnnotation.ChangingSpeed.Accelerating) { UIColor.Green.SetColor(); } else if (_Annotation._ChangingSpeed == PlaneAnnotation.ChangingSpeed.Decelerating) { UIColor.Orange.SetColor(); } else { UIColor.White.SetColor(); } text.DrawString(trect, UIFont.BoldSystemFontOfSize(9.0f)); text.Dispose(); // Line 6, Coordinates trect = new CGRect(rect.X + 5, rect.Y + 45, rect.Width, 9); text = new NSString( string.Format("Coordinates: {0:0.0000}, {1:0.0000} ({2})", _Annotation.Coordinate.Longitude, _Annotation.Coordinate.Latitude, _Annotation._IsFaa ? "Calculated" : (_Annotation._Heading == 0 && _Annotation._Speed == 0) ? "M-LAT" : "Real-time") ); if (_Annotation._SameCoord) { UIColor.Orange.SetColor(); } else { UIColor.White.SetColor(); } text.DrawString(trect, UIFont.BoldSystemFontOfSize(9.0f)); text.Dispose(); // Line 7, Route double distance = 0; if (_Annotation._RouteDetail.ToAirportLat != 0 && _Annotation._RouteDetail.ToAirportLong != 0) { distance = GetDistanceFromLatLonInKm( _Annotation.Coordinate.Latitude, _Annotation.Coordinate.Longitude, _Annotation._RouteDetail.ToAirportLat, _Annotation._RouteDetail.ToAirportLong); } trect = new CGRect(rect.X + 5, rect.Y + 54, rect.Width, 9); text = new NSString( string.Format("Distance: {0:0.0}km - ETA: {1}", distance, CalcETA(distance, _Annotation._Speed * 1.852) ) ); UIColor.White.SetColor(); text.DrawString(trect, UIFont.BoldSystemFontOfSize(9.0f)); text.Dispose(); // Line 8, From _FromFlagImageView.Image = UIImage.FromBundle("Flags/" + _Annotation._RouteDetail.FromAirportCountryCode); trect = new CGRect(rect.X + 5, rect.Y + 63, rect.Width, 9); text = new NSString( string.Format("From: ({0}) {1}, {2}", string.IsNullOrEmpty(_Annotation._RouteDetail.FromAirportCode) ? "N/A" : _Annotation._RouteDetail.FromAirportCode, string.IsNullOrEmpty(_Annotation._RouteDetail.FromAirportCity) ? "N/A" : _Annotation._RouteDetail.FromAirportCity, string.IsNullOrEmpty(_Annotation._RouteDetail.FromAirportCountryCode) ? "N/A" : _Annotation._RouteDetail.FromAirportCountryCode.ToUpper() ) ); UIColor.White.SetColor(); text.DrawString(trect, UIFont.BoldSystemFontOfSize(9.0f)); text.Dispose(); // Line 9, To _ToFlagImageView.Image = UIImage.FromBundle("Flags/" + _Annotation._RouteDetail.ToAirportCountryCode); trect = new CGRect(rect.X + 5, rect.Y + 72, rect.Width, 9); text = new NSString( string.Format("To: ({0}) {1}, {2}", string.IsNullOrEmpty(_Annotation._RouteDetail.ToAirportCode) ? "N/A" : _Annotation._RouteDetail.ToAirportCode, string.IsNullOrEmpty(_Annotation._RouteDetail.ToAirportCity) ? "N/A" : _Annotation._RouteDetail.ToAirportCity, string.IsNullOrEmpty(_Annotation._RouteDetail.ToAirportCountryCode) ? "N/A" : _Annotation._RouteDetail.ToAirportCountryCode.ToUpper() ) ); UIColor.White.SetColor(); text.DrawString(trect, UIFont.BoldSystemFontOfSize(9.0f)); text.Dispose(); } }
public virtual string Hello (string name) { if (name == null) throw new ArgumentNullException ("name"); var nsname = new NSString (name); string ret; if (IsDirectBinding) { ret = NSString.FromHandle (MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (this.Handle, selHello_, nsname.Handle)); } else { ret = NSString.FromHandle (MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_IntPtr (this.SuperHandle, selHello_, nsname.Handle)); } nsname.Dispose (); return ret; }
public static string Echo (string message) { if (message == null) throw new ArgumentNullException ("message"); var nsmessage = new NSString (message); string ret; ret = NSString.FromHandle (MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (class_ptr, selEcho_, nsmessage.Handle)); nsmessage.Dispose (); return ret; }
internal static UIKeyCommand[] GetKeyCommands() { var element = HardwareKeyPage.FocusedElement ?? HardwareKeyPage.DefaultFocusedElement; if (element == null) { return(null); } var result = new List <UIKeyCommand>(); var listeners = element.GetHardwareKeyListeners(); for (int i = 0; i < listeners.Count; i++) { var listener = listeners[i]; var keyInput = listener?.HardwareKey?.KeyInput; if (string.IsNullOrEmpty(keyInput)) { continue; } NSString nsInput; switch (keyInput) { case HardwareKey.UpArrowKeyInput: nsInput = new NSString(UIKeyCommand.UpArrow); break; case HardwareKey.DownArrowKeyInput: nsInput = new NSString(UIKeyCommand.DownArrow); break; case HardwareKey.LeftArrowKeyInput: nsInput = new NSString(UIKeyCommand.LeftArrow); break; case HardwareKey.RightArrowKeyInput: nsInput = new NSString(UIKeyCommand.RightArrow); break; case HardwareKey.EscapeKeyInput: nsInput = new NSString(UIKeyCommand.Escape); break; case HardwareKey.BackspaceDeleteKeyInput: nsInput = new NSString(UIKeyCommand_BackspaceDeleteKeyInput); break; case HardwareKey.ForwardDeleteKeyInput: //nsInput = new NSString("\0x7F"); nsInput = new NSString(UIKeyCommand_InputDeleteKeyInput); break; // there is not an insert key on mac extended keyboard. In it's place is the Fn? case HardwareKey.TabKeyInput: nsInput = new NSString(UIKeyCommand_TabKeyInput); break; case HardwareKey.EnterReturnKeyInput: nsInput = new NSString(UIKeyCommand_EnterReturnKeyInput); break; case HardwareKey.PageUpKeyInput: nsInput = new NSString(UIKeyCommand_PageUpKeyInput); break; case HardwareKey.PageDownKeyInput: nsInput = new NSString(UIKeyCommand_PageDownKeyInput); break; case HardwareKey.HomeKeyInput: nsInput = new NSString(UIKeyCommand_HomeKeyInput); break; case HardwareKey.EndKeyInput: nsInput = new NSString(UIKeyCommand_EndKeyInput); break; case HardwareKey.InsertKeyInput: nsInput = new NSString(UIKeyCommand_InsertKeyInput); break; default: nsInput = new NSString(keyInput.ToLower()); break; } var modifier = listener.HardwareKey.ModifierKeys; if (modifier.HasFlag(HardwareKeyModifierKeys.Any)) { for (uint m = 0; m < (int)HardwareKeyModifierKeys.Any; m++) { result.Add(UIKeyCommandFrom(nsInput, (HardwareKeyModifierKeys)m, listener.HardwareKey.DiscoverableTitle)); } } else { result.Add(UIKeyCommandFrom(nsInput, modifier, listener.HardwareKey.DiscoverableTitle)); } nsInput.Dispose(); } return(result.ToArray()); }
public virtual void CustomizeViewWithText (string message) { if (message == null) throw new ArgumentNullException ("message"); var nsmessage = new NSString (message); if (IsDirectBinding) { MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (this.Handle, selCustomizeViewWithText_, nsmessage.Handle); } else { MonoTouch.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr (this.SuperHandle, selCustomizeViewWithText_, nsmessage.Handle); } nsmessage.Dispose (); }
public override void DrawFooterForPage (int index, RectangleF footerRect) { NSString footer = new NSString (string.Format ("Page {0} of {1}", index - pageRange.Location + 1, pageRange.Length)); footer.DrawString (footerRect, SystemFont, UILineBreakMode.Clip, UITextAlignment.Center); footer.Dispose (); }
// Custom UIPrintPageRenderer's may override this class to draw a custom print page header. // To illustrate that, this class sets the date in the header. public override void DrawHeaderForPage (int index, RectangleF headerRect) { NSDateFormatter dateFormatter = new NSDateFormatter (); dateFormatter.DateFormat = "MMMM d, yyyy 'at' h:mm a"; NSString dateString = new NSString (dateFormatter.ToString (NSDate.Now)); dateFormatter.Dispose (); dateString.DrawString (headerRect, SystemFont, UILineBreakMode.Clip, UITextAlignment.Right); dateString.Dispose (); }
public static void Configure (string APIKey, string userID) { if (APIKey == null) throw new ArgumentNullException ("APIKey"); if (userID == null) throw new ArgumentNullException ("userID"); var nsAPIKey = new NSString (APIKey); var nsuserID = new NSString (userID); MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (class_ptr, selConfigureWithAPIKeyAndUserID_, nsAPIKey.Handle, nsuserID.Handle); nsAPIKey.Dispose (); nsuserID.Dispose (); }