/// <summary> /// 重绘背景方法 /// </summary> /// <param name="paint">绘图对象</param> public void OnPaintBackground(CPaint paint) { if (m_k != 0 && m_b != 0) { RECT drawRect = new RECT(m_location.x - m_tick, m_location.y - m_tick, m_location.x + m_tick, m_location.y + m_tick); paint.DrawGradientEllipse(m_backColor, COLOR.RatioColor(paint, m_backColor, 1.1), drawRect, 90); if (m_tick2 % 5 == 0) { if (m_mode == 0) { m_tick++; if (m_tick > 10) { m_mode = 1; } } else if (m_mode == 1) { m_tick--; if (m_tick < 4) { m_mode = 0; } } } m_tick2++; if (m_tick2 > 1000) { m_tick2 = 0; } } }
/// <summary> /// 重绘背景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void OnPaintBackground(CPaint paint, RECT clipRect) { int width = Width; int height = Height; if (width > 0 && height > 0) { //绘制食物 RECT drawRect = new RECT(0, 0, width - 1, height - 1); long paintingBackColor = GetPaintingBackColor(); paint.DrawGradientEllipse(paintingBackColor, COLOR.RatioColor(paint, paintingBackColor, 0.9), drawRect, 90); } }
/// <summary> /// 重绘背景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void OnPaintBackground(CPaint paint, RECT clipRect) { int width = Width; int height = Height; if (width > 0 && height > 0) { //绘制关节 RECT drawRect = new RECT(0, 0, width, width); long paintingBackColor = GetPaintingBackColor(); paint.DrawGradientEllipse(paintingBackColor, COLOR.RatioColor(paint, paintingBackColor, 1.1), drawRect, 90); if (m_isHeader) { POINT eyeLeft = new POINT(); POINT eyeRight = new POINT(); //绘制眼睛 switch (m_direction) { //向下 case SnakeDirection.Down: eyeLeft = new POINT(width / 3, height * 2 / 3); eyeRight = new POINT(width * 2 / 3, height * 2 / 3); break; //向左 case SnakeDirection.Left: eyeLeft = new POINT(width / 3, height / 3); eyeRight = new POINT(width / 3, height * 2 / 3); break; //向右 case SnakeDirection.Right: eyeLeft = new POINT(width * 2 / 3, height * 2 / 3); eyeRight = new POINT(width * 2 / 3, height / 3); break; //向上 case SnakeDirection.Up: eyeLeft = new POINT(width / 3, height / 3); eyeRight = new POINT(width * 2 / 3, height / 3); break; } //画左眼 RECT lRect = new RECT(eyeLeft.x - 2, eyeLeft.y - 2, eyeLeft.x + 2, eyeLeft.y + 2); paint.FillEllipse(COLOR.ARGB(255, 255, 255), lRect); //画右眼 RECT rRect = new RECT(eyeRight.x - 2, eyeRight.y - 2, eyeRight.x + 2, eyeRight.y + 2); paint.FillEllipse(COLOR.ARGB(255, 255, 255), rRect); } } }
/// <summary> /// 获取正在绘制的背景色 /// </summary> /// <returns></returns> protected override long GetPaintingBackColor() { if (Native.PushedControl == this) { return(COLOR.Reverse(null, CDraw.PCOLORS_BACKCOLOR8)); } else if (Native.HoveredControl == this) { return(COLOR.RatioColor(null, CDraw.PCOLORS_BACKCOLOR8, 0.95)); } else { return(CDraw.PCOLORS_BACKCOLOR8); } }
/// <summary> /// 重绘背景方法 /// </summary> /// <param name="paint">绘图对象</param> public void OnPaintBackground(CPaint paint) { RECT drawRect = new RECT(m_location.x - 6, m_location.y - 6, m_location.x + 6, m_location.y + 6); paint.DrawGradientEllipse(m_backColor, COLOR.RatioColor(paint, m_backColor, 1.1), drawRect, 90); drawRect.left -= m_tick; drawRect.top -= m_tick; drawRect.right += m_tick; drawRect.bottom += m_tick; paint.FillEllipse(COLOR.ARGB(50, 255, 255, 0), drawRect); if (m_tick > 10) { m_tick = 0; } if (m_tick2 % 1 == 0) { m_tick++; } m_tick2++; if (m_tick2 > 1000) { m_tick2 = 0; } }
/// <summary> /// 重绘背景方法 /// </summary> /// <param name="paint">绘图对象</param> public void OnPaintBackground(CPaint paint) { if (m_k != 0 && m_b != 0) { if (IsClick) { int a = 0, r = 0, g = 0, b = 0; COLOR.ToARGB(paint, m_backColor, ref a, ref r, ref g, ref b); RECT bRect = new RECT(m_location.x - m_tick3, m_location.y - m_tick3, m_location.x + m_tick3, m_location.y + m_tick3); if (m_tick3 < 400) { paint.FillEllipse(COLOR.ARGB(200 - 200 * m_tick3 / 400, r, g, b), bRect); } paint.DrawEllipse(m_backColor, 2, 0, bRect); m_tick3 += 40; bRect = new RECT(m_location.x - m_tick4, m_location.y - m_tick4, m_location.x + m_tick4, m_location.y + m_tick4); if (m_tick4 < 300) { paint.FillEllipse(COLOR.ARGB(150 - 150 * m_tick4 / 400, r, g, b), bRect); } m_tick4 += 20; bRect = new RECT(m_location.x - m_tick5, m_location.y - m_tick5, m_location.x + m_tick5, m_location.y + m_tick5); if (m_tick5 < 200) { paint.FillEllipse(COLOR.ARGB(100 - 100 * m_tick5 / 400, r, g, b), bRect); } m_tick5 += 10; } else { RECT drawRect = new RECT(m_location.x - m_tick, m_location.y - m_tick, m_location.x + m_tick, m_location.y + m_tick); paint.FillGradientEllipse(m_backColor, COLOR.RatioColor(paint, m_backColor, 1.1), drawRect, 90); paint.DrawEllipse(m_backColor, 2, 0, new RECT(m_location.x - 20, m_location.y - 20, m_location.x + 20, m_location.y + 20)); } if (m_tick2 % 5 == 0) { if (m_mode == 0) { m_tick++; if (m_tick > 10) { m_mode = 1; } } else if (m_mode == 1) { m_tick--; if (m_tick < 4) { m_mode = 0; } } } m_tick2++; if (m_tick2 > 1000) { m_tick2 = 0; } if (m_security != null) { SecurityLatestData latestData = new SecurityLatestData(); if (SecurityService.GetLatestData(m_security.m_code, ref latestData) == 0) { latestData.m_securityName = m_security.m_name; } if (IsClick) { FONT nFont = new FONT("Arial", 30, true, false, false); FONT iFont = new FONT("SimSum", 30, true, false, false); String name = m_security.m_name; SIZE tSize = paint.TextSize(name, iFont); int x = m_location.x - tSize.cx / 2; int mid = x + tSize.cx / 2; int y = m_location.y - 90; RECT tRect = new RECT(x, y, x + tSize.cx, y + tSize.cy); paint.DrawText(name, m_backColor, iFont, tRect); double diff = 0; if (latestData.m_lastClose > 0) { diff = 100 * (latestData.m_close - latestData.m_lastClose) / latestData.m_lastClose; } y += tSize.cy; String strClose = latestData.m_close.ToString(); tSize = paint.TextSize(strClose, nFont); x = mid - tSize.cx / 2; tRect = new RECT(x, y, x + tSize.cx, y + tSize.cy); if (diff >= 0) { paint.DrawText(strClose, COLOR.ARGB(255, 82, 82), nFont, tRect); } else { paint.DrawText(strClose, COLOR.ARGB(82, 255, 82), nFont, tRect); } y += tSize.cy; String value = diff.ToString("0.00") + "%"; if (diff >= 0) { value = "+" + value; } if (latestData.m_close == 0) { value = "停牌"; } tSize = paint.TextSize(value, nFont); x = mid - tSize.cx / 2; tRect = new RECT(x, y, x + tSize.cx, y + tSize.cy); if (diff >= 0) { paint.DrawText(value, COLOR.ARGB(255, 82, 82), nFont, tRect); } else { paint.DrawText(value, COLOR.ARGB(82, 255, 82), nFont, tRect); } y += tSize.cy; double volume = latestData.m_volume / 100; String unit = ""; if (volume > 100000000) { volume /= 100000000; unit = "亿"; } else if (volume > 10000) { volume /= 10000; unit = "万"; } String strVol = (volume).ToString("0.00") + unit; tSize = paint.TextSize(strVol, nFont); x = mid - tSize.cx / 2; tRect = new RECT(x, y, x + tSize.cx, y + tSize.cy); paint.DrawText(strVol, COLOR.ARGB(255, 255, 0), nFont, tRect); } else { FONT iFont = new FONT("SimSum", 30, true, false, false); String name = m_security.m_name; SIZE tSize = paint.TextSize(name, iFont); int x = m_location.x - tSize.cx / 2; int mid = x + tSize.cx / 2; int y = m_location.y - 60; RECT tRect = new RECT(x, y, x + tSize.cx, y + tSize.cy); paint.DrawText(name, m_backColor, iFont, tRect); } } } }
/// <summary> /// 重绘背景方法 /// </summary> /// <param name="paint">绘图对象</param> public void OnPaintBackground(CPaint paint) { if (m_k != 0 && m_b != 0) { if (IsClick) { int a = 0, r = 0, g = 0, b = 0; COLOR.ToARGB(paint, m_backColor, ref a, ref r, ref g, ref b); RECT bRect = new RECT(m_location.x - m_tick3, m_location.y - m_tick3, m_location.x + m_tick3, m_location.y + m_tick3); if (m_tick3 < 400) { paint.FillEllipse(COLOR.ARGB(200 - 200 * m_tick3 / 400, r, g, b), bRect); } paint.DrawEllipse(m_backColor, 2, 0, bRect); m_tick3 += 40; bRect = new RECT(m_location.x - m_tick4, m_location.y - m_tick4, m_location.x + m_tick4, m_location.y + m_tick4); if (m_tick4 < 300) { paint.FillEllipse(COLOR.ARGB(150 - 150 * m_tick4 / 400, r, g, b), bRect); } m_tick4 += 20; bRect = new RECT(m_location.x - m_tick5, m_location.y - m_tick5, m_location.x + m_tick5, m_location.y + m_tick5); if (m_tick5 < 200) { paint.FillEllipse(COLOR.ARGB(100 - 100 * m_tick5 / 400, r, g, b), bRect); } m_tick5 += 10; } else { RECT drawRect = new RECT(m_location.x - m_tick - 10, m_location.y - m_tick - 10, m_location.x + m_tick + 10, m_location.y + m_tick + 10); paint.FillGradientEllipse(m_backColor, COLOR.RatioColor(paint, m_backColor, 1.1), drawRect, 90); paint.DrawEllipse(m_backColor, 2, 0, new RECT(m_location.x - 25, m_location.y - 25, m_location.x + 25, m_location.y + 25)); paint.DrawLine(m_backColor, 5, 0, m_location.x + 20, m_location.y - 15, m_location.x + 30, m_location.y - 25); } if (m_tick2 % 5 == 0) { if (m_mode == 0) { m_tick++; if (m_tick > 10) { m_mode = 1; } } else if (m_mode == 1) { m_tick--; if (m_tick < 4) { m_mode = 0; } } } m_tick2++; if (m_tick2 > 1000) { m_tick2 = 0; } } }