/// <summary> /// The method to creat the data /// </summary> private void Initialize() { int size = (int)myRandom.Next(0, 100); int year = (int)myRandom.Next(2015, 2017); int month = (int)myRandom.Next(0, 12); int day = (int)myRandom.Next(0, 28); for (int index = 0; index < 60; index++) { if (index == 0) { //Create some items for music ContentModel contentModel = new ContentModel(index, index.ToString(), index.ToString(), ContentItemType.eItemMusic, index.ToString(), "", "", 10); contentModel.Format = "MP3"; contentModel.Size = (size * (index + 1)).ToString(); contentModel.Data = day + "/" + month + "/" + year; dataList.Add(contentModel); sortedDataList.Add(contentModel); musicDataList.Add(contentModel); sortedMusicList.Add(contentModel); } else if (index > 10 && index <= 20) { //Create some items for movies string path = CommonResource.GetLocalReosurceURL() + "Movies/" + (index - 10).ToString() + ".jpg"; ContentModel contentModel = new ContentModel(index, index.ToString(), "NO." + index.ToString(), ContentItemType.eItemVideo, index.ToString(), path, "", 10); contentModel.ThumbnailPath = path; contentModel.ThumbDone = true; contentModel.Format = "MP4"; contentModel.Data = day + "/" + month + "/" + year; contentModel.Size = (size * (index + 1)).ToString(); dataList.Add(contentModel); sortedDataList.Add(contentModel); videoDataList.Add(contentModel); sortedVideoList.Add(contentModel); } else if (index > 53) { if (index % 2 == 0) { //Create some items for music string path = CommonResource.GetLocalReosurceURL() + "Musics/" + ((index - 50) / 2).ToString() + ".jpg"; ContentModel contentModel = new ContentModel(index, index.ToString(), "NO." + index.ToString(), ContentItemType.eItemMusic, index.ToString(), path, "", 10); contentModel.ThumbnailPath = path; contentModel.ThumbDone = true; contentModel.Format = "MP3"; contentModel.Data = day + "/" + month + "/" + year; contentModel.Size = (size * (index + 1)).ToString(); dataList.Add(contentModel); sortedDataList.Add(contentModel); musicDataList.Add(contentModel); sortedMusicList.Add(contentModel); } else { //Create some items for music ContentModel contentModel = new ContentModel(index, index.ToString(), "NO." + index.ToString(), ContentItemType.eItemMusic, index.ToString(), "", "", 10); contentModel.Format = "MP3"; contentModel.Data = day + "/" + month + "/" + year; contentModel.Size = (size * (index + 1)).ToString(); dataList.Add(contentModel); sortedDataList.Add(contentModel); musicDataList.Add(contentModel); sortedMusicList.Add(contentModel); } } else if (index % 4 == 0 && index % 3 == 0) { //Create some items for upFolder ContentModel contentModel = new ContentModel(index, index.ToString(), "NO." + index.ToString(), ContentItemType.eItemUpFolder, index.ToString(), "", "", 1); dataList.Add(contentModel); sortedDataList.Add(contentModel); } else if (index % 7 == 0) { //Create some items for upFolder ContentModel contentModel = new ContentModel(index, index.ToString(), "NO." + index.ToString(), ContentItemType.eItemUpFolder, index.ToString(), "", "", 2); dataList.Add(contentModel); sortedDataList.Add(contentModel); } else { //Create some items for photo string path = CommonResource.GetLocalReosurceURL() + "Photos/gallery-medium-" + index.ToString() + ".jpg"; ContentModel contentModel = new ContentModel(index, index.ToString(), "NO." + index.ToString(), ContentItemType.eItemPhoto, index.ToString(), "", "", 10); contentModel.Format = "JPEG"; contentModel.Data = day + "/" + month + "/" + year; contentModel.ThumbnailPath = path; contentModel.Size = (size * (index + 1)).ToString(); contentModel.ThumbDone = true; dataList.Add(contentModel); sortedDataList.Add(contentModel); photoDataList.Add(contentModel); sortedPhotoList.Add(contentModel); } } //sort the data sortedDataList.Sort(); sortedPhotoList.Sort(); sortedVideoList.Sort(); sortedMusicList.Sort(); CommonResource.SortedList.Clear(); CommonResource.SortedPhotoList.Clear(); CommonResource.SortedVideoList.Clear(); CommonResource.SortedMusicList.Clear(); for (int index = 0; index < sortedDataList.Count; index++) { CommonResource.SortedList.Add(sortedDataList[index]); } for (int index = 0; index < sortedPhotoList.Count; index++) { CommonResource.SortedPhotoList.Add(sortedPhotoList[index]); } for (int index = 0; index < sortedVideoList.Count; index++) { CommonResource.SortedVideoList.Add(sortedVideoList[index]); } for (int index = 0; index < sortedMusicList.Count; index++) { CommonResource.SortedMusicList.Add(sortedMusicList[index]); } CommonResource.DataList = dataList; CommonResource.MusicDataList = musicDataList; CommonResource.PhotoDataList = photoDataList; CommonResource.VideoDataList = videoDataList; }
/// <summary> /// Update view that display all the content thumbnail in the device /// </summary> /// <param name="bridge">grid view bridge</param> /// <param name="groupIndex">index for group</param> /// <param name="itemIndex">index for item</param> /// <param name="editMode">the edit mode: true / false </param> public override void UpdateItem(GridBridge bridge, int groupIndex, int itemIndex, bool editMode = false) { // return; string Folderpath = null; if (bridge == null) { return; } ContentModel itemData = bridge.GetData(itemIndex, groupIndex) as ContentModel; if (itemData == null) { return; } int itemType = itemData.MediaItemType; try { switch (itemType) { case ContentItemType.eItemFolder: //MainImageURL = (CommonReosurce.GetLocalReosurceURL() + "Folder/mc_folder.png"); MainImageURL = ""; MainText = itemData.DisplayName; Folderpath = itemData.FolderThumbPath; string defaultIcon = CommonResource.GetLocalReosurceURL() + "Folder/mc_folder.png"; if (itemData.FolderType == 0) { // exit file thumbnail defaultIcon = CommonResource.GetLocalReosurceURL() + "Folder/mc_folder_preview.png"; FolderThumbnailImage.SetImage(itemData.FolderThumbPath); FolderThumbnailImage.Size2D = new Size2D(109, 79); FolderThumbnailImage.Position = new Position(55, 95, 0); Add(FolderThumbnailImage); TopLayerImage.SetImage(defaultIcon); } else if (itemData.FolderType == 1) { // folder in folder defaultIcon = CommonResource.GetLocalReosurceURL() + "Folder/mc_folder_folder.png"; TopLayerImage.SetImage(defaultIcon); Remove(FolderThumbnailImage); } else if (itemData.FolderType == 2) { // no contents folder defaultIcon = CommonResource.GetLocalReosurceURL() + "Folder/mc_folder_nocont.png"; TopLayerImage.SetImage(defaultIcon); Remove(FolderThumbnailImage); } else { //request failed FolderThumbnailImage.SetImage(itemData.FolderThumbPath); FolderThumbnailImage.Size2D = new Size2D(109, 79); FolderThumbnailImage.Position = new Position(55, 95, 0); Add(FolderThumbnailImage); TopLayerImage.SetImage(defaultIcon); Remove(FolderThumbnailImage); } Add(TopLayerImage); TopLayerImage.RaiseToTop(); StateEnabled = !editMode; // inforIconURLArray[0] = ""; InformationIconURLArray = null; break; case ContentItemType.eItemUpFolder: this.Remove(TopLayerImage); this.Remove(FolderThumbnailImage); MainImageURL = (CommonResource.GetLocalReosurceURL() + "Folder/mc_upper_folder_n.png"); MainText = itemData.DisplayName; StateEnabled = !editMode; // inforIconURLArray[0] = ""; InformationIconURLArray = null; break; case ContentItemType.eItemPhoto: this.Remove(TopLayerImage); this.Remove(FolderThumbnailImage); inforIconURLArray[0] = CommonResource.GetLocalReosurceURL() + "Contents_icon/mc_icon_contents_camera.png"; StateEnabled = true; if (itemData.ThumbDone) { MainImageURL = (itemData.ThumbnailPath); } else { MainImageURL = (CommonResource.GetLocalReosurceURL() + "DefaultThumb/mc_f_default_photo.png"); } this.MainText = itemData.DisplayName; InformationIconURLArray = inforIconURLArray; break; case ContentItemType.eItemVideo: this.Remove(TopLayerImage); this.Remove(FolderThumbnailImage); inforIconURLArray[0] = CommonResource.GetLocalReosurceURL() + "Contents_icon/mc_icon_contents_play.png"; StateEnabled = true; if (itemData.ThumbDone) { MainImageURL = (itemData.ThumbnailPath); } else { MainImageURL = (CommonResource.GetLocalReosurceURL() + "DefaultThumb/mc_f_default_video.png"); } MainText = itemData.DisplayName; InformationIconURLArray = inforIconURLArray; break; case ContentItemType.eItemMusic: this.Remove(TopLayerImage); this.Remove(FolderThumbnailImage); inforIconURLArray[0] = CommonResource.GetLocalReosurceURL() + "Contents_icon/mc_icon_contents_music.png"; if (!itemData.Available) { inforIconURLArray[0] = CommonResource.GetLocalReosurceURL() + "Contents_icon/mc_icon_unsupported_music.png"; } StateEnabled = true; if (itemData.ThumbDone) { MainImageURL = (itemData.ThumbnailPath); } else { MainImageURL = (CommonResource.GetLocalReosurceURL() + "DefaultThumb/mc_f_default_music.png"); } MainText = itemData.DisplayName; InformationIconURLArray = inforIconURLArray; break; } ShowCheckBox(editMode, itemData.IsSelected); } catch (Exception e) { Tizen.Log.Fatal("NUI", " Thumbnail UpdateItem error: " + e.Message); } }