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


C# MediaLibrary.Dispose方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Media.MediaLibrary.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# MediaLibrary.Dispose方法的具体用法?C# MediaLibrary.Dispose怎么用?C# MediaLibrary.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Media.MediaLibrary的用法示例。


在下文中一共展示了MediaLibrary.Dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitList

 private void InitList()
 {
     var media = new MediaLibrary();
     var list = media.Pictures;
     List<MediaLibraryThumbnailedImage> imgSources = new List<MediaLibraryThumbnailedImage>();
     foreach (var pic in list)
     {
         imgSources.Add(new MediaLibraryThumbnailedImage(pic));
     }
     mediaViewer.Items = new ObservableCollection<object>(imgSources);
     media.Dispose();
     media = null;
 }
开发者ID:dqtruong,项目名称:PhotoViewer,代码行数:13,代码来源:MainPage.xaml.cs

示例2: SaveToPictureLiabray

 public static void SaveToPictureLiabray(this UIElement contentToSaveToImage, string folder, string fileName, int width, int height)
 {
     using (System.IO.IsolatedStorage.IsolatedStorageFile file = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())
     {
         if (!file.DirectoryExists(folder))
         {
             file.CreateDirectory(folder);
         }
         string path = folder + "//" + fileName;
         using (System.IO.IsolatedStorage.IsolatedStorageFileStream stream = file.OpenFile(path, System.IO.FileMode.OpenOrCreate))
         {
             new WriteableBitmap(contentToSaveToImage, null).SaveJpeg(stream, width, height, 0, 0x55);
             stream.Close();
             MediaLibrary library = new MediaLibrary();
             using (System.IO.IsolatedStorage.IsolatedStorageFileStream stream2 = file.OpenFile(path, System.IO.FileMode.Open, System.IO.FileAccess.Read))
             {
                 library.SavePicture(fileName, stream2);
                 library.Dispose();
             }
         }
     }
 }
开发者ID:RukaiYu,项目名称:TinyMoneyManager.WP8,代码行数:22,代码来源:PictureExportingHelper.cs

示例3: SaveImageToCameraRoll

        private void SaveImageToCameraRoll(int imageHandle, String imageName, Resource imageResource)
        {
            MediaLibrary library = new MediaLibrary();
            MemoryStream targetStream = new MemoryStream();

            int mediaType = MoSync.Constants.MA_MEDIA_TYPE_IMAGE;
            int mediaHandle = imageHandle;
            int eventReturnCode = MoSync.Constants.MA_MEDIA_RES_OK;

            try
            {
                WriteableBitmap data = (WriteableBitmap)imageResource.GetInternalObject();
                data.SaveJpeg(targetStream, data.PixelWidth, data.PixelHeight, 0, 100);
                data = null;

                library.SavePictureToCameraRoll(imageName, targetStream.GetBuffer()).Dispose();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
                eventReturnCode = MoSync.Constants.MA_MEDIA_RES_IMAGE_EXPORT_FAILED;
            }
            finally
            {
                library.Dispose();
                targetStream.Dispose();
                PostMediaEvent(mediaType, mediaHandle, eventReturnCode);
            }
        }
开发者ID:nagyist,项目名称:MoSync-MoSync,代码行数:29,代码来源:MoSyncMiscModule.cs

示例4: GetActualSongList

        private static List<SongEx> GetActualSongList()
        {
            var list = new List<SongEx>();
            MediaLibrary lib = new MediaLibrary();

            if (lib != null)
            {
                uint hMediaList = InteropSvc.InteropLib.Instance.ZMediaLibrary_GetSongs();
                int count = lib.Songs.Count;
                for (int x = 0; x < count; x++)
                {
                    var song = lib.Songs[x];
                    if (!song.IsProtected)
                    {
                        var songEx = new SongEx(song);

                        uint hash = InteropSvc.InteropLib.Instance.ZMediaList_GetHash(hMediaList, x);

                        string hashStr = String.Format("{0:X}", hash).PadLeft(8, '0');

                        string path = "\\My Documents\\Zune\\Content\\" + hashStr.Substring(0, 4) + "\\" + hashStr.Substring(4, 2) + "\\" + hashStr.Substring(6, 2);
                        if (InteropSvc.InteropLib.Instance.GetFileAttributes7(path + ".mp3") != 0xFFFFFFFFU)
                        {
                            path += ".mp3";
                        }
                        else
                        {
                            path += ".wma";
                        }
                        songEx.FilePath = path;

                        list.Add(songEx);
                    }
                }
                InteropSvc.InteropLib.Instance.ZMediaList_Release(hMediaList);
                lib.Dispose();
                list.Sort(new SongExComparer());
            }
            return list;
        }
