public void DrawCard(int nX, int nY, Graphics zGraphics, DeckLine zDeckLine, bool bExport, bool bDrawBackground) { // Custom Graphics Setting zGraphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; zGraphics.SmoothingMode = SmoothingMode.AntiAlias; //zGraphics.SmoothingMode = SmoothingMode.HighQuality; var matrixOriginal = zGraphics.Transform; // Zoom does not apply to export if (!bExport) { zGraphics.ScaleTransform(ZoomLevel, ZoomLevel); // Custom Graphics Setting zGraphics.InterpolationMode = 1.0f != ZoomLevel ? InterpolationMode.NearestNeighbor : InterpolationMode.Bilinear; } // draw the card background if (bDrawBackground) { zGraphics.FillRectangle(Brushes.White, nX, nY, CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height); } // All drawing is handled in reverse element order if (null != CurrentDeck.CardLayout.Element) { for (var nIdx = CurrentDeck.CardLayout.Element.Length - 1; nIdx > -1; nIdx--) { var zElement = CurrentDeck.CardLayout.Element[nIdx]; if (zElement.enabled) // only add enabled items to draw { IssueManager.Instance.FireChangeElementEvent(zElement.name); // get override Element (overrides based on data source) (this is a copy!) // This takes place before translation to cover the odd case where the variable field is override in the data source var zDrawElement = CurrentDeck.GetOverrideElement(zElement, zDeckLine, bExport); // translate any index values in the csv var zElementString = CurrentDeck.TranslateString(zDrawElement.variable, zDeckLine, zDrawElement, bExport); // get override Element (based on any overrides in the element variable string) zDrawElement = CurrentDeck.GetVariableOverrideElement(zDrawElement, zElementString.OverrideFieldToValueDictionary); // enabled is re-checked due to possible override of the enabled value if (!zElementString.DrawElement || !zDrawElement.enabled) { continue; } // initialize the translated fields on the element to draw zDrawElement.InitializeTranslatedFields(); DrawElement(zGraphics, CurrentDeck, zDrawElement, nX, nY, zElementString.String, bExport); if (!bExport) { zGraphics.ScaleTransform(ZoomLevel, ZoomLevel); } } } if (!bExport) { // draw all selections and element borders after everything else for (var nIdx = CurrentDeck.CardLayout.Element.Length - 1; nIdx > -1; nIdx--) { ProjectLayoutElement zElement = CurrentDeck.CardLayout.Element[nIdx]; if (zElement.enabled) // only add enabled items to draw { DrawElementDebugBorder(zGraphics, zElement, nX, nY, ElementManager.Instance.GetSelectedElement() == zElement); } } } } DrawLayoutDividers(zGraphics, bExport); // draw the card border if ((bExport && CardMakerSettings.PrintLayoutBorder) || (!bExport && CurrentDeck.CardLayout.drawBorder)) { // note that the border is inclusive in the width/height consuming 2 pixels (0 to total-1) zGraphics.DrawRectangle(Pens.Black, nX, nY, CurrentDeck.CardLayout.width - 1, CurrentDeck.CardLayout.height - 1); } zGraphics.Transform = matrixOriginal; }
public void DrawCard(int nX, int nY, Graphics zGraphics, DeckLine zDeckLine, bool bExport, bool bDrawBackground) { List <string> listLine = zDeckLine.LineColumns; // Custom Graphics Setting zGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; zGraphics.SmoothingMode = SmoothingMode.AntiAlias; //zGraphics.SmoothingMode = SmoothingMode.HighQuality; var matrixOriginal = zGraphics.Transform; // Zoom does not apply to export if (!bExport) { zGraphics.ScaleTransform(ZoomLevel, ZoomLevel); // Custom Graphics Setting zGraphics.InterpolationMode = 1.0f != ZoomLevel ? InterpolationMode.NearestNeighbor : InterpolationMode.Bilinear; } //Logger.Clear(); ProjectLayoutElement zSelectedElement = null; if (!bExport) { zSelectedElement = ElementManager.Instance.GetSelectedElement(); } // draw the background if (bDrawBackground) { zGraphics.FillRectangle(Brushes.White, nX, nY, CurrentDeck.CardLayout.width, CurrentDeck.CardLayout.height); } // All drawing is handled in reverse element order if (null != CurrentDeck.CardLayout.Element) { for (var nIdx = CurrentDeck.CardLayout.Element.Length - 1; nIdx > -1; nIdx--) { var zElement = CurrentDeck.CardLayout.Element[nIdx]; if (zElement.enabled) // only add enabled items to draw { IssueManager.Instance.FireChangeElementEvent(zElement.name); // get override Element ProjectLayoutElement zOverrideElement = CurrentDeck.GetOverrideElement(zElement, listLine, zDeckLine, bExport); var zDrawElement = zOverrideElement; // translate any index values in the csv var zElementString = CurrentDeck.TranslateString(zDrawElement.variable, zDeckLine, zDrawElement, bExport); // enabled is re-checked due to possible override of the enabled value if (!zElementString.DrawElement || !zDrawElement.enabled) { continue; } var eType = DrawItem.GetElementType(zDrawElement.type); //NOTE: removed transform backup (draw element resets it anyway...) //if (!bExport) // backup is only necessary for zoomed canvas //{ //matrixPrevious = zGraphics.Transform; //} DrawItem.DrawElement(zGraphics, CurrentDeck, zDrawElement, eType, nX, nY, zElementString.String, bExport); if (!bExport) { //zGraphics.Transform = matrixPrevious; zGraphics.ScaleTransform(ZoomLevel, ZoomLevel); } } } if (!bExport) { // draw all selections and element borders after everything else for (var nIdx = CurrentDeck.CardLayout.Element.Length - 1; nIdx > -1; nIdx--) { ProjectLayoutElement zElement = CurrentDeck.CardLayout.Element[nIdx]; if (zElement.enabled) // only add enabled items to draw { var bDrawSelection = zSelectedElement == zElement; if (CardMakerInstance.DrawElementBorder) { var matrixPrevious = zGraphics.Transform; DrawItem.DrawElementDebugBorder(zGraphics, zElement, nX, nY, bDrawSelection); zGraphics.Transform = matrixPrevious; } } } } } // draw the card border if ((bExport && CardMakerSettings.PrintLayoutBorder) || (!bExport && CurrentDeck.CardLayout.drawBorder)) { // note that the border is inclusive in the width/height consuming 2 pixels (0 to total-1) zGraphics.DrawRectangle(Pens.Black, nX, nY, CurrentDeck.CardLayout.width - 1, CurrentDeck.CardLayout.height - 1); } zGraphics.Transform = matrixOriginal; }