예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        public void Polyline(IList <PointD> coordinates)
        {
            DebugThrow.IfNull(nameof(coordinates), coordinates);

            using (PointInfoCollection pointInfo = new PointInfoCollection(coordinates))
            {
                _nativeInstance.Polyline(pointInfo, pointInfo.Count);
            }
        }
예제 #4
0
        public void PathLineToRel(IEnumerable <PointD> coordinates)
        {
            DebugThrow.IfNull(nameof(coordinates), coordinates);

            foreach (PointD coordinate in coordinates)
            {
                _nativeInstance.PathLineToRel(coordinate.X, coordinate.Y);
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
 public void Dispose()
 {
     DebugThrow.IfNull(_nativeInstance);
     _nativeInstance.Dispose();
 }
예제 #9
0
        public void StrokeDashArray(double[] dash)
        {
            DebugThrow.IfNull(nameof(dash), dash);

            _nativeInstance.StrokeDashArray(dash, dash.Length);
        }