public static void SetAttribute <TType>(XmlElement element, string name, TType value) { DebugThrow.IfNull(nameof(element), element); DebugThrow.IfNullOrEmpty(nameof(name), name); XmlAttribute attribute; if (element.HasAttribute(name)) { attribute = element.Attributes[name]; } else { attribute = element.Attributes.Append(element.OwnerDocument.CreateAttribute(name)); } if (typeof(TType) == typeof(string)) { attribute.Value = (string)(object)value; } else { attribute.Value = (string)Convert.ChangeType(value, typeof(string), CultureInfo.InvariantCulture); } }
public void PathArcAbs(IEnumerable <PathArc> pathArcs) { DebugThrow.IfNull(nameof(pathArcs), pathArcs); foreach (PathArc pathArc in pathArcs) { _nativeInstance.PathArcAbs(pathArc.X, pathArc.Y, pathArc.RadiusX, pathArc.RadiusY, pathArc.RotationX, pathArc.UseLargeArc, pathArc.UseSweep); } }
public void Polyline(IList <PointD> coordinates) { DebugThrow.IfNull(nameof(coordinates), coordinates); using (PointInfoCollection pointInfo = new PointInfoCollection(coordinates)) { _nativeInstance.Polyline(pointInfo, pointInfo.Count); } }
public void PathLineToRel(IEnumerable <PointD> coordinates) { DebugThrow.IfNull(nameof(coordinates), coordinates); foreach (PointD coordinate in coordinates) { _nativeInstance.PathLineToRel(coordinate.X, coordinate.Y); } }
public static XmlElement CreateElement(XmlNode node, string name) { DebugThrow.IfNull(nameof(node), node); DebugThrow.IfNullOrEmpty(nameof(name), name); XmlDocument doc = node.GetType() == typeof(XmlDocument) ? (XmlDocument)node : node.OwnerDocument; XmlElement element = doc.CreateElement(name); node.AppendChild(element); return(element); }
private IImageOptimizer GetOptimizer(FileInfo file) { MagickFormatInfo info = GetFormatInformation(file); DebugThrow.IfNull(nameof(info), info); foreach (IImageOptimizer optimizer in _optimizers) { if (optimizer.Format.Module == info.Module) { return(optimizer); } } throw new MagickCorruptImageErrorException("Invalid format, supported formats are: " + SupportedFormats); }
public static Dictionary <MagickColor, int> ToDictionary(IntPtr list, int length) { Dictionary <MagickColor, int> colors = new Dictionary <MagickColor, int>(); if (list == IntPtr.Zero) { return(colors); } for (int i = 0; i < length; i++) { IntPtr instance = NativeMagickColorCollection.GetInstance(list, i); DebugThrow.IfNull(instance); MagickColor color = MagickColor.CreateInstance(instance); colors[color] = color.Count; } return(colors); }
public void Dispose() { DebugThrow.IfNull(_nativeInstance); _nativeInstance.Dispose(); }
public void StrokeDashArray(double[] dash) { DebugThrow.IfNull(nameof(dash), dash); _nativeInstance.StrokeDashArray(dash, dash.Length); }