public void SetVarValueText( int index, string titleTxt, float maxValue, string fontTxt, string backTxt, Font font, Color color, RectangleF?incRect, float lineHeight, DrawPositionType drawPosType, bool isLimitBox) { ScTxtInfo txtInfo; if (rowTextInfoList[index] != null) { txtInfo = rowTextInfoList[index]; } else { txtInfo = new ScTxtInfo(this); } txtInfo.maxVarValue = maxValue; txtInfo.fontTxt = fontTxt; txtInfo.backTxt = backTxt; txtInfo.txtColor = color; txtInfo.txtFont = font; txtInfo.lineHeight = lineHeight; txtInfo.incRect = incRect; txtInfo.drawPosType = drawPosType; txtInfo.isLimitBox = isLimitBox; txtInfo.titleTxt = titleTxt; txtInfo.isMultipleRow = false; rowTextInfoList[index] = txtInfo; }
static public void LimitBoxDraw(Graphics g, string val, Font font, System.Drawing.RectangleF rect, bool isCenterPos, int direction) { DrawPositionType drawPosType = DrawPositionType.LeftTop; if (isCenterPos) { drawPosType = DrawPositionType.Center; } LimitBoxDraw(g, val, font, null, rect, drawPosType, true, false, direction); }
static public void LimitBoxDraw( Graphics g, string val, Font font, Brush brush, RectangleF rect, DrawPositionType drawPosType = DrawPositionType.Center, bool isLimitDraw = true, bool isMultipleRow = false, int direction = 0, float rotateAngle = 0) { LimitBoxDrawInfo drawInfo = new LimitBoxDrawInfo(); drawInfo.g = g; drawInfo.txt = val; drawInfo.font = font; drawInfo.brush = brush; drawInfo.rect = rect; drawInfo.drawPosType = drawPosType; drawInfo.isLimitDraw = isLimitDraw; drawInfo.isMultipleRow = isMultipleRow; drawInfo.direction = direction; drawInfo.rotateAngle = rotateAngle; LimitBoxDraw(drawInfo); }
static public void LimitBoxDraw( Graphics g, string val, Font font, System.Drawing.Brush brush, System.Drawing.RectangleF rect, bool isCenterPosX, bool isCenterPosY, int direction) { DrawPositionType drawPosType = DrawPositionType.LeftTop; if (isCenterPosX && isCenterPosY) { drawPosType = DrawPositionType.Center; } else if (isCenterPosX && !isCenterPosY) { drawPosType = DrawPositionType.Top; } else if (!isCenterPosX && isCenterPosY) { drawPosType = DrawPositionType.Left; } LimitBoxDraw(g, val, font, brush, rect, drawPosType, true, false, direction); }
static public void LimitBoxDraw( Graphics g, string val, Font font, System.Drawing.Brush brush, System.Drawing.RectangleF rect, DrawPositionType drawPosType, bool isLimitDraw, bool isMultipleRow, int direction) { PointF pt = new PointF(rect.X, rect.Y); float scalex = 1.0F; float scaley = 1.0F; float stringWidth; float stringHeight; StringFormat strF; SizeF fontSize; System.Drawing.RectangleF layoutRect = rect; if (direction == 0) { strF = new StringFormat(); if (!isMultipleRow) { fontSize = g.MeasureString(val, font); } else { fontSize = g.MeasureString(val, font, (int)rect.Width); layoutRect.Width = rect.Width; layoutRect.Height = fontSize.Height; } } else { strF = new StringFormat(StringFormatFlags.DirectionVertical); if (!isMultipleRow) { fontSize = g.MeasureString(val, font, 0, strF); } else { fontSize = g.MeasureString(val, font, (int)rect.Height); layoutRect.Width = rect.Width; layoutRect.Height = fontSize.Height; } } stringWidth = fontSize.Width; stringHeight = fontSize.Height; if (isLimitDraw) { if (fontSize.Width > rect.Width) { scalex = rect.Width / fontSize.Width; stringWidth = rect.Width; } if (fontSize.Height > rect.Height) { scaley = rect.Height / fontSize.Height; stringHeight = rect.Height; } } switch (drawPosType) { case DrawPositionType.LeftTop: pt.X = rect.X; pt.Y = rect.Y; break; case DrawPositionType.Top: pt.X = rect.X + rect.Width / 2 - stringWidth / 2; pt.Y = rect.Y; break; case DrawPositionType.RightTop: pt.X = rect.Right - stringWidth; pt.Y = rect.Y; break; case DrawPositionType.Left: pt.X = rect.X; pt.Y = rect.Y + rect.Height / 2 - stringHeight / 2; break; case DrawPositionType.Center: pt.X = rect.X + rect.Width / 2 - stringWidth / 2; pt.Y = rect.Y + rect.Height / 2 - stringHeight / 2; break; case DrawPositionType.Right: pt.X = rect.Right - stringWidth; pt.Y = rect.Y + rect.Height / 2 - stringHeight / 2; break; case DrawPositionType.LeftBottom: pt.X = rect.X; pt.Y = rect.Bottom - stringHeight; break; case DrawPositionType.Bottom: pt.X = rect.X + rect.Width / 2 - stringWidth / 2; pt.Y = rect.Bottom - stringHeight; break; case DrawPositionType.RightBottom: pt.X = rect.Right - stringWidth; pt.Y = rect.Bottom - stringHeight; break; } pt.X /= scalex; pt.Y /= scaley; System.Drawing.Drawing2D.Matrix matrix, oldMatrix; if (brush == null) { brush = new SolidBrush(System.Drawing.Color.Black); } if (scalex == 0) { scalex = 0.1F; } if (scaley == 0) { scaley = 0.1F; } oldMatrix = g.Transform; matrix = oldMatrix.Clone(); matrix.Scale(scalex, scaley); g.Transform = matrix; if (!isMultipleRow) { g.DrawString(val, font, brush, pt, strF); } else { layoutRect.X = pt.X; layoutRect.Y = pt.Y; g.DrawString(val, font, brush, layoutRect, strF); } g.Transform = oldMatrix; }
public void SetText(int index, string titleTxt, string txt, Font font, Color color, RectangleF?incRect, float lineHeight, DrawPositionType drawPosType, bool isLimitBox, bool isMultipleRow) { ScTxtInfo txtInfo; if (rowTextInfoList[index] != null) { txtInfo = rowTextInfoList[index]; } else { txtInfo = new ScTxtInfo(); } txtInfo.txt = txt; txtInfo.txtColor = color; txtInfo.txtFont = font; txtInfo.lineHeight = lineHeight; txtInfo.incRect = incRect; txtInfo.drawPosType = drawPosType; txtInfo.isLimitBox = isLimitBox; txtInfo.titleTxt = titleTxt; txtInfo.isMultipleRow = isMultipleRow; rowTextInfoList[index] = txtInfo; }
public void SetText(int index, string titleTxt, string txt, Font font, Color color, float lineHeight, DrawPositionType drawPosType, bool isLimitBox, bool isMultipleRow) { SetText(index, titleTxt, txt, font, color, null, lineHeight, drawPosType, isLimitBox, isMultipleRow); }