/// <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); }
/// <summary> /// 重绘选中按钮方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void onPaintCheckButton(FCPaint paint, FCRect clipRect) { //绘制背景图 String bkImage = getPaintingBackImage(); if (bkImage != null && bkImage.Length > 0) { paint.drawImage(bkImage, clipRect); } else { if (Checked) { FCRect innerRect = new FCRect(clipRect.left + 2, clipRect.top + 2, clipRect.right - 3, clipRect.bottom - 3); if (clipRect.right - clipRect.left < 4 || clipRect.bottom - clipRect.top < 4) { innerRect = clipRect; } paint.fillEllipse(getPaintingButtonBackColor(), innerRect); } paint.drawEllipse(getPaintingButtonBorderColor(), 1, 0, clipRect); } }
/// <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) { int width = Width, height = Height; if (width > 0 && height > 0) { int right = width; int midY = height / 2; String text = Text; int tRight = 0; long textColor = getPaintingTextColor(); if (text != null && text.Length > 0) { FCFont font = Font; FCSize tSize = paint.textSize(text, font); FCRect tRect = new FCRect(); tRect.left = 10; tRect.top = midY - tSize.cy / 2 + 2; tRect.right = tRect.left + tSize.cx; tRect.bottom = tRect.top + tSize.cy; paint.drawText(text, textColor, font, tRect); tRight = tRect.right + 4; } //绘制选中 if (m_checked) { FCRect eRect = new FCRect(tRight, height / 2 - 4, tRight + 8, height / 2 + 4); paint.fillEllipse(textColor, eRect); } //画子菜单的提示箭头 if (m_items.size() > 0) { FCPoint point1 = new FCPoint(), point2 = new FCPoint(), point3 = new FCPoint(); FCMenu menu = m_parentMenu; if (m_parentItem != null) { menu = m_parentItem.DropDownMenu; } FCLayoutStyle layoutStyle = menu.LayoutStyle; //横向 if (layoutStyle == FCLayoutStyle.LeftToRight || layoutStyle == FCLayoutStyle.RightToLeft) { point1.x = right - 25; point1.y = midY - 2; point2.x = right - 14; point2.y = midY - 2; point3.x = right - 20; point3.y = midY + 4; } //纵向 else { point1.x = right - 15; point1.y = midY; point2.x = right - 25; point2.y = midY - 5; point3.x = right - 25; point3.y = midY + 5; } FCPoint[] points = new FCPoint[] { point1, point2, point3 }; paint.fillPolygon(textColor, points); } } }