/// <summary> /// Returns the path for the media's file on the disk. /// </summary> public static string GetMediaPath(this IWebHostEnvironment env, Media media, MediaSize size = MediaSize.Original) { var fileName = Path.GetFileName(media.FilePath); var localPath = Path.Combine(env.WebRootPath, "media", fileName); return(MediaPresenterService.GetSizedMediaPath(localPath, size)); }
/// <summary> /// Gets the file path for a media frame of specified size. /// </summary> public static string GetSizedMediaPath(string fullPath, MediaSize size) { if (string.IsNullOrEmpty(fullPath)) { return(fullPath); } if (size == MediaSize.Original) { return(fullPath); } if (size == MediaSize.Large) { return(Path.ChangeExtension(fullPath, ".lg.jpg")); } if (size == MediaSize.Medium) { return(Path.ChangeExtension(fullPath, ".md.jpg")); } if (size == MediaSize.Small) { return(Path.ChangeExtension(fullPath, ".sm.jpg")); } throw new ArgumentOutOfRangeException(nameof(size), "Unexpected media size!"); }
public string GetProductImage(ProductModel product, MediaSize thumbSize, int fitX, int fitY, bool bHttp) { string rc = null; if (product != null) { if (product.PrimaryMediaId != null) { var prodMedia = db.FindProductMedia(product.PrimaryMediaId.Value); if (prodMedia != null) { var media = MediaServices.FindMediaModel(prodMedia.MediaId, thumbSize, fitX, fitY); if (media != null) { string temp = MediaServices.GetMediaFileName(media, false); if (File.Exists(temp)) { int imageW = 0, imageH = 0; rc = MediaServices.GetMediaThumb(media, thumbSize, fitX, fitY, ref imageW, ref imageH); } } } } } if (rc == null) { rc = GetConfigurationSetting("SiteFolder", "") + "\\Content\\Default.jpg"; } return(rc); }
public NoteModel FindNoteModel(int id, CompanyModel company, int parentId, NoteType noteType, bool bCreateEmptyIfNotfound = true, MediaSize thumbSize = MediaSize.Medium, int fitX = 0, int fitY = 0) { NoteModel model = null; var n = db.FindNote(id); if (n == null) { if (bCreateEmptyIfNotfound) { model = new NoteModel { CompanyId = company.Id, NoteType = noteType, ParentId = parentId } } ; } else { model = mapToModel(n, thumbSize, fitX, fitY); } return(model); }
/// <summary> /// Set the Media Size /// </summary> /// <param name="size">MediaSize</param> public void SetMediaSize(MediaSize size) { if (size != null) { m_mediaSize = size; } } // setMediaSize
public string GetThumbFileName(string fileName, MediaSize thumbSize = MediaSize.Small) { int ilPos = fileName.LastIndexOf("."); string result = fileName; if (ilPos != -1) { string extn = fileName.Substring(ilPos); result = fileName.Substring(0, ilPos); switch (thumbSize) { case MediaSize.Large: result += "_ThumbLarge" + extn; break; case MediaSize.Medium: result += "_ThumbMedium" + extn; break; case MediaSize.Small: default: result += "_ThumbSmall" + extn; break; } } return(result); }
NoteAttachmentModel mapToModel(NoteAttachment attachment, MediaSize thumbSize, int fitX, int fitY) { var attachmentModel = Mapper.Map <NoteAttachment, NoteAttachmentModel>(attachment); attachmentModel.Media = MediaServices.MapToModel(attachment.Medium, thumbSize, fitX, fitY); return(attachmentModel); }
public void setInputScale(int dev_id, MediaSize scale, bool keep) { pjsua2PINVOKE.VidDevManager_setInputScale(swigCPtr, dev_id, MediaSize.getCPtr(scale), keep); if (pjsua2PINVOKE.SWIGPendingException.Pending) { throw pjsua2PINVOKE.SWIGPendingException.Retrieve(); } }
public void setSize(MediaSize size) { pjsua2PINVOKE.VideoWindow_setSize(swigCPtr, MediaSize.getCPtr(size)); if (pjsua2PINVOKE.SWIGPendingException.Pending) { throw pjsua2PINVOKE.SWIGPendingException.Retrieve(); } }
public MediaSize GetMediaSizeDefault() { m_mediaSize = VAdvantage.Login.Language.GetLoginLanguage().GetMediaSize(); if (m_mediaSize == null) { m_mediaSize = MediaSize.ISO.A4; } log.Fine("Size=" + m_mediaSize); return(m_mediaSize); } // getMediaSizeDefault
public MediaSize getInputScale(int dev_id) { MediaSize ret = new MediaSize(pjsua2PINVOKE.VidDevManager_getInputScale(swigCPtr, dev_id), true); if (pjsua2PINVOKE.SWIGPendingException.Pending) { throw pjsua2PINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public MediaModel FindMediaModel(int?id, MediaSize thumbSize = MediaSize.Medium, int fitX = 0, int fitY = 0) { MediaModel model = null; if (id != null) { var media = db.FindMedia(id.Value); if (media != null) { model = MapToModel(media, thumbSize, fitX, fitY); } } return(model); }
public MediaSize GetMediaSize() { if (m_mediaSize != null) { return(m_mediaSize); } String nameCode = GetCode(); if (nameCode != null) { // Get Name MediaSizeName nameMedia = null; CMediaSizeName msn = new CMediaSizeName(4); String[] names = msn.GetStringTable(); for (int i = 0; i < names.Length; i++) { String name = names[i]; if (name.Equals(nameCode, StringComparison.InvariantCultureIgnoreCase)) { nameMedia = (MediaSizeName)msn.GetEnumValueTable()[i]; log.Finer("Name=" + nameMedia); break; } } if (nameMedia != null) { m_mediaSize = MediaSize.GetMediaSizeForName(nameMedia); log.Fine("Name->Size=" + m_mediaSize); } } // Create New Media Size if (m_mediaSize == null) { float x = (float)GetSizeX(); float y = (float)GetSizeY(); if (x > 0 && y > 0) { m_mediaSize = new MediaSize(x, y, GetUnitsInt(), MediaSizeName.A); log.Fine("Size=" + m_mediaSize); } // Fallback if (m_mediaSize == null) { m_mediaSize = GetMediaSizeDefault(); } return(m_mediaSize); } return(m_mediaSize); }
private int computePageCount(PrintAttributes printAttributes) { int itemsPerPage = 4; MediaSize pageSize = printAttributes.GetMediaSize(); if (!pageSize.IsPortrait) { itemsPerPage = 6; } int printItemCount = 6; return((int)Math.Ceiling((double)(printItemCount / itemsPerPage))); }
public string GetMediaThumb(MediaModel media, MediaSize thumbSize, int fitX, int fitY, ref int imageW, ref int imageH) { string thumbImage; imageW = imageH = 0; var mediaType = db.FindMediaType(media.MediaTypeId); if (mediaType.CreateThumb) { if (media.ImageW <= fitX && media.ImageH <= fitY) { // Image is smaller than the fit area, so use it 'as is' thumbImage = GetMediaFileName(media, true); } else { // Image is larger than the fit area, so shrink it to fit if (media.ImageW != null && media.ImageH != null) { Size size = CalculateFitSize(media.ImageW.Value, media.ImageH.Value, fitX, fitY); imageW = size.Width; imageH = size.Height; } thumbImage = GetMediaFileName(media, true); } } else { // Media item which doesn't have thumbs created from itself eg MP3, MP4, PDF thumbImage = "/Content/MediaThumbs/"; switch (thumbSize) { case MediaSize.Large: thumbImage += mediaType.ThumbLarge; break; case MediaSize.Medium: thumbImage += mediaType.ThumbMedium; break; default: thumbImage += mediaType.ThumbSmall; break; } } return(thumbImage); }
/// <summary> /// Returns the photo model. /// </summary> public static MediaThumbnailVM GetMediaThumbnail(Media media, MediaSize size = MediaSize.Small) { if (media == null) { return(null); } return(new MediaThumbnailVM { Type = media.Type, Key = media.Key, ThumbnailUrl = GetSizedMediaPath(media.FilePath, size), Date = FuzzyDate.TryParse(media.Date) }); }
private static string getImageUrl(Data.Models.Media media, string type) { var baseUrl = Path.Combine(Environment.GetEnvironmentVariable("STATIC_BASE_URL"), "Images"); if (type == MediaSize.Original) { return(Path.Combine(baseUrl, media.LocalFilename)); } if (MediaSize.Compare(media.LargestResize, type) >= 0) { return(Path.Combine(baseUrl, type, media.LocalFilename)); } return(null); }
public List <NoteAttachmentModel> FindNoteAttachmentsModel(NoteModel note, MediaSize thumbSize, int fitX, int fitY) { List <NoteAttachmentModel> model = new List <NoteAttachmentModel>(); var n = db.FindNote(note.Id); if (n != null) { foreach (var na in n.NoteAttachments) { var newItem = mapToModel(na, thumbSize, fitX, fitY); model.Add(newItem); } } return(model); }
public MediaModel MapToModel(Medium media, MediaSize thumbSize, int fitX, int fitY) { var model = Mapper.Map <Medium, MediaModel>(media); if (media.MediaType != null) { model.Lightboxable = media.MediaType.Lightboxable; int imageW = 0, imageH = 0; model.MediaFile = GetMediaThumb(model, thumbSize, fitX, fitY, ref imageW, ref imageH); model.MediaHtml = GetMediaHtml(model, thumbSize, fitX, fitY); } return(model); }
NoteModel mapToModel(Note item, MediaSize thumbSize, int fitX, int fitY) { var newItem = Mapper.Map <Note, NoteModel>(item); newItem.CreatedBy = (item.User.FirstName + " " + item.User.LastName).WordCapitalise(); foreach (var attachment in item.NoteAttachments) { var att = mapToModel(attachment, thumbSize, fitX, fitY); if (!string.IsNullOrEmpty(newItem.Attachments)) { newItem.Attachments += "<br/><br/>"; } newItem.Attachments += "<strong>" + attachment.Medium.Title + "</strong><br/>"; newItem.Attachments += att.Media.MediaHtml; } return(newItem); }
public NoteListModel FindNotesListModel(NoteType noteType, int parentId, int index, int pageNo, int pageSize, string search, MediaSize thumbSize, int fitX = 0, int fitY = 0) { var model = new NoteListModel(); model.GridIndex = index; var allItems = db.FindNotes(noteType, parentId) .Where(n => string.IsNullOrEmpty(search) || (n.Subject != null && n.Subject.ToLower().Contains(search.ToLower())) || (n.Message != null && n.Message.ToLower().Contains(search.ToLower()))) .OrderByDescending(n => n.DateCreated); model.TotalRecords = allItems.Count(); foreach (var item in allItems.Skip((pageNo - 1) * pageSize) .Take(pageSize)) { var newItem = mapToModel(item, thumbSize, fitX, fitY); model.Items.Add(newItem); } return(model); }
public void setSize(MediaSize size) { pjsua2PINVOKE.VideoWindow_setSize(swigCPtr, MediaSize.getCPtr(size)); if (pjsua2PINVOKE.SWIGPendingException.Pending) throw pjsua2PINVOKE.SWIGPendingException.Retrieve(); }
public string GetMediaHtml(MediaModel media, MediaSize thumbSize, int fitX, int fitY) { string htmlText = ""; int imageW = (media.ImageW != null ? media.ImageW.Value : 0), imageH = (media.ImageH != null ? media.ImageH.Value : 0); string sizeText = "", titleText = media.Title, mediaFileName = GetMediaFileName(media, true), mediaThumb = GetMediaThumb(media, thumbSize, fitX, fitY, ref imageW, ref imageH); if (fitX > 0 && fitY > 0) { sizeText = GetMediaSizeString(imageW, imageH); var mediaType = db.FindMediaType(media.MediaTypeId); if (mediaType.CreateThumb) { // This item type does have a thumb if (mediaType.Lightboxable) { htmlText = "<a class=\"fancybox\" href=\"" + mediaFileName + "\" data-fancybox-group=\"gallery\" title=\"" + titleText + "\">"; htmlText += "<img src=\""; if (media.FileName.IsWebUrl()) { htmlText += media.FileName; } else { htmlText += mediaThumb; } htmlText += "\"" + sizeText + "/></a>"; } else { htmlText = "<a href=\""; htmlText += mediaFileName; htmlText += "\" target=\"MediaViewer\">"; htmlText += "<img src=\"" + mediaThumb; htmlText += "\" border=\"0\"" + sizeText + "/></a>"; } } else { // This item type doesn't have a thumb so use a system thumb image // eg MP3, MP4 if (mediaType.Lightboxable) { // This item type doesn't have a thumb, but it is lightboxable switch ((Enumerations.MediaType)media.MediaTypeId) { case Enumerations.MediaType.YOUTUBE: htmlText = "<a class=\"fancybox-media\" href=\"" + mediaFileName + "\">"; htmlText += "<img src=\"" + mediaThumb; htmlText += "\" style=\"width:" + fitX.ToString() + ";height:auto\" border=\"0\"/></a>"; break; case Enumerations.MediaType.MPG3: htmlText = "<a class=\"fancybox-mp3\" rel=\"audio\" title=\"" + titleText + "\" href=\"#data_" + media.Id.ToString() + "_X\">"; htmlText += "<img src=\"" + mediaThumb + "\""; htmlText += " border=\"0\" alt=\"" + titleText + "\"/></a>"; htmlText += "<div style=\"display:none\">"; htmlText += " <div id=\"data_" + media.Id.ToString() + "_X\">"; htmlText += " <audio controls>"; htmlText += " <source src=\"" + mediaFileName + "\" type=\"audio/mpeg\">"; htmlText += " <p>Your browser does not support the audio element.</p>"; htmlText += " </audio>"; htmlText += " </div>"; htmlText += "</div>"; break; case Enumerations.MediaType.MPG4: htmlText = "<a class=\"fancybox-mp4\" rel=\"video\" title=\"" + titleText + "\" href=\"#data_" + media.Id.ToString() + "_X\">"; htmlText += "<img src=\"" + mediaThumb + "\""; htmlText += " border=\"0\" alt=\"" + titleText + "\"/></a>"; htmlText += "<div style=\"display:none\">"; htmlText += " <div id=\"data_" + media.Id.ToString() + "_X\">"; htmlText += " <video controls>"; htmlText += " <source src=\"" + mediaFileName + "\" type=\"video/mp4\" codecs=\"avc1.42E01E, mp4a.40.2\"/>"; htmlText += " <p>Your browser does not support the video element.</p>"; htmlText += " </video>"; htmlText += " </div>"; htmlText += "</div>"; break; default: htmlText = "<a class=\"fancybox\" href=\"" + mediaFileName + "\" data-fancybox-group=\"gallery\" title=\"" + titleText + "\">"; htmlText += "<img src=\"" + mediaThumb + "\""; htmlText += sizeText; htmlText += " border=\"0\"/></a>"; break; } } else { // This item type doesn't have a thumb and it isn't lightboxable htmlText = "<a href=\""; htmlText += mediaFileName; htmlText += "\" target=\"MediaViewer\">"; htmlText += "<img src=\"" + mediaThumb + "\" border=\"0\"/></a>"; } } } return(htmlText); }
public MediaSizeModel(MediaSize size) { Height = size.Height; Width = size.Width; Resize = size.Resize; }
public Language(String name, String AD_Language, System.Globalization.CultureInfo culture, Boolean?decimalPoint, String appDatePattern, MediaSize mediaSize) { if (name == null || AD_Language == null) { throw new ArgumentException("Language - parameter is null"); } _name = name; _AD_Language = AD_Language; _culture = culture; // _decimalPoint = decimalPoint; //set the decimal point SetDateFormat(appDatePattern); SetMediaSize(mediaSize); }
///<summary> ///Given a short link, issues a redirect to that media's JPG file. ///Search media by shortcode from url. An example shortlink is http://instagram.com/p/D/ Its corresponding shortcode is D. ///</summary> ///<param name="shortcode">A media object's shortcode can be found in its shortlink URL.</param> ///<param name="mediaSize">Size of the media.</param> ///<returns>An HttpResponse Message with the Content containting the image data</returns> public Task <HttpResponseMessage> ShortCode(string shortcode, MediaSize mediaSize = MediaSize.Medium) { var request = Request("/p/" + shortcode + "/media/?size=" + (char)mediaSize); return(Client.SendAsync(request)); }
/// <summary> /// Calculates a <code>PageFormat</code> with values consistent with those /// supported by the current <code>PrintService</code> for this job /// (ie the value returned by <code>getPrintService()</code>) and media, /// printable area and orientation contained in <code>attributes</code>. /// <para> /// Calling this method does not update the job. /// It is useful for clients that have a set of attributes obtained from /// <code>printDialog(PrintRequestAttributeSet attributes)</code> /// and need a PageFormat to print a Pageable object. /// </para> /// </summary> /// <param name="attributes"> a set of printing attributes, for example obtained /// from calling printDialog. If <code>attributes</code> is null a default /// PageFormat is returned. </param> /// <returns> a <code>PageFormat</code> whose settings conform with /// those of the current service and the specified attributes. /// @since 1.6 </returns> public virtual PageFormat GetPageFormat(PrintRequestAttributeSet attributes) { PrintService service = PrintService; PageFormat pf = DefaultPage(); if (service == null || attributes == null) { return(pf); } Media media = (Media)attributes.get(typeof(Media)); MediaPrintableArea mpa = (MediaPrintableArea)attributes.get(typeof(MediaPrintableArea)); OrientationRequested orientReq = (OrientationRequested)attributes.get(typeof(OrientationRequested)); if (media == null && mpa == null && orientReq == null) { return(pf); } Paper paper = pf.Paper; /* If there's a media but no media printable area, we can try * to retrieve the default value for mpa and use that. */ if (mpa == null && media != null && service.isAttributeCategorySupported(typeof(MediaPrintableArea))) { Object mpaVals = service.getSupportedAttributeValues(typeof(MediaPrintableArea), null, attributes); if (mpaVals is MediaPrintableArea[] && ((MediaPrintableArea[])mpaVals).Length > 0) { mpa = ((MediaPrintableArea[])mpaVals)[0]; } } if (media != null && service.isAttributeValueSupported(media, null, attributes)) { if (media is MediaSizeName) { MediaSizeName msn = (MediaSizeName)media; MediaSize msz = MediaSize.getMediaSizeForName(msn); if (msz != null) { double inch = 72.0; double paperWid = msz.getX(MediaSize.INCH) * inch; double paperHgt = msz.getY(MediaSize.INCH) * inch; paper.SetSize(paperWid, paperHgt); if (mpa == null) { paper.SetImageableArea(inch, inch, paperWid - 2 * inch, paperHgt - 2 * inch); } } } } if (mpa != null && service.isAttributeValueSupported(mpa, null, attributes)) { float[] printableArea = mpa.getPrintableArea(MediaPrintableArea.INCH); for (int i = 0; i < printableArea.Length; i++) { printableArea[i] = printableArea[i] * 72.0f; } paper.SetImageableArea(printableArea[0], printableArea[1], printableArea[2], printableArea[3]); } if (orientReq != null && service.isAttributeValueSupported(orientReq, null, attributes)) { int orient; if (orientReq.Equals(OrientationRequested.REVERSE_LANDSCAPE)) { orient = PageFormat.REVERSE_LANDSCAPE; } else if (orientReq.Equals(OrientationRequested.LANDSCAPE)) { orient = PageFormat.LANDSCAPE; } else { orient = PageFormat.PORTRAIT; } pf.Orientation = orient; } pf.Paper = paper; pf = ValidatePage(pf); return(pf); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(MediaSize obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
///<summary> ///Given a short link, issues a redirect to that media's JPG file. ///Search media by shortcode from url. An example shortlink is http://instagram.com/p/D/ Its corresponding shortcode is D. ///</summary> ///<param name="shortcode">A media object's shortcode can be found in its shortlink URL.</param> ///<param name="mediaSize">Size of the media.</param> ///<returns>An HttpResponse Message with the Content containting the image data</returns> public Task<HttpResponseMessage> ShortCode(string shortcode, MediaSize mediaSize = MediaSize.Medium) { var request = Request("/p/" + shortcode + "/media/?size=" + (char)mediaSize); return Client.SendAsync(request); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(MediaSize obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; }