/// <summary> /// 注册事件 /// </summary> /// <param name="control">控件</param> private void RegisterEvents(ControlA control) { ControlMouseEvent clickButtonEvent = new ControlMouseEvent(ClickButton); List <ControlA> controls = control.GetControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { ControlA subControl = controls[i]; ButtonA button = subControl as ButtonA; GridA grid = subControl as GridA; if (button != null) { button.RegisterEvent(clickButtonEvent, EVENTID.CLICK); } else if (grid != null) { GridRowStyle rowStyle = new GridRowStyle(); grid.RowStyle = rowStyle; rowStyle.BackColor = COLOR.EMPTY; rowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; rowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; } RegisterEvents(controls[i]); } }
public OrderTrade(MainFrame mainFrame) { m_mainFrame = mainFrame; // 委托表格 m_gridCommissionAccount = m_mainFrame.GetGrid("gridOrderAccount"); // 持仓表格 m_gridPositionAccount = m_mainFrame.GetGrid("gridPositionAccount"); // 成交表格 m_gridTradeAccount = m_mainFrame.GetGrid("gridTradeAccount"); List <GridA> grids = new List <GridA>(); grids.Add(m_gridCommissionAccount); grids.Add(m_gridPositionAccount); grids.Add(m_gridTradeAccount); int gridsSize = grids.Count; for (int i = 0; i < gridsSize; i++) { GridA grid = grids[i]; grid.GridLineColor = COLOR.CONTROLBORDER; grid.RowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; grid.RowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; grid.RowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4; grid.RowStyle.Font = new FONT("微软雅黑", 12, false, false, false); GridRowStyle alternateRowStyle = new GridRowStyle(); alternateRowStyle.BackColor = CDraw.PCOLORS_ALTERNATEROWCOLOR; alternateRowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; alternateRowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; alternateRowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4; alternateRowStyle.Font = new FONT("微软雅黑", 12, false, false, false); grid.AlternateRowStyle = alternateRowStyle; } }
public static extern bool SetForegroundWindow(IntPtr hWnd);//设置此窗体为活动窗体 /// <summary> /// 加载XML /// </summary> /// <param name="xmlPath">XML路径</param> public override void Load(String xmlPath) { LoadFile(xmlPath, null); DataCenter.MainUI = this; m_mainDiv = Native.GetControls()[0] as DivA; m_mainDiv.BackColor = COLOR.CONTROL; ControlPaintEvent paintLayoutEvent = new ControlPaintEvent(PaintLayoutDiv); m_mainDiv.RegisterEvent(paintLayoutEvent, EVENTID.PAINT); m_mainDiv.RegisterEvent(new ControlInvokeEvent(Invoke), EVENTID.INVOKE); DataCenter.ServerChatService.RegisterListener(DataCenter.ChatRequestID, new ListenerMessageCallBack(ChatMessageCallBack)); m_gridHosts = GetGrid("gridHosts"); m_gridHosts.GridLineColor = COLOR.CONTROLBORDER; GridRowStyle rowStyle = new GridRowStyle(); rowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; rowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; rowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4; rowStyle.Font = new FONT("微软雅黑", 12, false, false, false); m_gridHosts.RowStyle = rowStyle; GridRowStyle alternateRowStyle = new GridRowStyle(); alternateRowStyle.BackColor = CDraw.PCOLORS_ALTERNATEROWCOLOR; alternateRowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; alternateRowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; alternateRowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4; alternateRowStyle.Font = new FONT("微软雅黑", 12, false, false, false); m_gridHosts.AlternateRowStyle = alternateRowStyle; m_gridGroups = GetGrid("gridGroups"); m_gridGroups.RowStyle = rowStyle; m_gridGroups.AlternateRowStyle = alternateRowStyle; m_gridGroups.RegisterEvent(new GridCellMouseEvent(GridCellClick), EVENTID.GRIDCELLCLICK); RegisterEvents(m_mainDiv); //全节点服务器 if (DataCenter.IsFull) { DataCenter.UserID = DataCenter.HostInfo.m_localHost + ":" + CStr.ConvertIntToStr(DataCenter.HostInfo.m_localPort); DataCenter.UserName = DataCenter.UserID; Thread thread = new Thread(new ThreadStart(StartConnect)); thread.Start(); } else { UserCookie cookie = new UserCookie(); if (DataCenter.UserCookieService.GetCookie("USERINFO2", ref cookie) > 0) { String[] strs = cookie.m_value.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); GetTextBox("txtPhone").Text = strs[0]; GetTextBox("txtUserName").Text = strs[1]; GetTextBox("txtPort").Text = strs[2]; } } m_chatGroups = ChatGroup.ReadGroups(); BindGroups(); }
/// 注册事件 /// </summary> /// <param name="control">控件</param> private void RegisterEvents(ControlA control) { ControlMouseEvent clickButtonEvent = new ControlMouseEvent(ClickEvent); List <ControlA> controls = control.GetControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { ControlA subControl = controls[i]; ButtonA button = subControl as ButtonA; GridColumn column = subControl as GridColumn; GridA grid = subControl as GridA; CheckBoxA checkBox = subControl as CheckBoxA; if (column != null) { column.AllowResize = true; column.BackColor = CDraw.PCOLORS_BACKCOLOR; column.BorderColor = CDraw.PCOLORS_LINECOLOR2; column.ForeColor = CDraw.PCOLORS_FORECOLOR; } else if (checkBox != null) { checkBox.ButtonBackColor = CDraw.PCOLORS_BACKCOLOR; } else if (button != null) { button.RegisterEvent(clickButtonEvent, EVENTID.CLICK); } else if (grid != null) { grid.BackColor = COLOR.EMPTY; grid.GridLineColor = CDraw.PCOLORS_LINECOLOR2; GridRowStyle rowStyle = new GridRowStyle(); grid.RowStyle = rowStyle; rowStyle.BackColor = COLOR.EMPTY; rowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; rowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; grid.HorizontalOffset = grid.Width; grid.UseAnimation = true; } else { if (subControl.GetControlType() == "Div" || subControl.GetControlType() == "TabControl" || subControl.GetControlType() == "TabPage" || subControl.GetControlType() == "SplitLayoutDiv") { subControl.BackColor = COLOR.EMPTY; } } RegisterEvents(controls[i]); } }
/// 注册事件 /// </summary> /// <param name="control">控件</param> private void RegisterEvents(ControlA control) { ControlMouseEvent clickButtonEvent = new ControlMouseEvent(ClickButton); List <ControlA> controls = control.GetControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { ControlA subControl = controls[i]; ButtonA button = controls[i] as ButtonA; LinkLabelA linkLabel = subControl as LinkLabelA; GridColumn column = subControl as GridColumn; GridA grid = subControl as GridA; CheckBoxA checkBox = subControl as CheckBoxA; if (column != null) { column.AllowDrag = true; column.AllowResize = true; column.BackColor = CDraw.PCOLORS_BACKCOLOR; column.Font = new FONT("微软雅黑", 12, false, false, false); column.ForeColor = CDraw.PCOLORS_FORECOLOR; } else if (button != null) { button.RegisterEvent(clickButtonEvent, EVENTID.CLICK); } else if (linkLabel != null) { linkLabel.RegisterEvent(clickButtonEvent, EVENTID.CLICK); } else if (grid != null) { grid.GridLineColor = COLOR.CONTROLBORDER; grid.RowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; grid.RowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; grid.RowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4; grid.RowStyle.Font = new FONT("微软雅黑", 12, false, false, false); GridRowStyle alternateRowStyle = new GridRowStyle(); alternateRowStyle.BackColor = CDraw.PCOLORS_ALTERNATEROWCOLOR; alternateRowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; alternateRowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; alternateRowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4; alternateRowStyle.Font = new FONT("微软雅黑", 12, false, false, false); grid.AlternateRowStyle = alternateRowStyle; grid.UseAnimation = true; } RegisterEvents(controls[i]); } }
/// <summary> /// 注册事件 /// </summary> /// <param name="control">控件</param> private void RegisterEvents(ControlA control) { ControlMouseEvent clickButtonEvent = new ControlMouseEvent(ClickButton); ControlEvent selectedIndexChangedEvent = new ControlEvent(ComboBoxSelectedIndexChanged); List <ControlA> controls = control.GetControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { ControlA subControl = controls[i]; GridColumn column = subControl as GridColumn; ButtonA button = subControl as ButtonA; GridA grid = subControl as GridA; ComboBoxA comboBox = subControl as ComboBoxA; if (column != null) { column.AllowResize = true; column.BackColor = CDraw.PCOLORS_BACKCOLOR; column.BorderColor = COLOR.CONTROLBORDER; column.ForeColor = CDraw.PCOLORS_FORECOLOR; } else if (button != null) { button.RegisterEvent(clickButtonEvent, EVENTID.CLICK); } else if (comboBox != null) { comboBox.RegisterEvent(selectedIndexChangedEvent, EVENTID.SELECTEDINDEXCHANGED); } else if (grid != null) { grid.GridLineColor = COLOR.EMPTY; GridRowStyle rowStyle = new GridRowStyle(); grid.RowStyle = rowStyle; rowStyle.BackColor = COLOR.EMPTY; rowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; rowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; } RegisterEvents(subControl); } }
/// <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) { int clipW = clipRect.right - clipRect.left; int clipH = clipRect.bottom - clipRect.top; if (clipW > 0 && clipH > 0) { GridA grid = Grid; GridRow row = Row; GridColumn column = Column; if (grid != null && row != null && column != null) { //判断选中 String text = "-"; //绘制背景 bool selected = false; List <GridRow> selectedRows = grid.SelectedRows; int selectedRowsSize = selectedRows.Count; for (int i = 0; i < selectedRowsSize; i++) { if (selectedRows[i] == row) { selected = true; break; } } long backColor = COLOR.EMPTY; GridRowStyle rowStyle = grid.RowStyle; if (selected) { backColor = rowStyle.SelectedBackColor; } else if (row == grid.HoveredRow) { backColor = rowStyle.HoveredBackColor; } else { backColor = rowStyle.BackColor; } paint.FillRect(backColor, clipRect); //获取颜色 FONT font = null; long foreColor = COLOR.EMPTY; GridCellStyle style = Style; if (style != null) { foreColor = style.ForeColor; if (style.Font != null) { font = style.Font; } } double value = GetDouble(); if (!double.IsNaN(value)) { SecurityLatestData data = new SecurityLatestData(); String securityCode = row.GetCell(0).Text; if (m_userSecurityList.m_latestDatas.ContainsKey(securityCode)) { data = m_userSecurityList.m_latestDatas[securityCode]; } String columnName = column.Name; int dataSize = data != null ? data.m_securityCode.Length : 0; if (columnName == "colNo") { foreColor = CDraw.PCOLORS_FORECOLOR7; text = ((int)value + 1).ToString(); } else if (columnName == "colDiff") { if (dataSize > 0) { foreColor = GetPriceColor(value, 0); text = value.ToString("0.00"); } } else if (columnName == "colDiffRange") { if (dataSize > 0) { foreColor = GetPriceColor(data.m_close, data.m_lastClose); text = value.ToString("0.00") + "%"; } } else { if (dataSize > 0) { foreColor = GetPriceColor(value, data.m_lastClose); text = value.ToString("0.00"); } } } SIZE tSize = paint.TextSize(text, font); POINT tPoint = new POINT(rect.right - tSize.cx - 3, rect.top + clipH / 2 - tSize.cy / 2); RECT tRect = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy); paint.DrawText(text, foreColor, font, tRect); } } }
/// <summary> /// 创建表格 /// </summary> public GridExtend() { ShowHScrollBar = true; ShowVScrollBar = true; RowStyle.HoveredBackColor = Color.Empty; AddColumn(new GridColumn("colP1", "股票代码", 100)); AddColumn(new GridColumn("colP2", "股票名称", 100)); AddColumn(new GridColumn("colP3", "最新价", 90)); AddColumn(new GridColumn("colP4", "涨跌额", 90)); AddColumn(new GridColumn("colP5", "涨跌幅", 90)); AddColumn(new GridColumn("colP6", "最高价", 90)); AddColumn(new GridColumn("colP7", "最低价", 90)); AddColumn(new GridColumn("colP8", "开盘价", 90)); AddColumn(new GridColumn("colP9", "成交量", 120)); AddColumn(new GridColumn("colP10", "成交额", 110)); AddColumn(new GridColumn("colP11", "买一价", 90)); AddColumn(new GridColumn("colP12", "买一量", 110)); AddColumn(new GridColumn("colP13", "卖一价", 90)); AddColumn(new GridColumn("colP14", "卖一量", 110)); GetColumn("colP9").CellAlign = HorizontalAlign.Left; GetColumn("colP10").CellAlign = HorizontalAlign.Left; GetColumn("colP12").CellAlign = HorizontalAlign.Left; GetColumn("colP14").CellAlign = HorizontalAlign.Left; BeginUpdate(); //绑定数据 foreach (Security security in SecurityService.codedMaps.Values) { GridRow row = new GridRow(); AddRow(row); row.Height = 30; row.AddCell("colP1", new GridStringCell(security.m_code)); row.AddCell("colP2", new GridStringCell(security.m_name)); row.AddCell("colP3", new GridDoubleCell()); row.AddCell("colP4", new GridDoubleCell()); row.AddCell("colP5", new GridPercentCell()); row.AddCell("colP6", new GridDoubleCell()); row.AddCell("colP7", new GridDoubleCell()); row.AddCell("colP8", new GridDoubleCell()); row.AddCell("colP9", new GridLongCell()); row.AddCell("colP10", new GridLongCell()); row.AddCell("colP11", new GridDoubleCell()); row.AddCell("colP12", new GridLongCell()); row.AddCell("colP13", new GridDoubleCell()); row.AddCell("colP14", new GridLongCell()); rowsMap[security.m_code] = row; for (int i = 0; i < row.Cells.Count; i++) { GridCellStyle cellStyle = new GridCellStyle(); if (i > 1) { cellStyle.Align = HorizontalAlign.Right; } if (blackOrWhite) { cellStyle.TextColor = Color.FromArgb(255, 255, 255); } else { cellStyle.TextColor = Color.Black; } cellStyle.Font = new Font("微软雅黑", 12); row.Cells[i].Style = cellStyle; } } EndUpdate(); SecurityService.m_listener = this; SecurityService.Start(); System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); timer.Tick += new EventHandler(timer_Tick); timer.Interval = 300; timer.Enabled = true; if (!blackOrWhite) { for (int i = 0; i < Columns.Count; i++) { GridColumn gridColumn = Columns[i]; gridColumn.BackColor = Color.White; gridColumn.TextColor = Color.Black; } BackColor = Color.White; GridRowStyle gridRowStyle = RowStyle; gridRowStyle.BackColor = Color.White; gridRowStyle.TextColor = Color.Black; gridRowStyle.SelectedBackColor = Color.FromArgb(200, 200, 200); gridRowStyle.HoveredBackColor = Color.Empty; } }
private GridData GetClientGridLocal(GridState state) { ValidationUtils.NotNull(state, "Неверное значение входного параметра."); GridData model = new GridData(); //model.AddColumn("Action", "Действие", Unit.Pixel(70)); model.AddColumn("Number", "№ акк.", Unit.Pixel(35), align: GridColumnAlign.Right); model.AddColumn("CreationDate", "Дата создания", Unit.Pixel(20)); model.AddColumn("LastActivityDate", "Последняя активность", Unit.Pixel(60)); model.AddColumn("Type", "Тип", Unit.Pixel(100)); model.AddColumn("DisplayName", "Название", Unit.Percentage(40)); model.AddColumn("AdminDisplayName", "ФИО администратора", Unit.Percentage(30)); model.AddColumn("AdminEmail", "E-mail администратора", Unit.Pixel(100)); model.AddColumn("Phone", "Телефон", Unit.Pixel(100)); model.AddColumn("PromoCode", "Промокод", Unit.Pixel(60)); model.AddColumn("PrepaymentSum", "Неизрасх. аванс (руб.)", Unit.Pixel(67), align: GridColumnAlign.Right); model.AddColumn("CurrentConfiguration", "Текущая конфигурация", Unit.Percentage(30)); model.AddColumn("DBServerName", "Сервер БД", Unit.Pixel(65)); model.AddColumn("DBName", "БД", Unit.Pixel(90)); model.AddColumn("Id", "", Unit.Pixel(0), GridCellStyle.Hidden); model.State = state; var clientList = clientRepository.GetFilteredList(state); foreach (var client in clientList) { var actions = new GridActionCell("Action"); actions.AddAction("Заблокировать", "block_link"); var currentConfigurationName = ""; var currentServiceSet = client.ServiceSets.Where(x => x.IsCurrent).FirstOrDefault(); if (currentServiceSet != null) { currentConfigurationName = currentServiceSet.Configuration.Name; } GridRowStyle style = GridRowStyle.Normal; // не заходили больше недели if ((DateTime.Now - client.LastActivityDate).Days > 7) { style = GridRowStyle.Error; } // зарегистрированы сегодня if (client.CreationDate.Date == DateTime.Today) { style = GridRowStyle.Success; } model.AddRow(new GridRow( //actions, new GridLabelCell("Number") { Value = client.Number.ForDisplay() }, new GridLabelCell("CreationDate") { Value = client.CreationDate.ToShortDateString() + " " + client.CreationDate.ToShortTimeString() }, new GridLabelCell("LastActivityDate") { Value = client.LastActivityDate.ToShortDateString() + " " + client.LastActivityDate.ToShortTimeString() }, new GridLabelCell("Type") { Value = client.Type.GetDisplayName() }, new GridLabelCell("DisplayName") { Value = client.DisplayName }, new GridLabelCell("AdminDisplayName") { Value = client.Users.First(x => x.IsClientAdmin).DisplayName }, new GridLabelCell("AdminEmail") { Value = client.AdminEmail }, new GridLabelCell("Phone") { Value = client.Phone }, new GridLabelCell("PromoCode") { Value = client.PromoCode }, new GridLabelCell("PrepaymentSum") { Value = client.PrepaymentSum.ForDisplay() }, new GridLabelCell("CurrentConfiguration") { Value = currentConfigurationName }, new GridLabelCell("DBServerName") { Value = client.DBServerName }, new GridLabelCell("DBName") { Value = client.DBName }, new GridHiddenCell("Id") { Value = client.Id.ToString() } ) { Style = style }); } return(model); }
public GridRow(GridRowStyle style, string[] values) { Style = style; Values.AddRange(values); }
public GridRow(string[] values) { Style = GridRowStyle.Normal; Values.AddRange(values); }
public GridRow() { Style = GridRowStyle.Normal; }
public void AddRow(GridRowStyle style, string[] values) { mRows.Add(new GridRow(style, values)); Invalidate(); }