This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string FoundationLibrary = "/System/Library/Frameworks/Foundation.framework/Foundation"; | |
[System.Runtime.InteropServices.DllImport(FoundationLibrary)] | |
extern static void NSLog(IntPtr format, IntPtr s); | |
[System.Runtime.InteropServices.DllImport(FoundationLibrary, EntryPoint = "NSLog")] | |
extern static void NSLog_ARM64(IntPtr format, IntPtr p2, IntPtr p3, IntPtr p4, IntPtr p5, IntPtr p6, IntPtr p7, IntPtr p8, IntPtr s); | |
static readonly bool Is64Bit = IntPtr.Size == 8; | |
static readonly bool IsDevice = ObjCRuntime.Runtime.Arch == ObjCRuntime.Arch.DEVICE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using UIKit; | |
// based on http://blog.functionalfun.net/2008/07/random-pastel-colour-generator.html | |
public static UIColor RandomColor () | |
{ | |
Random random = new Random (); | |
// to create lighter colors: | |
// take a random integer between 0 & 128 (rather than between 0 and 255) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
/// <summary> | |
/// Contains approximate string matching | |
/// </summary> | |
static class LevenshteinDistance | |
{ | |
/// <summary> | |
/// Compute the distance between two strings. | |
/// </summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UIKit; | |
void AirPrint (CGRect frame, string pdfOrImageToPrint) | |
{ | |
var printer = UIPrintInteractionController.SharedPrintController; | |
if (printer == null) { | |
Console.WriteLine("Unable to print at this time."); | |
} else { | |
var printInfo = UIPrintInfo.PrintInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Foundation; | |
using UIKit; | |
namespace YourApp | |
{ | |
[Register ("AppDelegate")] | |
public partial class AppDelegate : UIApplicationDelegate | |
{ | |
NSObject _screenshotNotification = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSError error1 = null; | |
NSError error2 = null; | |
var atts = new NSAttributedStringDocumentAttributes (); | |
atts.DocumentType = NSDocumentType.RTF; | |
using (var wrapper = textView.AttributedText.GetFileWrapperFromRange (new NSRange (0, textView.Text.Length), atts, ref error1)) | |
{ | |
wrapper.Write (new NSUrl ("...Edited.rtf", false), NSFileWrapperWritingOptions.Atomic, new NSUrl ("...Sample.rtf", false), out error2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSError error = null; | |
var attributedString = new NSAttributedString (new NSUrl ("...Sample.rtf", false), null, ref error); | |
var attributedTextHolder = new NSMutableAttributedString (attributedString); | |
textView.AllowsEditingTextAttributes = true; | |
textView.AttributedText = attributedTextHolder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private UIImage GetVideoThumbnail(string path) | |
{ | |
try { | |
CMTime actualTime; | |
NSError outError; | |
using (var asset = AVAsset.FromUrl (NSUrl.FromFilename (path))) | |
using (var imageGen = new AVAssetImageGenerator (asset)) | |
using (var imageRef = imageGen.CopyCGImageAtTime (new CMTime (1, 1), out actualTime, out outError)) { | |
return UIImage.FromImage (imageRef); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Register ("AppDelegate")] | |
public partial class AppDelegate : UIApplicationDelegate | |
{ | |
UIVisualEffectView _blurView = null; | |
public override void OnActivated (UIApplication application) | |
{ | |
try { | |
if (_blurView != null) { | |
_blurView.RemoveFromSuperview (); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override bool FinishedLaunching (UIApplication app, NSDictionary options) | |
{ | |
UIUserNotificationType notificationTypes = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound; | |
var settings = UIUserNotificationSettings.GetSettingsForTypes(notificationTypes, new NSSet (new string[] {})); | |
UIApplication.SharedApplication.RegisterUserNotificationSettings (settings); | |
UIApplication.SharedApplication.RegisterForRemoteNotifications (); | |
return true; | |
} |