开发者ID:ultrashot,项目名称:ringtonemanager,代码行数:40,代码来源:MainViewModel.cs

示例5: OnNavigatedTo

        protected async override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back)
            {
                if (this.NavigationContext.QueryString.ContainsKey("FileName"))
                {
                    WorkingDesignName = string.Empty;
                    App.ExitCall = false;

                    OpenFlyer(this.NavigationContext.QueryString["FileName"]);
                }
               
            }
            else if (e.NavigationMode == System.Windows.Navigation.NavigationMode.Back)
            {
                if (App.SaveFileName != "" && App.FromWhere == "SaveHolo")
                {
                    if (App.SaveType == "H") // Save as Hologram
                    {
                        SaveFlyer(App.SaveFileName);

                        WorkingDesignName = App.SaveFileName;
                        //ApplicationTitle.Text = "DESIGNER :: " + App.SaveFileName;

                        if (App.ExitCall == true)
                        {
                            App.ExitCall = false;
                            NavigationService.GoBack();
                        }
                    }
                    else if (App.SaveType == "I") // Save as Image
                    {
                        MemoryStream ms = new MemoryStream();
                        WriteableBitmap wbmpThumbnail = new WriteableBitmap(this.ContentPanel, null);
                        wbmpThumbnail.SaveJpeg(ms, wbmpThumbnail.PixelWidth, wbmpThumbnail.PixelHeight, 0, 100);

                        ms.Seek(0, 0);
                        MediaLibrary mediaLibrary = new MediaLibrary();
                        Picture pic = mediaLibrary.SavePicture(App.SaveFileName + ".jpg", ms);

                        mediaLibrary.Dispose();
                        pic.Dispose();
                        ms.Flush();
                        ms.Close();
                        ms.Dispose();
                    }
                    else if (App.SaveType == "C") // Save in Cloud
                    {
                        if (App.SaveFileName.EndsWith(".4dh"))
                            WorkingDesignName = App.SaveFileName;
                        else
                            WorkingDesignName = App.SaveFileName + ".4dh";

                        SaveFlyer(WorkingDesignName);
                        
                        //ApplicationTitle.Text = "DESIGNER :: " + App.SaveFileName;

                        if (App.ExitCall == true)
                        {
                            App.ExitCall = false;
                            NavigationService.GoBack();
                        }

                        using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
                        {
                            using (IsolatedStorageFileStream stream = myIsolatedStorage.OpenFile(WorkingDesignName, FileMode.Open,FileAccess.Read,FileShare.Read))
                            {
                                try{
                                    //LiveOperationResult res = await App.client.BackgroundUploadAsync("me/skydrive", new Uri("/shared/transfers/" + WorkingDesignName, UriKind.Relative), OverwriteOption.Overwrite);
                                    var res = await App.client.UploadAsync("me/skydrive", WorkingDesignName, stream, OverwriteOption.Overwrite);
                                    
                                    //InfoText.Text = "File " + WorkingDesignName + " uploaded";

                                    myIsolatedStorage.DeleteFile(WorkingDesignName);
                                }
                                catch (Exception){}
                            }
                        }

                    }

                }
                else if (App.SaveFileName == "" && App.FromWhere == "SaveFlyer")
                {
                    if (App.ExitCall == true)
                    {
                        App.ExitCall = false;
                        //App.ChangesSaved = false;

                        NavigationService.GoBack();
                    }
                }
            }

            App.SaveType = "H";
            App.FromWhere = "";
            base.OnNavigatedTo(e);
        }
开发者ID:dannisliang,项目名称:Easy_Hologram_4d,代码行数:98,代码来源:4DImage.xaml.cs


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