Просмотр исходного кода

Bug in Width and Height properties of the Picture class is fixed (9525 EMUs in pixel instead of 4156).

Image class now has FileName property.
master
AndreyKovalenko_cp 15 лет назад
Родитель
Сommit
f1919e89ff
2 измененных файлов: 22 добавлений и 13 удалений
  1. 11
    0
      DocX/Image.cs
  2. 11
    13
      DocX/Picture.cs

+ 11
- 0
DocX/Image.cs Просмотреть файл

{ {
return Paragraph.CreatePicture(document, id, string.Empty, string.Empty); return Paragraph.CreatePicture(document, id, string.Empty, string.Empty);
} }
///<summary>
/// Returns the name of the image file.
///</summary>
public string FileName
{
get
{
return Path.GetFileName(this.pr.TargetUri.ToString());
}
}
} }
} }

+ 11
- 13
DocX/Picture.cs Просмотреть файл

/// </summary> /// </summary>
public class Picture: DocXElement public class Picture: DocXElement
{ {
private const int EmusInPixel = 9525;
internal Dictionary<PackagePart, PackageRelationship> picture_rels; internal Dictionary<PackagePart, PackageRelationship> picture_rels;
internal Image img; internal Image img;
where (a != null) where (a != null)
select a.Value select a.Value
).First(); ).First();
this.fileName =
(
from e in Xml.Descendants(XName.Get("cNvPr", "http://schemas.openxmlformats.org/drawingml/2006/picture"))
select e.Attribute("name").Value
).First();
this.descr = this.descr =
( (
from e in Xml.Descendants() from e in Xml.Descendants()
///</summary> ///</summary>
public string FileName public string FileName
{ {
get { return fileName; }
get
{
return img.FileName;
}
} }
/// <summary> /// <summary>
/// </summary> /// </summary>
public int Width public int Width
{ {
get { return cx / 4156; }
get { return cx / EmusInPixel; }
set set
{ {
cx = value; cx = value;
foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cx"))) foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cx")))
a.Value = (cx * 4156).ToString();
a.Value = (cx * EmusInPixel).ToString();
} }
} }
/// </summary> /// </summary>
public int Height public int Height
{ {
get { return cy / 4156; }
get { return cy / EmusInPixel; }
set set
{ {
cy = value; cy = value;
foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cy"))) foreach (XAttribute a in Xml.Descendants().Attributes(XName.Get("cy")))
a.Value = (cy * 4156).ToString();
a.Value = (cy * EmusInPixel).ToString();
} }
} }

Загрузка…
Отмена
Сохранить