/// <summary> /// 创建蛇身 /// </summary> /// <param name="rect">区域</param> public SnakeBody(RECT rect) { BackColor = COLOR.ARGB(20, 20, 20); BorderColor = COLOR.EMPTY; Bounds = rect; CanFocus = false; }
/// <summary> /// 创建填空 /// </summary> public Sky() { BackColor = COLOR.ARGB(255, 255, 255); BorderColor = COLOR.EMPTY; ForeColor = COLOR.ARGB(0, 0, 0); Font = new FONT("Arial", 80, true, false, true); }
/// <summary> /// 创建标签 /// </summary> /// <param name="battle">战场</param> public Play(Battle battle) { m_battle = battle; BorderColor = COLOR.EMPTY; Font = new FONT("SimSun", 16, true, false, true); ForeColor = COLOR.ARGB(255, 255, 255); }
/// <summary> /// 重绘单元格 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="rect">区域</param> /// <param name="clipRect">裁剪区域</param> /// <param name="isAlternate">是否交替</param> public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate) { base.OnPaint(paint, rect, clipRect, isAlternate); int width = rect.right - rect.left; if (width > 0) { width = (int)(width * m_rate / 100); int newRight = rect.left + width; if (clipRect.right > newRight) { clipRect.right = newRight; } long pColor = COLOR.ARGB(100, 255, 0, 0); if (m_rate > 80) { pColor = COLOR.ARGB(100, 0, 255, 0); } else if (m_rate > 60) { pColor = COLOR.ARGB(100, 255, 255, 0); } else if (m_rate > 40) { pColor = COLOR.ARGB(100, 0, 255, 255); } else if (m_rate > 20) { pColor = COLOR.ARGB(100, 255, 0, 255); } paint.FillRect(pColor, clipRect); } }
/// <summary> /// 绑定新闻 /// </summary> /// <param name="id"></param> private void BindStockNews(String id) { object data = StockNewsDataHelper.GetNewsById(id, "0", "100", "desc", ""); NewsListRoot newsRoot = JsonConvert.DeserializeObject <NewsListRoot>(data.ToString()); m_gridAllStockNews.ClearRows(); foreach (NewsListNode stockNew in newsRoot.records) { GridRow row = new GridRow(); m_gridAllStockNews.AddRow(row); row.Tag = stockNew; row.AddCell("colN1", new GridStringCell(stockNew.Date)); row.AddCell("colN2", new GridStringCell(stockNew.Title)); row.AddCell("colN3", new GridStringCell(stockNew.url)); row.AddCell("colN4", new GridStringCell(stockNew.Id)); row.GetCell("colN1").Style = new GridCellStyle(); row.GetCell("colN1").Style.ForeColor = COLOR.ARGB(255, 255, 80); row.GetCell("colN2").Style = new GridCellStyle(); row.GetCell("colN2").Style.ForeColor = COLOR.ARGB(255, 80, 80); row.GetCell("colN3").Style = new GridCellStyle(); row.GetCell("colN3").Style.ForeColor = COLOR.ARGB(255, 80, 255); } m_gridAllStockNews.Update(); m_gridAllStockNews.Invalidate(); }
/// <summary> /// 绑定新股名称表格 /// </summary> private void BindNewStockCalendar() { GridA gridNewStockCalendar = m_mainFrame.GetGrid("gridNewStockCalendar"); gridNewStockCalendar.GridLineColor = COLOR.EMPTY; gridNewStockCalendar.BackColor = COLOR.ARGB(0, 0, 0); gridNewStockCalendar.RowStyle = new GridRowStyle(); gridNewStockCalendar.RowStyle.BackColor = COLOR.ARGB(0, 0, 0); DataSet ds = NewStockDataHelper.GetNewStockCalendar(0); StringBuilder sb = new StringBuilder(); foreach (DataRow dr in ds.Tables[0].Rows) { GridRow row = new GridRow(); gridNewStockCalendar.AddRow(row); row.AddCell("colN1", new GridStringCell(dr[1].ToString())); row.AddCell("colN2", new GridStringCell(dr[2].ToString())); row.AddCell("colN3", new GridStringCell(dr[3].ToString())); row.AddCell("colN4", new GridStringCell(dr[4].ToString())); row.GetCell("colN1").Style = new GridCellStyle(); row.GetCell("colN1").Style.ForeColor = COLOR.ARGB(255, 80, 80); row.GetCell("colN2").Style = new GridCellStyle(); row.GetCell("colN2").Style.ForeColor = COLOR.ARGB(80, 255, 255); row.GetCell("colN3").Style = new GridCellStyle(); row.GetCell("colN3").Style.ForeColor = COLOR.ARGB(255, 80, 255); row.GetCell("colN4").Style = new GridCellStyle(); row.GetCell("colN4").Style.ForeColor = COLOR.ARGB(255, 255, 80); if (dr[3].ToString().IndexOf("网上申购日") != -1) { m_newStockList.Add(Convert.ToDateTime(dr[4]).ToString("yyyy-MM-dd") + " " + dr[2].ToString() + " " + dr[1].ToString() + "\r\n"); } } }
/// <summary> /// 创建江恩正方 /// </summary> public GannSquare() { BackColor = COLOR.ARGB(255, 255, 255); SIZE size = new SIZE(200, 200); Size = size; }
/// <summary> /// 创建填空 /// </summary> public Sky() { BackColor = COLOR.EMPTY; BorderColor = COLOR.EMPTY; Font = new FONT("微软雅黑", 100, true, false, true); ForeColor = COLOR.ARGB(255, 255, 40, 40); }
/// <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); paint.DrawRoundRect(m_backColor, 1, 0, drawRect, 5); 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 OnPaint(CPaint paint) { RECT rect = Bounds; int width = rect.right - rect.left; int height = rect.bottom - rect.top; if ((rect.left >= 0 || rect.top >= 0 || rect.right >= 0 || rect.bottom >= 0) && width > 0 && height > 0) { //绘制背景 paint.FillRect(BackColor, rect); String text = CStr.GetValueByDigit(Value, m_gannSquare.Digit); String suffix = m_gannSquare.Suffix; if (suffix != null && suffix.Length > 0) { text += suffix; } SIZE textSize = paint.TextSize(text, m_gannSquare.CellFont); //画文字 POINT tPoint = new POINT(rect.left + (width - textSize.cx) / 2, rect.top + (height - textSize.cy) / 2); RECT tRect = new RECT(tPoint.x, tPoint.y, tPoint.x + textSize.cx, tPoint.y + textSize.cy); paint.DrawText(text, ForeColor, m_gannSquare.CellFont, tRect); //绘制边线 paint.DrawLine(COLOR.ARGB(167, 170, 178), 0, 0, rect.left, rect.top, rect.right, rect.top); paint.DrawLine(COLOR.ARGB(167, 170, 178), 0, 0, rect.right, rect.top, rect.right, rect.bottom); } }
/// <summary> /// 绑定公告 /// </summary> /// <param name="id"></param> private void BindNotices(String id) { object data = NoticeDataHelper.GetNoticeById(id, "0", "100", "desc", ""); NoticeListRoot noticeRoot = JsonConvert.DeserializeObject <NoticeListRoot>(data.ToString()); List <NoticeListNodeBind> bindList = new List <NoticeListNodeBind>(); foreach (NoticeListNode noticeNode in noticeRoot.records) { NoticeListNodeBind bind = new NoticeListNodeBind(); bind.Copy(noticeNode); bindList.Add(bind); } m_gridAllStockNotices.ClearRows(); foreach (NoticeListNodeBind notice in bindList) { GridRow row = new GridRow(); m_gridAllStockNotices.AddRow(row); row.Tag = notice; row.AddCell("colN1", new GridStringCell(notice.Date)); row.AddCell("colN2", new GridStringCell(notice.Title)); row.AddCell("colN3", new GridStringCell(notice.url)); row.AddCell("colN4", new GridStringCell(notice.Id)); row.GetCell("colN1").Style = new GridCellStyle(); row.GetCell("colN1").Style.ForeColor = COLOR.ARGB(255, 255, 80); row.GetCell("colN2").Style = new GridCellStyle(); row.GetCell("colN2").Style.ForeColor = COLOR.ARGB(255, 80, 80); row.GetCell("colN3").Style = new GridCellStyle(); row.GetCell("colN3").Style.ForeColor = COLOR.ARGB(255, 80, 255); } m_gridAllStockNotices.Update(); m_gridAllStockNotices.Invalidate(); }
/// <summary> /// 重绘前景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void OnPaintBackground(CPaint paint, RECT clipRect) { base.OnPaintBackground(paint, clipRect); lock (m_barrages) { int barragesSize = m_barrages.Count; for (int i = 0; i < barragesSize; i++) { Barrage brg = m_barrages[i]; FONT font = brg.Font; RECT rect = brg.Rect; String str = brg.Text; SIZE size = paint.TextSize(str, font); rect.right = rect.left + size.cx; rect.bottom = rect.top + size.cy; brg.Rect = rect; long color = brg.Color; int mode = brg.Mode; if (mode == 1) { int a = 0, r = 0, g = 0, b = 0; COLOR.ToARGB(null, color, ref a, ref r, ref g, ref b); a = a * brg.Tick / 400; color = COLOR.ARGB(a, r, g, b); } paint.DrawText(str, color, font, rect); } } }
/// <summary> /// 绑定研报 /// </summary> /// <param name="id"></param> private void BindReports(String id) { object data = ReportDataHelper.GetReportByTreeNode("", "", id, "0", "100", "desc", "", ""); ReportListRoot reportRoot = JsonConvert.DeserializeObject <ReportListRoot>(data.ToString()); List <ReportListNodeBind> bindList = new List <ReportListNodeBind>(); foreach (ReportListNode noticeNode in reportRoot.records) { ReportListNodeBind bind = new ReportListNodeBind(); bind.Copy(noticeNode); bindList.Add(bind); } m_gridAllStockReports.ClearRows(); foreach (ReportListNodeBind report in bindList) { GridRow row = new GridRow(); m_gridAllStockReports.AddRow(row); row.Tag = report; row.AddCell("colN1", new GridStringCell(report.date)); row.AddCell("colN2", new GridStringCell(report.Title)); row.AddCell("colN3", new GridStringCell(report.Url)); row.AddCell("colN4", new GridStringCell(report.id)); row.GetCell("colN1").Style = new GridCellStyle(); row.GetCell("colN1").Style.ForeColor = COLOR.ARGB(255, 255, 80); row.GetCell("colN2").Style = new GridCellStyle(); row.GetCell("colN2").Style.ForeColor = COLOR.ARGB(255, 80, 80); row.GetCell("colN3").Style = new GridCellStyle(); row.GetCell("colN3").Style.ForeColor = COLOR.ARGB(255, 80, 255); } m_gridAllStockReports.Update(); m_gridAllStockReports.Invalidate(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="mainFrame"></param> public MacIndustry(MainFrame mainFrame) { m_mainFrame = mainFrame; m_cbMacIndustry = mainFrame.GetComboBox("cbMacIndustry"); m_cbMacIndustry.RegisterEvent(new ControlEvent(SelectedIndexChanged), EVENTID.SELECTEDINDEXCHANGED); m_gridMacIndustry = mainFrame.GetGrid("gridMacIndustry"); m_gridMacIndustry.GridLineColor = COLOR.EMPTY; m_gridMacIndustry.BackColor = COLOR.ARGB(0, 0, 0); m_gridMacIndustry.RowStyle = new GridRowStyle(); m_gridMacIndustry.RowStyle.BackColor = COLOR.ARGB(0, 0, 0); m_tvMacIndustry = mainFrame.GetTree("tvMacIndustry"); m_tvMacIndustry.BackColor = COLOR.ARGB(0, 0, 0); m_tvMacIndustry.ForeColor = COLOR.ARGB(255, 255, 255); m_tvMacIndustry.RowStyle = new GridRowStyle(); m_tvMacIndustry.RowStyle.BackColor = COLOR.ARGB(0, 0, 0); m_tvMacIndustry.RegisterEvent(new GridCellMouseEvent(GridCellClick), EVENTID.GRIDCELLCLICK); String[] names = Enum.GetNames(typeof(MacroDataType)); for (int i = 0; i < names.Length; i++) { MenuItemA item = new MenuItemA(); item.Text = names[i]; m_cbMacIndustry.AddItem(item); } m_cbMacIndustry.SelectedIndex = 0; m_fundCurve = mainFrame.FindControl("graphMacIndustry") as FundCurveDiv; m_fundCurve.BackColor = COLOR.ARGB(0, 0, 0); }
/// <summary> /// 绘制前景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void OnPaintForeground(CPaint paint, RECT clipRect) { RECT 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 = COLOR.ARGB(255, 255, 80); FONT font = new FONT("SimSun", 16, false, false, false); FONT indexFont = new FONT("Arial", 14, true, false, false); long grayColor = CDraw.PCOLORS_FORECOLOR4; //上证指数 long indexColor = CDraw.GetPriceColor(m_ssLatestData.m_close, m_ssLatestData.m_lastClose); int left = 1; CDraw.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") + "亿"; SIZE amountSize = paint.TextSize(amount, indexFont); CDraw.DrawText(paint, amount, titleColor, indexFont, width / 3 - amountSize.cx, 3); left += (width / 3 - 40 - amountSize.cx) / 4; int length = CDraw.DrawUnderLineNum(paint, m_ssLatestData.m_close, 2, indexFont, indexColor, false, left, 3); left += length + (width / 3 - 40 - amountSize.cx) / 4; length = CDraw.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 = CDraw.GetPriceColor(m_szLatestData.m_close, m_szLatestData.m_lastClose); CDraw.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); CDraw.DrawText(paint, amount, titleColor, indexFont, width * 2 / 3 - amountSize.cx, 3); left += (width / 3 - 40 - amountSize.cx) / 4; length = CDraw.DrawUnderLineNum(paint, m_szLatestData.m_close, 2, indexFont, indexColor, false, left, 3); left += length + (width / 3 - 40 - amountSize.cx) / 4; length = CDraw.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 = CDraw.GetPriceColor(m_cyLatestData.m_close, m_cyLatestData.m_lastClose); CDraw.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); CDraw.DrawText(paint, amount, titleColor, indexFont, width - amountSize.cx, 3); left += (width / 3 - 40 - amountSize.cx) / 4; length = CDraw.DrawUnderLineNum(paint, m_cyLatestData.m_close, 2, indexFont, indexColor, false, left, 3); left += (width / 3 - 40 - amountSize.cx) / 4 + length; length = CDraw.DrawUnderLineNum(paint, m_cyLatestData.m_close - m_cyLatestData.m_lastClose, 2, indexFont, indexColor, false, left, 3); paint.DrawRect(grayColor, 1, 0, new RECT(0, 0, width - 1, height - 1)); } } }
/// <summary> /// 绘制背景 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void OnPaintBackground(CPaint paint, RECT clipRect) { int width = Width - 1, height = Height - 1; RECT drawRect = new RECT(0, 0, width, height); paint.FillRect(COLOR.ARGB(0, 0, 0), drawRect); int outSize = 40; int oX = width / 2, oY = height / 2, r = (width - outSize * 2) / 2; long innerBorderColor = COLOR.ARGB(100, 100, 100); int[] angles = new int[] { 240, 180, 120, 60, 0, -60 }; int[] rs = new int[] { r, r * 2 / 3, r / 3 }; for (int i = 0; i < 3; i++) { POINT[] drawPoints = new POINT[6]; for (int j = 0; j < 6; j++) { drawPoints[j] = GetCyclePoint(oX, oY, rs[i], angles[j]); } paint.DrawPolygon(innerBorderColor, 1, 0, drawPoints); } FONT pFont = new FONT("微软雅黑", 16, false, false, false); POINT[] points = GetTitlePoints(); int pointsSize = points.Length; String[] strs = new String[] { "业务", "情商", "学识", "智商", "管理", "技术" }; int[] values = new int[6]; if (m_dimension != null) { values = new int[] { m_dimension.m_business, m_dimension.m_EQ, m_dimension.m_knowledge, m_dimension.m_IQ, m_dimension.m_lead, m_dimension.m_technology }; } POINT [] scopePoints = GetScopePoints(); for (int i = 0; i < pointsSize; i++) { int bSize = 5; POINT bPoint = points[i]; RECT bRect = new RECT(bPoint.x - bSize, bPoint.y - bSize, bPoint.x + bSize, bPoint.y + bSize); SIZE pSize = paint.TextSize(strs[i], pFont); if (i == 0 || i == 5) { bPoint.y -= 20; } CDraw.DrawText(paint, strs[i], m_sysColors[i], pFont, bPoint.x - pSize.cx / 2, bPoint.y - pSize.cy / 2); int iSize = 5; POINT cp = GetCyclePoint(oX, oY, r, angles[i]); paint.DrawLine(innerBorderColor, 1, 0, oX, oY, cp.x, cp.y); paint.FillEllipse(m_sysColors[i], new RECT(cp.x - iSize, cp.y - iSize, cp.x + iSize, cp.y + iSize)); String text = String.Format("({0})", CStr.ConvertIntToStr(values[i])); SIZE sSize = paint.TextSize(text, pFont); CDraw.DrawText(paint, text, m_sysColors[i], pFont, bPoint.x - sSize.cx / 2, bPoint.y + sSize.cy / 2); } if (m_dimension != null) { paint.FillGradientPolygon(COLOR.ARGB(200, 50, 105, 217), COLOR.ARGB(200, 50, 105, 217), scopePoints, 90); paint.DrawPolygon(COLOR.ARGB(100, 255, 255, 255), 1, 0, scopePoints); } }
/// <summary> /// 创建填空 /// </summary> public Sky() { BackColor = COLOR.ARGB(0, 0, 100, 255); BorderColor = COLOR.EMPTY; Font = new FONT("Arial", 16, false, false, false); ForeColor = COLOR.ARGB(255, 255, 255); ResourcePath = DataCenter.GetAppPath() + "\\config"; }
/// <summary> /// 重绘方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void OnPaint(CPaint paint, RECT clipRect) { int width = Width; int height = Height; if (width > 0 && height > 0) { //绘制背景 RECT drawRect = new RECT(0, 0, width, height); paint.FillRect(GetPaintingBackColor(), clipRect); for (int i = 0; i < m_bullets.Count; i++) { Bullet bullet = m_bullets[i]; bullet.OnPaintBackground(paint); } String text = String.Format("{0}/{1}", m_score, m_total); FONT font = Font; SIZE tSize = paint.TextSize(text, font); POINT tPoint = new POINT(width / 2 - tSize.cx / 2, 10); RECT tRect = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tSize.cy); //paint.DrawText(text, ForeColor, font, tRect); int pointsSize = m_points.Count; for (int i = 0; i < pointsSize; i++) { POINT point = m_points[i]; RECT pRect = new RECT(point.x - 10, point.y - 10, point.x + 10, point.y + 10); paint.FillGradientEllipse(COLOR.ARGB(50, 0, 0, 0), COLOR.ARGB(50, 30, 30, 30), pRect, 90); paint.DrawEllipse(COLOR.ARGB(50, 100, 100, 100), 1, 0, pRect); } String title = "随机选拔"; FONT tiFont = new FONT("微软雅黑", 30, true, false, false); SIZE tiSize = paint.TextSize(title, tiFont); RECT tiRect = new RECT(); tiRect.left = (width - tiSize.cx) / 2; tiRect.top = height - 120; tiRect.right = tiRect.left + tiSize.cx; tiRect.bottom = tiRect.top + tiSize.cy; paint.DrawText(title, COLOR.ARGB(255, 0, 0), tiFont, tiRect); int membersSize = m_members.Count; if (membersSize > 0) { int avgWidth = width / membersSize, mLeft = 0; for (int i = 0; i < membersSize; i++) { FONT mFont = new FONT("微软雅黑", 35, true, false, false); String member = m_members[i]; SIZE mSize = paint.TextSize(member, mFont); RECT mRect = new RECT(); mRect.left = mLeft + (avgWidth - mSize.cx) / 2; mRect.top = height - 80; mRect.right = mRect.left + mSize.cx; mRect.bottom = mRect.top + mSize.cy; paint.DrawText(member, m_sysColors[m_random.Next(0, m_sysColors.Length)], mFont, mRect); mLeft += avgWidth; } } } }
/// <summary> /// 创建战场 /// </summary> public Battle() { m_timerID = GetNewTimerID(); //初始化颜色 BorderColor = COLOR.ARGB(112, 112, 112); BackColor = COLOR.ARGB(255, 255, 255); ForeColor = COLOR.ARGB(255, 255, 255); Font = new FONT("Arial", 100, false, false, false); }
/// <summary> /// 创建新闻 /// </summary> public StockNews(MainFrame mainFrame) { m_mainFrame = mainFrame; m_gridNews = mainFrame.GetGrid("gridStockNews"); m_gridNews.GridLineColor = COLOR.EMPTY; m_gridNews.BackColor = COLOR.ARGB(0, 0, 0); m_gridNews.RowStyle = new GridRowStyle(); m_gridNews.RowStyle.BackColor = COLOR.ARGB(0, 0, 0); m_gridNews.RegisterEvent(new GridCellMouseEvent(GridCellClick), EVENTID.GRIDCELLCLICK); }
/// <summary> /// 重绘层 /// </summary> /// <param name="sender">调用者</param> /// <param name="paint">绘图对象</param> /// <param name="clicpRect">裁剪区域</param> private void PaintDiv(Object sender, CPaint paint, RECT clicpRect) { DivA div = sender as DivA; int width = div.Width, height = div.Height; RECT drawRect = new RECT(0, 0, width, height); if (m_mode == 5) { paint.FillGradientRect(COLOR.ARGB(200, 255, 40, 24), COLOR.ARGB(200, 255, 255, 40), drawRect, 0, m_tick % 360); } else { paint.FillGradientRect(COLOR.ARGB(200, 90, 120, 24), COLOR.ARGB(200, 122, 156, 40), drawRect, 0, 0); } RECT bounds = m_lblTime.Bounds; RECT fullBloodRect = new RECT(bounds.left, bounds.bottom, bounds.left + 400, bounds.bottom + 15); paint.FillRect(COLOR.ARGB(255, 0, 0), fullBloodRect); int bloodWidth = (int)(m_currentTick / m_totalTick * 400); RECT bloodRect = new RECT(bounds.left, bounds.bottom, bounds.left + bloodWidth, bounds.bottom + 15); if (bloodWidth < 40) { paint.FillRect(COLOR.ARGB(255, 150, 0), bloodRect); } else if (bloodWidth < 120) { paint.FillRect(COLOR.ARGB(255, 200, 0), bloodRect); } else { paint.FillRect(COLOR.ARGB(255, 255, 0), bloodRect); } if (m_currentQuestion != null && m_currentQuestion.m_type == "极限") { String[] strs = m_txtAnswer.Text.Split(new String[] { "\r" }, StringSplitOptions.RemoveEmptyEntries); int cCount = 0; foreach (String str in strs) { if (str == "for(int i = 0; i < 100; i++)") { cCount++; } } String strLine = cCount.ToString(); FONT tFont = new FONT("微软雅黑", 100, true, false, true); SIZE tSize = paint.TextSize(strLine, tFont); RECT tRect = new RECT(); tRect.left = (width - tSize.cx) / 2; tRect.top = (height - tSize.cy) / 2; tRect.right = tRect.left + tSize.cx; tRect.bottom = tRect.top + tSize.cy; paint.DrawText(strLine, COLOR.ARGB(200, 255, 255, 255), tFont, tRect); } }
/// <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, height); //paint.DrawGradientRect(COLOR.ARGB(200, 90, 120, 24), COLOR.ARGB(200, 122, 156, 40), drawRect, 0, 90); paint.DrawRoundRect(COLOR.ARGB(200, 90, 120, 24), 1, 0, drawRect, 5); if (m_play.GameState != GameState.Begin) { //绘制分数 FONT font = Font; String strScore = m_eatCount.ToString(); SIZE tSize = paint.TextSize(strScore, font); //修正透明度 if (m_play.GameState == GameState.Playing) { //减少 if (m_alphaDirection == 0) { m_alpha -= 5; } //增加 else if (m_alphaDirection == 1) { m_alpha += 5; } //改变变动方向 if (m_alpha > 50) { m_alphaDirection = 0; m_alpha = 50; } else if (m_alpha < 20) { m_alphaDirection = 1; m_alpha = 20; } } else { m_alpha = 50; } RECT tRect = new RECT(); tRect.left = drawRect.right / 2 - tSize.cx / 2; tRect.top = drawRect.bottom / 2 - tSize.cy / 2; tRect.right = tRect.left + tSize.cx; tRect.bottom = tRect.top + tSize.cy; paint.DrawText(strScore, COLOR.ARGB(m_alpha * 3, 255, 255, 255), font, tRect); } } }
/// <summary> /// 加载单元格 /// </summary> private void LoadCells() { int cellsSize = m_cells.Count; Dictionary <String, UserSecurityCellT2> removeCells = new Dictionary <String, UserSecurityCellT2>(); for (int i = 0; i < cellsSize; i++) { UserSecurityCellT2 cell = m_cells[i]; removeCells[cell.SecurityCode] = cell; } m_cells.Clear(); List <UserSecurityCategory> categories = new List <UserSecurityCategory>(); m_userSecurityService.GetCategories(categories); UserSecurityCategory category = categories[0]; String[] strs = category.m_codes.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); int strsSize = strs.Length; for (int i = 0; i < strsSize; i++) { String securityCode = strs[i]; if (removeCells.ContainsKey(securityCode)) { m_cells.Add(removeCells[securityCode]); removeCells.Remove(securityCode); } else { UserSecurityCellT2 cell = new UserSecurityCellT2(); cell.SecurityCode = securityCode; cell.BackColor = COLOR.ARGB(200, 0, 0, 0); cell.PaintRect = cell.Bounds; cell.List = this; if (m_userSecurityService.VisitsCount.ContainsKey(securityCode)) { cell.Clicks = m_userSecurityService.VisitsCount[securityCode]; } m_cells.Add(cell); AddControl(cell); } } foreach (UserSecurityCellT2 cell in removeCells.Values) { if (cell == m_selectedCell) { m_selectedCell = null; } RemoveControl(cell); cell.Dispose(); } removeCells.Clear(); m_cells.Sort(new UserSecurityCellT2Compare()); Update(); }
/// <summary> /// 创建窗体 /// </summary> /// <param name="native">方法库</param> public LevelWindow(INativeBase native) { Load(native, "LevelWindow", "levelWindow"); RegisterEvents(m_window); m_chartLevels = GetChart("chartLevels"); m_chartLevels.HScalePixel = 20; m_chartLevels.HScaleFieldText = "日期"; CTable dataSource = m_chartLevels.DataSource; dataSource.AddColumn(0); dataSource.AddColumn(1); dataSource.AddColumn(2); dataSource.AddColumn(3); dataSource.AddColumn(4); CDiv div = m_chartLevels.AddDiv(); div.BackColor = COLOR.ARGB(255, 255, 255); div.LeftVScale.ScaleColor = COLOR.ARGB(50, 105, 217); div.HScale.ScaleColor = COLOR.ARGB(50, 105, 217); div.HGrid.GridColor = COLOR.ARGB(50, 105, 217); div.HGrid.LineStyle = 2; PolylineShape ps = new PolylineShape(); ps.FieldName = 0; ps.FieldText = "开发"; ps.FillColor = COLOR.ARGB(100, 50, 105, 217); ps.Color = COLOR.ARGB(50, 105, 217); div.AddShape(ps); PolylineShape ps2 = new PolylineShape(); ps2.FieldName = 3; ps2.FieldText = "研发"; ps2.FillColor = COLOR.ARGB(100, 255, 80, 80); ps2.Color = COLOR.ARGB(255, 80, 80); div.AddShape(ps2); PolylineShape ps3 = new PolylineShape(); ps3.FieldName = 4; ps3.FieldText = "规范"; ps3.FillColor = COLOR.ARGB(100, 80, 255, 80); ps3.Color = COLOR.ARGB(80, 255, 80); div.AddShape(ps3); PolylineShape psTop = new PolylineShape(); psTop.FieldName = 1; div.AddShape(psTop); PolylineShape psBottom = new PolylineShape(); psBottom.FieldName = 2; div.AddShape(psBottom); m_gridLevels = GetGrid("gridLevels"); m_gridLevels.RegisterEvent(new GridCellEvent(GridCellEditEnd), EVENTID.GRIDCELLEDITEND); BindLevels(); BindChart(); }
/// <summary> /// 重绘前景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void OnPaintForeground(CPaint paint, RECT clipRect) { int width = Width; int height = Height; FONT font = new FONT("微软雅黑", 14, true, false, false); if (m_tick != 0) { font.m_fontSize += 2; } long foreColor = GetPaintingForeColor(); String backImage = GetPaintingBackImage(); int border = m_tick; if (border > 10) { border = 10; } int imgWidth = 88 - (10 - border); int imgHeight = 88 - (10 - border); int gap = 15; RECT imageRect = new RECT((width - imgWidth) / 2, (height - imgHeight) / 2 - gap, (width + imgWidth) / 2, (height + imgHeight) / 2 - gap); if (backImage != null && backImage.Length > 0) { if (m_tick != 0) { paint.SetOpacity((float)(0.5 + border * 0.05f)); } paint.DrawImage(backImage, imageRect); paint.SetOpacity(1); } if (m_text != null && m_name.Length > 0) { SIZE tSize = paint.TextSize(m_text, font); RECT tRect = new RECT(); tRect.left = (width - tSize.cx) / 2; tRect.top = imageRect.bottom + gap; tRect.right = tRect.left + tSize.cx; tRect.bottom = tRect.top + tSize.cy; paint.DrawText(m_text, foreColor, font, tRect); } if (m_direction == 1) { int pointsSize = m_points.Count; for (int i = 0; i < pointsSize; i++) { POINT point = m_points[i]; RECT pRect = new RECT(point.x - 10, point.y - 10, point.x + 10, point.y + 10); paint.FillGradientEllipse(COLOR.ARGB(50, 255, 255, 255), COLOR.ARGB(50, 220, 220, 220), pRect, 90); paint.DrawEllipse(COLOR.ARGB(50, 100, 100, 100), 1, 0, pRect); } } }
/// <summary> /// 绘图方法 /// </summary> /// <param name="sender">调用者</param> /// <param name="paint">绘图</param> /// <param name="clipRect">裁剪区域</param> private void PaintDiv(object sender, CPaint paint, RECT clipRect) { List <DialogInfo> dialogs = DataCenter.DialogService.m_dialogs; int dialogsSize = dialogs.Count; Dictionary <String, int> names = new Dictionary <String, int>(); for (int i = 0; i < dialogsSize; i++) { DialogInfo dialog = dialogs[i]; if (names.ContainsKey(dialog.m_name)) { names[dialog.m_name] = names[dialog.m_name] + 1; } else { names[dialog.m_name] = 1; } } List <DialogData> datas = new List <DialogData>(); foreach (String key in names.Keys) { DialogData data = new DialogData(); data.m_name = key; data.m_times = names[key]; datas.Add(data); } datas.Sort(new DialogDataCompare()); int width = m_divDialogs.Width, height = m_divDialogs.Height; int datasSize = datas.Count; if (datasSize > 0) { int paddingLeft = 50, paddingRight = 50, paddingTop = 20, paddingBottom = 20; int top = paddingTop; int pSize = (height - paddingTop - paddingBottom) / datasSize; double max = 0; for (int i = 0; i < datasSize; i++) { DialogData data = datas[i]; if (i == 0) { max = data.m_times; } int wSize = (int)((width - paddingLeft - paddingRight) * data.m_times / max); CDraw.DrawText(paint, data.m_name, COLOR.ARGB(0, 0, 0), m_divDialogs.Font, 5, top); paint.FillGradientRect(m_sysColors[i % m_sysColors.Length], m_sysColors[(i + 1) % m_sysColors.Length], new RECT(paddingLeft, top + 2, paddingLeft + wSize, top + 12), 2, 0); FONT font = new FONT("微软雅黑", 14, false, false, false); CDraw.DrawText(paint, data.m_times.ToString(), COLOR.ARGB(0, 0, 0), font, paddingLeft + wSize, top); top += pSize; } } }
/// <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); paint.DrawRoundRect(m_backColor, 1, 0, drawRect, 5); 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() { INativeBase native = Native; if (m_style == WindowButtonStyle.Close) { if (native.PushedControl == this) { return(COLOR.ARGB(255, 0, 0)); } else if (native.HoveredControl == this) { return(COLOR.ARGB(255, 150, 150)); } else { return(COLOR.ARGB(255, 80, 80)); } } else if (m_style == WindowButtonStyle.Min) { if (native.PushedControl == this) { return(COLOR.ARGB(0, 255, 0)); } else if (native.HoveredControl == this) { return(COLOR.ARGB(150, 255, 150)); } else { return(COLOR.ARGB(80, 255, 80)); } } else { if (native.PushedControl == this) { return(COLOR.ARGB(255, 255, 0)); } else if (native.HoveredControl == this) { return(COLOR.ARGB(255, 255, 150)); } else { return(COLOR.ARGB(255, 255, 80)); } } }
/// <summary> /// 根据价格获取颜色 /// </summary> /// <param name="price">价格</param> /// <param name="comparePrice">比较价格</param> /// <returns>颜色</returns> public static long GetPriceColor(double price, double comparePrice) { if (price != 0) { if (price > comparePrice) { return(CDraw.PCOLORS_UPCOLOR); } else if (price < comparePrice) { return(CDraw.PCOLORS_DOWNCOLOR); } } return(COLOR.ARGB(255, 255, 255)); }
/// <summary> /// 重绘背景方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void OnPaintBackground(CPaint paint, RECT clipRect) { int width = Width - 10, height = Height - 10; RECT drawRect = new RECT(0, 0, width, height); RECT shadowRect = new RECT(5, 5, width + 2, height + 5); paint.FillEllipse(COLOR.ARGB(100, 0, 0, 0), shadowRect); if (m_mainFrame != null && m_mainFrame.Mode == 5) { paint.FillGradientEllipse(COLOR.ARGB(255, 40, 24), COLOR.ARGB(255, 120, 40), drawRect, 45); } else { paint.FillGradientEllipse(COLOR.ARGB(90, 120, 24), COLOR.ARGB(122, 156, 40), drawRect, 45); } }