当前位置: 首页>>代码示例>>C#>>正文


C# NSDictionary.Dispose方法代码示例

本文整理汇总了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 ();
        }
开发者ID:nagyist,项目名称:TweetStation,代码行数:50,代码来源:Composer.cs

示例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));
            });
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:42,代码来源:ImagePickerProvider.cs


注:本文中的NSDictionary.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。