public StrategyGroup ToEntity() { StrategyGroup strategyGroup = Mapper.Map <StrategyGroupViewModel, StrategyGroup>(this); if (ImageFile != null) { // original image MemoryStream memoryStream = new MemoryStream(); ImageFile.InputStream.CopyTo(memoryStream); byte[] originalImageContent = memoryStream.ToArray(); strategyGroup.OriginalImage = new Image { Content = originalImageContent, Type = ImageFile.ContentType }; // thumbnail image byte[] thumbnailImageContent = ThumbnailHelper.CreateThumbnail(originalImageContent); strategyGroup.ThumbnailImage = new Image { Content = thumbnailImageContent, Type = ImageFile.ContentType }; } return(strategyGroup); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var file = (StorageFile)e.Parameter; var parent = await file.GetParentAsync(); var list = await parent.GetFilesAsync(); var videolist = VideoHelper.getVideosFromFolder(list, false); foreach (var item in videolist) { FolderVideoModel model = new FolderVideoModel() { title = item.DisplayName, duration = await VideoHelper.GetVideoDuration(item), imageSource = await ThumbnailHelper.getThumbnailForVideo(item), subtitle = null, videoPath = item.Path, mediaPlaybackItem = new MediaPlaybackItem(MediaSource.CreateFromStorageFile(item)) }; videoFiles.Add(model); playbackList.Items.Add(model.mediaPlaybackItem); } }
private void GetVideoFileList(string currentPath, List <VideoInfo> videoFilePathList) { if (Directory.GetFiles(currentPath).Length > 0) { string[] fileList = Directory.GetFiles(currentPath); for (int i = 0; i < fileList.Length; i++) { VideoInfo thumbnailInfo = new VideoInfo(); thumbnailInfo.VideoFullUrl = fileList[i]; thumbnailInfo.VideoName = Path.GetFileName(fileList[i]); // Nitin Start //thumbnailInfo.ThumbnailFilePath = Path.Combine(ClientHelper.GetClientThumbanailPath(), ThumbnailHelper.GetThumbnailFileName(ClientHelper.GetClientThumbanailPath(), ClientHelper.GetClassNameFromFullPath(currentPath), currentPath)); thumbnailInfo.ThumbnailFilePath = ThumbnailHelper.GetThumbnailFilePathByVideoPath(fileList[i]); // Nitin End videoFilePathList.Add(thumbnailInfo); } } else { string[] currentDirectoryList = Directory.GetDirectories(currentPath); for (int i = 0; i < currentDirectoryList.Length; i++) { GetVideoFileList(currentDirectoryList[i], videoFilePathList); } } }
public async Task InvokeAsync(HttpContext context) { if (!IsImageRequested(context)) { await _next(context); return; } var imagePath = GetRequestedImagePath(context); var fullImagePath = Path.Combine(_storageConfig.Value.RootPath, imagePath); if (!File.Exists(fullImagePath)) { context.Response.StatusCode = 404; return; } if (IsThumbnailRequested(context)) { var size = CreateSizeFromQueryString(context); fullImagePath = ThumbnailHelper.GenerateThumbnail(fullImagePath, size); } await using var fs = new FileStream(fullImagePath, FileMode.Open); await fs.CopyToAsync(context.Response.Body); }
public ActionResult CreateImgByFolderPathAndDpi(string folderPath, string dpi) { int count = 0; var path = Server.MapPath(Request.ApplicationPath + folderPath); DirectoryInfo folder = new DirectoryInfo(path); string fileFullName; dpi = dpi.ToUpper(); int[] dpiWAndH = dpi.Split('X').Select(o => int.Parse(o)).Where(w => w > 0).ToArray(); foreach (FileInfo file in folder.GetFiles()) { fileFullName = file.FullName; if (fileFullName.IndexOf(dpi, StringComparison.Ordinal) == -1) { if (dpiWAndH != null && dpiWAndH.Length == 2) { if (dpi.StartsWith("-") == false) { dpi = string.Concat("-", dpi); } if (System.IO.File.Exists(fileFullName)) { string descPath = fileFullName.Insert(fileFullName.LastIndexOf('.'), dpi); if (System.IO.File.Exists(descPath) == false) { count++; ThumbnailHelper.GenerateImage2(fileFullName, descPath, dpiWAndH[0], dpiWAndH[1]); } } } } } return Content("生成缩略图总计:" + count); }
/// <summary> /// 文件上传到服务器之后执行的操作 /// </summary> /// <returns></returns> private void UploadAfterAction(UploadifyResult uploadifyResult) { //图片dpi if (_dpi.IsNotNullAndNotEmpty()) { List <string> paths = uploadifyResult.uploadPath.Split(_splitChar).ToList(); foreach (var path in paths) { string ext = Path.GetExtension(path).ToUpper(); if (ext.EndsWith("JPG") || ext.EndsWith("JPEG") || ext.EndsWith("PNG")) { int[] whInt = GetDpi(_dpi); //生成的缩略图的路径格式是:原图路径 + “-”+ dpi + 后缀 string desPath = path.Insert(path.LastIndexOf('.'), "-" + _dpi); ThumbnailHelper.GenerateImage2(WebHelper.GetMapPath("~" + path), WebHelper.GetMapPath("~" + desPath), whInt[0], whInt[1]); } } } //视频dpi if (_videoCoverDpi.IsNotNullAndNotWhiteSpace()) { string path = uploadifyResult.uploadPath.Split(_splitChar).First();//正常情况下,视频一次只能传一个 string ext = Path.GetExtension(path).ToUpper(); if (ext.EndsWith("MP4") || ext.EndsWith("MOV")) { GenerateVideoCoverImg(path, uploadifyResult); } } }
public FileEntity UploadCutImage(string inputFileName, string outputFileName, string fileFolder, string filePhysicalPath, int toWidth, int toHeight, int cropWidth, int cropHeight, int x, int y) { string fileType = "jpg"; FileEntity file = new FileEntity(); try { string filePath = filePhysicalPath + "/"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } file.DisplayName = Path.GetFileName(outputFileName); file.Extension = Path.GetExtension(file.DisplayName); file.CreateTime = DateTime.Now; file.DbName = GetFileDBName(file.Extension); file.FilePath = "/" + fileFolder + "/" + file.DbName; file.ImgPath = file.FilePath; ThumbnailHelper.Cut(inputFileName, filePath + file.DbName, toWidth, toHeight, cropWidth, cropHeight, x, y, fileType); return(file); } catch (Exception ex) { WebLogAgent.Write(ex); return(null); } }
private static bool PreparePromSimsForThumbnail(ulong sim1, ulong sim2) { List <SimDescription> collection = new List <SimDescription>(); foreach (Sim sim in Sims3.Gameplay.Queries.GetObjects <Sim>()) { if ((sim.ObjectId.mValue == sim1) || (sim.ObjectId.mValue == sim2)) { /* * if (collection.Count == 0x1) * { * foreach (SimDescription description in collection) * { * description.SetPartner(sim.SimDescription); * sim.SimDescription.SetPartner(description); * } * } */ collection.Add(sim.SimDescription); } } if (collection.Count != 0x0) { List <SimDescription> descriptions = new List <SimDescription>(collection); Hashtable simPosesForPromThumbnnail = ThumbnailHelper.GetSimPosesForPromThumbnnail(collection); ThumbnailHelper.BuildSimsForPoses(descriptions, simPosesForPromThumbnnail); PromSituation.SetBackdrop(); ThumbnailManager.SetHouseholdCamera(0x5815de37); } return(true); }
private void MakeThumbnail(string filePath, string suffix, int width, int height, string mode) { string fileExt = filePath.Substring(filePath.LastIndexOf('.')); string fileHead = filePath.Substring(0, filePath.LastIndexOf('.')); var thumbPath = string.Format("{0}_{1}{2}", fileHead, suffix, fileExt); ; ThumbnailHelper.MakeThumbnail(filePath, thumbPath, width, height, mode, false); }
public async Task <JsonResult> UEditor() { try { string host = string.Format("{0}://{1}", Request.Scheme, Request.Host); List <string> urls = new List <string>(); IFormFile file = Request.Form.Files[0]; Guid fileId = Guid.NewGuid(); DateTime nowDate = DateTime.Now; // 服务器的存储全路径 string destFileName = MapPath(file.FileName); urls.Add(host + file.FileName); // 创建目录路径 if (!Directory.Exists(Path.GetDirectoryName(destFileName))) { Directory.CreateDirectory(Path.GetDirectoryName(destFileName)); } var suffix = Path.GetExtension(file.FileName).ToLower(); string ThumbnailSizes = Request.Form["thumbnailSizes"].FirstOrDefault(); using (var stream = System.IO.File.Create(destFileName)) { await file.CopyToAsync(stream); } // 图片文件扩展名验证正则表达式 Regex regexExtension = new Regex(@".*\.(jpg|jpeg|png|gif|bmp)"); if (regexExtension.IsMatch(destFileName.ToLower())) { string[] ThumbnailSizeArr = new string[] { }; //生成缩略图 if (!string.IsNullOrEmpty(ThumbnailSizes) && (ThumbnailSizeArr = ThumbnailSizes.Split(';')).Length > 0) { for (int i = 0; i < ThumbnailSizeArr.Length; i++) { string size = ThumbnailSizeArr[i]; string ThumbFileName = Path.GetFileNameWithoutExtension(file.FileName) + "_" + size + suffix; string ThumbPath = file.FileName.Replace(Path.GetFileName(file.FileName), ThumbFileName); ThumbnailHelper.MakeThumbnail(Convert.ToInt32(size), MapPath(file.FileName), MapPath(ThumbPath)); urls.Add(host + ThumbPath); } } } //返回所有地址 return(Json(new { Code = 0, Msg = "", Data = urls })); } catch (Exception ex) { LogHelper.SaveLog(ex); return(Json(new { Code = 1, Msg = "服务器异常,请联系管理员!" })); } }
public async Task <JsonResult> Upload() { try { string host = string.Format("{0}://{1}", Request.Scheme, Request.Host); Dictionary <string, string> result = new Dictionary <string, string>(); IFormFile file = Request.Form.Files[0]; // 服务器的存储全路径 string destFileName = MapPath(file.FileName); result.Add("url", host + file.FileName); result.Add("path", host + file.FileName.Substring(0, file.FileName.LastIndexOf("/"))); // 创建目录路径 if (!Directory.Exists(Path.GetDirectoryName(destFileName))) { Directory.CreateDirectory(Path.GetDirectoryName(destFileName)); } var suffix = Path.GetExtension(file.FileName).ToLower(); string ThumbnailSizes = Request.Form["thumbnailSizes"].FirstOrDefault(); using (var stream = System.IO.File.Create(destFileName)) { await file.CopyToAsync(stream); } // 图片文件扩展名验证正则表达式 Regex regexExtension = new Regex(@".*\.(jpg|jpeg|png|gif|bmp)"); if (regexExtension.IsMatch(destFileName.ToLower())) { string[] ThumbnailSizeArr = new string[] { }; //生成缩略图 if (!string.IsNullOrEmpty(ThumbnailSizes) && (ThumbnailSizeArr = ThumbnailSizes.Split(';')).Length > 0) { string[] fileNamesArr = new string[ThumbnailSizeArr.Length]; for (int i = 0; i < ThumbnailSizeArr.Length; i++) { string size = ThumbnailSizeArr[i]; string ThumbFileName = Path.GetFileNameWithoutExtension(file.FileName) + "_" + size + suffix; string ThumbPath = file.FileName.Replace(Path.GetFileName(file.FileName), ThumbFileName); ThumbnailHelper.MakeThumbnail(Convert.ToInt32(size), MapPath(file.FileName), MapPath(ThumbPath)); fileNamesArr[i] = ThumbFileName; } result.Add("names", string.Join("|", fileNamesArr)); } } //返回所有地址 return(Json(new { Code = 0, Msg = "", Data = result })); } catch (Exception ex) { LogHelper.SaveLog(ex); return(Json(new { Code = 1, Msg = "服务器异常,请联系管理员!" })); } }
public async static Task <ObservableCollection <FolderVideoModel> > populateGrid(IReadOnlyList <IStorageItem> files) { var watch = Stopwatch.StartNew(); list.Clear(); if (files.Count > 0) { var model = new FolderVideoModel(); foreach (var item in files) { if (item is StorageFolder) { var folder = (StorageFolder)item; Debug.WriteLine($"{folder.DisplayName} is a folder"); var count = await VideoHelper.GetVideoCountFromFolder(folder); var bitmap = new BitmapImage(new Uri("ms-appx:///Assets/folder-icon.png")); model = new FolderVideoModel(folder.DisplayName, count.ToString(), folder.Path, bitmap, null, null); } else if (item is StorageFile) { var file = (StorageFile)item; if (VideoHelper.isVideo(file)) { var duration = await VideoHelper.GetVideoDuration(file); var bitmap = await ThumbnailHelper.getThumbnailForVideo(file); model = new FolderVideoModel(file.DisplayName, duration, file.Path, bitmap, null, null); } } list.Add(model); //list.Add(Task.Run(() => model)); } /* var results = await Task.WhenAll(list); * * foreach (var item in results) * { * videoFiles.Add(item); * }*/ } return(list); watch.Stop(); var time = watch.ElapsedMilliseconds; Debug.WriteLine($" Time ----------- {time}"); }
public IActionResult AddArticle(Article model) { if (model.KId <= 0) { tip.Message = "请选择一个文章栏目"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Title)) { tip.Message = "请填写文章标题"; return(Json(tip)); } if (string.IsNullOrWhiteSpace(model.Content)) { tip.Message = "请填写文章内容"; return(Json(tip)); } if (!string.IsNullOrEmpty(model.Pic) && !Utils.IsImgFilename(model.Pic)) { tip.Message = "文章图片填写的不是图片格式!"; return(Json(tip)); } //处理文章更多图片 string[] moreImgSrc = Request.Form["nImgUrl"]; string morIMG = string.Empty;//更多图片的时候用到 if (moreImgSrc != null && moreImgSrc.Length > 0) { foreach (string s in moreImgSrc) { if (Utils.IsImgFilename(s)) { morIMG += s + "|||";//使用“|||”分隔图片 } } } string content = model.Content; if (Request.Form["autoSaveRemoteImg"] == "1" && !string.IsNullOrEmpty(content)) { content = ThumbnailHelper.SaveRemoteImgForContent(content); model.Content = content; } model.ItemImg = morIMG; model.AuthorId = Core.Admin.GetMyInfo().Id; model.Insert(); ArticleCategory.UpdateDetailCount(model.KId); SessionHelper.WriteSession("com_add_article_kid", model.KId); //添加TAG //Tag.InsertTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title); Core.Admin.WriteLogActions("添加文章(id:" + model.Id + ");"); tip.Status = JsonTip.SUCCESS; tip.Message = "添加文章成功"; tip.ReturnUrl = "close"; return(Json(tip)); }
public string GetThumbnial(string name, string strBBox) { #region [生成缩略图] ThumbnailHelper tbh = new ThumbnailHelper(); return(tbh.CreateThumbnail(name, "map", strBBox)); #endregion }
private void ThumbnailOssPutObject(string bucketName, string imageName, byte[] images, OssClient ossClient) { string graphFileName = string.Format("graph_{0}", imageName); byte[] listGraphSizeByte = ThumbnailHelper.MakeThumbnail(ThumbnailHelper.ReturnPhoto(images), "", 200, 200, "Cut"); var objStream = new MemoryStream(listGraphSizeByte); ossClient.PutObject(config.Bucket, graphFileName, objStream); objStream.Close(); }
private static string GenerateThumbnail(string imageFileName) { var fc = FileCache.GetInstance(); string thumbnailFileName = fc.GetPublicTempFileName(".jpg"); ThumbnailHelper.CreateThumbnail(imageFileName, fc.GetAbsolutePublicCachePath(thumbnailFileName), new System.Drawing.Size(40, 40), true); return(fc.GetRelativePublicCachePath(thumbnailFileName)); }
/// <summary> /// 下载缩略图 /// </summary> /// <param name="name"></param> /// <param name="type"></param> /// <param name="bbox"></param> public void ThumbnailCreate(string name, string type, string bbox) { try { ThumbnailHelper tbh = new ThumbnailHelper(); string imagePath = tbh.CreateThumbnail(name, type, bbox); } catch (Exception ex) { logger.Info(UtilityMessageConvert.Get("缩略图下载异常:图层名称") + "(" + name + ")" + ex.Message); } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { FileListViewNode fileListViewNode = value as FileListViewNode; if (fileListViewNode.FileType == FileType.Directory) { return(fileListViewNode.ImagePath); } //todo:1处理图标性能问题 //todo:2处理图标预览效果问题 BitmapImage img = ThumbnailHelper.GetInstance().GetBitmapThumbnail(fileListViewNode.FullName).ToBitmapImage(); return(img); }
private void AddRecomandatedVideos() { _mostRecommandedVideos.Clear(); Random random = new Random(); int[] randomVideoIndexList = Enumerable.Repeat <int>(-1, CommonAppStateDataHelper.ClientInfoObject.VideoInfoList.Count).ToArray(); //new int[CommonAppStateDataHelper.ClientInfoObject.VideoInfoList.Count]; int noOfIterations = 0; do { noOfIterations++; int newRandomNumber = random.Next(0, CommonAppStateDataHelper.ClientInfoObject.VideoInfoList.Count - 1); if (randomVideoIndexList.Contains(newRandomNumber) == false) { _mostRecommandedVideos.Add(CommonAppStateDataHelper.ClientInfoObject.VideoInfoList[newRandomNumber]); randomVideoIndexList[newRandomNumber] = newRandomNumber; } }while ((_mostRecommandedVideos.Count < 5 && _mostRecommandedVideos.Count <= CommonAppStateDataHelper.ClientInfoObject.VideoInfoList.Count) && noOfIterations < (CommonAppStateDataHelper.ClientInfoObject.VideoInfoList.Count * 2)); if (_mostRecommandedVideos.Count < 5 && _mostRecommandedVideos.Count < CommonAppStateDataHelper.ClientInfoObject.VideoInfoList.Count) { int intialCounterValue = _mostRecommandedVideos.Count == 0 ? 0 : _mostRecommandedVideos.Count - 1; for (int i = intialCounterValue; i < 5 && i < CommonAppStateDataHelper.ClientInfoObject.VideoInfoList.Count; i++) { // int newRandomNumber = 0; if (randomVideoIndexList[i] < 0) { _mostRecommandedVideos.Add(CommonAppStateDataHelper.ClientInfoObject.VideoInfoList[i]); randomVideoIndexList[i] = i; } } } for (int i = 0; _mostRecommandedVideos != null && i < _mostRecommandedVideos.Count; i++) { // Nitin Start //ThumbnailInfo thumbInfo = new ThumbnailInfo(); //thumbInfo.FileName = _mostRecommandedVideos[i].VideoName; //thumbInfo.ThumbnailFilePath = Path.Combine(ClientHelper.GetClientThumbanailPath(), ThumbnailHelper.GetThumbnailFileName(ClientHelper.GetClientThumbanailPath(),_mostRecommandedVideos[i].ClassName, _mostRecommandedVideos[i].Book)); //thumbInfo.VideoFullUrl = _mostRecommandedVideos[i].VideoFullUrl; //_mostRecommandedVideosThumbList.Add(thumbInfo); _mostRecommandedVideos[i].ThumbnailFilePath = ThumbnailHelper.GetThumbnailFilePathByVideoPath(_mostRecommandedVideos[i].VideoFullUrl); // Nitin End } if (_mostRecommandedVideos != null && _mostRecommandedVideos.Count > 0) { AddVideoThumbnailControls(pnlRecomVideo, _mostRecommandedVideos, CtlMostWatchedVideo_Click); } }
private string CreateThumbnail(string filePath) { if (File.Exists(filePath)) { var fc = Aurigma.GraphicsMill.AjaxControls.FileCache.GetInstance(); string thumbnailFileName = fc.GetPublicTempFileName(".jpg"); ThumbnailHelper.CreateThumbnail(filePath, fc.GetAbsolutePublicCachePath(thumbnailFileName), new System.Drawing.Size(40, 40), true); return(fc.GetRelativePublicCachePath(thumbnailFileName)); } else { return(null); } }
/// <summary> /// 得到图片文件,缩略图,根据参数(width:100,height:75)返回如: /// http://...../upload/editorial/day_111013/thumb/201110130326326847_100_75.jpg /// </summary> /// <param name="helper"></param> /// <param name="path"></param> /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> public static string ImageFile(this UrlHelper helper, string path, int width, int height, bool containStaticServiceUri = true) { if (string.IsNullOrEmpty(path)) { return(helper.StaticFile(@"/content/images/no_picture.jpg")); } if (width <= 0 || height <= 0) { return(helper.StaticFile(path)); } var thumbnailUrl = ThumbnailHelper.GetThumbnailUrl(path, width, height); var url = (containStaticServiceUri ? GetStaticServiceUri() : string.Empty) + thumbnailUrl; return(url); }
private async void PopulateGrid(StorageFolder folder) { if (folder != null) { var image = new Image(); var bitmapImage = new BitmapImage(); files = await folder.GetFilesAsync(); var videoList = VideoHelper.getVideosFromFolder(files, true); if (videoList.Count > 0) { Debug.WriteLine("Trying to generate video thumbnail"); bitmapImage = await ThumbnailHelper.getThumbnailForVideo(videoList[0]); image.Source = bitmapImage; Debug.WriteLine("Thumbnail set"); } else { bitmapImage.UriSource = new Uri("ms-appx:///Assets/folder-icon.png"); image.Source = bitmapImage; } var count = await VideoHelper.GetVideoCountFromFolder(folder); var model = new FolderModel() { title = folder.DisplayName, path = folder.Path, fileCount = count, imgSource = image.Source }; Debug.WriteLine(model.title + model.path + model.fileCount); folders.Add(model); Debug.WriteLine("********************"); foreach (var path in pathTree) { Debug.WriteLine(path); } Debug.WriteLine("********************"); } }
public FileEntity UploadImageThumbnailByWidth (HttpPostedFile fileData, string fileFolder, string physicalpath, int width, int height, string prefix = "") { ThumnailMode mode = ThumnailMode.EqualW; string fileType = "jpg"; FileEntity file = new FileEntity(); if (fileData != null) { try { string filePath = physicalpath + "/"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } file.DisplayName = Path.GetFileName(fileData.FileName); file.Extension = Path.GetExtension(file.DisplayName); file.Size = fileData.ContentLength; file.ContentType = fileData.ContentType; file.CreateTime = DateTime.Now; file.DbName = GetFileDBName(file.Extension); file.FilePath = "/" + fileFolder + "/" + file.DbName; Image image = Image.FromStream(fileData.InputStream); int outWidth = 0; int outHeight = 0; ThumbnailHelper.CreateOutWAndH(image, filePath + file.DbName, width, height, mode, fileType, out outWidth, out outHeight); file.ImageWidth = outWidth; file.ImageHeight = outHeight; return(file); } catch (Exception ex) { WebLogAgent.Write(ex); return(null); } } else { return(null); } }
public StoredFileService(IStoredFileRepository <StoredFileModelBussines <int>, int> storedFileRepository, IStoredFolderRepository <StoredFolderModelBussines <int>, int> storedFolderRepository, IAccountSubscriptionRepository <AccountSubscriptionModelBussines <int>, int> accountSubscriptionRepository, IRootFolderRepository <RootFolderModelBussines <int>, int> rootFolderRepository, ISubscriptionCapacityService subscriptionCapacityService, HostingEnvironmentHelper hostingEnvironmentHelper, ThumbnailHelper thumbnailHelper ) { this._storedFileRepository = storedFileRepository; this._storedFolderRepository = storedFolderRepository; this._accountSubscriptionRepository = accountSubscriptionRepository; this._rootFolderRepository = rootFolderRepository; this._hostingEnvironmentHelper = hostingEnvironmentHelper; this._thumbnailHelper = thumbnailHelper; this._subscriptionCapacityService = subscriptionCapacityService; }
private string CreateThumbnail(string filePath) { if (File.Exists(filePath)) { var fc = FileCache.GetInstance(); var thumbnailFileName = fc.GetPublicTempFileName(".gif"); ThumbnailHelper.CreateThumbnail(filePath, fc.GetAbsolutePublicCachePath(thumbnailFileName), new System.Drawing.Size(150, 100), false); return(fc.GetRelativePublicCachePath(thumbnailFileName)); } else { return(null); } }
public async Task <List <VideoData> > GetVideosIndexerData() { var response = await _client.GetAsync(videoIndexerApiUrl); if (response.IsSuccessStatusCode) { var json = await response.Content.ReadAsStringAsync(); var videoData = JsonConvert.DeserializeObject <List <VideoData> >(json); foreach (var item in videoData) { item.Thumbnail.Content = ThumbnailHelper.AddData(item.Thumbnail); } return(videoData); } return(default);
public void OnClick(CategorySystemInfo categoryInfo, ThumbnailHelper clickedOn) { var iData = ((Item)clickedOn.Data).Data; var data = iData.TryAndFind <CrossMetaData.OtherAppsData>(x => x.HasValues); var activeLink = data.GooglePlayLink; //for editor #if UNITY_ANDROID activeLink = data.GooglePlayLink; #elif UNITY_IOS activeLink = data.AppStoreLink; #endif if (!string.IsNullOrEmpty(activeLink)) { Application.OpenURL(activeLink); //AnalyticsManager.Instance.LogLinkClick(activeLink, "Promo App"); } }
/// <summary> /// /// </summary> /// <param name="originalImagePath"></param> /// <param name="imagesDpiDetail"></param> /// <param name="fileType">image/video</param> public Tuple <int, int> MakeThumbnail(string originalImagePath, ImagesDpiDetail imagesDpiDetail, string fileType = "image") { Tuple <int, int> wh = Tuple.Create(0, 0); if (imagesDpiDetail != null) { imagesDpiDetail.SectionItems.ForEach(s => { //生成的缩略图的路径格式是:原图路径 + “-”+ dpi + 后缀 string desPath = originalImagePath.Insert(originalImagePath.LastIndexOf('.'), "-" + (s.dpi ?? imagesDpiDetail.def)); //ThumbnailHelper.GenerateImage(originalImagePath, desPath, s.width, s.height); if (!System.IO.File.Exists(desPath)) { wh = ThumbnailHelper.GenerateImage2(originalImagePath, desPath, s.width, s.height, fileType); } }); } return(wh); }
private void AddMostWatchedVideos() { _mostWatchedVideos.Clear(); _mostWatchedVideos = CommonAppStateDataHelper.ClientInfoObject.VideoInfoList.OrderByDescending(k => k.WatchCount).Take(5).ToList <VideoInfo>(); for (int i = 0; _mostWatchedVideos != null && i < _mostWatchedVideos.Count; i++) { // Nitin Start //ThumbnailInfo thumbInfo = new ThumbnailInfo(); //thumbInfo.FileName = _mostWatchedVideos[i].VideoName; //thumbInfo.ThumbnailFilePath = Path.Combine(ClientHelper.GetClientThumbanailPath(), ThumbnailHelper.GetThumbnailFileName(ClientHelper.GetClientThumbanailPath(),_mostWatchedVideos[i].ClassName, _mostWatchedVideos[i].Book)); //thumbInfo.VideoFullUrl = _mostWatchedVideos[i].VideoFullUrl; //_mostWatchedVideosThumbList.Add(thumbInfo); _mostWatchedVideos[i].ThumbnailFilePath = ThumbnailHelper.GetThumbnailFilePathByVideoPath(_mostWatchedVideos[i].VideoFullUrl); // Nitin End } if (_mostWatchedVideos != null && _mostWatchedVideos.Count > 0) { AddVideoThumbnailControls(pnlMostWatchVideo, _mostWatchedVideos, CtlMostWatchedVideo_Click); } }
private void ExportTrack() { var track = new Track(); track.Map = sharedContainer.GetMap(); track.Checkpoints = sharedContainer.GetCheckpoints(); track.StartPosition = sharedContainer.StartPosition; track.InitialHeading = sharedContainer.StartRotation; var trackText = JsonConvert.SerializeObject(track, Formatting.Indented); var baseFileName = $"{Directory.GetCurrentDirectory()}\\Track_{DateTime.Now:YY_DD_MM_hh.mm.ss}"; var trackFileName = $"{baseFileName}.json"; var trackThumbnailName = $"{baseFileName}.png"; File.WriteAllText(trackFileName, trackText); ThumbnailHelper.GenerateTrackThumbnail(track, trackThumbnailName); notificationService.ShowToast( ToastType.Successful, "Track exported successfully"); }