/// <summary> /// 重绘边线方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public virtual void onPaintBorder(FCPaint paint, FCRect clipRect) { long borderColor = getPaintingBorderColor(); paint.drawLine(borderColor, 1, 0, m_bounds.left, m_bounds.bottom - 1, m_bounds.right - 1, m_bounds.bottom - 1); paint.drawLine(borderColor, 1, 0, m_bounds.right - 1, m_bounds.top, m_bounds.right - 1, m_bounds.bottom - 1); }
/// <summary> /// 绘制前景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintForeground(FCPaint paint, FCRect clipRect) { FCRect bounds = Bounds; int width = bounds.right - bounds.left; int height = bounds.bottom - bounds.top; if (width > 0 && height > 0) { if (m_ssLatestData != null && m_szLatestData != null && m_cyLatestData != null) { long titleColor = FCColor.argb(255, 255, 80); FCFont font = new FCFont("SimSun", 16, false, false, false); FCFont indexFont = new FCFont("Arial", 14, true, false, false); long grayColor = FCColor.Border; //上证指数 long indexColor = FCDraw.getPriceColor(m_ssLatestData.m_close, m_ssLatestData.m_lastClose); int left = 1; FCDraw.drawText(paint, "上证", titleColor, font, left, 3); left += 40; paint.drawLine(grayColor, 1, 0, left, 0, left, height); String amount = (m_ssLatestData.m_amount / 100000000).ToString("0.0") + "亿"; FCSize amountSize = paint.textSize(amount, indexFont); FCDraw.drawText(paint, amount, titleColor, indexFont, width / 3 - amountSize.cx, 3); left += (width / 3 - 40 - amountSize.cx) / 4; int length = FCDraw.drawUnderLineNum(paint, m_ssLatestData.m_close, 2, indexFont, indexColor, false, left, 3); left += length + (width / 3 - 40 - amountSize.cx) / 4; length = FCDraw.drawUnderLineNum(paint, m_ssLatestData.m_close - m_ssLatestData.m_lastClose, 2, indexFont, indexColor, false, left, 3); //深证指数 left = width / 3; paint.drawLine(grayColor, 1, 0, left, 0, left, height); indexColor = FCDraw.getPriceColor(m_szLatestData.m_close, m_szLatestData.m_lastClose); FCDraw.drawText(paint, "深证", titleColor, font, left, 3); left += 40; paint.drawLine(grayColor, 1, 0, left, 0, left, height); amount = (m_szLatestData.m_amount / 100000000).ToString("0.0") + "亿"; amountSize = paint.textSize(amount, indexFont); FCDraw.drawText(paint, amount, titleColor, indexFont, width * 2 / 3 - amountSize.cx, 3); left += (width / 3 - 40 - amountSize.cx) / 4; length = FCDraw.drawUnderLineNum(paint, m_szLatestData.m_close, 2, indexFont, indexColor, false, left, 3); left += length + (width / 3 - 40 - amountSize.cx) / 4; length = FCDraw.drawUnderLineNum(paint, m_szLatestData.m_close - m_szLatestData.m_lastClose, 2, indexFont, indexColor, false, left, 3); //创业指数 left = width * 2 / 3; paint.drawLine(grayColor, 1, 0, left, 0, left, height); indexColor = FCDraw.getPriceColor(m_cyLatestData.m_close, m_cyLatestData.m_lastClose); FCDraw.drawText(paint, "创业", titleColor, font, left, 3); left += 40; paint.drawLine(grayColor, 1, 0, left, 0, left, height); amount = (m_cyLatestData.m_amount / 100000000).ToString("0.0") + "亿"; amountSize = paint.textSize(amount, indexFont); FCDraw.drawText(paint, amount, titleColor, indexFont, width - amountSize.cx, 3); left += (width / 3 - 40 - amountSize.cx) / 4; length = FCDraw.drawUnderLineNum(paint, m_cyLatestData.m_close, 2, indexFont, indexColor, false, left, 3); left += (width / 3 - 40 - amountSize.cx) / 4 + length; length = FCDraw.drawUnderLineNum(paint, m_cyLatestData.m_close - m_cyLatestData.m_lastClose, 2, indexFont, indexColor, false, left, 3); paint.drawRect(grayColor, 1, 0, new FCRect(0, 0, width - 1, height - 1)); } } }
/// <summary> /// 绘制有下划线的数字 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="value">值</param> /// <param name="digit">保留小数位数</param> /// <param name="font">字体</param> /// <param name="fontColor">文字颜色</param> /// <param name="zeroAsEmpty">0是否为空</param> /// <param name="x">横坐标</param> /// <param name="y">纵坐标</param> /// <returns>绘制的横坐标</returns> public static int drawUnderLineNum(FCPaint paint, double value, int digit, FCFont font, long fontColor, bool zeroAsEmpty, int x, int y) { if (zeroAsEmpty && value == 0) { String text = "-"; FCSize size = paint.textSize(text, font); FCDraw.drawText(paint, text, fontColor, font, x, y); return(size.cx); } else { String[] nbs = FCStr.getValueByDigit(value, digit).Split(new String[] { "." }, StringSplitOptions.RemoveEmptyEntries); if (nbs.Length == 1) { FCSize size = paint.textSize(nbs[0], font); FCDraw.drawText(paint, nbs[0], fontColor, font, x, y); return(size.cx); } else { FCSize decimalSize = paint.textSize(nbs[0], font); FCSize size = paint.textSize(nbs[1], font); FCDraw.drawText(paint, nbs[0], fontColor, font, x, y); FCDraw.drawText(paint, nbs[1], fontColor, font, x + decimalSize.cx + 1, y); paint.drawLine(fontColor, 1, 0, x + decimalSize.cx + 1, y + decimalSize.cy, x + decimalSize.cx + size.cx, y + decimalSize.cy); return(decimalSize.cx + size.cx); } } }
/// <summary> /// 重绘背景 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintBackground(FCPaint paint, FCRect clipRect) { FCNative native = Native; int width = Width, height = Height; int mw = width / 2, mh = height / 2; FCRect drawRect = new FCRect(0, 0, width, height); int cornerRadius = 0; if (m_isClose) { long lineColor = FCDraw.FCCOLORS_LINECOLOR; FCRect ellipseRect = new FCRect(1, 1, width - 2, height - 2); //paint->FillEllipse(FCCOLORS_BACKCOLOR7, ellipseRect); paint.drawLine(lineColor, 2, 0, 4, 4, width - 7, height - 7); paint.drawLine(lineColor, 2, 0, 4, height - 7, width - 7, 3); } else { cornerRadius = 0; if (m_arrowType > 0) { cornerRadius = 0; } FCView parent = Parent; if (parent != null) { FCTabControl tabControl = parent as FCTabControl; if (tabControl != null) { cornerRadius = 0; } } paint.fillGradientRect(FCDraw.FCCOLORS_BACKCOLOR, FCDraw.FCCOLORS_BACKCOLOR2, drawRect, cornerRadius, 90); paint.drawRect(FCDraw.FCCOLORS_EXCOLOR1, 1, 0, drawRect); cornerRadius = 0; if (m_arrowType > 0) { FCPoint point1 = new FCPoint(); FCPoint point2 = new FCPoint(); FCPoint point3 = new FCPoint(); int dSize = Math.Min(mw, mh) / 2; switch (m_arrowType) { case 1: point1.x = mw - dSize; point1.y = mh; point2.x = mw + dSize; point2.y = mh - dSize; point3.x = mw + dSize; point3.y = mh + dSize; break; case 2: point1.x = mw + dSize; point1.y = mh; point2.x = mw - dSize; point2.y = mh - dSize; point3.x = mw - dSize; point3.y = mh + dSize; break; case 3: point1.x = mw; point1.y = mh - dSize; point2.x = mw - dSize; point2.y = mh + dSize; point3.x = mw + dSize; point3.y = mh + dSize; break; case 4: point1.x = mw; point1.y = mh + dSize; point2.x = mw - dSize; point2.y = mh - dSize; point3.x = mw + dSize; point3.y = mh - dSize; break; } FCPoint[] points = new FCPoint[3]; points[0] = point1; points[1] = point2; points[2] = point3; paint.fillPolygon(FCDraw.FCCOLORS_FORECOLOR, points); } } bool state = false; if (Selected) { state = true; paint.fillRoundRect(FCDraw.FCCOLORS_BACKCOLOR8, drawRect, cornerRadius); } else if (this == native.PushedControl) { state = true; paint.fillRoundRect(FCDraw.FCCOLORS_BACKCOLOR6, drawRect, cornerRadius); } else if (this == native.HoveredControl) { state = true; paint.fillRoundRect(FCDraw.FCCOLORS_BACKCOLOR5, drawRect, cornerRadius); } if (state) { if (cornerRadius > 0) { paint.drawRoundRect(FCColor.Border, 2, 0, drawRect, cornerRadius); } else { paint.drawRect(FCColor.Border, 1, 0, drawRect); } } }
/// <summary> /// 重绘前景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintBackground(FCPaint paint, FCRect clipRect) { int width = Width; int height = Height; FCRect rect = new FCRect(0, 0, width, height); long backColor = FCDraw.FCCOLORS_WINDOWBACKCOLOR; long textColor = FCDraw.FCCOLORS_WINDOWTEXTCOLOR; if (paint.supportTransparent()) { backColor = FCDraw.FCCOLORS_WINDOWBACKCOLOR2; } long borderColor = FCDraw.FCCOLORS_BACKCOLOR8; FCPoint[] points1 = new FCPoint[6]; int dw1 = 30; int dw2 = 50; int dSize = 10; int dSize2 = 20; points1[0] = new FCPoint(dSize, dw1 + dSize); points1[1] = new FCPoint(dSize + dw1, dSize); points1[2] = new FCPoint(width - dSize, dSize); points1[3] = new FCPoint(width - dSize, height - dw2 - dSize2); points1[4] = new FCPoint(width - dSize - dw2, height - dSize2); points1[5] = new FCPoint(dSize, height - dSize2); if (FCDraw.m_style == 0) { paint.fillGradientPolygon(FCDraw.FCCOLORS_BACKCOLOR, FCDraw.FCCOLORS_BACKCOLOR2, points1, 45); } paint.fillPolygon(backColor, points1); paint.drawPolygon(borderColor, 3, 0, points1); paint.drawLine(borderColor, 2, 0, width - dSize - 30, 1, width - 1, 1); paint.drawLine(borderColor, 2, 0, width - 1, 1, width - 1, dSize * 2); paint.drawLine(borderColor, 2, 0, width - dSize - 20, dSize + 5, width - dSize - 5, dSize + 5); paint.drawLine(borderColor, 2, 0, width - dSize - 5, dSize + 5, width - dSize - 5, dSize + 20); FCPoint[] points2 = new FCPoint[4]; points2[0] = new FCPoint(dSize + 10, dSize + dw1 + 30); points2[1] = new FCPoint(dSize + 10, dSize + dw1 + 2); points2[2] = new FCPoint(dSize + dw1 + 2, dSize + 10); points2[3] = new FCPoint(dSize + dw1 + 30, dSize + 10); paint.drawPolyline(borderColor, 2, 0, points2); paint.drawLine(borderColor, 2, 0, dSize + dw1 + 31, dSize + 10, dSize + dw1 + 50, dSize + 10); paint.drawLine(borderColor, 2, 0, dSize + dw1 + 10, dSize + 18, dSize + dw1 + 40, dSize + 18); paint.drawLine(borderColor, 2, 0, dSize + 10, height - dSize * 2 - 8, dSize + 60, height - dSize * 2 - 8); FCPoint[] points3 = new FCPoint[4]; points3[0] = new FCPoint(dSize + 14, height - dSize2 - 8); points3[1] = new FCPoint(dSize + 18, height - dSize2 - 12); points3[2] = new FCPoint(dSize + 30, height - dSize2 - 12); points3[3] = new FCPoint(dSize + 34, height - dSize2 - 8); paint.fillPolygon(borderColor, points3); FCPoint[] points4 = new FCPoint[6]; points4[0] = new FCPoint(dSize, height - dSize2 - 20); points4[1] = new FCPoint(dSize - 8, height - dSize2 - 10); points4[2] = new FCPoint(dSize - 8, height - 4 - dSize); points4[3] = new FCPoint(dSize + 16, height - 4 - dSize); points4[4] = new FCPoint(dSize + 20, height - dSize2); points4[5] = new FCPoint(dSize, height - dSize2); paint.fillPolygon(borderColor, points4); FCPoint[] points5 = new FCPoint[4]; points5[0] = new FCPoint(width - dSize, height - dSize2 - dw2 - 20); points5[1] = new FCPoint(width - dSize - 4, height - dSize2 - dw2 - 16); points5[2] = new FCPoint(width - dSize - 4, height - dSize2 - dw2); points5[3] = new FCPoint(width - dSize, height - dSize2 - dw2); paint.fillPolygon(borderColor, points5); FCPoint[] points6 = new FCPoint[4]; points6[0] = new FCPoint(width - dSize, height - dSize2 - dw2); points6[1] = new FCPoint(width - dSize - 4, height - dSize2 - dw2 - 2); points6[2] = new FCPoint(width - dSize - 22, height - dSize2 - dw2 + 16); points6[3] = new FCPoint(width - dSize - 20, height - dSize2 - dw2 + 22); paint.fillPolygon(borderColor, points6); FCPoint[] points7 = new FCPoint[3]; points7[0] = new FCPoint(width - 1, height - dSize2 - dw2 - 30); points7[1] = new FCPoint(width - 1, height - dSize2 - dw2 + 3); points7[2] = new FCPoint(width - 1 - dw2 + 20, height - dSize2 - 16); paint.drawPolyline(borderColor, 2, 0, points7); FCPoint[] points8 = new FCPoint[3]; points8[0] = new FCPoint(width - 1 - dw2 + 19, height - dSize2 - 15); points8[1] = new FCPoint(width - dSize - dw2 + 1, height - dSize + 3); points8[2] = new FCPoint(width - dSize - dw2 - 25, height - dSize + 3); paint.drawPolyline(borderColor, 2, 0, points8); FCPoint[] points9 = new FCPoint[6]; points9[0] = new FCPoint(width - dSize - dw2 + 1, height - dSize + 3); points9[1] = new FCPoint(width - dSize - dw2 - 14, height - dSize + 3); points9[2] = new FCPoint(width - dSize - dw2 - 10, height - dSize + 8); points9[3] = new FCPoint(width - dSize - dw2 + 3, height - dSize + 8); points9[4] = new FCPoint(width - dSize - dw2 + 16, height - dSize - 6); points9[5] = new FCPoint(width - dSize - dw2 + 16, height - dSize - 14); paint.fillPolygon(borderColor, points9); int rwidth = width * 3 / 5; if (rwidth > width - dSize * 2 - dw2) { rwidth = width - dSize2 * 2 - dw2; } FCPoint[] points10 = new FCPoint[4]; points10[0] = new FCPoint(rwidth - 8, height - dSize2 - 6); points10[1] = new FCPoint(rwidth - 12, height - dSize2); points10[2] = new FCPoint(rwidth + 12, height - dSize2); points10[3] = new FCPoint(rwidth + 8, height - dSize2 - 6); paint.fillPolygon(borderColor, points10); rwidth = width * 7 / 10; if (rwidth > width - 30) { rwidth = width - 30; } FCPoint[] points11 = new FCPoint[4]; points11[0] = new FCPoint(rwidth - 16, dSize - 6); points11[1] = new FCPoint(rwidth - 20, dSize); points11[2] = new FCPoint(rwidth + 20, dSize); points11[3] = new FCPoint(rwidth + 16, dSize - 6); paint.fillPolygon(borderColor, points11); FCDraw.drawText(paint, Text, textColor, Font, 100, 15); }
/// <summary> /// 重绘背景 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintBackground(FCPaint paint, FCRect clipRect) { int width = Width, height = Height; int mw = width / 2, mh = height / 2; FCRect drawRect = new FCRect(0, 0, width, height); if (m_isClose) { long lineColor = FCDraw.FCCOLORS_LINECOLOR; FCRect ellipseRect = new FCRect(1, 1, width - 2, height - 2); paint.fillEllipse(FCDraw.FCCOLORS_UPCOLOR, ellipseRect); paint.drawLine(lineColor, 2, 0, 4, 4, width - 7, height - 7); paint.drawLine(lineColor, 2, 0, 4, height - 7, width - 7, 3); } else { int cornerRadius = 4; if (m_arrowType > 0) { cornerRadius = 0; } FCView parent = Parent; if (parent != null) { FCTabControl tabControl = parent as FCTabControl; if (tabControl != null) { cornerRadius = 0; } } paint.fillGradientRect(FCDraw.FCCOLORS_BACKCOLOR, FCDraw.FCCOLORS_BACKCOLOR2, drawRect, cornerRadius, 90); paint.drawRoundRect(FCDraw.FCCOLORS_LINECOLOR3, 1, 0, drawRect, cornerRadius); } if (m_arrowType > 0) { FCPoint[] points = new FCPoint[3]; int ts = Math.Min(mw, mh) / 2; switch (m_arrowType) { //向左 case 1: points[0] = new FCPoint(mw - ts, mh); points[1] = new FCPoint(mw + ts, mh - ts); points[2] = new FCPoint(mw + ts, mh + ts); break; //向右 case 2: points[0] = new FCPoint(mw + ts, mh); points[1] = new FCPoint(mw - ts, mh - ts); points[2] = new FCPoint(mw - ts, mh + ts); break; //向上 case 3: points[0] = new FCPoint(mw, mh - ts); points[1] = new FCPoint(mw - ts, mh + ts); points[2] = new FCPoint(mw + ts, mh + ts); break; //向下 case 4: points[0] = new FCPoint(mw, mh + ts); points[1] = new FCPoint(mw - ts, mh - ts); points[2] = new FCPoint(mw + ts, mh - ts); break; } paint.fillPolygon(FCDraw.FCCOLORS_FORECOLOR, points); } //绘制选中效果 if (paint.supportTransparent()) { FCNative native = Native; if (Selected) { paint.fillRect(FCDraw.FCCOLORS_BACKCOLOR2, drawRect); } else if (this == native.PushedControl) { paint.fillRect(FCDraw.FCCOLORS_BACKCOLOR6, drawRect); } else if (this == native.HoveredControl) { paint.fillRect(FCDraw.FCCOLORS_BACKCOLOR5, drawRect); } } }
/// <summary> /// 重绘前景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintForeground(FCPaint paint, FCRect clipRect) { String text = Text; //绘制文字 if (text != null && text.Length > 0) { int width = Width, height = Height; if (width > 0 && height > 0) { FCFont font = Font; FCSize tSize = paint.textSize(text, font); long linkColor = getPaintingLinkColor(); FCPoint tPoint = new FCPoint((width - tSize.cx) / 2, (height - tSize.cy) / 2); FCPadding padding = Padding; switch (m_textAlign) { case FCContentAlignment.BottomCenter: tPoint.y = height - tSize.cy; break; case FCContentAlignment.BottomLeft: tPoint.x = padding.left; tPoint.y = height - tSize.cy - padding.bottom; break; case FCContentAlignment.BottomRight: tPoint.x = width - tSize.cx - padding.right; tPoint.y = height - tSize.cy - padding.bottom; break; case FCContentAlignment.MiddleLeft: tPoint.x = padding.left; break; case FCContentAlignment.MiddleRight: tPoint.x = width - tSize.cx - padding.right; break; case FCContentAlignment.TopCenter: tPoint.y = padding.top; break; case FCContentAlignment.TopLeft: tPoint.x = padding.left; tPoint.y = padding.top; break; case FCContentAlignment.TopRight: tPoint.x = width - tSize.cx - padding.right; tPoint.y = padding.top; break; } FCRect tRect = new FCRect(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy); if (AutoEllipsis && (tRect.right > clipRect.right || tRect.bottom > clipRect.bottom)) { if (tRect.right > clipRect.right) { tRect.right = clipRect.right; } if (tRect.bottom > clipRect.bottom) { tRect.bottom = clipRect.bottom; } paint.drawTextAutoEllipsis(text, linkColor, font, tRect); } else { paint.drawText(text, linkColor, font, tRect); } //画下划线 FCNative native = Native; if (m_linkBehavior == FCLinkBehavior.AlwaysUnderLine || (m_linkBehavior == FCLinkBehavior.HoverUnderLine && (this == native.PushedControl || this == native.HoveredControl))) { paint.drawLine(linkColor, 1, 0, tPoint.x, tPoint.y + tSize.cy, tPoint.x + tSize.cx, tPoint.y + tSize.cy); } } } }
/// <summary> /// 重绘前景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintBackground(FCPaint paint, FCRect clipRect) { int width = Width; int height = Height; FCRect rect = new FCRect(0, 0, width, height); long backColor = FCDraw.FCCOLORS_WINDOWBACKCOLOR; long foreColor = FCColor.argb(255, 255, 255); if (paint.supportTransparent()) { backColor = FCDraw.FCCOLORS_WINDOWBACKCOLOR2; } long borderColor = FCColor.argb(50, 105, 217); if (m_tick >= 200) { borderColor = FCColor.argb(255 - (m_tick - 200) * 2, 50, 105, 217); foreColor = FCColor.argb(255 - (m_tick - 200) * 2, 255, 255, 255); } int dw1 = 30; int dw2 = 50; int dSize = 10; int dSize2 = 20; if (m_tick >= 200) { dw1 += (m_tick - 200) / 6; dw2 += (m_tick - 200) / 6; dSize += (m_tick - 200) / 6; dSize2 += (m_tick - 200) / 6; } FCPoint[] points1 = new FCPoint[6]; points1[0] = new FCPoint(dSize, dw1 + dSize); points1[1] = new FCPoint(dSize + dw1, dSize); points1[2] = new FCPoint(width - dSize, dSize); points1[3] = new FCPoint(width - dSize, height - dw2 - dSize2); points1[4] = new FCPoint(width - dSize - dw2, height - dSize2); points1[5] = new FCPoint(dSize, height - dSize2); paint.fillGradientPolygon(FCColor.argb(255, 9, 30, 42), FCColor.argb(200, 9, 30, 42), points1, m_tick); //paint.fillPolygon(backColor, points1); paint.drawPolygon(borderColor, 3, 0, points1); paint.drawLine(borderColor, 2, 0, width - dSize - 30, 1, width - 1, 1); paint.drawLine(borderColor, 2, 0, width - 1, 1, width - 1, dSize * 2); paint.drawLine(borderColor, 2, 0, width - dSize - 20, dSize + 5, width - dSize - 5, dSize + 5); paint.drawLine(borderColor, 2, 0, width - dSize - 5, dSize + 5, width - dSize - 5, dSize + 20); FCPoint[] points2 = new FCPoint[4]; points2[0] = new FCPoint(dSize + 10, dSize + dw1 + 30); points2[1] = new FCPoint(dSize + 10, dSize + dw1 + 2); points2[2] = new FCPoint(dSize + dw1 + 2, dSize + 10); points2[3] = new FCPoint(dSize + dw1 + 30, dSize + 10); paint.drawPolyline(borderColor, 2, 0, points2); paint.drawLine(borderColor, 2, 0, dSize + dw1 + 31, dSize + 10, dSize + dw1 + 50, dSize + 10); paint.drawLine(borderColor, 2, 0, dSize + dw1 + 10, dSize + 18, dSize + dw1 + 40, dSize + 18); paint.drawLine(borderColor, 2, 0, dSize + 10, height - dSize * 2 - 8, dSize + 60, height - dSize * 2 - 8); FCPoint[] points3 = new FCPoint[4]; points3[0] = new FCPoint(dSize + 14, height - dSize2 - 8); points3[1] = new FCPoint(dSize + 18, height - dSize2 - 12); points3[2] = new FCPoint(dSize + 30, height - dSize2 - 12); points3[3] = new FCPoint(dSize + 34, height - dSize2 - 8); paint.fillPolygon(borderColor, points3); FCPoint[] points4 = new FCPoint[6]; points4[0] = new FCPoint(dSize, height - dSize2 - 20); points4[1] = new FCPoint(dSize - 8, height - dSize2 - 10); points4[2] = new FCPoint(dSize - 8, height - 4 - dSize); points4[3] = new FCPoint(dSize + 16, height - 4 - dSize); points4[4] = new FCPoint(dSize + 20, height - dSize2); points4[5] = new FCPoint(dSize, height - dSize2); paint.fillPolygon(borderColor, points4); FCPoint[] points5 = new FCPoint[4]; points5[0] = new FCPoint(width - dSize, height - dSize2 - dw2 - 20); points5[1] = new FCPoint(width - dSize - 4, height - dSize2 - dw2 - 16); points5[2] = new FCPoint(width - dSize - 4, height - dSize2 - dw2); points5[3] = new FCPoint(width - dSize, height - dSize2 - dw2); paint.fillPolygon(borderColor, points5); FCPoint[] points6 = new FCPoint[4]; points6[0] = new FCPoint(width - dSize, height - dSize2 - dw2); points6[1] = new FCPoint(width - dSize - 4, height - dSize2 - dw2 - 2); points6[2] = new FCPoint(width - dSize - 22, height - dSize2 - dw2 + 16); points6[3] = new FCPoint(width - dSize - 20, height - dSize2 - dw2 + 22); paint.fillPolygon(borderColor, points6); FCPoint[] points7 = new FCPoint[3]; points7[0] = new FCPoint(width - 1, height - dSize2 - dw2 - 30); points7[1] = new FCPoint(width - 1, height - dSize2 - dw2 + 3); points7[2] = new FCPoint(width - 1 - dw2 + 20, height - dSize2 - 16); paint.drawPolyline(borderColor, 2, 0, points7); FCPoint[] points8 = new FCPoint[3]; points8[0] = new FCPoint(width - 1 - dw2 + 19, height - dSize2 - 15); points8[1] = new FCPoint(width - dSize - dw2 + 1, height - dSize + 3); points8[2] = new FCPoint(width - dSize - dw2 - 25, height - dSize + 3); paint.drawPolyline(borderColor, 2, 0, points8); FCPoint[] points9 = new FCPoint[6]; points9[0] = new FCPoint(width - dSize - dw2 + 1, height - dSize + 3); points9[1] = new FCPoint(width - dSize - dw2 - 14, height - dSize + 3); points9[2] = new FCPoint(width - dSize - dw2 - 10, height - dSize + 8); points9[3] = new FCPoint(width - dSize - dw2 + 3, height - dSize + 8); points9[4] = new FCPoint(width - dSize - dw2 + 16, height - dSize - 6); points9[5] = new FCPoint(width - dSize - dw2 + 16, height - dSize - 14); paint.fillPolygon(borderColor, points9); int rwidth = width * 3 / 5; if (rwidth > width - dSize * 2 - dw2) { rwidth = width - dSize2 * 2 - dw2; } FCPoint[] points10 = new FCPoint[4]; points10[0] = new FCPoint(rwidth - 8, height - dSize2 - 6); points10[1] = new FCPoint(rwidth - 12, height - dSize2); points10[2] = new FCPoint(rwidth + 12, height - dSize2); points10[3] = new FCPoint(rwidth + 8, height - dSize2 - 6); paint.fillPolygon(borderColor, points10); rwidth = width * 7 / 10; if (rwidth > width - 30) { rwidth = width - 30; } FCPoint[] points11 = new FCPoint[4]; points11[0] = new FCPoint(rwidth - 16, dSize - 6); points11[1] = new FCPoint(rwidth - 20, dSize); points11[2] = new FCPoint(rwidth + 20, dSize); points11[3] = new FCPoint(rwidth + 16, dSize - 6); paint.fillPolygon(borderColor, points11); FCDraw.drawText(paint, Text, foreColor, Font, 100, 15); if (m_tick > 200) { int count = (m_tick - 200) / 8 + 1; int left = 80; for (int i = 0; i < count; i++) { FCRect pRect = new FCRect(left, height - 10, left + 8, height - 6); paint.fillRect(borderColor, pRect); left += 10; } left = 15; int top = 80; count = (m_tick - 200) / 10 + 1; for (int i = 0; i < count; i++) { FCRect pRect = new FCRect(left, top, left + 8, top + 6); paint.fillRect(borderColor, pRect); top += 10; } } }
/// <summary> /// 重绘边线方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintBorder(FCPaint paint, FCRect clipRect) { int width = Width, height = Height; paint.drawLine(getPaintingBorderColor(), 1, 0, 0, height - 1, width, height - 1); }
/// <summary> /// 重绘背景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintBackground(FCPaint paint, FCRect clipRect) { int width = Width; int height = Height; FCNative native = Native; FCRect drawRect = convertBoundsToPRect(new FCRect(0, 0, width, height)); //绘制选中的点 int resizePoint = m_resizePoint != -1 ? m_resizePoint : getResizePoint(TouchPoint); if (width > 4 && height > 4) { long borderColor = FCDraw.FCCOLORS_BACKCOLOR8; //绘制多目标 int targetsSize = m_targets.Count; if (targetsSize > 1) { for (int i = 0; i < targetsSize; i++) { FCView target = m_targets[i]; FCPoint clientLocation = pointToControl(new FCPoint(Native.clientX(target), Native.clientY(target))); paint.drawRect(borderColor, 2, 0, new FCRect(clientLocation.x, clientLocation.y, clientLocation.x + target.Width, clientLocation.y + target.Height)); } } if (resizePoint != -1 && resizePoint != 8) { paint.fillGradientRect(FCDraw.FCCOLORS_BACKCOLOR5, FCDraw.FCCOLORS_BACKCOLOR6, drawRect, 0, 90); paint.drawRect(borderColor, 1, 2, drawRect); int thick = 4; List <int> positions = new List <int>(); //左上右下 if (resizePoint < 4) { positions.Add(resizePoint); } else { switch (resizePoint) { //左上 case 4: positions.Add(0); positions.Add(1); break; //左下 case 5: positions.Add(0); positions.Add(3); break; //右上 case 6: positions.Add(1); positions.Add(2); break; //右下 case 7: positions.Add(2); positions.Add(3); break; } } //绘制选中点 int positionsSize = positions.Count; for (int i = 0; i < positionsSize; i++) { switch (positions[i]) { //左 case 0: paint.fillRect(borderColor, new FCRect(0, 0, thick, height)); break; //上 case 1: paint.fillRect(borderColor, new FCRect(0, 0, width, thick)); break; //右 case 2: paint.fillRect(borderColor, new FCRect(width - thick, 0, width, height)); break; //下 case 3: paint.fillRect(borderColor, new FCRect(0, height - thick, width, height)); break; } } } else { if (Native.PushedControl == this) { if (Math.Abs(m_point1.x - m_point2.x) > 5 && Math.Abs(m_point1.y - m_point2.y) > 5) { FCRect moveRect = getRectangle(pointToControl(m_point1), pointToControl(m_point2)); paint.drawRect(borderColor, 2, 0, moveRect); } } paint.drawRect(borderColor, 2, 2, drawRect); FCRect[] pRects = getResizePoints(); int pRectsSize = pRects.Length; for (int p = 0; p < pRectsSize; p++) { paint.fillRect(borderColor, pRects[p]); } //绘制动画 if (resizePoint == -1) { if (m_tick < 20) { if (m_tick > 2 && m_tick < 18) { int xTick = width / 20; int yTick = height / 20; int tWidth = width / 3, tHeight = height / 3; int nSize = RESIZEPOINT_SIZE; paint.setLineCap(2, 2); int a = (10 - Math.Abs(m_tick - 10)) * 20; paint.drawLine(FCColor.argb(a, m_random.Next(0, 256), m_random.Next(0, 256), m_random.Next(0, 256)), m_random.Next(1, 10), 0, xTick * m_tick - tWidth / 2, (m_direction == 1 ? nSize : height - nSize), xTick * m_tick + tWidth / 2, (m_direction == 1 ? nSize : height - nSize)); paint.drawLine(FCColor.argb(a, m_random.Next(0, 256), m_random.Next(0, 256), m_random.Next(0, 256)), m_random.Next(1, 10), 0, width - xTick * m_tick - tWidth / 2, (m_direction == 0 ? nSize : height - nSize), width - (xTick * m_tick - tWidth / 2), (m_direction == 0 ? nSize : height - nSize)); paint.drawLine(FCColor.argb(a, m_random.Next(0, 256), m_random.Next(0, 256), m_random.Next(0, 256)), m_random.Next(1, 10), 0, (m_direction == 1 ? nSize : width - nSize), height - yTick * m_tick - tHeight / 2, (m_direction == 1 ? nSize : width - nSize), height - (yTick * m_tick - tHeight / 2)); paint.drawLine(FCColor.argb(a, m_random.Next(0, 256), m_random.Next(0, 256), m_random.Next(0, 256)), m_random.Next(1, 10), 0, (m_direction == 0 ? nSize : width - nSize), yTick * m_tick - tHeight / 2, (m_direction == 0 ? nSize : width - nSize), yTick * m_tick + tHeight / 2); paint.setLineCap(0, 0); } } } } } }
/// <summary> /// 绘制背景 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintBackground(FCPaint paint, FCRect clipRect) { int width = Width, height = Height; float xRate = (float)width / 200; float yRate = (float)height / 200; FCRect drawRect = new FCRect(0, 0, width - 1, height - 1); if (m_isEllipse) { paint.fillEllipse(getPaintingBackColor(), drawRect); } else { paint.fillRect(getPaintingBackColor(), drawRect); } long textColor = getPaintingTextColor(); float lineWidth = 10 * xRate; if (m_style == WindowButtonStyle.Close) { paint.setLineCap(2, 2); paint.drawLine(textColor, lineWidth, 0, (int)(135 * xRate), (int)(70 * yRate), (int)(70 * xRate), (int)(135 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(70 * xRate), (int)(70 * yRate), (int)(135 * xRate), (int)(135 * yRate)); } else if (m_style == WindowButtonStyle.Max) { paint.setLineCap(2, 2); paint.drawLine(textColor, lineWidth, 0, (int)(80 * xRate), (int)(80 * yRate), (int)(60 * xRate), (int)(60 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(125 * xRate), (int)(145 * yRate), (int)(145 * xRate), (int)(145 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(145 * xRate), (int)(125 * yRate), (int)(145 * xRate), (int)(145 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(125 * xRate), (int)(125 * yRate), (int)(145 * xRate), (int)(145 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(60 * xRate), (int)(80 * yRate), (int)(60 * xRate), (int)(60 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(80 * xRate), (int)(60 * yRate), (int)(60 * xRate), (int)(60 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(125 * xRate), (int)(80 * yRate), (int)(145 * xRate), (int)(60 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(145 * xRate), (int)(80 * yRate), (int)(145 * xRate), (int)(60 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(125 * xRate), (int)(60 * yRate), (int)(145 * xRate), (int)(60 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(80 * xRate), (int)(125 * yRate), (int)(60 * xRate), (int)(145 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(60 * xRate), (int)(125 * yRate), (int)(60 * xRate), (int)(145 * yRate)); paint.drawLine(textColor, lineWidth, 0, (int)(80 * xRate), (int)(145 * yRate), (int)(60 * xRate), (int)(145 * yRate)); } else if (m_style == WindowButtonStyle.Min) { paint.setLineCap(2, 2); paint.drawLine(textColor, lineWidth, (int)(0 * xRate), (int)(60 * yRate), (int)(105 * xRate), (int)(135 * xRate), (int)(105 * yRate)); } else if (m_style == WindowButtonStyle.Restore) { paint.setLineCap(2, 2); paint.drawLine(textColor, lineWidth, (int)(0 * xRate), (int)(90 * yRate), (int)(90 * xRate), (int)(70 * xRate), (int)(70 * yRate)); paint.drawLine(textColor, lineWidth, (int)(0 * xRate), (int)(90 * yRate), (int)(90 * xRate), (int)(70 * xRate), (int)(90 * yRate)); paint.drawLine(textColor, lineWidth, (int)(0 * xRate), (int)(90 * yRate), (int)(90 * xRate), (int)(90 * xRate), (int)(70 * yRate)); paint.drawLine(textColor, lineWidth, (int)(0 * xRate), (int)(115 * yRate), (int)(115 * xRate), (int)(135 * xRate), (int)(135 * yRate)); paint.drawLine(textColor, lineWidth, (int)(0 * xRate), (int)(115 * yRate), (int)(115 * xRate), (int)(135 * xRate), (int)(115 * yRate)); paint.drawLine(textColor, lineWidth, (int)(0 * xRate), (int)(115 * yRate), (int)(115 * xRate), (int)(115 * xRate), (int)(135 * yRate)); } paint.setLineCap(0, 0); }