public void BaseTestResize(IPicture input, IPicture Compare, double scaleX, double scaleY) { input.Resize(scaleX, scaleY); IClientAnchor inpCA = input.ClientAnchor; IClientAnchor cmpCA = Compare.ClientAnchor; Size inpDim = ImageUtils.GetDimensionFromAnchor(input); Size cmpDim = ImageUtils.GetDimensionFromAnchor(Compare); double emuPX = Units.EMU_PER_PIXEL; Assert.AreEqual(inpDim.Height, cmpDim.Height, emuPX * 6, "the image height differs"); Assert.AreEqual(inpDim.Width, cmpDim.Width, emuPX * 6, "the image width differs"); Assert.AreEqual(inpCA.Col1, cmpCA.Col1, "the starting column differs"); Assert.AreEqual(inpCA.Dx1, cmpCA.Dx1, 1, "the column x-offset differs"); Assert.AreEqual(inpCA.Dy1, cmpCA.Dy1, 1, "the column y-offset differs"); Assert.AreEqual(inpCA.Col2, cmpCA.Col2, "the ending columns differs"); // can't compare row heights because of variable test heights input.Resize(); inpDim = ImageUtils.GetDimensionFromAnchor(input); Size imgDim = input.GetImageDimension(); Assert.AreEqual(imgDim.Height, inpDim.Height / emuPX, 1, "the image height differs"); Assert.AreEqual(imgDim.Width, inpDim.Width / emuPX, 1, "the image width differs"); }
/*[STAThread] static void Main() { if(!SoundCloudCore.Connect(new Login(user, pass, ClientID, ClientSecret))) return; var list = new List<int>(); for(var i = 0; i < Me.LikesCount; i += 10) { if(i >= Me.LikesCount) break; list = list.Concat(Me.GetLikedTracks(i, 10)).ToList(); Console.WriteLine("SEARCHING: " + i + "/" + Me.LikesCount); } Console.WriteLine("COMPLETED: " + list.Count + " / " + Me.LikesCount + "Track info was downloaded"); // Download all tracks to folder foreach(var id in list) DownloadTrack(SoundCloudCore.Tracks[id]); Directory.Delete("Images", true); Console.ReadLine(); }*/ static void DownloadTrack(Track track) { var wc = new WebClient(); if(!Directory.Exists("Tracks")) Directory.CreateDirectory("Tracks"); if(!Directory.Exists("Images")) Directory.CreateDirectory("Images"); var path = "Tracks\\" + track.Title + ".mp3"; if(System.IO.File.Exists(path)) return; try { wc.DownloadFile(new Uri(track.StreamUrl), path); // Write tag if(!System.IO.File.Exists(path)) return; var tag = TagLib.File.Create(path); tag.Tag.Title = track.Title; tag.Tag.BeatsPerMinute = (uint)track.Bpm; tag.Tag.Year = (uint)track.Created.Year; // Get track cover var imgPath = "Images\\" + track.Title + ".jpg"; wc.DownloadFile(new Uri(track.GetCover(AlbumSize.x300)), imgPath); if(System.IO.File.Exists(imgPath)) { var pic = new IPicture[1]; pic[0] = new Picture(imgPath); tag.Tag.Pictures = pic; } // Save tag info tag.Save(); Console.WriteLine("Downloaded track: " + track.Title); } catch(Exception ex) { Console.WriteLine("Error downloading track: " + track.Title + "; Exception: " + ex.Message); } }
public Button(IPicture picture, string caption) : base() { TextLabel = new Label(caption); MyPicture = new PictureBox(picture); this.Add(MyPicture); this.Add(TextLabel); }
public CollapsePicture(IPicture expandedPicture, IPicture collapsedPicture) : base(expandedPicture, collapsedPicture) { this.Box.Margins.SetLeftAndTop(3); this.Box.Margins.Right = 8; this.Box.Margins.Bottom = 3; this.Box.MouseSensitivityArea = this.Box.Margins; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the DraftViewVc class /// </summary> /// <param name="target">target of the view (printer or draft)</param> /// <param name="filterInstance">Number used to make filters unique for each main /// window</param> /// <param name="styleSheet">Optional stylesheet. Null is okay if this view constructor /// promises never to try to display a back translation</param> /// <param name="displayInTable">True to display the paragraphs in a table layout, /// false otherwise</param> /// ------------------------------------------------------------------------------------ public DraftViewVc(LayoutViewTarget target, int filterInstance, IVwStylesheet styleSheet, bool displayInTable) : base(target, filterInstance) { m_UnfinishedPic = PrepareImage(TeResourceHelper.BackTranslationUnfinishedImage); m_FinishedPic = PrepareImage(TeResourceHelper.BackTranslationFinishedImage); m_CheckedPic = PrepareImage(TeResourceHelper.BackTranslationCheckedImage); m_stylesheet = styleSheet; m_fDisplayInTable = displayInTable; //m_fLazy = true; // This makes the paragraphs lazy. }
public static Bitmap GetBitmap(IPicture picture) { try { Image image = PictureToImage(picture); return (Bitmap) image; } catch (Exception) { return null; } }
public AttachedPictureFrame(IPicture picture) : base(FrameType.APIC, 4) { this.text_encoding = TagLib.Id3v2.Tag.DefaultEncoding; if (picture == null) { throw new ArgumentNullException("picture"); } this.mime_type = picture.MimeType; this.type = picture.Type; this.description = picture.Description; this.data = picture.Data; }
public Id3v2AttachedPictureFrame(IPicture picture) : base("APIC") { if (picture != null) { //textEncoding = StringType.UTF8; mimeType = picture.MimeType; type = picture.Type; description = picture.Description; data = picture.Data; } //this.resourceFormat = null; }
private static void CopyTags(Tag source, Tag target) { source.CopyTo(target, true); var l = source.Pictures.Length; var pictures = new IPicture[l]; for (var i = 0; i < source.Pictures.Length; i++) { pictures[i] = new Picture(source.Pictures[i].Data) { MimeType = source.Pictures[i].MimeType, Description = source.Pictures[i].Description, Type = source.Pictures[i].Type }; } target.Pictures = pictures; }
private void ItemImageCopy_Click(object sender, RoutedEventArgs e) { try { var track = SelectedTrack; if (track != null) { var file = TagLib.File.Create(track.Path); if (file.Tag != null && file.Tag.Pictures != null && file.Tag.Pictures.Length > 0) copiedPicture = file.Tag.Pictures[0]; } } catch (Exception ex) { var message = ex.Message; } }
public Picture(IPicture picture) { if (picture == null) { throw new ArgumentNullException("picture"); } this.type = picture.Type; this.mime_type = picture.MimeType; this.description = picture.Description; this.picture_data = picture.Data; TagLib.Flac.Picture picture2 = picture as TagLib.Flac.Picture; if (picture2 != null) { this.width = picture2.Width; this.height = picture2.Height; this.color_depth = picture2.ColorDepth; this.indexed_colors = picture2.IndexedColors; } }
public Picture (IPicture picture) { if (picture == null) throw new ArgumentNullException ("picture"); _type = picture.Type; _mimetype = picture.MimeType; _description = picture.Description; _data = picture.Data; TagLib.Flac.Picture flac_picture = picture as TagLib.Flac.Picture; if (flac_picture != null) { _width = flac_picture.Width; _height = flac_picture.Height; _color_depth = flac_picture.ColorDepth; _indexed_colors = flac_picture.IndexedColors; } }
private static void InsertAlbumArt(Guid albumId, IPicture pic, ref Repository repo) { if (repo.Images.Count(x => x.LinkedId == albumId) > 0) return; var bitmap = ImageUtilities.ImageFromBuffer(pic.Data.ToArray()); var img = new Image { Height = (int) bitmap.Height, Id = Guid.NewGuid(), ImageData = pic.Data.ToArray(), LinkedId = albumId, Size = (int) ImageSize.ExtraLarge, Url = "", Width = (int) bitmap.Width }; repo.Images.InsertOnSubmit(img); repo.SubmitChanges(); }
public void AddPicture(IOldTrack track, IPicture picture) { var file = GetFile(track.Path); var existingPictures = file.Tag.Pictures; if (existingPictures == null || existingPictures.Length == 0) { file.Tag.Pictures = new IPicture[1] { picture }; file.Save(); track.ImageData = picture.Data; } else { var pictures = new IPicture[existingPictures.Length + 1]; pictures[0] = picture; for (var i = 1; i < pictures.Length; i++) pictures[i] = existingPictures[i]; file.Tag.Pictures = pictures; file.Save(); track.ImageData = picture.Data; } }
/// <summary/> protected virtual void Dispose(bool fDisposing) { Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType() + " *******"); // Must not be run more than once. if (IsDisposed) return; if (fDisposing) { // Dispose managed resources here. var disposable = m_UnfinishedPic as IDisposable; if (disposable != null) disposable.Dispose(); disposable = m_FinishedPic as IDisposable; if (disposable != null) disposable.Dispose(); disposable = m_CheckedPic as IDisposable; if (disposable != null) disposable.Dispose(); } // Dispose unmanaged resources here, whether disposing is true or false. if (m_UnfinishedPic != null && Marshal.IsComObject(m_UnfinishedPic)) Marshal.ReleaseComObject(m_UnfinishedPic); m_UnfinishedPic = null; if (m_FinishedPic != null && Marshal.IsComObject(m_FinishedPic)) Marshal.ReleaseComObject(m_FinishedPic); m_FinishedPic = null; if (m_CheckedPic != null && Marshal.IsComObject(m_CheckedPic)) Marshal.ReleaseComObject(m_CheckedPic); m_CheckedPic = null; IsDisposed = true; }
void OnButtonClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.Presentation.Templates.Images.pptx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fileStream); #region Slide 1 ISlide slide1 = presentation.Slides[0]; IShape shape1 = (IShape)slide1.Shapes[0]; shape1.Left = 1.27 * 72; shape1.Top = 0.85 * 72; shape1.Width = 10.86 * 72; shape1.Height = 3.74 * 72; ITextBody textFrame = shape1.TextBody; IParagraphs paragraphs = textFrame.Paragraphs; paragraphs.Add(); IParagraph paragraph = paragraphs[0]; paragraph.HorizontalAlignment = HorizontalAlignmentType.Left; ITextParts textParts = paragraph.TextParts; textParts.Add(); ITextPart textPart = textParts[0]; textPart.Text = "Essential Presentation "; textPart.Font.CapsType = TextCapsType.All; textPart.Font.FontName = "Calibri Light (Headings)"; textPart.Font.FontSize = 80; textPart.Font.Color = ColorObject.Black; IComment comment = slide1.Comments.Add(0.35, 0.04, "Author1", "A1", "Essential Presentation is available from 13.1 versions of Essential Studio", DateTime.Now); #endregion #region Slide2 ISlide slide2 = presentation.Slides.Add(SlideLayoutType.Blank); IPresentationChart chart = slide2.Shapes.AddChart(230, 80, 500, 400); //Specifies the chart title chart.ChartTitle = "Sales Analysis"; //Sets chart data - Row1 chart.ChartData.SetValue(1, 2, "Jan"); chart.ChartData.SetValue(1, 3, "Feb"); chart.ChartData.SetValue(1, 4, "March"); //Sets chart data - Row2 chart.ChartData.SetValue(2, 1, 2010); chart.ChartData.SetValue(2, 2, 60); chart.ChartData.SetValue(2, 3, 70); chart.ChartData.SetValue(2, 4, 80); //Sets chart data - Row3 chart.ChartData.SetValue(3, 1, 2011); chart.ChartData.SetValue(3, 2, 80); chart.ChartData.SetValue(3, 3, 70); chart.ChartData.SetValue(3, 4, 60); //Sets chart data - Row4 chart.ChartData.SetValue(4, 1, 2012); chart.ChartData.SetValue(4, 2, 60); chart.ChartData.SetValue(4, 3, 70); chart.ChartData.SetValue(4, 4, 80); //Creates a new chart series with the name IOfficeChartSerie serieJan = chart.Series.Add("Jan"); //Sets the data range of chart serie � start row, start column, end row, end column serieJan.Values = chart.ChartData[2, 2, 4, 2]; //Creates a new chart series with the name IOfficeChartSerie serieFeb = chart.Series.Add("Feb"); //Sets the data range of chart serie � start row, start column, end row, end column serieFeb.Values = chart.ChartData[2, 3, 4, 3]; //Creates a new chart series with the name IOfficeChartSerie serieMarch = chart.Series.Add("March"); //Sets the data range of chart series � start row, start column, end row, end column serieMarch.Values = chart.ChartData[2, 4, 4, 4]; //Sets the data range of the category axis chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 4, 1]; //Specifies the chart type chart.ChartType = OfficeChartType.Column_Clustered_3D; slide2.Comments.Add(0.35, 0.04, "Author2", "A2", "All 3D-chart types are supported in Presentation library.", DateTime.Now); #endregion #region Slide3 ISlide slide3 = presentation.Slides.Add(SlideLayoutType.ContentWithCaption); slide3.Background.Fill.FillType = FillType.Solid; slide3.Background.Fill.SolidFill.Color = ColorObject.White; //Adds shape in slide IShape shape2 = (IShape)slide3.Shapes[0]; shape2.Left = 0.47 * 72; shape2.Top = 1.15 * 72; shape2.Width = 3.5 * 72; shape2.Height = 4.91 * 72; ITextBody textFrame1 = shape2.TextBody; //Instance to hold paragraphs in textframe IParagraphs paragraphs1 = textFrame1.Paragraphs; IParagraph paragraph1 = paragraphs1.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left; ITextPart textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph2 = paragraphs1.Add(); paragraph2.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph2.AddTextPart(); textpart1.Text = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph3 = paragraphs1.Add(); paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph3.AddTextPart(); textpart1.Text = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph4 = paragraphs1.Add(); paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph4.AddTextPart(); textpart1.Text = "Lorem tortor neque, purus taciti quis id. Elementum integer orci accumsan minim phasellus vel."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); slide3.Shapes.RemoveAt(1); slide3.Shapes.RemoveAt(1); //Adds picture in the shape resourcePath = "SampleBrowser.Samples.Presentation.Templates.tablet.jpg"; fileStream = assembly.GetManifestResourceStream(resourcePath); IPicture picture1 = slide3.Shapes.AddPicture(fileStream, 5.18 * 72, 1.15 * 72, 7.3 * 72, 5.31 * 72); fileStream.Dispose(); slide3.Comments.Add(0.14, 0.04, "Author3", "A3", "Can we use a different font family for this text?", DateTime.Now); #endregion MemoryStream stream = new MemoryStream(); presentation.Save(stream); presentation.Close(); stream.Position = 0; if (stream != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save("Comments.pptx", "application/powerpoint", stream, m_context); } }
private void InitCover(Tag tag) { IPicture pic = null; foreach (var p in tag.Pictures) { if (p.Type == PictureType.FrontCover) { pic = p; break; } switch (p.Type) { case PictureType.Other: case PictureType.OtherFileIcon: case PictureType.FileIcon: pic = p; break; default: if (pic == null) { pic = p; } break; } } // Check for art in the files folder var maybeAlbumFolder = false; if (pic == null) { var fileGuid = string.Empty; // We could check all files with the same extension all have the same artist or album // For now just check if we have 20 or less files with the same extension if (Item.Directory.GetFiles("*" + Item.Extension).Length <= 20) { maybeAlbumFolder = true; } if (tag.TagTypes.HasFlag(TagTypes.Id3v2)) { File tagv2File = File.Create(Item.FullName); var tag2 = (TagLib.Id3v2.Tag)tagv2File.GetTag(TagTypes.Id3v2); var pvt = TagLib.Id3v2.PrivateFrame.Get(tag2, "WM/WMCollectionID", false); if (pvt != null) { var albumGuid = new Guid(pvt.PrivateData.Data); fileGuid = albumGuid.ToString(); } } if (maybeAlbumFolder || !string.IsNullOrEmpty(fileGuid)) { var largeFiles = Directory.GetFiles(Item.Directory.FullName, AlbumArtPrefix + "*" + fileGuid + "*Large.jpg"); if (largeFiles.Length > 0) { pic = new FilePicture(new FileInfo(largeFiles[0])); } } } if (pic == null && maybeAlbumFolder) { var albumFolderImg = System.IO.Path.Combine(Item.Directory.FullName, AlbumFolder); if (System.IO.File.Exists(albumFolderImg)) { pic = new FilePicture(new FileInfo(albumFolderImg)); } } if (pic != null) { try { CachedCover = new Cover(Item, pic.Data.ToStream()); } catch (Exception ex) { Debug("Failed to generate thumb for " + Item.FullName, ex); } } }
public override void Flip(IPicture picture, Base.FlipMode flipMode) { using var image = FromPicture(picture, out var imageFormat); image.Mutate(x => x.Flip(SixLabors.ImageSharp.Processing.FlipMode.Horizontal)); picture.Data = ToByteArray(image, imageFormat); }
/** * Calculates the dimensions in EMUs for the anchor of the given picture * * @param picture the picture Containing the anchor * @return the dimensions in EMUs */ public static Size GetDimensionFromAnchor(IPicture picture) { IClientAnchor anchor = picture.ClientAnchor; bool isHSSF = (anchor is HSSFClientAnchor); ISheet sheet = picture.Sheet; double w = 0; int col2 = anchor.Col1; //space in the leftmost cell w = sheet.GetColumnWidthInPixels(col2++); if (isHSSF) { w *= 1 - anchor.Dx1 / 1024d; } else { w -= anchor.Dx1 / Units.EMU_PER_PIXEL; } while (col2 < anchor.Col2) { w += sheet.GetColumnWidthInPixels(col2++); } if (isHSSF) { w += sheet.GetColumnWidthInPixels(col2) * anchor.Dx2 / 1024d; } else { w += anchor.Dx2 / Units.EMU_PER_PIXEL; } double h = 0; int row2 = anchor.Row1; h = GetRowHeightInPixels(sheet, row2++); if (isHSSF) { h *= 1 - anchor.Dy1 / 256d; } else { h -= anchor.Dy1 / Units.EMU_PER_PIXEL; } while (row2 < anchor.Row2) { h += GetRowHeightInPixels(sheet, row2++); } if (isHSSF) { h += GetRowHeightInPixels(sheet, row2) * anchor.Dy2 / 256; } else { h += anchor.Dy2 / Units.EMU_PER_PIXEL; } return new Size((int)w * Units.EMU_PER_PIXEL, (int)h * Units.EMU_PER_PIXEL); }
// ---------------------------------------------------------------------- partial static void OnChange_Picture(DependencyObject dobj, IPicture oldValue, IPicture newValue, ref bool handled);
public Button(IPicture picture) : base() { MyPicture = new PictureBox(picture); this.Add(MyPicture); }
public PictureDto(IPicture picture) { Reset(picture); }
/// <summary> /// Recibe una imagen, la guarda en una variable image y la retorna. /// </summary> /// <param name="picture">Imagen a recibir</param> /// <returns>La misma imagen</returns> public IPicture Send(IPicture picture) { this.image = picture; return(this.image); }
private async void Button_Click_1(object sender, RoutedEventArgs e) { Assembly assembly = typeof(ImagesPresentation).GetTypeInfo().Assembly; string resourcePath = "Syncfusion.SampleBrowser.UWP.Presentation.Presentation.Assets.Images.pptx"; Stream fileStream = assembly.GetManifestResourceStream(resourcePath); IPresentation presentation = await Presentation.OpenAsync(fileStream); #region Slide1 ISlide slide1 = presentation.Slides[0]; IShape shape1 = (IShape)slide1.Shapes[0]; shape1.Left = 1.27 * 72; shape1.Top = 0.56 * 72; shape1.Width = 9.55 * 72; shape1.Height = 5.4 * 72; ITextBody textFrame = shape1.TextBody; IParagraphs paragraphs = textFrame.Paragraphs; paragraphs.Add(); IParagraph paragraph = paragraphs[0]; paragraph.HorizontalAlignment = HorizontalAlignmentType.Left; ITextParts textParts = paragraph.TextParts; textParts.Add(); ITextPart textPart = textParts[0]; textPart.Text = "Essential Presentation "; textPart.Font.CapsType = TextCapsType.All; textPart.Font.FontName = "Calibri Light (Headings)"; textPart.Font.FontSize = 80; textPart.Font.Color = ColorObject.Black; #endregion #region Slide2 ISlide slide2 = presentation.Slides.Add(SlideLayoutType.ContentWithCaption); slide2.Background.Fill.FillType = FillType.Solid; slide2.Background.Fill.SolidFill.Color = ColorObject.White; //Adds shape in slide shape1 = (IShape)slide2.Shapes[0]; shape1.Left = 0.47 * 72; shape1.Top = 1.15 * 72; shape1.Width = 3.5 * 72; shape1.Height = 4.91 * 72; ITextBody textFrame1 = shape1.TextBody; //Instance to hold paragraphs in textframe IParagraphs paragraphs1 = textFrame1.Paragraphs; IParagraph paragraph1 = paragraphs1.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left; ITextPart textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph2 = paragraphs1.Add(); paragraph2.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph2.AddTextPart(); textpart1.Text = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph3 = paragraphs1.Add(); paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph3.AddTextPart(); textpart1.Text = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph4 = paragraphs1.Add(); paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph4.AddTextPart(); textpart1.Text = "Lorem tortor neque, purus taciti quis id. Elementum integer orci accumsan minim phasellus vel."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); slide2.Shapes.RemoveAt(1); slide2.Shapes.RemoveAt(1); //Adds picture in the shape resourcePath = "Syncfusion.SampleBrowser.UWP.Presentation.Presentation.Assets.tablet.jpg"; fileStream = assembly.GetManifestResourceStream(resourcePath); IPicture picture1 = slide2.Shapes.AddPicture(fileStream, 5.18 * 72, 1.15 * 72, 7.3 * 72, 5.31 * 72); fileStream.Dispose(); #endregion MemoryStream ms = new MemoryStream(); SavePPTX(presentation); }
public GIF(IPicture img) : base(img) { }
public static extern int OleCreatePictureIndirect(PicDesc pDesc, GUID RefIID, int fPictureOwnsHandle, IPicture pPic);
internal static void Go(string path) { int filesProcessed = 0; int filesWritten = 0; int filesSkipped = 0; if (string.IsNullOrWhiteSpace(path)) { path = Path.GetDirectoryName(typeof(Program).Assembly.Location); } DirectoryInfo dir = new DirectoryInfo(path); Console.WriteLine(Properties.Resources.ProcessBegin, dir.FullName); /* "Supported" extensions. Actually we support a lot more (via TagLibSharp). * However these are sufficient for me. You may add any other extension you like. */ IList <string> extensions = new List <string>(); extensions.Add(WildcardMp3); extensions.Add(WildcardFlac); foreach (string ext in extensions) { Console.WriteLine(Properties.Resources.ProcessingWildcardNow, ext); IEnumerable <FileInfo> files = dir.EnumerateFiles(ext, SearchOption.AllDirectories); foreach (FileInfo file in files) { filesProcessed++; DirectoryInfo fileDir = file.Directory; FileInfo folderJpg = new FileInfo(Path.Combine(fileDir.FullName, FolderJpgFileName)); if (folderJpg.Exists) { filesSkipped++; continue; } var taggedFile = TagLib.File.Create(file.FullName); IPicture[] pictures = taggedFile.Tag.Pictures; IPicture pic = pictures.FirstOrDefault(_ => _.Type == PictureType.FrontCover) ?? pictures.FirstOrDefault(); if (pic == null) { continue; } using (MemoryStream srcImgStream = new MemoryStream(pic.Data.Data)) { _fac.Load(srcImgStream); _fac.Format(new JpegFormat()); using (FileStream fs = new FileStream(folderJpg.FullName, FileMode.Create, FileAccess.Write, FileShare.Read)) { _fac.Save(fs); } filesWritten++; } } } Console.WriteLine(Properties.Resources.ProcessFinished, filesProcessed, filesSkipped, filesWritten); }
public void AddPictureWithCaption(IPicture _pict, int tag, ITsTextProps _ttpCaption, int hvoCmFile, int ws, int dxmpWidth, int dympHeight, IVwViewConstructor _vwvc) { throw new NotImplementedException(); }
/// <summary> /// Initializes a new instance of the <see cref="ComPictureWrapper"/> class. /// </summary> /// <param name="picture">The picture.</param> public ComPictureWrapper(IPicture picture) { m_picture = picture; }
public void Reset(IPicture picture) { Source = picture.Source; Name = picture.Name; Type = picture.Type; }
/// <summary> /// Converts a <see cref="IPicture" /> object into raw ASF /// picture data. /// </summary> /// <param name="picture"> /// A <see cref="IPicture" /> object to convert. /// </param> /// <returns> /// A <see cref="ByteVector" /> object containing raw ASF /// picture data. /// </returns> private static ByteVector PictureToData (IPicture picture) { ByteVector v = new ByteVector ((byte) picture.Type); v.Add (Object.RenderDWord ((uint) picture.Data.Count)); v.Add (Object.RenderUnicode (picture.MimeType)); v.Add (Object.RenderUnicode (picture.Description)); v.Add (picture.Data); return v; }
public void DrawImage(IPicture picture, Point p) { GDIPlusPicture pict = picture as GDIPlusPicture; mGraphics.DrawImage(pict.Image, new System.Drawing.Point(p.X, p.Y)); }
public static Image ToImage(this IPicture Value) { return((Value != null) ? Image.FromStream(new System.IO.MemoryStream(Value.Data.Data)) : null); }
/// <summary> /// La cañería recibe una imagen, construye un duplicado de la misma, /// y envía la original por una cañería y el duplicado por otra. /// </summary> /// <param name="picture">imagen a filtrar y enviar a las siguientes cañerías</param> public IPicture Send(IPicture picture) { next2Pipe.Send(picture.Clone()); return(this.nextPipe.Send(picture)); }
private Image <Rgba32> FromPicture(IPicture picture, out IImageFormat imageFormat) { return(Image.Load <Rgba32>(picture.Data, out imageFormat)); }
private async void Button_Click_1(object sender, RoutedEventArgs e) { Assembly assembly = typeof(SlidesPresentation).GetTypeInfo().Assembly; string resourcePath = "Syncfusion.SampleBrowser.UWP.Presentation.Presentation.Assets.Slides.pptx"; Stream fileStream = assembly.GetManifestResourceStream(resourcePath); IPresentation presentation = await Presentation.OpenAsync(fileStream); #region Slide1 ISlide slide1 = presentation.Slides[0]; IShape shape1 = slide1.Shapes[0] as IShape; shape1.Left = 1.5 * 72; shape1.Top = 1.94 * 72; shape1.Width = 10.32 * 72; shape1.Height = 2 * 72; ITextBody textFrame1 = shape1.TextBody; IParagraphs paragraphs1 = textFrame1.Paragraphs; IParagraph paragraph1 = paragraphs1.Add(); ITextPart textPart1 = paragraph1.AddTextPart(); paragraphs1[0].IndentLevelNumber = 0; textPart1.Text = "ESSENTIAL PRESENTATION"; textPart1.Font.FontName = "HelveticaNeue LT 65 Medium"; textPart1.Font.FontSize = 48; textPart1.Font.Bold = true; slide1.Shapes.RemoveAt(1); #endregion #region Slide2 ISlide slide2 = presentation.Slides.Add(SlideLayoutType.SectionHeader); shape1 = slide2.Shapes[0] as IShape; shape1.Left = 0.77 * 72; shape1.Top = 0.32 * 72; shape1.Width = 7.96 * 72; shape1.Height = 0.99 * 72; textFrame1 = shape1.TextBody; //Instance to hold paragraphs in textframe paragraphs1 = textFrame1.Paragraphs; paragraph1 = paragraphs1.Add(); ITextPart textpart1 = paragraph1.AddTextPart(); paragraphs1[0].HorizontalAlignment = HorizontalAlignmentType.Left; textpart1.Text = "Slide with simple text"; textpart1.Font.FontName = "Helvetica CE 35 Thin"; textpart1.Font.FontSize = 40; IShape shape2 = slide2.Shapes[1] as IShape; shape2.Left = 1.21 * 72; shape2.Top = 1.66 * 72; shape2.Width = 10.08 * 72; shape2.Height = 4.93 * 72; ITextBody textFrame2 = shape2.TextBody; //Instance to hold paragraphs in textframe IParagraphs paragraphs2 = textFrame2.Paragraphs; IParagraph paragraph2 = paragraphs2.Add(); paragraph2.HorizontalAlignment = HorizontalAlignmentType.Left; ITextPart textpart2 = paragraph2.AddTextPart(); textpart2.Text = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus."; textpart2.Font.FontName = "Calibri (Body)"; textpart2.Font.FontSize = 15; textpart2.Font.Color = ColorObject.Black; //Instance to hold paragraphs in textframe IParagraph paragraph3 = paragraphs2.Add(); paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph3.AddTextPart(); textpart1.Text = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet."; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; textpart1.Font.Color = ColorObject.Black; //Instance to hold paragraphs in textframe IParagraph paragraph4 = paragraphs2.Add(); paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph4.AddTextPart(); textpart1.Text = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula."; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; textpart1.Font.Color = ColorObject.Black; //Instance to hold paragraphs in textframe IParagraph paragraph5 = paragraphs2.Add(); paragraph5.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph5.AddTextPart(); textpart1.Text = "Vestibulum duis integer diam mi libero felis, sollicitudin id dictum etiam blandit lacus, ac condimentum magna dictumst interdum et,"; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; textpart1.Font.Color = ColorObject.Black; //Instance to hold paragraphs in textframe IParagraph paragraph6 = paragraphs2.Add(); paragraph6.HorizontalAlignment = HorizontalAlignmentType.Left; ITextPart textpart3 = paragraph6.AddTextPart(); textpart1.Text = "nam commodo mi habitasse enim fringilla nunc, amet aliquam sapien per tortor luctus. Conubia voluptates at nunc, congue lectus, malesuada nulla."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; textpart1.Font.Color = ColorObject.Black; //Instance to hold paragraphs in textframe IParagraph paragraph7 = paragraphs2.Add(); paragraph7.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph7.AddTextPart(); textpart1.Text = "Rutrum quo morbi, feugiat sed mi turpis, ac cursus integer ornare dolor. Purus dui in et tincidunt, sed eros pede adipiscing tellus, est suscipit nulla,"; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; textpart1.Font.Color = ColorObject.Black; //Instance to hold paragraphs in textframe IParagraph paragraph8 = paragraphs2.Add(); paragraph8.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph8.AddTextPart(); textpart1.Text = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula."; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; textpart1.Font.Color = ColorObject.Black; //Instance to hold paragraphs in textframe IParagraph paragraph9 = paragraphs2.Add(); paragraph9.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph9.AddTextPart(); textpart1.Text = "arcu nec fringilla vel aliquam, mollis lorem rerum hac vestibulum ante nullam. Volutpat a lectus, lorem pulvinar quis. Lobortis vehicula in imperdiet orci urna."; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.Color = ColorObject.Black; textpart1.Font.FontSize = 15; #endregion #region Slide3 slide2 = presentation.Slides.Add(SlideLayoutType.TwoContent); shape1 = slide2.Shapes[0] as IShape; shape1.Left = 0.36 * 72; shape1.Top = 0.51 * 72; shape1.Width = 11.32 * 72; shape1.Height = 1.06 * 72; //Adds textframe in shape textFrame1 = shape1.TextBody; //Instance to hold paragraphs in textframe paragraphs1 = textFrame1.Paragraphs; paragraphs1.Add(); paragraph1 = paragraphs1[0]; textpart1 = paragraph1.AddTextPart(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left; //Assigns value to textpart textpart1.Text = "Slide with Image"; textpart1.Font.FontName = "Helvetica CE 35 Thin"; //Adds shape in slide shape2 = slide2.Shapes[1] as IShape; shape2.Left = 8.03 * 72; shape2.Top = 1.96 * 72; shape2.Width = 4.39 * 72; shape2.Height = 4.53 * 72; textFrame2 = shape2.TextBody; //Instance to hold paragraphs in textframe paragraphs2 = textFrame2.Paragraphs; paragraph2 = paragraphs2.Add(); textpart2 = paragraph2.AddTextPart(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left; textpart2.Text = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus."; textpart2.Font.FontName = "Helvetica CE 35 Thin"; textpart2.Font.FontSize = 16; paragraph3 = paragraphs2.Add(); textpart2 = paragraph3.AddTextPart(); paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left; textpart2.Text = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet."; textpart2.Font.FontName = "Helvetica CE 35 Thin"; textpart2.Font.FontSize = 16; paragraph4 = paragraphs2.Add(); textpart2 = paragraph4.AddTextPart(); paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left; textpart2.Text = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula."; textpart2.Font.FontName = "Helvetica CE 35 Thin"; textpart2.Font.FontSize = 16; IShape shape3 = (IShape)slide2.Shapes[2]; slide2.Shapes.RemoveAt(2); //Adds picture in the shape resourcePath = "Syncfusion.SampleBrowser.UWP.Presentation.Presentation.Assets.tablet.jpg"; fileStream = assembly.GetManifestResourceStream(resourcePath); IPicture picture1 = slide2.Shapes.AddPicture(fileStream, 0.81 * 72, 1.96 * 72, 6.63 * 72, 4.43 * 72); fileStream.Dispose(); #endregion #region Slide4 ISlide slide4 = presentation.Slides.Add(SlideLayoutType.TwoContent); shape1 = slide4.Shapes[0] as IShape; shape1.Left = 0.51 * 72; shape1.Top = 0.34 * 72; shape1.Width = 11.32 * 72; shape1.Height = 1.06 * 72; textFrame1 = shape1.TextBody; //Instance to hold paragraphs in textframe paragraphs1 = textFrame1.Paragraphs; paragraphs1.Add(); paragraph1 = paragraphs1[0]; textpart1 = paragraph1.AddTextPart(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left; //Assigns value to textpart textpart1.Text = "Slide with Table"; textpart1.Font.FontName = "Helvetica CE 35 Thin"; shape2 = slide4.Shapes[1] as IShape; slide4.Shapes.Remove(shape2); ITable table = (ITable)slide4.Shapes.AddTable(6, 6, 0.81 * 72, 2.14 * 72, 11.43 * 72, 3.8 * 72); table.Rows[0].Height = 0.85 * 72; table.Rows[1].Height = 0.42 * 72; table.Rows[2].Height = 0.85 * 72; table.Rows[3].Height = 0.85 * 72; table.Rows[4].Height = 0.85 * 72; table.Rows[5].Height = 0.85 * 72; table.HasBandedRows = true; table.HasHeaderRow = true; table.HasBandedColumns = false; table.BuiltInStyle = BuiltInTableStyle.MediumStyle2Accent1; ICell cell1 = table.Rows[0].Cells[0]; textFrame2 = cell1.TextBody; paragraph2 = textFrame2.Paragraphs.Add(); paragraph2.HorizontalAlignment = HorizontalAlignmentType.Center; ITextPart textPart2 = paragraph2.AddTextPart(); textPart2.Text = "ID"; ICell cell2 = table.Rows[0].Cells[1]; ITextBody textFrame3 = cell2.TextBody; paragraph3 = textFrame3.Paragraphs.Add(); paragraph3.HorizontalAlignment = HorizontalAlignmentType.Center; ITextPart textPart3 = paragraph3.AddTextPart(); textPart3.Text = "Company Name"; ICell cell3 = table.Rows[0].Cells[2]; ITextBody textFrame4 = cell3.TextBody; paragraph4 = textFrame4.Paragraphs.Add(); paragraph4.HorizontalAlignment = HorizontalAlignmentType.Center; ITextPart textPart4 = paragraph4.AddTextPart(); textPart4.Text = "Contact Name"; ICell cell4 = table.Rows[0].Cells[3]; ITextBody textFrame5 = cell4.TextBody; paragraph5 = textFrame5.Paragraphs.Add(); paragraph5.HorizontalAlignment = HorizontalAlignmentType.Center; ITextPart textPart5 = paragraph5.AddTextPart(); textPart5.Text = "Address"; ICell cell5 = table.Rows[0].Cells[4]; ITextBody textFrame6 = cell5.TextBody; paragraph6 = textFrame6.Paragraphs.Add(); paragraph6.HorizontalAlignment = HorizontalAlignmentType.Center; ITextPart textPart6 = paragraph6.AddTextPart(); textPart6.Text = "City"; ICell cell6 = table.Rows[0].Cells[5]; ITextBody textFrame7 = cell6.TextBody; paragraph7 = textFrame7.Paragraphs.Add(); paragraph7.HorizontalAlignment = HorizontalAlignmentType.Center; ITextPart textPart7 = paragraph7.AddTextPart(); textPart7.Text = "Country"; cell1 = table.Rows[1].Cells[0]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "1"; cell1 = table.Rows[1].Cells[1]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "New Orleans Cajun Delights"; cell1 = table.Rows[1].Cells[2]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Shelley Burke"; cell1 = table.Rows[1].Cells[3]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "P.O. Box 78934"; cell1 = table.Rows[1].Cells[4]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "New Orleans"; cell1 = table.Rows[1].Cells[5]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "USA"; cell1 = table.Rows[2].Cells[0]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "2"; cell1 = table.Rows[2].Cells[1]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Cooperativa de Quesos 'Las Cabras"; cell1 = table.Rows[2].Cells[2]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Antonio del Valle Saavedra"; cell1 = table.Rows[2].Cells[3]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Calle del Rosal 4"; cell1 = table.Rows[2].Cells[4]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Oviedo"; cell1 = table.Rows[2].Cells[5]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Spain"; cell1 = table.Rows[3].Cells[0]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "3"; cell1 = table.Rows[3].Cells[1]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Mayumi"; cell1 = table.Rows[3].Cells[2]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Mayumi Ohno"; cell1 = table.Rows[3].Cells[3]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "92 Setsuko Chuo-ku"; cell1 = table.Rows[3].Cells[4]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Osaka"; cell1 = table.Rows[3].Cells[5]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Japan"; cell1 = table.Rows[4].Cells[0]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "4"; cell1 = table.Rows[4].Cells[1]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Pavlova, Ltd."; cell1 = table.Rows[4].Cells[2]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Ian Devling"; cell1 = table.Rows[4].Cells[3]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "74 Rose St. Moonie Ponds"; cell1 = table.Rows[4].Cells[4]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Melbourne"; cell1 = table.Rows[4].Cells[5]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Australia"; cell1 = table.Rows[5].Cells[0]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "5"; cell1 = table.Rows[5].Cells[1]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Specialty Biscuits, Ltd."; cell1 = table.Rows[5].Cells[2]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Peter Wilson"; cell1 = table.Rows[5].Cells[3]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "29 King's Way"; cell1 = table.Rows[5].Cells[4]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Manchester"; cell1 = table.Rows[5].Cells[5]; textFrame1 = cell1.TextBody; paragraph1 = textFrame1.Paragraphs.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center; textpart1 = paragraph1.AddTextPart(); textpart1.Text = "UK"; slide4.Shapes.RemoveAt(1); #endregion MemoryStream ms = new MemoryStream(); SavePPTX(presentation); }
public override void Rotate(IPicture picture, double angle) { using var image = FromPicture(picture, out var imageFormat); image.Mutate(x => x.Rotate(45)); picture.Data = ToByteArray(image, imageFormat); }
internal static Image GetPictureFromIPicture(IPicture picture) => GetPictureFromIPicture((object)picture);
public void Apply(IPicture pic) { Console.WriteLine("Applies brightness"); }
private IPattern AddPictureAsPattern(IPicture picture, float stepX, float stepY) { return(new PicturePattern(picture, stepX, stepY)); }
void search() { List <string> Files = new List <string>(); char[] mp3 = new char[4] { '.', 'm', 'p', '3' }; string path; try { path = Singleton.GetPath(); if (path == null) { System.Windows.MessageBox.Show("Done!"); return; } } catch { ErrorLog("Invalid path midway?: " + DirectoryLbl.Text); return; } Files.AddRange(System.IO.Directory.GetFiles(path)); string Title = null; string Artist = null; string AudioName = null; string AudioPath = null; string ImagePath = null; string Version = null; IPicture[] Image = new IPicture[1]; if (Files.Count <= 0) { return; } foreach (string SubFilePath in Files) { if (System.IO.Path.GetExtension(SubFilePath) == ".osu") { List <string> Lines = System.IO.File.ReadLines(SubFilePath).ToList(); foreach (string Line in Lines) { if (Line == null || Line.Length < 6) { continue; } try { if (Line.Substring(0, 14) == "AudioFilename:") { AudioName = Line.Substring(15); AudioPath = path + "\\" + AudioName; } } catch { } try { if (Line.Substring(0, 6) == "Title:") { Title = Line.Substring(6); } } catch { } try { if (Line.Substring(0, 7) == "Artist:") { Artist = Line.Substring(7); } } catch { } try { if (Line.Substring(0, 8) == "Version:") { Version = Line.Substring(8); } } catch { } try { if (Line.Substring(0, 5) == "0,0,\"") { string[] values = Line.Substring(5).Split('"'); ImagePath = path + "\\" + values[0]; Image[0] = new Picture(ImagePath); break; } } catch { } } } } if (Artist != null && Title != null) { foreach (char c in System.IO.Path.GetInvalidFileNameChars()) { Artist = Artist.Replace(c, ' '); Title = Title.Replace(c, ' '); } } /*if (System.IO.File.Exists(System.IO.Path.Combine(Singleton.OutputDirectory + "\\", Artist + " - " + Title + ".mp3"))) { * Title = Title + " (" + AudioName.TrimEnd(mp3) + " " + Version + " " + ")"; * var file = TagLib.File.Create(System.IO.Path.Combine(Singleton.OutputDirectory + "\\", Artist + " - " + Title + ".mp3")); * if (file.Tag.Comment == AudioName.TrimEnd(mp3)){ * return; * } * }*/ try { System.IO.File.Copy(AudioPath, (System.IO.Path.Combine(Singleton.OutputDirectory + "\\", Artist + " - " + Title + ".mp3")), true); var file = TagLib.File.Create(System.IO.Path.Combine(Singleton.OutputDirectory + "\\", Artist + " - " + Title + ".mp3")); file.Tag.Title = Title; file.Tag.Performers = new string[1] { Artist }; file.Tag.Track = new uint(); if (Singleton.SingleAlbum == true) { file.Tag.Album = "osu! Music Exporter"; file.Tag.AlbumArtists = new string[1] { "osu! Music Exporter" }; } else { file.Tag.Album = Title; } file.Tag.Genres = new string[1] { "osu! Music Exporter" }; file.Tag.Comment = AudioName.TrimEnd(mp3); if (Singleton.Artwork == true && Singleton.SingleAlbum == true && Singleton.Selection == 1) { try { file.Tag.Pictures = new IPicture[0]; var b = new System.Drawing.Bitmap(Properties.Resources.Osu_Music_Logo); b.Save(Singleton.OutputDirectory + "\\_art.png"); Image[0] = new Picture(Singleton.OutputDirectory + "\\_art.png"); file.Tag.Pictures = Image; } catch { } } else if (Singleton.Artwork == true) { try { file.Tag.Pictures = new IPicture[0]; file.Tag.Pictures = Image; } catch { ErrorLog("Error saving artwork:" + AudioPath + file.Name); } } file.Save(); } catch { ErrorLog("Error copying file:" + path); } Singleton.beatmapCount--; Singleton.threadCount--; if (Singleton.threadCount == 0 && Singleton.cancel != true) { Thread copyThread = new Thread(CopySongs); copyThread.Start(); } }
private void ReleasePicture(IPicture picture) { if (picture is IDisposable) ((IDisposable) picture).Dispose(); // typically Linux else if (picture != null && Marshal.IsComObject(picture)) Marshal.ReleaseComObject(picture); // typically Windows }
private void SlideWithComments3(IPresentation presentation) { xValue = 250; yValue = 100; ISlide slide3 = presentation.Slides.Add(SlideLayoutType.ContentWithCaption); slide3.Background.Fill.FillType = FillType.Solid; slide3.Background.Fill.SolidFill.Color = ColorObject.White; //Adds shape in slide IShape shape2 = (IShape)slide3.Shapes[0]; shape2.Left = 0.47 * 72; shape2.Top = 1.15 * 72; shape2.Width = 3.5 * 72; shape2.Height = 4.91 * 72; ITextBody textFrame1 = shape2.TextBody; //Instance to hold paragraphs in textframe IParagraphs paragraphs1 = textFrame1.Paragraphs; IParagraph paragraph1 = paragraphs1.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left; ITextPart textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph2 = paragraphs1.Add(); paragraph2.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph2.AddTextPart(); textpart1.Text = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph3 = paragraphs1.Add(); paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph3.AddTextPart(); textpart1.Text = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph4 = paragraphs1.Add(); paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph4.AddTextPart(); textpart1.Text = "Lorem tortor neque, purus taciti quis id. Elementum integer orci accumsan minim phasellus vel."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); slide3.Shapes.RemoveAt(1); slide3.Shapes.RemoveAt(1); //Adds picture in the shape string dataPath = ResolveApplicationImagePath("tablet.jpg"); Stream imageStream = System.IO.File.Open(dataPath, FileMode.Open); IPicture picture1 = slide3.Shapes.AddPicture(imageStream, 5.18 * 72, 1.15 * 72, 7.3 * 72, 5.31 * 72); imageStream.Close(); //Add comment to the slide IComment comment = slide3.Comments.Add(xValue, yValue, "Author3", "A3", "Can we use a different font family for this text?", DateTime.Now); //Add reply to a parent comment slide3.Comments.Add("Author1", "A1", "Please specify the desired font for modification", DateTime.Now, comment); }
/// <summary> /// Constructs and initializes a new instance of <see /// cref="AttachedPictureFrame" /> by populating it with /// the contents of another <see cref="IPicture" /> object. /// </summary> /// <param name="picture"> /// A <see cref="IPicture" /> object containing values to use /// in the new instance. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="picture" /> is <see langword="null" />. /// </exception> /// <remarks> /// <para>When a frame is created, it is not automatically /// added to the tag. Consider using <see /// cref="Get(Tag,string,PictureType,bool)" /> for more /// integrated frame creation.</para> /// <para>Additionally, <see cref="TagLib.Tag.Pictures" /> /// provides a generic way or getting and setting /// pictures which is preferable to format specific /// code.</para> /// </remarks> /// <example> /// <para>Add a picture to a file.</para> /// <code lang="C#"> /// using TagLib; /// using TagLib.Id3v2; /// /// public static class AddId3v2Picture /// { /// public static void Main (string [] args) /// { /// if (args.Length != 2) /// throw new ApplicationException ( /// "USAGE: AddId3v2Picture.exe AUDIO_FILE PICTURE_FILE"); /// /// // Create the file. Can throw file to TagLib# exceptions. /// File file = File.Create (args [0]); /// /// // Get or create the ID3v2 tag. /// TagLib.Id3v2.Tag tag = file.GetTag (TagTypes.Id3v2, true) as TagLib.Id3v2.Tag; /// if (tag == null) /// throw new ApplicationException ("File does not support ID3v2 tags."); /// /// // Create a picture. Can throw file related exceptions. /// TagLib.Picture picture = TagLib.Picture.CreateFromPath (path); /// /// // Add a new picture frame to the tag. /// tag.AddFrame (new AttachedPictureFrame (picture)); /// /// // Save the file. /// file.Save (); /// } /// } /// </code> /// </example> public AttachedPictureFrame (IPicture picture) : base(FrameType.APIC, 4) { if (picture == null) throw new ArgumentNullException ("picture"); mime_type = picture.MimeType; type = picture.Type; description = picture.Description; data = picture.Data; }
public void AddPicture(IPicture _pict, int tag, int dxmpWidth, int dympHeight) { throw new NotImplementedException(); }
//public override void RaiseMouseDown(GuiLabs.Canvas.Events.MouseWithKeysEventArgs e) //{ // // We need to explicitly call Toggle() each time // // the thing is toggled // // No need to call it here // //Toggle(); // this.RaiseMouseDown(e); //} public void Toggle() { IPicture tmp = MyPicture; MyPicture = TogglePicture; TogglePicture = tmp; }
public void doMe(object num) { LastFMWorker last = (LastFMWorker)num; last.busy = true; int count = last.id; int arcount = last.orignial_index; try { XmlDocument xdoc; XmlNode node; double confidence; string artist; string title; string mbid; LastFmLib.API20.Types.TrackInformation tr; string cd = ""; ListViewItem item1; updateTdisplay(count, 4); string xmlsreing = HBPUID.GenUID.LastFM.Run(last.filename, 0).Trim(); updateTdisplay(count, 2); xdoc = new XmlDocument(); xdoc.LoadXml(xmlsreing); node = xdoc.SelectSingleNode("//lfm/tracks/track"); confidence = 0; double.TryParse(xdoc.SelectSingleNode("//lfm/tracks/track/@rank").InnerText, out confidence); confidence = confidence * 100; artist = node.SelectSingleNode("//track/artist/name").InnerText; title = node.SelectSingleNode("//track/name").InnerText; mbid = node.SelectSingleNode("//track/mbid").InnerText; string largim = null ; try { largim = xdoc.SelectNodes("//lfm/tracks/track/image").Item(3).InnerXml; } catch (Exception imagex) { } if (largim != null) { TagLib.File tfile; string localFilename = @"c:\temp.jpg"; using (WebClient client = new WebClient()) { client.DownloadFile(largim, localFilename); } tfile = TagLib.File.Create(last.filename); TagLib.Picture picture = new TagLib.Picture(localFilename); TagLib.Id3v2.AttachedPictureFrame albumCoverPictFrame = new TagLib.Id3v2.AttachedPictureFrame(picture); albumCoverPictFrame.MimeType = System.Net.Mime.MediaTypeNames.Image.Jpeg; albumCoverPictFrame.Type = TagLib.PictureType.FrontCover; TagLib.IPicture[] pictFrames = new IPicture[1]; pictFrames[0] = (IPicture)albumCoverPictFrame; tfile.Tag.Pictures = pictFrames; if (mbid != null) { tfile.Tag.MusicBrainzTrackId = mbid; } tfile.Save(); } item1 = new ListViewItem(confidence.ToString()); if (mbid.Length > 2) { tr = client.Track.GetInfo(new Guid(mbid)); } else { tr = client.Track.GetInfo(new LastFmLib.API20.Types.Track(artist, title)); //client.Track. } string tt1 = HttpGetTrackInfo("", artist, title, "868b33aa44239a11ebd04e58e7e484ff"); dynamic json = JValue.Parse(tt1); TagLib.File mp3file; mp3file = TagLib.File.Create(last.filename); try { if (json.track != null) { if (json.track.name != null) { mp3file.Tag.Title = (string)json.track.name; } if (json.track.mbid != null) { mp3file.Tag.MusicBrainzTrackId = (string)json.track.mbid; } if (json.track.url != null) { mp3file.Tag.Lyrics = (string)json.track.url; } if (json.track.album != null) { if (json.track.album.title != null) { mp3file.Tag.Album = (string)json.track.album.title; } if (json.track.album.mbid != null) { mp3file.Tag.MusicBrainzReleaseId = (string)json.track.album.mbid; } if (json.track.album.@attr != null) { if ([email protected] != null) { mp3file.Tag.Track = (uint)json.track.album.attr.position; } } } if (json.track.artist != null) { if (json.track.artist.name != null) { mp3file.Tag.AlbumArtists[0] = (string)json.track.artist.name; } if (json.track.artist.mbid != null) { mp3file.Tag.MusicBrainzArtistId = (string)json.track.artist.mbid; } } if (json.track.toptags != null) { if (json.track.toptags.tag != null) { if (json.track.toptags.tag[0].name != null) { mp3file.Tag.Genres[0] = (string)json.track.toptags.tag[0].name; } } } } } catch (Exception ex11) { } mp3file.Save(); //client.Album.Search( XmlDocument xdoc2 = new XmlDocument(); xdoc2.LoadXml("<xml>" + tr.innerxml + "</xml>"); try { string albumname; string track; albumname = xdoc2.SelectSingleNode("//album/title").InnerText; track = xdoc2.SelectSingleNode("//album/@position").InnerText; if (albumname != null) { cd = albumname; } else { TagLib.File tfile; tfile = TagLib.File.Create(last.filename); if (tfile.Tag.Album != null) { cd = tfile.Tag.Album; } } if (track != null) { } } catch (Exception ex) { //Album retrieval failed , lets load the old album back shall we TagLib.File tfile; tfile = TagLib.File.Create(last.filename); if (tfile.Tag.Album != null) { cd = tfile.Tag.Album; } } item1.SubItems.Add(title); item1.SubItems.Add(cd); item1.SubItems.Add(artist); this.mainC1.listView1.Invoke(new MethodInvoker(delegate { this.mainC1.listView1.Items[arcount].BackColor = Color.LightGray; this.progressBar1.Value += 1; double perc = ((this.progressBar1.Value * 100) / this.progressBar1.Maximum); this.label1.Text = perc.ToString() + " %"; string no = this.mainC1.listView1.Items[arcount].SubItems[4].Text; item1.SubItems.Add(no); item1.SubItems.Add(this.mainC1.listView1.Items[arcount].SubItems[0].Text); })); AddListBoxItem(item1); last.status = false; last.busy = false; doEndLast(last.id); } catch (Exception e1) { TagLib.File mp3file; mp3file = TagLib.File.Create(last.filename); Regex rgx = new Regex("[^a-zA-Z0-9'&(). -]"); bool gotart = false; bool gottrack = false; dynamic json = ""; try { string tt1 = HttpGetTrackInfo("", rgx.Replace(mp3file.Tag.AlbumArtists[0].ToString(), ""), rgx.Replace(mp3file.Tag.Title , "") , "868b33aa44239a11ebd04e58e7e484ff"); json = JValue.Parse(tt1); if (json.track != null) { if (json.track.name != null) { gotart = true; mp3file.Tag.Title = (string)json.track.name; } if (json.track.mbid != null) { mp3file.Tag.MusicBrainzTrackId = (string)json.track.mbid; } if (json.track.url != null) { mp3file.Tag.Lyrics = (string)json.track.url; } if (json.track.album != null) { if (json.track.album.title != null) { mp3file.Tag.Album = (string)json.track.album.title; } if (json.track.album.mbid != null) { mp3file.Tag.MusicBrainzReleaseId = (string)json.track.album.mbid; } if (json.track.album.@attr != null) { if ([email protected] != null) { mp3file.Tag.Track = (uint)json.track.album.attr.position; } } } if (json.track.artist != null) { if (json.track.artist.name != null) { gottrack = true; mp3file.Tag.AlbumArtists[0] = (string)json.track.artist.name; } if (json.track.artist.mbid != null) { mp3file.Tag.MusicBrainzArtistId = (string)json.track.artist.mbid; } } if (json.track.toptags != null) { if (json.track.toptags.tag != null) { if (json.track.toptags.tag[0].name != null) { mp3file.Tag.Genres[0] = (string)json.track.toptags.tag[0].name; } } } } } catch (Exception ex11) { } if (gottrack && gotart) { ListViewItem item1 = new ListViewItem("0"); item1.SubItems.Add((string)json.track.name); item1.SubItems.Add(mp3file.Tag.Album); item1.SubItems.Add((string)json.track.artist.name); this.mainC1.listView1.Invoke(new MethodInvoker(delegate { this.mainC1.listView1.Items[arcount].BackColor = Color.LightGray; this.progressBar1.Value += 1; double perc = ((this.progressBar1.Value * 100) / this.progressBar1.Maximum); this.label1.Text = perc.ToString() + " %"; string no = this.mainC1.listView1.Items[arcount].SubItems[4].Text; item1.SubItems.Add(no); item1.SubItems.Add(this.mainC1.listView1.Items[arcount].SubItems[0].Text); })); AddListBoxItem(item1); } else { this.mainC1.listView1.Invoke(new MethodInvoker(delegate { this.progressBar1.Value += 1; this.mainC1.listView1.Items[arcount].BackColor = Color.LightPink; double perc = ((this.progressBar1.Value * 100) / this.progressBar1.Maximum); this.label1.Text = perc.ToString() + " %"; })); } try { mp3file.Save(); } catch (Exception nex1) { } updateTdisplay(count, 3); last.status = false; last.busy = false; doEndLast(last.id); } }
/** * Calculate and Set the preferred size (anchor) for this picture. * * @param scaleX the amount by which image width is multiplied relative to the original width. * @param scaleY the amount by which image height is multiplied relative to the original height. * @return the new Dimensions of the scaled picture in EMUs */ public static Size SetPreferredSize(IPicture picture, double scaleX, double scaleY) { IClientAnchor anchor = picture.ClientAnchor; bool isHSSF = (anchor is HSSFClientAnchor); IPictureData data = picture.PictureData; ISheet sheet = picture.Sheet; // in pixel Size imgSize = GetImageDimension(new MemoryStream(data.Data), data.PictureType); // in emus Size anchorSize = ImageUtils.GetDimensionFromAnchor(picture); double scaledWidth = (scaleX == Double.MaxValue) ? imgSize.Width : anchorSize.Width / Units.EMU_PER_PIXEL * scaleX; double scaledHeight = (scaleY == Double.MaxValue) ? imgSize.Height : anchorSize.Height / Units.EMU_PER_PIXEL * scaleY; double w = 0; int col2 = anchor.Col1; int dx2 = 0; //space in the leftmost cell w = sheet.GetColumnWidthInPixels(col2++); if (isHSSF) { w *= 1 - anchor.Dx1 / 1024d; } else { w -= anchor.Dx1 / Units.EMU_PER_PIXEL; } while (w < scaledWidth) { w += sheet.GetColumnWidthInPixels(col2++); } if (w > scaledWidth) { //calculate dx2, offset in the rightmost cell double cw = sheet.GetColumnWidthInPixels(--col2); double delta = w - scaledWidth; if (isHSSF) { dx2 = (int)((cw - delta) / cw * 1024); } else { dx2 = (int)((cw - delta) * Units.EMU_PER_PIXEL); } if (dx2 < 0) { dx2 = 0; } } anchor.Col2 = (/*setter*/ col2); anchor.Dx2 = (/*setter*/ dx2); double h = 0; int row2 = anchor.Row1; int dy2 = 0; h = GetRowHeightInPixels(sheet, row2++); if (isHSSF) { h *= 1 - anchor.Dy1 / 256d; } else { h -= anchor.Dy1 / Units.EMU_PER_PIXEL; } while (h < scaledHeight) { h += GetRowHeightInPixels(sheet, row2++); } if (h > scaledHeight) { double ch = GetRowHeightInPixels(sheet, --row2); double delta = h - scaledHeight; if (isHSSF) { dy2 = (int)((ch - delta) / ch * 256); } else { dy2 = (int)((ch - delta) * Units.EMU_PER_PIXEL); } if (dy2 < 0) { dy2 = 0; } } anchor.Row2 = (/*setter*/ row2); anchor.Dy2 = (/*setter*/ dy2); Size dim = new Size( (int)Math.Round(scaledWidth * Units.EMU_PER_PIXEL), (int)Math.Round(scaledHeight * Units.EMU_PER_PIXEL) ); return(dim); }
/// <summary> /// 设置单元格值 /// </summary> /// <param name="cell">单元格</param> /// <param name="value">值</param> public static void SetValue(this ICell cell, object value) { if (null == cell) { return; } if (null == value) { cell.SetCellValue(string.Empty); } else { var fullName = value.GetType().FullName; if (fullName != null && fullName.Equals("System.Byte[]")) { int pictureIdx = cell.Sheet.Workbook.AddPicture((Byte[])value, PictureType.PNG); IClientAnchor anchor = cell.Sheet.Workbook.GetCreationHelper().CreateClientAnchor(); anchor.Col1 = cell.ColumnIndex; anchor.Col2 = cell.ColumnIndex + cell.GetSpan().ColSpan; anchor.Row1 = cell.RowIndex; anchor.Row2 = cell.RowIndex + cell.GetSpan().RowSpan; IDrawing patriarch = cell.Sheet.CreateDrawingPatriarch(); IPicture pic = patriarch.CreatePicture(anchor, pictureIdx); } else { var valueTypeCode = Type.GetTypeCode(value.GetType()); switch (valueTypeCode) { case TypeCode.String: //字符串类型 cell.SetCellValue(Convert.ToString(value)); break; case TypeCode.DateTime: //日期类型 cell.SetCellValue(Convert.ToDateTime(value)); break; case TypeCode.Boolean: //布尔型 cell.SetCellValue(Convert.ToBoolean(value)); break; case TypeCode.Int16: //整型 case TypeCode.Int32: case TypeCode.Int64: case TypeCode.Byte: case TypeCode.Single: //浮点型 case TypeCode.Double: case TypeCode.Decimal: case TypeCode.UInt16: //无符号整型 case TypeCode.UInt32: case TypeCode.UInt64: cell.SetCellValue(Convert.ToDouble(value)); break; default: cell.SetCellValue(string.Empty); break; } } } }
private async Task <string> ImportImage(Tag tag, IPicture picture, ArtworkType type, bool overwrite) { return(await this.ImportImage(picture, picture.Data.Checksum.ToString(), overwrite).ConfigureAwait(false)); }
public static void SetPicture(DependencyObject dobj, IPicture value) { if (dobj != null) { dobj.SetValue (PictureProperty, value); } }
public Boolean SendRequest(SongPoster spRef, SongData nowPlayingData, string template, string[] networks, int userId, string password, bool coverArtEnabled) { string logFileName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Plugin_SongPoster.log"; // Parse variable message template and fill in data from nowPlaying string sendTextVars = Variables.Update(template, nowPlayingData, false).Replace("/", "___SLASHslashSLASH___"); string pictureVars = Variables.Update("$album_cover$", nowPlayingData, false); Boolean success = true; // For each selected network, build custom URL and start a "send" task foreach (string network in networks) { string sendText = "http://songposter.net/send-post/" + network.ToLower() + "/0/" + userId.ToString() + "/" + Uri.EscapeDataString(password) + "/" + Uri.EscapeDataString(sendTextVars); if (coverArtEnabled) { if (spRef.SendCoverArtPictureLocation == "picturesOnline") { sendText = sendText + "/" + Uri.EscapeDataString(pictureVars); } else if (spRef.SendCoverArtPictureLocation == "picturesTag") { string base64Picture = "data:"; try { string filePath = nowPlayingData.Path; TagLib.File trackFile = TagLib.File.Create(filePath); if (trackFile.Tag.Pictures.Length > 0) { IPicture picture = trackFile.Tag.Pictures.First(); base64Picture += picture.MimeType + ";base64,"; base64Picture += Convert.ToBase64String(picture.Data.Data); base64Picture.Replace('+', '-').Replace('/', '_'); sendText = sendText + "/" + base64Picture; } } catch (FileNotFoundException e) { using (StreamWriter logFile = new StreamWriter(logFileName, true)) { logFile.WriteLine("Error loading:" + e.FileName); } } } } try { WebClient client = new WebClient { Encoding = Encoding.UTF8 }; client.Headers.Add("user-agent", "SongPoster/0.8 (RadioDJ)"); client.DownloadStringCompleted += (sender, e) => { if (!e.Cancelled && e.Error == null) { using (StreamWriter logFile = new StreamWriter(logFileName, true)) { logFile.WriteLine(sendText); logFile.WriteLine(e.Result); } } else { HttpWebResponse response = (HttpWebResponse)((WebException)e.Error).Response; int statusCode = (int)response.StatusCode; string responseText; using (var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) { responseText = reader.ReadToEnd(); } // Only show the messagebox if the success variable was previously set if (success) { success = false; MessageBox.Show(responseText, "SongPoster Plugin Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } using (StreamWriter logFile = new StreamWriter(logFileName, true)) { logFile.WriteLine(sendText); logFile.WriteLine("[" + DateTime.Now.ToString("u") + "] ERROR: " + responseText); } } }; client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Log_completedDownload); client.DownloadStringAsync(new Uri(sendText)); } catch (Exception e) { // @ToDo do some proper error handling Console.WriteLine(e.Message); success = false; } } return(success); }
/// <summary> /// Constructs and initializes a new instance of <see /// cref="Attachment" /> by doing a shallow copy of <see /// cref="IPicture" />. /// </summary> /// <param name="picture"> /// A <see cref="IPicture"/> object containing picture data /// to convert to an Attachment. /// </param> public Attachment(IPicture picture) : base(picture) { }
/** * Calculates the dimensions in EMUs for the anchor of the given picture * * @param picture the picture Containing the anchor * @return the dimensions in EMUs */ public static Size GetDimensionFromAnchor(IPicture picture) { IClientAnchor anchor = picture.ClientAnchor; bool isHSSF = (anchor is HSSFClientAnchor); ISheet sheet = picture.Sheet; double w = 0; int col2 = anchor.Col1; //space in the leftmost cell w = sheet.GetColumnWidthInPixels(col2++); if (isHSSF) { w *= 1 - anchor.Dx1 / 1024d; } else { w -= anchor.Dx1 / Units.EMU_PER_PIXEL; } while (col2 < anchor.Col2) { w += sheet.GetColumnWidthInPixels(col2++); } if (isHSSF) { w += sheet.GetColumnWidthInPixels(col2) * anchor.Dx2 / 1024d; } else { w += anchor.Dx2 / Units.EMU_PER_PIXEL; } double h = 0; int row2 = anchor.Row1; h = GetRowHeightInPixels(sheet, row2++); if (isHSSF) { h *= 1 - anchor.Dy1 / 256d; } else { h -= anchor.Dy1 / Units.EMU_PER_PIXEL; } while (row2 < anchor.Row2) { h += GetRowHeightInPixels(sheet, row2++); } if (isHSSF) { h += GetRowHeightInPixels(sheet, row2) * anchor.Dy2 / 256; } else { h += anchor.Dy2 / Units.EMU_PER_PIXEL; } return(new Size((int)w * Units.EMU_PER_PIXEL, (int)h * Units.EMU_PER_PIXEL)); }
/// <summary> /// Constructs and initializes a new instance of <see /// cref="Picture" /> by copying the properties of a <see /// cref="IPicture" /> object. /// </summary> /// <param name="picture"> /// A <see cref="IPicture" /> object to use for the new /// instance. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="picture" /> is <see langword="null" />. /// </exception> public Picture(IPicture picture) { if (picture == null) throw new ArgumentNullException ("picture"); type = picture.Type; mime_type = picture.MimeType; description = picture.Description; picture_data = picture.Data; TagLib.Flac.Picture flac_picture = picture as TagLib.Flac.Picture; if (flac_picture == null) return; width = flac_picture.Width; height = flac_picture.Height; color_depth = flac_picture.ColorDepth; indexed_colors = flac_picture.IndexedColors; }
public PictureChangeBox(IPicture defaultPicture, IPicture togglePicture) : base(defaultPicture) { TogglePicture = togglePicture; }
internal static void SlideWithComments3(IPresentation presentation) { #region Slide3 ISlide slide3 = presentation.Slides.Add(SlideLayoutType.ContentWithCaption); slide3.Background.Fill.FillType = FillType.Solid; slide3.Background.Fill.SolidFill.Color = ColorObject.White; //Adds shape in slide IShape shape2 = (IShape)slide3.Shapes[0]; shape2.Left = 0.47 * 72; shape2.Top = 1.15 * 72; shape2.Width = 3.5 * 72; shape2.Height = 4.91 * 72; ITextBody textFrame1 = shape2.TextBody; //Instance to hold paragraphs in textframe IParagraphs paragraphs1 = textFrame1.Paragraphs; IParagraph paragraph1 = paragraphs1.Add(); paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left; ITextPart textpart1 = paragraph1.AddTextPart(); textpart1.Text = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph2 = paragraphs1.Add(); paragraph2.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph2.AddTextPart(); textpart1.Text = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph3 = paragraphs1.Add(); paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph3.AddTextPart(); textpart1.Text = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); IParagraph paragraph4 = paragraphs1.Add(); paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left; textpart1 = paragraph4.AddTextPart(); textpart1.Text = "Lorem tortor neque, purus taciti quis id. Elementum integer orci accumsan minim phasellus vel."; textpart1.Font.Color = ColorObject.White; textpart1.Font.FontName = "Calibri (Body)"; textpart1.Font.FontSize = 15; paragraphs1.Add(); slide3.Shapes.RemoveAt(1); slide3.Shapes.RemoveAt(1); Assembly assembly = Assembly.GetExecutingAssembly(); //Adds picture in the shape string resourcePath = "SampleBrowser.Samples.Presentation.Templates.tablet.jpg"; Stream fileStream = assembly.GetManifestResourceStream(resourcePath); IPicture picture1 = slide3.Shapes.AddPicture(fileStream, 5.18 * 72, 1.15 * 72, 7.3 * 72, 5.31 * 72); fileStream.Dispose(); slide3.Comments.Add(0.14, 0.04, "Author3", "A3", "Can we use a different font family for this text?", DateTime.Now); #endregion }
/// <summary> /// This method is called by mediaportal when it wants information for a music file /// The method will check which tagreader supports the file and ask it to extract the information from it /// </summary> /// <param name="strFile">filename of the music file</param> /// <returns> /// MusicTag instance when file has been read /// null when file type is not supported or if the file does not contain any information /// </returns> public static MusicTag ReadTag(string strFile) { // Read Cue info if (CueUtil.isCueFakeTrackFile(strFile)) { try { return CueUtil.CueFakeTrackFile2MusicTag(strFile); } catch (Exception ex) { Log.Warn("TagReader: Exception reading file {0}. {1}", strFile, ex.Message); } } if (!IsAudio(strFile)) return null; char[] trimChars = { ' ', '\x00' }; try { // Set the flag to use the standard System Encoding set by the user // Otherwise Latin1 is used as default, which causes characters in various languages being displayed wrong TagLib.ByteVector.UseBrokenLatin1Behavior = true; TagLib.File tag = TagLib.File.Create(strFile); if (tag == null) { Log.Warn("Tagreader: No tag in file - {0}", strFile); return null; } MusicTag musictag = new MusicTag(); string[] artists = tag.Tag.Performers; if (artists.Length > 0) { musictag.Artist = String.Join(";", artists).Trim(trimChars); // The AC/DC exception if (musictag.Artist.Contains("AC;DC")) { musictag.Artist = musictag.Artist.Replace("AC;DC", "AC/DC"); } } musictag.Album = tag.Tag.Album == null ? "" : tag.Tag.Album.Trim(trimChars); musictag.HasAlbumArtist = false; string[] albumartists = tag.Tag.AlbumArtists; if (albumartists.Length > 0) { musictag.AlbumArtist = String.Join(";", albumartists).Trim(trimChars); musictag.HasAlbumArtist = true; // The AC/DC exception if (musictag.AlbumArtist.Contains("AC;DC")) { musictag.AlbumArtist = musictag.AlbumArtist.Replace("AC;DC", "AC/DC"); } } musictag.BitRate = tag.Properties.AudioBitrate; musictag.Comment = tag.Tag.Comment == null ? "" : tag.Tag.Comment.Trim(trimChars); string[] composer = tag.Tag.Composers; if (composer.Length > 0) { musictag.Composer = string.Join(";", composer).Trim(trimChars); } musictag.Conductor = tag.Tag.Conductor == null ? "" : tag.Tag.Conductor.Trim(trimChars); IPicture[] pics = new IPicture[] { }; pics = tag.Tag.Pictures; if (pics.Length > 0) { musictag.CoverArtImageBytes = pics[0].Data.Data; } musictag.Duration = (int)tag.Properties.Duration.TotalSeconds; musictag.FileName = strFile; musictag.FileType = tag.MimeType.Substring(tag.MimeType.IndexOf("/") + 1); string[] genre = tag.Tag.Genres; if (genre.Length > 0) { musictag.Genre = String.Join(";", genre).Trim(trimChars); } string lyrics = tag.Tag.Lyrics == null ? "" : tag.Tag.Lyrics.Trim(trimChars); musictag.Title = tag.Tag.Title == null ? "" : tag.Tag.Title.Trim(trimChars); // Prevent Null Ref execption, when Title is not set musictag.Track = (int)tag.Tag.Track; musictag.TrackTotal = (int)tag.Tag.TrackCount; musictag.DiscID = (int)tag.Tag.Disc; musictag.DiscTotal = (int)tag.Tag.DiscCount; musictag.Codec = tag.Properties.Description; if (tag.MimeType == "taglib/mp3") { musictag.BitRateMode = tag.Properties.Description.IndexOf("VBR") > -1 ? "VBR" : "CBR"; } else { musictag.BitRateMode = ""; } musictag.BPM = (int)tag.Tag.BeatsPerMinute; musictag.Channels = tag.Properties.AudioChannels; musictag.SampleRate = tag.Properties.AudioSampleRate; musictag.Year = (int)tag.Tag.Year; musictag.ReplayGainTrack = tag.Tag.ReplayGainTrack ?? ""; musictag.ReplayGainTrackPeak = tag.Tag.ReplayGainTrackPeak ?? ""; musictag.ReplayGainAlbum = tag.Tag.ReplayGainAlbum ?? ""; musictag.ReplayGainAlbumPeak = tag.Tag.ReplayGainAlbumPeak ?? ""; if (tag.MimeType == "taglib/mp3") { bool foundPopm = false; // Handle the Rating, which comes from the POPM frame TagLib.Id3v2.Tag id32_tag = tag.GetTag(TagLib.TagTypes.Id3v2) as TagLib.Id3v2.Tag; if (id32_tag != null) { // Do we have a POPM frame written by MediaPortal or MPTagThat? TagLib.Id3v2.PopularimeterFrame popmFrame = TagLib.Id3v2.PopularimeterFrame.Get(id32_tag, "MediaPortal", false); if (popmFrame == null) { popmFrame = TagLib.Id3v2.PopularimeterFrame.Get(id32_tag, "MPTagThat", false); } if (popmFrame != null) { musictag.Rating = popmFrame.Rating; foundPopm = true; } // Now look for a POPM frame written by WMP if (!foundPopm) { TagLib.Id3v2.PopularimeterFrame popm = TagLib.Id3v2.PopularimeterFrame.Get(id32_tag, "Windows Media Player 9 Series", false); if (popm != null) { // Get the rating stored in the WMP POPM frame int rating = popm.Rating; int i = 0; if (rating == 255) i = 5; else if (rating == 196) i = 4; else if (rating == 128) i = 3; else if (rating == 64) i = 2; else if (rating == 1) i = 1; musictag.Rating = i; foundPopm = true; } } if (!foundPopm) { // Now look for any other POPM frame that might exist foreach (TagLib.Id3v2.PopularimeterFrame popm in id32_tag.GetFrames<TagLib.Id3v2.PopularimeterFrame>()) { int rating = popm.Rating; int i = 0; if (rating > 205 || rating == 5) i = 5; else if (rating > 154 || rating == 4) i = 4; else if (rating > 104 || rating == 3) i = 3; else if (rating > 53 || rating == 2) i = 2; else if (rating > 0 || rating == 1) i = 1; musictag.Rating = i; foundPopm = true; break; // we only take the first popm frame } } if (!foundPopm) { // If we don't have any POPM frame, we might have an APE Tag embedded in the mp3 file TagLib.Ape.Tag apetag = tag.GetTag(TagTypes.Ape, false) as TagLib.Ape.Tag; if (apetag != null) { TagLib.Ape.Item apeItem = apetag.GetItem("RATING"); if (apeItem != null) { string rating = apeItem.ToString(); try { musictag.Rating = Convert.ToInt32(rating); } catch (Exception ex) { musictag.Rating = 0; Log.Warn("Tagreader: Unsupported APE rating format - {0} in {1} {2}", rating, strFile, ex.Message); } } } } } } else { if (tag.MimeType == "taglib/ape") { TagLib.Ape.Tag apetag = tag.GetTag(TagTypes.Ape, false) as TagLib.Ape.Tag; if (apetag != null) { TagLib.Ape.Item apeItem = apetag.GetItem("RATING"); if (apeItem != null) { string rating = apeItem.ToString(); try { musictag.Rating = Convert.ToInt32(rating); } catch (Exception ex) { musictag.Rating = 0; Log.Warn("Tagreader: Unsupported APE rating format - {0} in {1} {2}", rating, strFile, ex.Message); } } } } } // if we didn't get a title, use the Filename without extension to prevent the file to appear as "unknown" if (musictag.Title == "") { Log.Warn("TagReader: Empty Title found in file: {0}. Please retag.", strFile); musictag.Title = System.IO.Path.GetFileNameWithoutExtension(strFile); } return musictag; } catch (UnsupportedFormatException) { Log.Warn("Tagreader: Unsupported File Format {0}", strFile); } catch (Exception ex) { Log.Warn("TagReader: Exception reading file {0}. {1}", strFile, ex.Message); } return null; }
/// <summary> /// This method is called by mediaportal when it wants information for a music file /// The method will check which tagreader supports the file and ask it to extract the information from it /// </summary> /// <param name="strFile">filename of the music file</param> /// <returns> /// MusicTag instance when file has been read /// null when file type is not supported or if the file does not contain any information /// </returns> public static MusicTag ReadTag(string strFile) { // Read Cue info if (CueUtil.isCueFakeTrackFile(strFile)) { try { return(CueUtil.CueFakeTrackFile2MusicTag(strFile)); } catch (Exception ex) { Log.Warn("TagReader: Exception reading file {0}. {1}", strFile, ex.Message); } } if (!IsAudio(strFile)) { return(null); } char[] trimChars = { ' ', '\x00' }; try { // Set the flag to use the standard System Encoding set by the user // Otherwise Latin1 is used as default, which causes characters in various languages being displayed wrong TagLib.ByteVector.UseBrokenLatin1Behavior = true; TagLib.File tag = TagLib.File.Create(strFile); if (tag == null) { Log.Warn("Tagreader: No tag in file - {0}", strFile); return(null); } MusicTag musictag = new MusicTag(); string[] artists = tag.Tag.Performers; if (artists.Length > 0) { musictag.Artist = String.Join(";", artists).Trim(trimChars); // The AC/DC exception if (musictag.Artist.Contains("AC;DC")) { musictag.Artist = musictag.Artist.Replace("AC;DC", "AC/DC"); } } musictag.Album = tag.Tag.Album == null ? "" : tag.Tag.Album.Trim(trimChars); musictag.HasAlbumArtist = false; string[] albumartists = tag.Tag.AlbumArtists; if (albumartists.Length > 0) { musictag.AlbumArtist = String.Join(";", albumartists).Trim(trimChars); musictag.HasAlbumArtist = true; // The AC/DC exception if (musictag.AlbumArtist.Contains("AC;DC")) { musictag.AlbumArtist = musictag.AlbumArtist.Replace("AC;DC", "AC/DC"); } } musictag.BitRate = tag.Properties.AudioBitrate; musictag.Comment = tag.Tag.Comment == null ? "" : tag.Tag.Comment.Trim(trimChars); string[] composer = tag.Tag.Composers; if (composer.Length > 0) { musictag.Composer = string.Join(";", composer).Trim(trimChars); } musictag.Conductor = tag.Tag.Conductor == null ? "" : tag.Tag.Conductor.Trim(trimChars); IPicture[] pics = new IPicture[] { }; pics = tag.Tag.Pictures; if (pics.Length > 0) { musictag.CoverArtImageBytes = pics[0].Data.Data; } musictag.Duration = (int)tag.Properties.Duration.TotalSeconds; musictag.FileName = strFile; musictag.FileType = tag.MimeType.Substring(tag.MimeType.IndexOf("/") + 1); string[] genre = tag.Tag.Genres; if (genre.Length > 0) { musictag.Genre = String.Join(";", genre).Trim(trimChars); } string lyrics = tag.Tag.Lyrics == null ? "" : tag.Tag.Lyrics.Trim(trimChars); musictag.Title = tag.Tag.Title == null ? "" : tag.Tag.Title.Trim(trimChars); // Prevent Null Ref execption, when Title is not set musictag.Track = (int)tag.Tag.Track; musictag.TrackTotal = (int)tag.Tag.TrackCount; musictag.DiscID = (int)tag.Tag.Disc; musictag.DiscTotal = (int)tag.Tag.DiscCount; musictag.Codec = tag.Properties.Description; if (tag.MimeType == "taglib/mp3") { musictag.BitRateMode = tag.Properties.Description.IndexOf("VBR") > -1 ? "VBR" : "CBR"; } else { musictag.BitRateMode = ""; } musictag.BPM = (int)tag.Tag.BeatsPerMinute; musictag.Channels = tag.Properties.AudioChannels; musictag.SampleRate = tag.Properties.AudioSampleRate; musictag.Year = (int)tag.Tag.Year; if (tag.MimeType == "taglib/mp3") { bool foundPopm = false; // Handle the Rating, which comes from the POPM frame TagLib.Id3v2.Tag id32_tag = tag.GetTag(TagLib.TagTypes.Id3v2) as TagLib.Id3v2.Tag; if (id32_tag != null) { // Do we have a POPM frame written by MediaPortal or MPTagThat? TagLib.Id3v2.PopularimeterFrame popmFrame = TagLib.Id3v2.PopularimeterFrame.Get(id32_tag, "MediaPortal", false); if (popmFrame == null) { popmFrame = TagLib.Id3v2.PopularimeterFrame.Get(id32_tag, "MPTagThat", false); } if (popmFrame != null) { musictag.Rating = popmFrame.Rating; foundPopm = true; } // Now look for a POPM frame written by WMP if (!foundPopm) { TagLib.Id3v2.PopularimeterFrame popm = TagLib.Id3v2.PopularimeterFrame.Get(id32_tag, "Windows Media Player 9 Series", false); if (popm != null) { // Get the rating stored in the WMP POPM frame int rating = popm.Rating; int i = 0; if (rating == 255) { i = 5; } else if (rating == 196) { i = 4; } else if (rating == 128) { i = 3; } else if (rating == 64) { i = 2; } else if (rating == 1) { i = 1; } musictag.Rating = i; foundPopm = true; } } if (!foundPopm) { // Now look for any other POPM frame that might exist foreach (TagLib.Id3v2.PopularimeterFrame popm in id32_tag.GetFrames <TagLib.Id3v2.PopularimeterFrame>()) { int rating = popm.Rating; int i = 0; if (rating > 205 || rating == 5) { i = 5; } else if (rating > 154 || rating == 4) { i = 4; } else if (rating > 104 || rating == 3) { i = 3; } else if (rating > 53 || rating == 2) { i = 2; } else if (rating > 0 || rating == 1) { i = 1; } musictag.Rating = i; foundPopm = true; break; // we only take the first popm frame } } if (!foundPopm) { // If we don't have any POPM frame, we might have an APE Tag embedded in the mp3 file TagLib.Ape.Tag apetag = tag.GetTag(TagTypes.Ape, false) as TagLib.Ape.Tag; if (apetag != null) { TagLib.Ape.Item apeItem = apetag.GetItem("RATING"); if (apeItem != null) { string rating = apeItem.ToString(); try { musictag.Rating = Convert.ToInt32(rating); } catch (Exception ex) { musictag.Rating = 0; Log.Warn("Tagreader: Unsupported APE rating format - {0} in {1} {2}", rating, strFile, ex.Message); } } } } } } else { if (tag.MimeType == "taglib/ape") { TagLib.Ape.Tag apetag = tag.GetTag(TagTypes.Ape, false) as TagLib.Ape.Tag; if (apetag != null) { TagLib.Ape.Item apeItem = apetag.GetItem("RATING"); if (apeItem != null) { string rating = apeItem.ToString(); try { musictag.Rating = Convert.ToInt32(rating); } catch (Exception ex) { musictag.Rating = 0; Log.Warn("Tagreader: Unsupported APE rating format - {0} in {1} {2}", rating, strFile, ex.Message); } } } } } // if we didn't get a title, use the Filename without extension to prevent the file to appear as "unknown" if (musictag.Title == "") { Log.Warn("TagReader: Empty Title found in file: {0}. Please retag.", strFile); musictag.Title = System.IO.Path.GetFileNameWithoutExtension(strFile); } return(musictag); } catch (UnsupportedFormatException) { Log.Warn("Tagreader: Unsupported File Format {0}", strFile); } catch (Exception ex) { Log.Warn("TagReader: Exception reading file {0}. {1}", strFile, ex.Message); } return(null); }