本文整理汇总了C#中NSDictionary.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# NSDictionary.Dispose方法的具体用法?C# NSDictionary.Dispose怎么用?C# NSDictionary.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSDictionary
的用法示例。
在下文中一共展示了NSDictionary.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PictureSelected
void PictureSelected(NSDictionary pictureDict)
{
int level = Util.Defaults.IntForKey ("sizeCompression");
if ((pictureDict [UIImagePickerController.MediaType] as NSString) == "public.image"){
Picture = pictureDict [UIImagePickerController.EditedImage] as UIImage;
if (Picture == null)
Picture = pictureDict [UIImagePickerController.OriginalImage] as UIImage;
// Save a copy of the original picture
if (!FromLibrary){
Picture.SaveToPhotosAlbum (delegate {
// ignore errors
});
}
var size = Picture.Size;
float maxWidth;
switch (level){
case 0:
maxWidth = 640;
break;
case 1:
maxWidth = 1024;
break;
default:
maxWidth = size.Width;
break;
}
var hud = new LoadingHUDView (Locale.GetText ("Image"), Locale.GetText ("Compressing"));
View.AddSubview (hud);
hud.StartAnimating ();
// Show the UI, and on a callback, do the scaling, so the user gets an animation
NSTimer.CreateScheduledTimer (TimeSpan.FromSeconds (0), delegate {
if (size.Width > maxWidth || size.Height > maxWidth)
Picture = Scale (Picture, new SizeF (maxWidth, maxWidth*size.Height/size.Width));
hud.StopAnimating ();
hud.RemoveFromSuperview ();
hud = null;
});
} else {
//NSUrl movieUrl = pictureDict [UIImagePickerController.MediaURL] as NSUrl;
// Future use, when we find a video host that does not require your Twitter login/password
}
pictureDict.Dispose ();
}
示例2: Save
private void Save(string path, int size, Action<bool> callback, NSDictionary data)
{
bool result = false;
UIImage photo = null;
UIImage source = null;
NSData file = null;
NSError error = null;
try
{
source = data.ObjectForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
if (source != null)
{
photo = ScaleImage(source, size);
file = photo.AsJPEG();
bool saved = file.Save(path, false, out error);
if (!saved)
Context.HandleException(new NonFatalException(D.IO_EXCEPTION, error.LocalizedDescription));
result = saved;
}
}
finally
{
if (photo != null)
photo.Dispose();
if (source != null)
source.Dispose();
if (file != null)
file.Dispose();
if (error != null)
error.Dispose();
if (data != null)
data.Dispose();
}
Task.Run(() =>
{
Thread.Sleep(300);
Context.InvokeOnMainThread(() => callback(result));
});
}