Пример #1
0
        public override void FormatToDrawItem(HCCustomData aRichData, int aItemNo)
        {
            HCStyle vStyle = aRichData.Style;

            vStyle.ApplyTempStyle(TextStyleNo);
            int vH       = vStyle.TextStyles[TextStyleNo].FontHeight;
            int vTopW    = Math.Max(vStyle.TempCanvas.TextWidth(FTopText), FPadding);
            int vBottomW = Math.Max(vStyle.TempCanvas.TextWidth(FBottomText), FPadding);

            // 计算尺寸
            if (vTopW > vBottomW)
            {
                Width = vTopW + 4 * FPadding;
            }
            else
            {
                Width = vBottomW + 4 * FPadding;
            }

            Height = vH * 2 + 4 * FPadding;

            // 计算各字符串位置

            FTopRect = HC.Bounds(FPadding + (Width - FPadding - FPadding - vTopW) / 2,
                                 FPadding, vTopW, vH);
            FBottomRect = HC.Bounds(FPadding + (Width - FPadding - FPadding - vBottomW) / 2,
                                    Height - FPadding - vH, vBottomW, vH);
        }
Пример #2
0
        public override void FormatToDrawItem(HCCustomData aRichData, int aItemNo)
        {
            HCStyle vStyle = aRichData.Style;

            vStyle.ApplyTempStyle(TextStyleNo);
            int vH       = vStyle.TempCanvas.TextHeight("H");
            int vLeftW   = Math.Max(vStyle.TempCanvas.TextWidth(FLeftText), Padding);
            int vTopW    = Math.Max(vStyle.TempCanvas.TextWidth(TopText), Padding);
            int vRightW  = Math.Max(vStyle.TempCanvas.TextWidth(FRightText), Padding);
            int vBottomW = Math.Max(vStyle.TempCanvas.TextWidth(BottomText), Padding);

            // 计算尺寸
            if (vTopW > vBottomW)
            {
                Width = vLeftW + vTopW + vRightW + 6 * Padding;
            }
            else
            {
                Width = vLeftW + vBottomW + vRightW + 6 * Padding;
            }

            Height = vH * 2 + 4 * Padding;

            // 计算各字符串位置
            FLeftRect  = HC.Bounds(Padding, (Height - vH) / 2, vLeftW, vH);
            FRightRect = HC.Bounds(Width - Padding - vRightW, (Height - vH) / 2, vRightW, vH);
            TopRect    = HC.Bounds(FLeftRect.Right + Padding + (FRightRect.Left - Padding - (FLeftRect.Right + Padding) - vTopW) / 2,
                                   Padding, vTopW, vH);
            BottomRect = HC.Bounds(FLeftRect.Right + Padding + (FRightRect.Left - Padding - (FLeftRect.Right + Padding) - vBottomW) / 2,
                                   Height - Padding - vH, vBottomW, vH);
        }