本文整理汇总了C#中NSMutableDictionary.LowlevelSetObject方法的典型用法代码示例。如果您正苦于以下问题:C# NSMutableDictionary.LowlevelSetObject方法的具体用法?C# NSMutableDictionary.LowlevelSetObject怎么用?C# NSMutableDictionary.LowlevelSetObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSMutableDictionary
的用法示例。
在下文中一共展示了NSMutableDictionary.LowlevelSetObject方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToDictionary
internal NSDictionary ToDictionary()
{
int n = 0;
if (Enhance.HasValue && Enhance.Value == false)
n++;
if (RedEye.HasValue && RedEye.Value == false)
n++;
if (ImageOrientation.HasValue)
n++;
if (Features != null && Features.Length != 0)
n++;
if (n == 0)
return null;
NSMutableDictionary dict = new NSMutableDictionary ();
if (Enhance.HasValue && Enhance.Value == false){
dict.LowlevelSetObject (CFBoolean.False.Handle, CIImage.AutoAdjustEnhanceKey.Handle);
}
if (RedEye.HasValue && RedEye.Value == false){
dict.LowlevelSetObject (CFBoolean.False.Handle, CIImage.AutoAdjustRedEyeKey.Handle);
}
if (Features != null && Features.Length != 0){
dict.LowlevelSetObject (NSArray.FromObjects (Features), CIImage.AutoAdjustFeaturesKey.Handle);
}
if (ImageOrientation.HasValue){
dict.LowlevelSetObject (new NSNumber ((int)ImageOrientation.Value), CIImage.ImagePropertyOrientation.Handle);
}
#if false
for (i = 0; i < n; i++){
Console.WriteLine ("{0} {1}-{2}", i, keys [i], values [i]);
}
#endif
return dict;
}
示例2: CreatePDFViewer
/// <summary>
/// Creates an instance of the PDF viewer.
/// </summary>
/// <returns>
/// The PDF viewer.
/// </returns>
/// <param name='sFilename'>
/// Name of the PDF to open.
/// </param>
/// <param name='iInitialPage'>
/// The initial pae number to go to.
/// </param>
/// <param name='bAllowsPrinting'>
/// True to enable the print menu.
/// </param>
/// <param name='bAllowsExport'>
/// True to allow exporting the document to other apps.
/// </param>
public static PSPDFViewController CreatePDFViewer(string sFilename, uint iInitialPage, bool bAllowsPrinting, bool bAllowsExport)
{
// Use PSPDFKit to view PDFs.
var document = new PSPDFKitDocument(NSUrl.FromFilename(sFilename), bAllowsExport && bAllowsPrinting, bAllowsExport && bAllowsPrinting);
var oClassDic = new NSMutableDictionary();
//oClassDic [new NSString("PSPDFFileAnnotationProvider")] = new NSString("CustomFileAnnnotationsProvider");
oClassDic.LowlevelSetObject(new Class(typeof(CustomFileAnnnotationsProvider)).Handle, new Class(typeof(PSPDFFileAnnotationProvider)).Handle);
document.OverrideClassNames = oClassDic;
// Read PDF properties from config.
PSPDFPageTransition ePageTransition = PSPDFPageTransition.Curl;
PSPDFPageMode ePageMode = PSPDFPageMode.Automatic;
PSPDFScrollDirection eScrollDirection = PSPDFScrollDirection.Horizontal;
var oPdfViewer = new PSPDFViewController(document)
{
ModalPresentationStyle = MonoTouch.UIKit.UIModalPresentationStyle.FullScreen,
ModalTransitionStyle = MonoTouch.UIKit.UIModalTransitionStyle.CoverVertical,
LinkAction = PSPDFLinkAction.OpenSafari,
PageTransition = ePageTransition,
PageMode = ePageMode,
ScrollDirection = eScrollDirection,
RenderAnnotationTypes = PSPDFAnnotationType.Highlight | PSPDFAnnotationType.Ink | PSPDFAnnotationType.Note | PSPDFAnnotationType.Text | PSPDFAnnotationType.Link,
Delegate = new PSPDFKitViewControllerDelegate()
};
var oControllerClassDic = new NSMutableDictionary();
oControllerClassDic.LowlevelSetObject(new Class(typeof(CustomNoteAnnotationController)).Handle, new Class(typeof(PSPDFNoteAnnotationController)).Handle);
oControllerClassDic.LowlevelSetObject(new Class(typeof(CustomLinkAnnotationView)).Handle, new Class(typeof(PSPDFLinkAnnotationView)).Handle);
oPdfViewer.OverrideClassNames = oControllerClassDic;
List<PSPDFBarButtonItem> aButtons = new List<PSPDFBarButtonItem>()
{
oPdfViewer.AnnotationButtonItem,
oPdfViewer.BookmarkButtonItem,
oPdfViewer.SearchButtonItem,
oPdfViewer.OutlineButtonItem
};
if(bAllowsPrinting && bAllowsExport)
{
//aButtons.Add(this.oPdfViewer.EmailButtonItem);
aButtons.Add(oPdfViewer.PrintButtonItem);
aButtons.Add(oPdfViewer.OpenInButtonItem);
}
aButtons.Add(oPdfViewer.ViewModeButtonItem);
oPdfViewer.RightBarButtonItems = aButtons.ToArray();
aButtons = null;
oPdfViewer.SetPageAnimated(iInitialPage, false);
return oPdfViewer;
}
示例3: ToDictionary
internal NSMutableDictionary ToDictionary ()
{
Init ();
var dict = new NSMutableDictionary ();
if (LossyCompressionQuality.HasValue)
dict.LowlevelSetObject (new NSNumber (LossyCompressionQuality.Value), kLossyCompressionQuality);
if (DestinationBackgroundColor != null)
dict.LowlevelSetObject (DestinationBackgroundColor.Handle, kBackgroundColor);
return dict;
}
示例4: ToDictionary
internal NSDictionary ToDictionary ()
{
if (OutputColorSpace == null && WorkingColorSpace == null && UseSoftwareRenderer == false)
return null;
var ret = new NSMutableDictionary ();
if (OutputColorSpace != null)
ret.LowlevelSetObject (OutputColorSpace.Handle, CIContext.OutputColorSpace.Handle);
if (WorkingColorSpace != null)
ret.LowlevelSetObject (WorkingColorSpace.Handle, CIContext.WorkingColorSpace.Handle);
if (UseSoftwareRenderer)
ret.LowlevelSetObject (CFBoolean.True.Handle, CIContext.UseSoftwareRenderer.Handle);
return ret;
}
示例5: ToDictionary
internal virtual NSMutableDictionary ToDictionary ()
{
Init ();
var dict = new NSMutableDictionary ();
if (BestGuessTypeIdentifier != null)
dict.LowlevelSetObject (new NSString (BestGuessTypeIdentifier), kTypeIdentifierHint);
if (!ShouldCache)
dict.LowlevelSetObject (CFBoolean.False.Handle, kShouldCache);
if (ShouldAllowFloat)
dict.LowlevelSetObject (CFBoolean.True.Handle, kShouldAllowFloat);
return dict;
}
示例6: CMMemoryPool
public CMMemoryPool (TimeSpan ageOutPeriod)
{
using (var dict = new NSMutableDictionary ()) {
dict.LowlevelSetObject (AgeOutPeriodSelector, new NSNumber (ageOutPeriod.TotalSeconds).Handle);
handle = CMMemoryPoolCreate (dict.Handle);
}
}
示例7: Create
public static CGImage Create(NSUrl url, SizeF maxThumbnailSize, float scaleFactor = 1, bool iconMode = false)
{
NSMutableDictionary dictionary = null;
if (scaleFactor != 1 && iconMode != false) {
dictionary = new NSMutableDictionary ();
dictionary.LowlevelSetObject ((NSNumber) scaleFactor, OptionScaleFactorKey.Handle);
dictionary.LowlevelSetObject (iconMode ? CFBoolean.True.Handle : CFBoolean.False.Handle, OptionIconModeKey.Handle);
}
var handle = QLThumbnailImageCreate (IntPtr.Zero, url.Handle, maxThumbnailSize, dictionary == null ? IntPtr.Zero : dictionary.Handle);
GC.KeepAlive (dictionary);
if (handle != null)
return new CGImage (handle, true);
return null;
}
示例8: ViewDidLoad
// On load, construct the CIRawFilter
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var asset = Asset;
if (asset == null)
return;
// Setup options to request original image.
var options = new PHImageRequestOptions {
Version = PHImageRequestOptionsVersion.Original,
Synchronous = true
};
// Request the image data and UTI type for the image.
PHImageManager.DefaultManager.RequestImageData (asset, options, (imageData, dataUTI, _, __) => {
if (imageData == null || dataUTI == null)
return;
// Create a CIRawFilter from original image data.
// UTI type is passed in to provide the CIRawFilter with a hint about the UTI type of the Raw file.
//var rawOptions = [String (kCGImageSourceTypeIdentifierHint) : dataUTI ]
var rawOptions = new NSMutableDictionary ();
var imageIOLibrary = Dlfcn.dlopen ("/System/Library/Frameworks/ImageIO.framework/ImageIO", 0);
var key = Dlfcn.GetIntPtr (imageIOLibrary, "kCGImageSourceTypeIdentifierHint");
rawOptions.LowlevelSetObject (dataUTI, key);
ciRawFilter = CIFilter.CreateRawFilter (imageData, rawOptions);
if (ciRawFilter == null)
return;
// Get the native size of the image produced by the CIRawFilter.
var sizeValue = ciRawFilter.ValueForKey (Keys.kCIOutputNativeSizeKey) as CIVector;
if (sizeValue != null)
imageNativeSize = new CGSize (sizeValue.X, sizeValue.Y);
// Record the original value of the temperature, and setup the editing slider.
var tempValue = (NSNumber)ciRawFilter.ValueForKey (Keys.kCIInputNeutralTemperatureKey);
if (tempValue != null) {
originalTemp = tempValue.FloatValue;
TempSlider.SetValue (tempValue.FloatValue, animated: false);
}
// Record the original value of the tint, and setup the editing slider.
var tintValue = (NSNumber)ciRawFilter.ValueForKey (Keys.kCIInputNeutralTintKey);
if (tintValue != null) {
originalTint = tintValue.FloatValue;
TintSlider.SetValue (tintValue.FloatValue, animated: false);
}
});
// Create EAGL context used to render the CIImage produced by the CIRawFilter to display.
ImageView.Context = new EAGLContext (EAGLRenderingAPI.OpenGLES3);
ciContext = CIContext.FromContext (ImageView.Context, new CIContextOptions { CIImageFormat = CIImage.FormatRGBAh });
}
示例9: Add
static void Add (NSMutableDictionary dict, IntPtr key, RectangleF? val)
{
if (!val.HasValue)
return;
NSData data;
unsafe {
RectangleF f = val.Value;
RectangleF *pf = &f;
data = NSData.FromBytes ((IntPtr) pf, 16);
}
dict.LowlevelSetObject (data, key);
}
示例10: SetLimit
static NSNumber SetLimit(NSMutableDictionary dict, int max)
{
NSNumber n = null;
IntPtr val;
if (max == -1)
val = SecMatchLimit.MatchLimitAll;
else if (max == 1)
val = SecMatchLimit.MatchLimitOne;
else {
n = NSNumber.FromInt32 (max);
val = n.Handle;
}
dict.LowlevelSetObject (val, SecItem.MatchLimit);
return n;
}
示例11: KSCatalogViewController
public KSCatalogViewController () : base (UITableViewStyle.Grouped, null)
{
NSUrl samplesURL = NSBundle.MainBundle.ResourceUrl.Append ("Samples", true);
NSUrl hackerMagURL = samplesURL.Append(HackerMagazineExample, false);
NSUrl annotTestURL = samplesURL.Append(AnnotTestExample, false);
this.Root = new RootElement ("KSCatalogViewController")
{
new Section ("Full example apps", "Can be used as a template for your own apps.")
{
// PDF playground.
new StringElement ("PSPDFViewController playground", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
var controller = new KSKioskViewController(doc);
controller.StatusBarStyleSetting = PSPDFStatusBarStyleSetting.Default;
this.NavigationController.PushViewController(controller, true);
}),
},
new Section("Customizing")
{
new StringElement("Combine search, TOC and bookmarks", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
var controller = new PSPDFViewController(doc);
var tabBarController = new KSCombinedTabBarController(controller, doc);
var tabBarBtn = new KSBarButtonItem(controller)
{
Title = "Show!",
Style = UIBarButtonItemStyle.Bordered
};
tabBarBtn.Clicked += (object sender, EventArgs e) => controller.PresentViewControllerModalOrPopover(tabBarController, true, false, true, tabBarBtn, null);
controller.RightBarButtonItems = new PSPDFBarButtonItem[] { controller.BookmarkButtonItem, tabBarBtn };
this.NavigationController.PushViewController(controller, true);
})
},
new Section ("Subclassing")
{
// Subclassing PSPDFAnnotationToolbar
new StringElement ("Subclass annotation toolbar and drawing toolbar", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
var controller = new PSPDFViewController(doc);
var barButtons = new List<PSPDFBarButtonItem>(controller.RightBarButtonItems);
barButtons.Add(controller.AnnotationButtonItem);
controller.RightBarButtonItems = barButtons.ToArray();
var classDic = new NSMutableDictionary();
classDic.LowlevelSetObject( new Class(typeof(KSAnnotationToolbar)).Handle, new Class(typeof(PSPDFAnnotationToolbar)).Handle);
controller.OverrideClassNames = classDic;
this.NavigationController.PushViewController(controller, true);
}),
// Demonstrates always visible vertical toolbar.
new StringElement ("Vertical always-visible annotation bar", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
var controller = new KSExampleAnnotationViewController(doc);
this.NavigationController.PushViewController(controller, true);
}),
// Tests potential binding issue when subclassing PSPDFViewController
new StringElement ("PSPDFViewController with NULL document", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
var controller = new KSNoDocumentPDFViewController();
controller.Document = doc;
this.NavigationController.PushViewController(controller, true);
}),
// Demonstrates capturing bookmark set/remove.
new StringElement ("Capture bookmarks", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
// Create an entry for overriding the default bookmark parser.
var classDic = new NSMutableDictionary();
classDic.LowlevelSetObject( new Class(typeof(KSBookmarkParser)).Handle, new Class(typeof(PSPDFBookmarkParser)).Handle);
doc.OverrideClassNames = classDic;
var controller = new PSPDFViewController(doc);
controller.RightBarButtonItems = new PSPDFBarButtonItem[]
{
controller.BookmarkButtonItem,
controller.SearchButtonItem,
controller.OutlineButtonItem,
controller.ViewModeButtonItem
};
this.NavigationController.PushViewController(controller, true);
}),
//.........这里部分代码省略.........
示例12: DVCMenu
public DVCMenu()
: base(UITableViewStyle.Grouped, null)
{
Root = new RootElement ("PSPDFKit") {
new Section (PSPDFKitGlobal.VersionString){
new StringElement ("PSPDFViewController playground", () => {
var pdfViewer = new PlayGroundViewController (NSUrl.FromFilename (HackerMonthlyFile));
NavigationController.PushViewController (pdfViewer, true);
})
},
new Section ("Annotations"){
new StringElement ("Annotations From Code", () => {
// we use a NSData document here but it'll work even better with a file-based variant.
NSError err;
var documentData = NSData.FromUrl (NSUrl.FromFilename (HackerMonthlyFile), NSDataReadingOptions.Mapped, out err);
var pdfViewer = new AnnotationsFromCodeViewController (documentData);
NavigationController.PushViewController (pdfViewer, true);
})
},
new Section ("Interface"){
new StringElement ("Dropbox-like interface", () => {
var document = new PSPDFDocument (NSUrl.FromFilename (HackerMonthlyFile));
var pdfViewer = new DropboxPDFViewController (document);
NavigationController.PushViewController (pdfViewer, true);
})
},
new Section ("Password / Security", "Password is: test123") {
new StringElement ("Password Preset", () => {
var document = new PSPDFDocument (NSUrl.FromFilename (ProtectedFile));
document.UnlockWithPassword ("test123");
var pdfViewer = new PSPDFViewController (document);
NavigationController.PushViewController (pdfViewer, true);
}),
new StringElement ("Password Not Preset", () => {
var document = new PSPDFDocument (NSUrl.FromFilename (ProtectedFile));
var pdfViewer = new PSPDFViewController (document);
NavigationController.PushViewController (pdfViewer, true);
}),
new StringElement ("Create Password Protected PDF", () => {
var document = new PSPDFDocument (NSUrl.FromFilename (HackerMonthlyFile));
var status = PSPDFStatusHUDItem.GetProgressItem ("Preparing");
status.Push (true);
// Create temp file and password
var tempPdf = NSUrl.FromFilename (Path.Combine (Path.GetTempPath (), Guid.NewGuid ().ToString () + ".pdf"));
var password = new NSString ("test123");
// Lets create the dictionary options needed by the PSPDFProcesor
// With password protected pages, PSPDFProcessor can only add link annotations.
// We use a helper class to access the CGPDFContextKeys used by the dictionary
var processorOptions = new NSMutableDictionary ();
processorOptions.LowlevelSetObject (password, Helper.CGPDFContextUserPassword);
processorOptions.LowlevelSetObject (password, Helper.CGPDFContextOwnerPassword);
processorOptions.LowlevelSetObject (NSNumber.FromInt32 (128), Helper.CGPDFContextEncryptionKeyLength);
processorOptions.LowlevelSetObject (NSNumber.FromBoolean (true), PSPDFProcessorOptionKeys.AnnotationAsDictionary.Handle);
processorOptions.LowlevelSetObject (NSNumber.FromObject (PSPDFAnnotationType.Link), PSPDFProcessorOptionKeys.AnnotationTypes.Handle);
// We create the page range we want to include in our pdf
var pageRange = new [] { NSIndexSet.FromNSRange (new NSRange (0, (int)document.PageCount)) };
// We start a new task so this executes on a separated thread since it is a hevy task and we don't want to block the UI
Task.Factory.StartNew (()=> {
NSError err;
PSPDFProcessor.DefaultProcessor.GeneratePDFFromDocument (document: document,
pageRange: pageRange,
fileURL: tempPdf,
options: (NSDictionary) processorOptions,
progressHandler: (currentPage, numberOfProcessedPages, totalPages) => InvokeOnMainThread (()=> status.Progress = ((float)numberOfProcessedPages / (float)totalPages)),
error: out err);
}).ContinueWith ((task) => {
InvokeOnMainThread (()=> {
status.Pop (true);
var docToShow = new PSPDFDocument (tempPdf);
var pdfViewer = new PSPDFViewController (docToShow);
NavigationController.PushViewController (pdfViewer, true);
});
});
}),
},
new Section ("Subclassing", "Examples how to subclass PSPDFKit."){
new StringElement ("Annotation Link Editor", () => {
var document = new PSPDFDocument (NSUrl.FromFilename (HackerMonthlyFile));
// Need to cast to solve ambiguity between NSObject and string ctor
document.EditableAnnotationTypes = new NSOrderedSet (
(NSObject) PSPDFAnnotationString.Link, // Important!!
(NSObject) PSPDFAnnotationString.Highlight,
(NSObject) PSPDFAnnotationString.Underline,
(NSObject) PSPDFAnnotationString.Squiggly,
(NSObject) PSPDFAnnotationString.StrikeOut,
(NSObject) PSPDFAnnotationString.Note,
(NSObject) PSPDFAnnotationString.FreeText,
(NSObject) PSPDFAnnotationString.Ink,
(NSObject) PSPDFAnnotationString.Square,
(NSObject) PSPDFAnnotationString.Circle,
(NSObject) PSPDFAnnotationString.Stamp );
var pdfViewer = new LinkEditorViewController (document);
NavigationController.PushViewController (pdfViewer, true);
}),
new StringElement ("Capture Bookmarks", () => {
var document = new PSPDFDocument (NSUrl.FromFilename (HackerMonthlyFile));
document.OverrideClass (new Class (typeof (PSPDFBookmarkParser)), new Class (typeof (CustomBookmarkParser)));
//.........这里部分代码省略.........
示例13: KSCatalogViewController
public KSCatalogViewController()
: base(UITableViewStyle.Grouped, null)
{
PSPDFKitGlobal.LogLevel = PSPDFLogLevel.Verbose;
// Add some custom localization to ensure the bindings work.
PSPDFKitGlobal.Localize("en", new NameValueCollection
{
{"Outline", "File Content"},
{"Bookmarks", "Remember"}
});
// Call cache method to ensure the bindings for the cache work.
var oPdfCache = PSPDFCache.SharedCache;
oPdfCache.ClearCache ( );
PSPDFKitGlobal.LogLevel = PSPDFLogLevel.Info;
NSUrl samplesURL = NSBundle.MainBundle.ResourceUrl.Append ("Samples", true);
NSUrl hackerMagURL = samplesURL.Append(HackerMagazineExample, false);
NSUrl annotTestURL = samplesURL.Append(AnnotTestExample, false);
this.Root = new RootElement ("KSCatalogViewController")
{
new Section ("Full example apps", "Can be used as a template for your own apps.")
{
// PDF playground.
new StringElement ("PSPDFViewController playground", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
var kioskController = new KSKioskViewController(doc);
kioskController.StatusBarStyleSetting = PSPDFStatusBarStyleSetting.Default;
this.NavigationController.PushViewController(kioskController, true);
}),
},
new Section("Customizing")
{
// Combines various view controllers in a tab bar controller.
new StringElement("Combine search, TOC and bookmarks", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
// Don't use PSPDFVieController directly but a subclass that allows attaching to ViewDidDisappear in order to clear
// the RightBarButtonItems property. Otherwise the tabBarBtn would keep a reference to the PSPDFViewController and the instances
// would never be freed.
//var controller = new PSPDFViewController(doc);
var controller = new KSKioskViewController(doc);
//controller.ViewDisappeared += (sender, args) => controller.RightBarButtonItems = new PSPDFBarButtonItem[0];
var tabBarController = new KSCombinedTabBarController(controller, doc);
var tabBarBtn = new KSBarButtonItem(controller)
{
Title = "UITabBarController",
Style = UIBarButtonItemStyle.Bordered
};
tabBarBtn.Clicked += (object sender, EventArgs e) => controller.PresentViewControllerModalOrPopover(tabBarController, true, false, true, tabBarBtn, null);
controller.RightBarButtonItems = new PSPDFBarButtonItem[] { controller.AnnotationButtonItem, controller.BookmarkButtonItem, tabBarBtn };
var classDic = new NSMutableDictionary();
classDic.LowlevelSetObject( new Class(typeof(KSInkAnnotation)).Handle, new Class(typeof(PSPDFInkAnnotation)).Handle);
classDic.LowlevelSetObject( new Class(typeof(KSNoteAnnotation)).Handle, new Class(typeof(PSPDFNoteAnnotation)).Handle);
classDic.LowlevelSetObject( new Class(typeof(KSHighlightAnnotation)).Handle, new Class(typeof(PSPDFHighlightAnnotation)).Handle);
doc.OverrideClassNames = classDic;
this.NavigationController.PushViewController(controller, true);
}),
// Shows an alert when tapping a link annotation.
new StringElement("Custom reaction on annotation links", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
var controller = new PSPDFViewController(doc);
controller.Delegate = new KSCatchTappingLinkDelegate();
// There are link annotations on page 2.
controller.SetPageAnimated(1, false);
this.NavigationController.PushViewController(controller, true);
})
},
new Section ("Subclassing")
{
// Subclassing PSPDFAnnotationToolbar
new StringElement ("Subclass annotation toolbar and drawing toolbar", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
var controller = new PSPDFViewController(doc);
var barButtons = new List<PSPDFBarButtonItem>(controller.RightBarButtonItems);
barButtons.Add(controller.AnnotationButtonItem);
controller.RightBarButtonItems = barButtons.ToArray();
var classDic = new NSMutableDictionary();
classDic.LowlevelSetObject( new Class(typeof(KSAnnotationToolbar)).Handle, new Class(typeof(PSPDFAnnotationToolbar)).Handle);
controller.OverrideClassNames = classDic;
//.........这里部分代码省略.........
示例14: KSCatalogViewController
public KSCatalogViewController()
: base(UITableViewStyle.Grouped, null)
{
PSPDFKitGlobal.LogLevel = PSPDFLogLevel.Verbose;
// Add some custom localization to ensure the bindings work.
PSPDFKitGlobal.Localize("en", new NameValueCollection
{
{"Outline", "File Content"},
{"Bookmarks", "Remember"}
});
// Call cache method to ensure the bindings for the cache work.
var oPdfCache = PSPDFCache.SharedCache;
oPdfCache.ClearCache ( );
PSPDFKitGlobal.LogLevel = PSPDFLogLevel.Info;
NSUrl samplesURL = NSBundle.MainBundle.ResourceUrl.Append ("Samples", true);
NSUrl hackerMagURL = samplesURL.Append(HackerMagazineExample, false);
NSUrl aesEncryptedURL = samplesURL.Append(AesEncryptedDoc, false);
this.Root = new RootElement ("KSCatalogViewController")
{
new Section ("Full example apps", "Can be used as a template for your own apps.")
{
// PDF playground.
new StringElement ("PSPDFViewController playground", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
var kioskController = new KSKioskViewController(doc);
kioskController.StatusBarStyleSetting = PSPDFStatusBarStyleSetting.Default;
this.NavigationController.PushViewController(kioskController, true);
}),
},
new Section("Customizing")
{
// Combines various view controllers in a tab bar controller.
new StringElement("Combine search, TOC and bookmarks", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
// Don't use PSPDFVieController directly but a subclass that allows attaching to ViewDidDisappear in order to clear
// the RightBarButtonItems property. Otherwise the tabBarBtn would keep a reference to the PSPDFViewController and the instances
// would never be freed.
//var controller = new PSPDFViewController(doc);
var controller = new KSKioskViewController(doc);
//controller.ViewDisappeared += (sender, args) => controller.RightBarButtonItems = new PSPDFBarButtonItem[0];
var tabBarController = new KSCombinedTabBarController(controller, doc);
var tabBarBtn = new KSBarButtonItem(controller)
{
Title = "UITabBarController",
Style = UIBarButtonItemStyle.Bordered
};
tabBarBtn.Clicked += (object sender, EventArgs e) => controller.PresentViewControllerModalOrPopover(tabBarController, true, false, true, tabBarBtn, null);
controller.RightBarButtonItems = new PSPDFBarButtonItem[] { controller.AnnotationButtonItem, controller.BookmarkButtonItem, tabBarBtn };
var classDic = new NSMutableDictionary();
classDic.LowlevelSetObject( new Class(typeof(KSInkAnnotation)).Handle, new Class(typeof(PSPDFInkAnnotation)).Handle);
classDic.LowlevelSetObject( new Class(typeof(KSNoteAnnotation)).Handle, new Class(typeof(PSPDFNoteAnnotation)).Handle);
classDic.LowlevelSetObject( new Class(typeof(KSHighlightAnnotation)).Handle, new Class(typeof(PSPDFHighlightAnnotation)).Handle);
doc.OverrideClassNames = classDic;
this.NavigationController.PushViewController(controller, true);
}),
// Shows an alert when tapping a link annotation.
new StringElement("Custom reaction on annotation links", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
var controller = new PSPDFViewController(doc);
controller.Delegate = new KSCatchTappingLinkDelegate();
// There are link annotations on page 2.
controller.SetPageAnimated(1, false);
this.NavigationController.PushViewController(controller, true);
})
},
new Section ("Subclassing")
{
// Subclassing PSPDFAnnotationToolbar
new StringElement ("Subclass annotation toolbar and drawing toolbar", () =>
{
var doc = new PSPDFDocument(hackerMagURL);
var controller = new PSPDFViewController(doc);
var barButtons = new List<PSPDFBarButtonItem>(controller.RightBarButtonItems);
barButtons.Add(controller.AnnotationButtonItem);
controller.RightBarButtonItems = barButtons.ToArray();
var classDic = new NSMutableDictionary();
classDic.LowlevelSetObject( new Class(typeof(KSAnnotationToolbar)).Handle, new Class(typeof(PSPDFAnnotationToolbar)).Handle);
controller.OverrideClassNames = classDic;
//.........这里部分代码省略.........