getOffset() public method

public getOffset ( ) : float
return float
        public bool drawRule(String key, Graphics graph)
        {
            const int LINE_COLOR = 0xcc6600;
            int top = 0;
            float heightSec = 0;
            cReportAspect aspect = null;

            aspect = new cReportAspect();

            cReportPaintObject w_item = m_paintSections.item(key);
            heightSec = w_item.getHeightSecLine() * 0.5f;
            cReportAspect w_aspect = w_item.getAspect();
            aspect.setTop(w_aspect.getTop() + 3 - heightSec);
            aspect.setOffset(w_aspect.getOffset());
            aspect.setTransparent(true);
            aspect.setLeft(0);
            aspect.setHeight(20);
            aspect.setAlign(HorizontalAlignment.Right);
            aspect.setWidth(graph.ClipBounds.Width - 1);

            if (w_item.getTextLine() != "")
            {
                top = - Convert.ToInt32(w_item.getHeightSec());
                w_aspect = w_item.getAspect();
                top += Convert.ToInt32(w_aspect.getTop() - w_aspect.getOffset() - 6 + w_aspect.getHeight() * 2);

                printLine(graph, 
                            true, 
                            0, 
                            top, 
                            aspect.getWidth(), 
                            top,
                            LINE_COLOR, 
                            1, 
                            true,
                            LINE_COLOR, 
                            false);

                // last section line
                //
                printText(graph, w_item.getTextLine(), aspect, w_item.getImage());

                heightSec = w_item.getHeightSec() * 0.5f;

                // print section's name
                //
                w_aspect = m_paintSections.item(key).getAspect();
                aspect.setTop(w_aspect.getTop() - heightSec);
                aspect.setAlign(HorizontalAlignment.Left);

                printText(graph, w_item.getText(), aspect, w_item.getImage());

            }
            else
            {
                top = Convert.ToInt32(aspect.getTop() - aspect.getOffset() - heightSec + w_item.getAspect().getHeight());

                if (w_item.getIsSection())
                {
                    printLine(graph, 
                                true,
                                0, 
                                top, 
                                aspect.getWidth(), 
                                top,
                                LINE_COLOR, 
                                1, 
                                true,
                                LINE_COLOR, 
                                false);
                }

                // every section line except the last one
                //
                printText(graph, w_item.getText(), aspect, w_item.getImage());
            }
            
            if (w_item == m_paintSections.item(m_paintSections.count() - 1)) 
            {
                top = Convert.ToInt32(aspect.getTop() + w_item.getHeightSecLine() - heightSec - aspect.getOffset() + 6);

                if (w_item.getIsSection())
                {
                    printLine(graph,
                                true,
                                0,
                                top,
                                aspect.getWidth(),
                                top,
                                LINE_COLOR,
                                1,
                                true,
                                LINE_COLOR,
                                false);
                }
            }

            return true;
        }
示例#2
0
        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 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();
        }