public TextDetail(string templateDir, JObject text, CustomJPrototypeResolver resolver) { _templateDir = templateDir; _resolver = resolver; Content = resolver.GetString(text, "Content"); Font = resolver.GetString(text, "Font"); FontSize = resolver.GetIntOrDefault(text, "FontSize", 0); FontStyle = resolver.GetFlagsEnumOrDefault(text, "FontStyle", FontStyle.Regular); Color = resolver.GetColorOrDefault(text, "Color", Color.Black); BackgroundColor = resolver.GetColorOrDefault(text, "BackgroundColor", Color.Transparent); BackgroundBorderColor = resolver.GetColorOrDefault(text, "BackgroundBorderColor", Color.Transparent); BackgroundBorderThickness = resolver.GetIntOrDefault(text, "BackgroundBorderThickness", 0); OutlineColor = resolver.GetColorOrDefault(text, "OutlineColor", Color.Transparent); OutlineThickness = resolver.GetIntOrDefault(text, "OutlineThickness", 0); X = resolver.GetInt(text, "X"); Y = resolver.GetInt(text, "Y"); Width = resolver.GetInt(text, "Width"); Height = resolver.GetInt(text, "Height"); HorizontalAlignment = resolver.GetEnumOrDefault(text, "HorizontalAlignment", HorizontalAlignment.Center); LineAlignment = resolver.GetEnumOrDefault(text, "LineAlignment", HorizontalAlignment.Center); VerticalAlignment = resolver.GetEnumOrDefault(text, "VerticalAlignment", VerticalAlignment.Center); WordAlignment = resolver.GetEnumOrDefault(text, "WordAlignment", VerticalAlignment.Bottom); FlawedRotation = resolver.GetIntOrDefault(text, "FlawedRotation", 0); FlawedDynamicFontSizeEnabled = resolver.GetBoolOrDefault(text, "FlawedDynamicSizeEnabled", false); }
public TextStyling(Graphics graphics, TextStyling previousStyle, CustomJPrototypeResolver resolver, JObject prototype) : this(graphics, resolver.GetStringOrDefault(prototype, "Font", previousStyle.FontName), resolver.GetIntOrDefault(prototype, "FontSize", previousStyle.FontSize), resolver.GetFlagsEnumOrDefault(prototype, "FontStyle", previousStyle.FontStyle), resolver.GetColorOrDefault(prototype, "Color", previousStyle.Color), resolver.GetColorOrDefault(prototype, "BackgroundColor", previousStyle.BackgroundColor), resolver.GetColorOrDefault(prototype, "BackgroundBorderColor", previousStyle.BackgroundBorderColor), resolver.GetIntOrDefault(prototype, "BackgroundBorderThickness", previousStyle.BackgroundBorderThickness), resolver.GetColorOrDefault(prototype, "OutlineColor", previousStyle.OutlineColor), resolver.GetIntOrDefault(prototype, "OutlineThickness", previousStyle.OutlineThickness)) { }
private void SaveTrimmedImage(CustomJPrototypeResolver resolver, JObject instructions, JObject blueprint, Bitmap bitmap, string instructionsDir, string savePath, string saveName, int item, Canvas canvas, HashSet <string> savedPaths) { var trim = resolver.GetIntOrDefault(blueprint, "PostTrim", 0); var path = GetSavePath(resolver, instructions, blueprint, instructionsDir, savePath, saveName, item, savedPaths); if (trim == 0) { bitmap.Save(path, ImageFormat.Png); } else { var trimmedBitmap = new Bitmap(canvas.Width - trim * 2, canvas.Height - trim * 2); WithGraphics(trimmedBitmap, g => { g.DrawImage(bitmap, new Rectangle(0, 0, trimmedBitmap.Width, trimmedBitmap.Height), new Rectangle(trim, trim, trimmedBitmap.Width, trimmedBitmap.Height), GraphicsUnit.Pixel); trimmedBitmap.Save(path, ImageFormat.Png); }); } }