private void CollectionScriptRead(object sender, ScriptReadEventArgs arguments) { switch (arguments.Id) { case "icon": arguments.Image = new MagickImage(Files.MagickNETIconPNG, arguments.Settings); break; case "snakeware": arguments.Image = new MagickImage(Files.SnakewarePNG, arguments.Settings); break; default: throw new NotImplementedException(arguments.Id); } }
private MagickImage CreateMagickImage(XmlElement element) { Throw.IfNull(nameof(element), element); MagickImage image = null; MagickReadSettings settings = CreateReadSettings((XmlElement)element.SelectSingleNode("readSettings")); string fileName = element.GetAttribute("fileName"); if (!string.IsNullOrEmpty(fileName)) { if (settings != null) image = new MagickImage(fileName, settings); else image = new MagickImage(fileName); } else { if (Read == null) throw new InvalidOperationException("The Read event should be bound when the fileName attribute is not set."); string id = element.GetAttribute("id"); ScriptReadEventArgs eventArgs = new ScriptReadEventArgs(id, settings); Read(this, eventArgs); if (eventArgs.Image == null) throw new InvalidOperationException("The Image property should not be null after the Read event has been raised."); image = eventArgs.Image; } Execute(element, image); return image; }
private void Script_ReadNothing(object sender, ScriptReadEventArgs arguments) { }
private void ResizeScriptRead(object sender, ScriptReadEventArgs arguments) { arguments.Image = new MagickImage(Files.ImageMagickJPG, arguments.Settings); Assert.AreEqual("64x64", arguments.Image.GetDefine(MagickFormat.Jpeg, "size")); }
private void EventsScriptRead(object sender, ScriptReadEventArgs arguments) { Assert.AreEqual("read.id", arguments.Id); arguments.Image = new MagickImage(Files.SnakewarePNG, arguments.Settings); }
private void DefinesScriptRead(object sender, ScriptReadEventArgs arguments) { arguments.Image = new MagickImage(Files.InvitationTif, arguments.Settings); Assert.IsNull(arguments.Image.GetAttribute("exif:PixelXDimension")); }
private static void OnScriptRead(object sender, ScriptReadEventArgs arguments) { arguments.Image = new MagickImage(SampleFiles.SnakewareJpg); }