private void InitializeDiagram() { var node1 = NewNode(50, 50); var node2 = NewNode(400, 50); _diagram.Nodes.Add(new[] { node1, node2 }); var link = new LinkModel(node1.GetPort(PortAlignment.Right), node2.GetPort(PortAlignment.Left)); link.SourceMarker = LinkMarker.Arrow; link.TargetMarker = LinkMarker.Arrow; link.Labels.Add(new LinkLabelModel(link, "Arrow")); _diagram.Links.Add(link); node1 = NewNode(50, 160); node2 = NewNode(400, 160); _diagram.Nodes.Add(new[] { node1, node2 }); link = new LinkModel(node1.GetPort(PortAlignment.Right), node2.GetPort(PortAlignment.Left)); link.SourceMarker = LinkMarker.Circle; link.TargetMarker = LinkMarker.Circle; link.Labels.Add(new LinkLabelModel(link, "Circle")); _diagram.Links.Add(link); node1 = NewNode(50, 270); node2 = NewNode(400, 270); _diagram.Nodes.Add(new[] { node1, node2 }); link = new LinkModel(node1.GetPort(PortAlignment.Right), node2.GetPort(PortAlignment.Left)); link.SourceMarker = LinkMarker.Square; link.TargetMarker = LinkMarker.Square; link.Labels.Add(new LinkLabelModel(link, "Square")); _diagram.Links.Add(link); node1 = NewNode(50, 380); node2 = NewNode(400, 380); _diagram.Nodes.Add(new[] { node1, node2 }); link = new LinkModel(node1.GetPort(PortAlignment.Right), node2.GetPort(PortAlignment.Left)); link.SourceMarker = LinkMarker.NewRectangle(10, 20); link.TargetMarker = LinkMarker.NewArrow(20, 10); link.Labels.Add(new LinkLabelModel(link, "Factory")); _diagram.Links.Add(link); node1 = NewNode(50, 490); node2 = NewNode(400, 490); _diagram.Nodes.Add(new[] { node1, node2 }); link = new LinkModel(node1.GetPort(PortAlignment.Right), node2.GetPort(PortAlignment.Left)); link.SourceMarker = new LinkMarker("M 0 -8 L 3 -8 3 8 0 8 z M 4 -8 7 -8 7 8 4 8 z M 8 -8 16 0 8 8 z", 16); link.TargetMarker = new LinkMarker("M 0 -8 L 8 -8 4 0 8 8 0 8 4 0 z", 8); link.Labels.Add(new LinkLabelModel(link, "Custom")); _diagram.Links.Add(link); }
private void DrawLinkMarkers(Graphics graphics, Data data) { LinkMarker lm = (LinkMarker)data.defence; if ((lm & LinkMarker.LINK_MARKER_BOTTOM_LEFT) > 0) { graphics.DrawImage(this.bLinkMarkers[0], 34, 387, 38, 37); } if ((lm & LinkMarker.LINK_MARKER_BOTTOM) > 0) { graphics.DrawImage(this.bLinkMarkers[1], 163, 406, 73, 25); } if ((lm & LinkMarker.LINK_MARKER_BOTTOM_RIGHT) > 0) { graphics.DrawImage(this.bLinkMarkers[2], 329, 387, 37, 37); } if ((lm & LinkMarker.LINK_MARKER_LEFT) > 0) { graphics.DrawImage(this.bLinkMarkers[3], 27, 222, 24, 72); } if ((lm & LinkMarker.LINK_MARKER_RIGHT) > 0) { graphics.DrawImage(this.bLinkMarkers[5], 349, 221, 24, 72); } if ((lm & LinkMarker.LINK_MARKER_TOP_LEFT) > 0) { graphics.DrawImage(this.bLinkMarkers[6], 34, 91, 37, 37); } if ((lm & LinkMarker.LINK_MARKER_TOP) > 0) { graphics.DrawImage(this.bLinkMarkers[7], 163, 85, 74, 23); } if ((lm & LinkMarker.LINK_MARKER_TOP_RIGHT) > 0) { graphics.DrawImage(this.bLinkMarkers[8], 329, 91, 37, 37); } }
private Point GetPortPositionBasedOnAlignment(PortModel port, LinkMarker marker) { if (port == null) { return(null); } if (marker == null) { return(port.MiddlePosition); } var pt = port.Position; switch (port.Alignment) { case PortAlignment.Top: return(new Point(pt.X + port.Size.Width / 2, pt.Y)); case PortAlignment.TopRight: return(new Point(pt.X + port.Size.Width, pt.Y)); case PortAlignment.Right: return(new Point(pt.X + port.Size.Width, pt.Y + port.Size.Height / 2)); case PortAlignment.BottomRight: return(new Point(pt.X + port.Size.Width, pt.Y + port.Size.Height)); case PortAlignment.Bottom: return(new Point(pt.X + port.Size.Width / 2, pt.Y + port.Size.Height)); case PortAlignment.BottomLeft: return(new Point(pt.X, pt.Y + port.Size.Height)); case PortAlignment.Left: return(new Point(pt.X, pt.Y + port.Size.Height / 2)); default: return(pt); } }
private static Bitmap DrawImage(int code, Data data, Text text) { Bitmap bitmap; SizeF ef; int nWidth; if (data.isType(Type.TYPE_SPELL)) { bitmap = new Bitmap(bTemplates[0]); } else if (data.isType(Type.TYPE_TRAP)) { bitmap = new Bitmap(bTemplates[1]); } else if (data.isType(Type.TYPE_PENDULUM)) { if (data.isType(Type.TYPE_SYNCHRO)) { bitmap = new Bitmap(bTemplates[12]); } else if (data.isType(Type.TYPE_XYZ)) { bitmap = new Bitmap(bTemplates[9]); } else if (data.isType(Type.TYPE_FUSION)) { bitmap = new Bitmap(bTemplates[13]); } else if (data.isType(Type.TYPE_EFFECT)) { bitmap = new Bitmap(bTemplates[10]); } else //pnormal { bitmap = new Bitmap(bTemplates[11]); } } else if (data.isType(Type.TYPE_LINK)) { bitmap = new Bitmap(bTemplates[14]); } else if (data.isType(Type.TYPE_SYNCHRO)) { bitmap = new Bitmap(bTemplates[2]); } else if (data.isType(Type.TYPE_XYZ)) { bitmap = new Bitmap(bTemplates[3]); } else if (data.isType(Type.TYPE_FUSION)) { bitmap = new Bitmap(bTemplates[4]); } else if (data.isType(Type.TYPE_RITUAL)) { bitmap = new Bitmap(bTemplates[5]); } else if (data.isType(Type.TYPE_TOKEN)) { bitmap = new Bitmap(bTemplates[6]); } else if (data.isType(Type.TYPE_EFFECT)) { bitmap = new Bitmap(bTemplates[7]); } else //normal { bitmap = new Bitmap(bTemplates[8]); } Graphics graphics = Graphics.FromImage(bitmap); text.text = GetStandardText(text.text); if (data.isType(Type.TYPE_MONSTER)) { if (!zeroStarCards.Contains(data.code)) { int nStar; if (data.isType(Type.TYPE_XYZ)) { for (nStar = 0; nStar < (data.level & 0xff); nStar++) { graphics.DrawImage(bStar[1], (int)35 + (22.5f * nStar), 60, 20, 20); } } else if (!data.isType(Type.TYPE_LINK)) { for (nStar = 0; nStar < (data.level & 0xff); nStar++) { graphics.DrawImage(bStar[0], (int)282 - (22.5f * nStar), 60, 20, 20); } } } int nAttr; if (data.attribute == Attribute.ATTRIBUTE_EARTH) { nAttr = 0; } else if (data.attribute == Attribute.ATTRIBUTE_WATER) { nAttr = 1; } else if (data.attribute == Attribute.ATTRIBUTE_FIRE) { nAttr = 2; } else if (data.attribute == Attribute.ATTRIBUTE_WIND) { nAttr = 3; } else if (data.attribute == Attribute.ATTRIBUTE_LIGHT) { nAttr = 4; } else if (data.attribute == Attribute.ATTRIBUTE_DARK) { nAttr = 5; } else { nAttr = 6; } graphics.DrawImage(bAttributes[nAttr], 280, 22, 32, 32); if (data.attack >= 0) { graphics.DrawString(data.attack.ToString(), numFont, Brushes.Black, 210, 447); } else { graphics.DrawString("?", numFont, textBrush, 210, 447); } if (data.isType(Type.TYPE_LINK)) { graphics.DrawString(data.level.ToString(), linkFont, Brushes.Black, 296, 446); } else { if (data.defence >= 0) { graphics.DrawString(data.defence.ToString(), numFont, Brushes.Black, 277, 447); } else { graphics.DrawString("?", numFont, textBrush, 277, 447); } } string type_string = GetTypeString(data); float tWidth = graphics.MeasureString(type_string, typeFont).Width; float sx1 = 1f; if (tWidth > 280f) { sx1 *= 280f / tWidth; } graphics.ScaleTransform(sx1, 1f); graphics.DrawString(type_string, typeFont, typeBrush, 19, 369); graphics.ResetTransform(); string monster_effect = text.text; if (data.isType(Type.TYPE_PENDULUM)) { monster_effect = GetPendulumDesc(text.text, regex_monster); } nWidth = 288; ef = graphics.MeasureString(monster_effect, txtFont, nWidth); while (ef.Height > 60 * nWidth / 288f) { nWidth += 3; ef = graphics.MeasureString(monster_effect, txtFont, nWidth); } graphics.TranslateTransform(23f, 385f); graphics.ScaleTransform(288f / nWidth, 288f / nWidth); graphics.DrawString(monster_effect, txtFont, textBrush, new RectangleF(0f, 0f, ef.Width, ef.Height)); graphics.ResetTransform(); if (data.isType(Type.TYPE_PENDULUM)) { int lscale = (data.level >> 0x18) & 0xff; int rscale = (data.level >> 0x10) & 0xff; if (lscale > 9) { graphics.DrawString(lscale.ToString(), scaleFontSmall, Brushes.Black, 19f, 336f); } else { graphics.DrawString(lscale.ToString(), scaleFontNormal, Brushes.Black, 24f, 333f); } if (rscale > 9) { graphics.DrawString(rscale.ToString(), scaleFontSmall, Brushes.Black, 287f, 336f); } else { graphics.DrawString(rscale.ToString(), scaleFontNormal, Brushes.Black, 291f, 333f); } int nWidthP; SizeF pf; string pendulum_effect = GetPendulumDesc(text.text, regex_pendulum); nWidthP = 232; pf = graphics.MeasureString(pendulum_effect, txtFont, nWidthP); while (pf.Height > 52 * nWidthP / 232f) { nWidthP += 1; pf = graphics.MeasureString(pendulum_effect, txtFont, nWidthP); } graphics.TranslateTransform(51f, 311f); graphics.ScaleTransform(232f / nWidthP, 232f / nWidthP); graphics.DrawString(pendulum_effect, txtFont, textBrush, new RectangleF(0f, 0f, pf.Width, pf.Height)); graphics.ResetTransform(); } } else { if (data.isType(Type.TYPE_SPELL)) { if (data.type == Type.TYPE_SPELL) { graphics.DrawImage(bType[0], 204, 60, 96, 19); } else { int nType = 0; if (data.isType(Type.TYPE_QUICKPLAY)) { nType = 1; } if (data.isType(Type.TYPE_CONTINUOUS)) { nType = 2; } if (data.isType(Type.TYPE_EQUIP)) { nType = 3; } if (data.isType(Type.TYPE_FIELD)) { nType = 4; } if (data.isType(Type.TYPE_RITUAL)) { nType = 5; } graphics.DrawImage(bType[nType], 192, 60, 108, 19); } } else if (data.isType(Type.TYPE_TRAP)) { if (data.type == Type.TYPE_TRAP) { graphics.DrawImage(bType[6], 221, 60, 80, 19); } else { int nType = 6; if (data.isType(Type.TYPE_CONTINUOUS)) { nType = 7; } if (data.isType(Type.TYPE_COUNTER)) { nType = 8; } graphics.DrawImage(bType[nType], 209, 60, 91, 19); } } nWidth = 288; ef = graphics.MeasureString(text.text, txtFont, nWidth); while (ef.Height > 80 * nWidth / 288f) { nWidth += 3; ef = graphics.MeasureString(text.text, txtFont, nWidth); } graphics.TranslateTransform(24f, 370f); graphics.ScaleTransform(288f / nWidth, 288f / nWidth); graphics.DrawString(text.text, txtFont, textBrush, new RectangleF(0f, 0f, ef.Width, ef.Height)); graphics.ResetTransform(); } try { Bitmap image = new Bitmap("./pico/" + code.ToString() + ".jpg"); graphics.CompositingMode = CompositingMode.SourceOver; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.SmoothingMode = SmoothingMode.AntiAlias; if (data.isType(Type.TYPE_PENDULUM)) { float ar = image.Width / image.Height; if ((ar >= 1.3) && (ar <= 1.4)) { graphics.DrawImage(image, 22, 88, 292, 217); } else { graphics.DrawImage(image, new Rectangle(22, 88, 292, 217), new Rectangle(0, 0, image.Width, image.Width * 217 / 292), GraphicsUnit.Pixel); } } else { graphics.DrawImage(image, 40, 90, 256, 256); } } catch (Exception e) { Console.WriteLine("Error prasing {0} {1}", data.code, e); } if (data.isType(Type.TYPE_LINK)) { LinkMarker lm = (LinkMarker)data.defence; if ((lm & LinkMarker.LINK_MARKER_BOTTOM_LEFT) == 0) { graphics.DrawImage(bLinkMarkers1[0], 26, 326, 34, 34); } else { graphics.DrawImage(bLinkMarkers2[0], 26, 326, 34, 34); } if ((lm & LinkMarker.LINK_MARKER_BOTTOM) == 0) { graphics.DrawImage(bLinkMarkers1[1], 139, 343, 62, 23); } else { graphics.DrawImage(bLinkMarkers2[1], 139, 343, 62, 23); } if ((lm & LinkMarker.LINK_MARKER_BOTTOM_RIGHT) == 0) { graphics.DrawImage(bLinkMarkers1[2], 277, 326, 35, 34); } else { graphics.DrawImage(bLinkMarkers2[2], 277, 326, 35, 34); } if ((lm & LinkMarker.LINK_MARKER_LEFT) == 0) { graphics.DrawImage(bLinkMarkers1[3], 20, 187, 23, 62); } else { graphics.DrawImage(bLinkMarkers2[3], 20, 187, 23, 62); } if ((lm & LinkMarker.LINK_MARKER_RIGHT) == 0) { graphics.DrawImage(bLinkMarkers1[5], 294, 187, 23, 62); } else { graphics.DrawImage(bLinkMarkers2[5], 294, 187, 23, 62); } if ((lm & LinkMarker.LINK_MARKER_TOP_LEFT) == 0) { graphics.DrawImage(bLinkMarkers1[6], 26, 75, 35, 34); } else { graphics.DrawImage(bLinkMarkers2[6], 26, 75, 35, 34); } if ((lm & LinkMarker.LINK_MARKER_TOP) == 0) { graphics.DrawImage(bLinkMarkers1[7], 138, 69, 63, 23); } else { graphics.DrawImage(bLinkMarkers2[7], 138, 69, 63, 23); } if ((lm & LinkMarker.LINK_MARKER_TOP_RIGHT) == 0) { graphics.DrawImage(bLinkMarkers1[8], 278, 75, 34, 34); } else { graphics.DrawImage(bLinkMarkers2[8], 278, 75, 34, 34); } } string nametext = text.name.Replace('\x00b7', '・'); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; float width = graphics.MeasureString(nametext, nameFont).Width; float sx = 1f; if (width > 265f) { sx *= 265f / width; } graphics.TranslateTransform(21f, 23f); graphics.ScaleTransform(sx, 1f); graphics.DrawString(nametext, nameFont, nameBrush, 0f, 0f); graphics.DrawString(nametext, nameFont, Brushes.Gold, 1f, 1f); graphics.ResetTransform(); return(bitmap); }
public bool HasLinkMarker(LinkMarker dir) { return((LinkMarker & (int)dir) != 0); }