private void pMoveControl(cReportAspect aspect, bool bSizing) { const int C_MIN_WIDTH = 10; const int C_MIN_HEIGHT = 10; cReportAspect rptCtrlAspect = null; if (m_paint.getPaintObject(m_keySizing).getRptType() == csRptTypeSection.CONTROL) { rptCtrlAspect = m_report.getControls().item(m_paint.getPaintObject(m_keySizing).getTag()).getLabel().getAspect(); rptCtrlAspect.setLeft(aspect.getLeft()); if (!bSizing) { rptCtrlAspect.setTop(aspect.getTop() + aspect.getOffset()); } else { rptCtrlAspect.setTop(aspect.getTop()); } rptCtrlAspect.setWidth(aspect.getWidth()); rptCtrlAspect.setHeight(aspect.getHeight()); } switch (m_moveType) { case csRptEditorMoveType.CSRPTEDMOVDOWN: m_paint.alingObjBottomToGrid(m_keySizing); break; case csRptEditorMoveType.CSRPTEDMOVLEFT: m_paint.alingObjLeftToGrid(m_keySizing); break; case csRptEditorMoveType.CSRPTEDMOVRIGHT: m_paint.alingObjRightToGrid(m_keySizing); break; case csRptEditorMoveType.CSRPTEDMOVUP: m_paint.alingObjTopToGrid(m_keySizing); break; case csRptEditorMoveType.CSRPTEDMOVLEFTDOWN: m_paint.alingObjLeftBottomToGrid(m_keySizing); break; case csRptEditorMoveType.CSRPTEDMOVLEFTUP: m_paint.alingObjLeftTopToGrid(m_keySizing); break; case csRptEditorMoveType.CSRPTEDMOVRIGHTDOWN: m_paint.alingObjRightBottomToGrid(m_keySizing); break; case csRptEditorMoveType.CSRPTEDMOVRIGHTUP: m_paint.alingObjRightTopToGrid(m_keySizing); break; } // Validations // Width can't be lower than C_MIN_WIDTH // if (aspect.getWidth() < C_MIN_WIDTH) { aspect.setWidth(C_MIN_WIDTH); } // Height can't be lower than C_MIN_HEIGHT // if (aspect.getHeight() < C_MIN_HEIGHT) { aspect.setHeight(C_MIN_HEIGHT); } }
private String paintSection(cReportAspect aspect, String sKey, csRptTypeSection rptType, String text, bool isSectionLine) { CSReportPaint.cReportPaintObject paintObj = null; paintObj = m_paint.getNewSection(CSReportPaint.csRptPaintObjType.CSRPTPAINTOBJBOX); cReportAspect w_aspect = paintObj.getAspect(); // we only draw the bottom line of the sections // w_aspect.setLeft(0); w_aspect.setTop(aspect.getTop() + aspect.getHeight() - cGlobals.C_HEIGHT_BAR_SECTION); w_aspect.setWidth(aspect.getWidth()); w_aspect.setHeight(cGlobals.C_HEIGHT_BAR_SECTION); int innerColor = 0; innerColor = 0xAEAEAE; if (isSectionLine) { w_aspect.setBackColor(innerColor); w_aspect.setBorderColor(Color.Red.ToArgb()); } else { if (rptType == csRptTypeSection.GROUP_SECTION_FOOTER || rptType == csRptTypeSection.GROUP_SECTION_HEADER) { w_aspect.setBackColor(innerColor); w_aspect.setBorderColor(0xC0C000); } else { w_aspect.setBackColor(innerColor); w_aspect.setBorderColor(0x5A7FB); } } if (rptType == csRptTypeSection.CSRPTTPMAINSECTIONFOOTER || rptType == csRptTypeSection.CSRPTTPSCFOOTER) { w_aspect.setOffset(m_offSet); } paintObj.setIsSection(!isSectionLine); paintObj.setRptType(rptType); paintObj.setTag(sKey); paintObj.setText(text); return paintObj.getKey(); }
private String paintSection(cReportAspect aspect, String sKey, csRptSectionType rptType, String text, bool isSecLn) { cReportPaintObject paintObj = null; paintObj = m_paint.getNewSection(csRptPaintObjType.CSRPTPAINTOBJBOX); cReportAspect w_aspect = paintObj.getAspect(); // we only draw the bottom line of the sections // w_aspect.setLeft(0); w_aspect.setTop(aspect.getTop() + aspect.getHeight() - cGlobals.C_HEIGHT_BAR_SECTION); w_aspect.setWidth(aspect.getWidth()); w_aspect.setHeight(cGlobals.C_HEIGHT_BAR_SECTION); w_aspect.setBorderType(csReportBorderType.CSRPTBSFIXED); w_aspect.setBorderWidth(1); if (isSecLn) { w_aspect.setBackColor(0xffcc99); w_aspect.setBorderColor(Color.Red.ToArgb()); } else { const int innerColor = 0x99ccff; if (rptType == csRptSectionType.GROUP_FOOTER || rptType == csRptSectionType.GROUP_HEADER) { w_aspect.setBackColor(innerColor); w_aspect.setBorderColor(0xC0C000); } else { w_aspect.setBackColor(innerColor); w_aspect.setBorderColor(0x0066cc); } } if (rptType == csRptSectionType.MAIN_FOOTER || rptType == csRptSectionType.FOOTER) { w_aspect.setOffset(m_offSet); } paintObj.setIsSection(!isSecLn); paintObj.setRptType(rptType); paintObj.setTag(sKey); paintObj.setText(text); return paintObj.getKey(); }
// TODO: this function shouldn't be needed // private void pCopyAspectToPaint(cReportAspect fromAspect, cReportAspect toAspect) { toAspect.setAlign(fromAspect.getAlign()); toAspect.setBackColor(fromAspect.getBackColor()); toAspect.setBorderColor(fromAspect.getBorderColor()); toAspect.setBorderColor3d(fromAspect.getBorderColor3d()); toAspect.setBorderColor3dShadow(fromAspect.getBorderColor3dShadow()); toAspect.setBorderType(fromAspect.getBorderType()); toAspect.setBorderWidth(fromAspect.getBorderWidth()); toAspect.setCanGrow(fromAspect.getCanGrow()); toAspect.setFormat(fromAspect.getFormat()); toAspect.setHeight(fromAspect.getHeight()); toAspect.setIsAccounting(fromAspect.getIsAccounting()); toAspect.setLeft(fromAspect.getLeft()); toAspect.setNZOrder(fromAspect.getNZOrder()); toAspect.setSelectColor(fromAspect.getSelectColor()); toAspect.setSymbol(fromAspect.getSymbol()); toAspect.setTop(fromAspect.getTop()); toAspect.setTransparent(fromAspect.getTransparent()); toAspect.setWidth(fromAspect.getWidth()); toAspect.setWordWrap(fromAspect.getWordWrap()); pCopyFontPaint(fromAspect.getFont(), toAspect.getFont()); }
private void printText(Graphics graph, String sText, cReportAspect aspect, Image image) { // TODO: Use of ByRef founded Private Sub PrintText(ByVal hDC As Long, ByVal sText As String, ByRef Aspect As cReportAspect, ByVal hImage As Long) /* // Para separarlo del borde Const(c_Margen_Y As Integer == 20); Const(c_Margen_X As Integer == 80); Const(c_Margen_Bottom As Integer == 80); StdFont oFont = null; oFont = new StdFont(); RECT tR = null; int oldBkColor = 0; int oldBkMode = 0; int oldFontColor = 0; int flags = 0; cReportFont w_font = aspect.getFont(); oFont.Name = w_font.getName(); oFont.Bold = w_font.getBold(); oFont.Italic = w_font.getItalic(); oFont.UnderLine = w_font.getUnderLine(); oFont.Size = (w_font.getSize() > 0) ? w_font.getSize() : 3); // {end with: w_font} int stringWidth = 0; int stringHeight = 0; int nWidth = 0; int hFntOld = 0; hFntOld = SelectObject(hDC, m_hFnt[mAux.addFontIfRequired(oFont, hDC, m_fontCount, m_fnt, m_hFnt)]); // With aspect; oldFontColor = SetTextColor(hDC, mAux.translateColor(aspect.getFont().getForeColor())); oldBkColor = SetBkColor(hDC, mAux.translateColor(aspect.getBackColor())); oldBkMode = SetBkMode(hDC, aspect.getTransparent() ? C_TRANSPARENT : C_OPAQUE)); if (aspect.getWordWrap()) { flags = ECGTextAlignFlags.DT_WORDBREAK || ECGTextAlignFlags.DT_WORD_ELLIPSIS || ECGTextAlignFlags.DT_LEFT || ECGTextAlignFlags.DT_NOPREFIX || ECGTextAlignFlags.DT_EDITCONTROL; } else { flags = ECGTextAlignFlags.DT_SINGLELINE || ECGTextAlignFlags.DT_WORD_ELLIPSIS || ECGTextAlignFlags.DT_LEFT || ECGTextAlignFlags.DT_NOPREFIX; } // {end with: aspect} stringWidth = getPlEvaluateTextWidth(sText, hDC, m_scaleX); stringHeight = getPlEvaluateTextHeight(sText, hDC, aspect.getWidth(), flags, m_scaleY, m_scaleX); // Esto es por seguridad, ya que // cuando imprimo en la impresora (en pantalla esto no pasa) // por pequeñas diferencias en la // proceso de escalar hasta la resolucion // de la impresora en algunos casos // pierdo parte del texto si el // rectangulo que pido es demasiado pequeño // stringHeight = stringHeight + 400; int margenX = 0; int margenY = 0; int width = 0; int height = 0; margenX = c_Margen_X; margenY = c_Margen_Y; if (hImage != 0) { mAux.getBitmapSize(hImage, width, height); margenX = margenX + width; margenY = height - stringHeight - c_Margen_Bottom; // With aspect; if (margenY + stringHeight > aspect.getHeight()) { margenY = aspect.getHeight() - stringHeight - c_Margen_Bottom; } // {end with: aspect} if (margenY < c_Margen_Y) { margenY = c_Margen_Y; } } nWidth = aspect.getWidth() - margenX * 2; if (stringWidth > nWidth) { stringWidth = nWidth; } int x = 0; int y = 0; switch (aspect.setAlign()) { case AlignmentConstants.vbRightJustify: x = aspect.getLeft() + aspect.getWidth() - stringWidth - margenX; break; case AlignmentConstants.vbCenter: x = aspect.getLeft() + (aspect.getWidth() - stringWidth) * 0.5; break; case AlignmentConstants.vbLeftJustify: x = aspect.getLeft() + margenX; break; } y = aspect.getTop() - aspect.setOffset() + margenY; // With aspect; //'.Height) tR = cGlobals.newRectangle(x, y, x + aspect.getWidth() - margenX, y + stringHeight); mAux.rectTwipsToPixel(tR, m_scaleX, m_scaleY); // If .WordWrap Then // Flags = DT_WORDBREAK Or DT_WORD_ELLIPSIS Or DT_LEFT Or DT_NOPREFIX Or DT_EDITCONTROL // Else // Flags = DT_SINGLELINE Or DT_WORD_ELLIPSIS Or DT_LEFT Or DT_NOPREFIX // End If DrawText(hDC, sText+ vbNullChar, -1, tR, flags); // {end with: aspect} SetBkColor(hDC, oldBkColor); SetTextColor(hDC, oldFontColor); SetBkMode(hDC, oldBkMode); SelectObject(hDC, hFntOld); */ // padding const int c_Margen_Y = 1; // 20 twips; const int c_Margen_X = 4; // 80 twips; const int c_Margen_Bottom = 4; // 80 twips; int idx = cGlobals.addFontIfRequired(aspect.getFont(), ref m_fnt); Font font = m_fnt[idx]; StringFormat format = new StringFormat(); format.Trimming = StringTrimming.EllipsisWord; format.Alignment = StringAlignment.Near; if (!aspect.getWordWrap()) { format.FormatFlags = StringFormatFlags.NoWrap; } int stringWidth = getPlEvaluateTextWidth(sText, font, m_scaleX); int stringHeight = getPlEvaluateTextHeight(sText, font, aspect.getWidth(), format, m_scaleY, m_scaleX); // TODO: translate this to English if it is really needed // // Esto es por seguridad, ya que // cuando imprimo en la impresora (en pantalla esto no pasa) // por pequeñas diferencias en la // proceso de escalar hasta la resolucion // de la impresora en algunos casos // pierdo parte del texto si el // rectangulo que pido es demasiado pequeño // stringHeight += 25; //+ 400 the original code was in twips; int margenX = c_Margen_X; int margenY = c_Margen_Y; if (image != null) { margenX += image.Size.Width; margenY = image.Size.Height - stringHeight - c_Margen_Bottom; if (margenY + stringHeight > aspect.getHeight()) { margenY = Convert.ToInt32(aspect.getHeight() - stringHeight - c_Margen_Bottom); } if (margenY < c_Margen_Y) { margenY = c_Margen_Y; } } int nWidth = Convert.ToInt32(aspect.getWidth() - margenX * 2); if (stringWidth > nWidth) { stringWidth = nWidth; } int x = 0; int y = 0; switch (aspect.getAlign()) { case HorizontalAlignment.Right: x = Convert.ToInt32(aspect.getLeft() + aspect.getWidth() - stringWidth - margenX); break; case HorizontalAlignment.Center: x = Convert.ToInt32(aspect.getLeft() + (aspect.getWidth() - stringWidth) * 0.5); break; case HorizontalAlignment.Left: x = Convert.ToInt32(aspect.getLeft() + margenX); break; } y = Convert.ToInt32(aspect.getTop() - aspect.getOffset() + margenY); RectangleF rect = cGlobals.newRectangleF(x, y, Convert.ToInt32(x + aspect.getWidth() - margenX), y + stringHeight); SolidBrush brush = new SolidBrush(cColor.colorFromRGB(aspect.getFont().getForeColor())); graph.DrawString(sText, font, brush, rect, format); brush.Dispose(); }