/// <summary> /// 获取App功能 /// </summary> public void GetApps(List <UserAppsTable> type1List, List <UserAppsTable> type2List, List <UserAppsTable> type3List, List <UserAppsTable> type4List) { PADDING margin1 = new PADDING(5, 5, 5, 5); PADDING padding = new PADDING(5, 5, 5, 5); PADDING margin2 = new PADDING(5, 5, 5, 5); Dictionary <String, FoldSubMenuA> menuCaches = new Dictionary <String, FoldSubMenuA>(); if (type1List != null && type1List.Count > 0) { int num = type1List.Count; FoldSubMenuA menuItemAccount = new FoldSubMenuA(); m_foldMenu.AddSubMenu(menuItemAccount); menuItemAccount.Name = "TYPE1"; menuCaches[menuItemAccount.Name] = menuItemAccount; menuItemAccount.TitleLabel.Text = "员工管理(" + num + ")"; menuItemAccount.ShrinkButton.Text = "收缩"; menuItemAccount.ShrinkButton.Name = "shrink"; menuItemAccount.LayoutDiv.Margin = margin1; menuItemAccount.Padding = padding; menuItemAccount.Margin = margin2; menuItemAccount.TitleLabel.Size = new SIZE(150, 20); menuItemAccount.ShrinkButton.Size = new SIZE(80, 20); foreach (UserAppsTable userApp in type1List) { FoldMenuItemA menuButtonAddUser = new FoldMenuItemA(); menuButtonAddUser.Text = userApp.m_appName; menuButtonAddUser.Name = userApp.m_appID; menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'"; menuButtonAddUser.Margin = margin2; menuItemAccount.LayoutDiv.AddControl(menuButtonAddUser); } } if (type2List != null && type2List.Count > 0) { int num = type2List.Count; FoldSubMenuA menuItemFundTrade = new FoldSubMenuA(); m_foldMenu.AddSubMenu(menuItemFundTrade); menuItemFundTrade.Name = "TYPE2"; menuCaches[menuItemFundTrade.Name] = menuItemFundTrade; menuItemFundTrade.TitleLabel.Text = "项目管理(" + num + ")"; menuItemFundTrade.ShrinkButton.Text = "收缩"; menuItemFundTrade.ShrinkButton.Name = "shrink"; menuItemFundTrade.LayoutDiv.Margin = margin1; menuItemFundTrade.Padding = padding; menuItemFundTrade.Margin = margin2; menuItemFundTrade.TitleLabel.Size = new SIZE(150, 20); menuItemFundTrade.ShrinkButton.Size = new SIZE(80, 20); foreach (UserAppsTable userApp in type2List) { FoldMenuItemA menuButtonAddUser = new FoldMenuItemA(); menuButtonAddUser.Text = userApp.m_appName; menuButtonAddUser.Name = userApp.m_appID; menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'"; menuButtonAddUser.Margin = margin2; menuItemFundTrade.LayoutDiv.AddControl(menuButtonAddUser); } } if (type3List != null && type3List.Count > 0) { int num = type3List.Count; FoldSubMenuA menuItemSystem = new FoldSubMenuA(); menuItemSystem.Name = "TYPE3"; menuCaches[menuItemSystem.Name] = menuItemSystem; m_foldMenu.AddSubMenu(menuItemSystem); menuItemSystem.TitleLabel.Text = "个人管理(" + num + ")"; menuItemSystem.ShrinkButton.Text = "收缩"; menuItemSystem.ShrinkButton.Name = "shrink"; menuItemSystem.LayoutDiv.Margin = margin1; menuItemSystem.Padding = padding; menuItemSystem.Margin = margin2; menuItemSystem.TitleLabel.Size = new SIZE(150, 20); menuItemSystem.ShrinkButton.Size = new SIZE(80, 20); foreach (UserAppsTable userApp in type3List) { FoldMenuItemA menuButtonAddUser = new FoldMenuItemA(); menuButtonAddUser.Text = userApp.m_appName; menuButtonAddUser.Name = userApp.m_appID; menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'"; menuButtonAddUser.Margin = margin2; menuItemSystem.LayoutDiv.AddControl(menuButtonAddUser); } } if (type4List != null && type4List.Count > 0) { int num = type4List.Count; FoldSubMenuA menuItemRisk = new FoldSubMenuA(); menuItemRisk.Name = "TYPE4"; menuCaches[menuItemRisk.Name] = menuItemRisk; m_foldMenu.AddSubMenu(menuItemRisk); menuItemRisk.TitleLabel.Text = "情报管理(" + num + ")"; menuItemRisk.ShrinkButton.Text = "收缩"; menuItemRisk.ShrinkButton.Name = "shrink"; menuItemRisk.LayoutDiv.Margin = margin1; menuItemRisk.Padding = padding; menuItemRisk.Margin = margin2; menuItemRisk.TitleLabel.Size = new SIZE(150, 20); menuItemRisk.ShrinkButton.Size = new SIZE(80, 20); foreach (UserAppsTable userApp in type4List) { FoldMenuItemA menuButtonAddUser = new FoldMenuItemA(); menuButtonAddUser.Text = userApp.m_appName; menuButtonAddUser.Name = userApp.m_appID; menuButtonAddUser.BackImage = "file='images\\" + userApp.m_appID + ".jpg'"; menuButtonAddUser.Margin = margin2; menuItemRisk.LayoutDiv.AddControl(menuButtonAddUser); } } //读取布局信息 UserCookie cookie = new UserCookie(); cookie.m_key = "MENULAYOUT" + DataCenter.UserID.ToString(); cookie.m_userID = DataCenter.UserID; if (DataCenter.UserCookieService.GetCookie(cookie.m_key, ref cookie) > 0) { String value = cookie.m_value; String[] strs = value.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); int strsSize = strs.Length; for (int i = 0; i < strsSize; i++) { String[] subStrs = strs[i].Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); String foldName = subStrs[0]; bool visible = subStrs[1] == "1"; if (menuCaches.ContainsKey(foldName)) { FoldSubMenuA foldSubMenu = menuCaches[foldName]; foldSubMenu.LayoutDiv.Visible = visible; int subStrsSize = subStrs.Length; int orderNum = 0; for (int j = 2; j < subStrsSize; j++) { List <ControlA> subControls = foldSubMenu.LayoutDiv.m_controls; int subControlsSize = subControls.Count; for (int m = 0; m < subControlsSize; m++) { ControlA subControl = subControls[m]; if (subControl.Name == subStrs[j]) { (subControl as FoldMenuItemA).OrderNum = orderNum; orderNum++; break; } } } foldSubMenu.LayoutDiv.m_controls.Sort(new FoldMenuItemOrderNumCompare()); } } } menuCaches.Clear(); m_foldMenu.Update(); Native.Update(); ControlPaintEvent paintLayoutEvent = new ControlPaintEvent(PaintLayoutDiv); m_foldMenu.RegisterEvent(paintLayoutEvent, EVENTID.PAINT); }
void ControlB_Click (object sender, EventArgs e) { focus ^= true; if (focus && c == null) { c = new ControlA (); c.Location = new Point (0, 0); c.Size = new Size (Width, Height / 2); FindForm ().Controls.Add (c); c.BringToFront (); } else if (!focus && c != null) { FindForm ().Controls.Remove (c); c = null; } Invalidate (); }
/// <summary> /// 设置参数 /// </summary> private void SetParameters() { List <ControlA> controls = m_window.GetControls(); List <LabelA> labels = new List <LabelA>(); List <SpinA> spins = new List <SpinA>(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { ControlA control = controls[i]; LabelA label = control as LabelA; SpinA spin = control as SpinA; if (label != null) { labels.Add(label); } else if (spin != null) { spins.Add(spin); } } int labelsSize = labels.Count; String newParameters = ""; for (int i = 0; i < labelsSize; i++) { newParameters += labels[i].Text + ",0,0," + spins[i].Value.ToString(); newParameters += ";"; } labels.Clear(); spins.Clear(); m_indicator.Clear(); m_indicator.SetSourceField(KeyFields.CLOSE, KeyFields.CLOSE_INDEX); m_indicator.SetSourceField(KeyFields.HIGH, KeyFields.HIGH_INDEX); m_indicator.SetSourceField(KeyFields.LOW, KeyFields.LOW_INDEX); m_indicator.SetSourceField(KeyFields.OPEN, KeyFields.OPEN_INDEX); m_indicator.SetSourceField(KeyFields.VOL, KeyFields.VOL_INDEX); m_indicator.SetSourceField(KeyFields.AMOUNT, KeyFields.AMOUNT_INDEX); m_indicator.SetSourceField(KeyFields.CLOSE.Substring(0, 1), KeyFields.CLOSE_INDEX); m_indicator.SetSourceField(KeyFields.HIGH.Substring(0, 1), KeyFields.HIGH_INDEX); m_indicator.SetSourceField(KeyFields.LOW.Substring(0, 1), KeyFields.LOW_INDEX); m_indicator.SetSourceField(KeyFields.OPEN.Substring(0, 1), KeyFields.OPEN_INDEX); m_indicator.SetSourceField(KeyFields.VOL.Substring(0, 1), KeyFields.VOL_INDEX); m_indicator.SetSourceField(KeyFields.AMOUNT.Substring(0, 1), KeyFields.AMOUNT_INDEX); IndicatorData indicatorData = m_indicator.Tag as IndicatorData; indicatorData.m_parameters = newParameters; String constValue = ""; if (newParameters != null && newParameters.Length > 0) { String[] strs = newParameters.Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int strsSize = strs.Length; for (int i = 0; i < strsSize; i++) { String str = strs[i]; String[] strs2 = str.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); constValue += "const " + strs2[0] + ":" + strs2[3] + ";"; } } m_indicator.Script = constValue + indicatorData.m_script; m_indicator.OnCalculate(0); if (m_indicator.AttachVScale == AttachVScale.Left) { //m_indicator.Div.TitleBar.Text = m_indicator.Title; } m_chart.Chart.Update(); m_chart.Chart.Invalidate(); }
/// <summary> /// 证券列表窗体关闭事件 /// </summary> /// <param name="sender">调用者</param> /// <param name="cancel">是否取消</param> private void SecurityListWindowClosed(object sender, ref bool cancel) { ControlA control = sender as ControlA; OnSecurityListWindowClosed(control.Tag as SecurityList, ref cancel); }
/// <summary> /// 重绘背景 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="clipRect">裁剪区域</param> public override void OnPaintBackground(CPaint paint, RECT clipRect) { int width = Width, height = Height; int mw = width / 2, mh = height / 2; RECT drawRect = new RECT(0, 0, width, height); if (m_isClose) { long lineColor = CDraw.PCOLORS_LINECOLOR; RECT ellipseRect = new RECT(1, 1, width - 2, height - 2); paint.FillEllipse(CDraw.PCOLORS_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; } ControlA parent = Parent; if (parent != null) { TabControlA tabControl = parent as TabControlA; if (tabControl != null) { cornerRadius = 0; } } paint.DrawGradientRect(CDraw.PCOLORS_BACKCOLOR, CDraw.PCOLORS_BACKCOLOR2, drawRect, cornerRadius, 90); paint.DrawRoundRect(CDraw.PCOLORS_LINECOLOR3, 1, 0, drawRect, cornerRadius); } if (m_arrowType > 0) { POINT[] points = new POINT[3]; int ts = Math.Min(mw, mh) / 2; switch (m_arrowType) { //向左 case 1: points[0] = new POINT(mw - ts, mh); points[1] = new POINT(mw + ts, mh - ts); points[2] = new POINT(mw + ts, mh + ts); break; //向右 case 2: points[0] = new POINT(mw + ts, mh); points[1] = new POINT(mw - ts, mh - ts); points[2] = new POINT(mw - ts, mh + ts); break; //向上 case 3: points[0] = new POINT(mw, mh - ts); points[1] = new POINT(mw - ts, mh + ts); points[2] = new POINT(mw + ts, mh + ts); break; //向下 case 4: points[0] = new POINT(mw, mh + ts); points[1] = new POINT(mw - ts, mh - ts); points[2] = new POINT(mw + ts, mh - ts); break; } paint.FillPolygon(CDraw.PCOLORS_FORECOLOR, points); } //绘制选中效果 if (paint.SupportTransparent()) { INativeBase native = Native; if (Selected) { paint.FillRect(CDraw.PCOLORS_BACKCOLOR2, drawRect); } else if (this == native.PushedControl) { paint.FillRect(CDraw.PCOLORS_BACKCOLOR6, drawRect); } else if (this == native.HoveredControl) { paint.FillRect(CDraw.PCOLORS_BACKCOLOR5, drawRect); } } }
/// <summary> /// 创建内部控件 /// </summary> /// <param name="parent">父控件</param> /// <param name="clsid">控件标识</param> /// <returns>内部控件</returns> public override ControlA CreateInternalControl(ControlA parent, String clsid) { //日历控件 CalendarA calendar = parent as CalendarA; if (calendar != null) { if (clsid == "datetitle") { return(new DateTitle(calendar)); } else if (clsid == "headdiv") { HeadDiv headDiv = new HeadDiv(calendar); headDiv.Width = parent.Width; headDiv.Dock = DockStyleA.Top; return(headDiv); } else if (clsid == "lastbutton") { return(new ArrowButton(calendar)); } else if (clsid == "nextbutton") { ArrowButton nextBtn = new ArrowButton(calendar); nextBtn.ToLast = false; return(nextBtn); } } //分割层 SplitLayoutDivA splitLayoutDiv = parent as SplitLayoutDivA; if (splitLayoutDiv != null) { if (clsid == "splitter") { ButtonA splitter = new ButtonA(); splitter.BackColor = CDraw.PCOLORS_BACKCOLOR; splitter.Size = new SIZE(5, 5); return(splitter); } } //滚动条 ScrollBarA scrollBar = parent as ScrollBarA; if (scrollBar != null) { scrollBar.BackColor = COLOR.EMPTY; if (clsid == "addbutton") { RibbonButton addButton = new RibbonButton(); addButton.Size = new SIZE(15, 15); if (scrollBar is HScrollBarA) { addButton.ArrowType = 2; } else if (scrollBar is VScrollBarA) { addButton.ArrowType = 4; } return(addButton); } else if (clsid == "backbutton") { ButtonA backButton = new ButtonA(); return(backButton); } else if (clsid == "scrollbutton") { ButtonA scrollButton = new ButtonA(); scrollButton.AllowDrag = true; scrollButton.BackColor = CDraw.PCOLORS_BACKCOLOR; scrollButton.BorderColor = CDraw.PCOLORS_LINECOLOR3; return(scrollButton); } else if (clsid == "reducebutton") { RibbonButton reduceButton = new RibbonButton(); reduceButton.Size = new SIZE(15, 15); if (scrollBar is HScrollBarA) { reduceButton.ArrowType = 1; } else if (scrollBar is VScrollBarA) { reduceButton.ArrowType = 3; } return(reduceButton); } } //页夹 TabPageA tabPage = parent as TabPageA; if (tabPage != null) { if (clsid == "headerbutton") { RibbonButton button = new RibbonButton(); button.AllowDrag = true; SIZE size = new SIZE(100, 20); button.Size = size; return(button); } } //下拉列表 ComboBoxA comboBox = parent as ComboBoxA; if (comboBox != null) { if (clsid == "dropdownbutton") { RibbonButton dropDownButton = new RibbonButton(); dropDownButton.ArrowType = 4; dropDownButton.DisplayOffset = false; int width = comboBox.Width; int height = comboBox.Height; POINT location = new POINT(width - 20, 0); dropDownButton.Location = location; SIZE size = new SIZE(20, height); dropDownButton.Size = size; return(dropDownButton); } else if (clsid == "dropdownmenu") { ComboBoxMenu comboBoxMenu = new ComboBoxMenu(); comboBoxMenu.ComboBox = comboBox; comboBoxMenu.Popup = true; SIZE size = new SIZE(100, 200); comboBoxMenu.Size = size; return(comboBoxMenu); } } //日期选择 DateTimePickerA datePicker = parent as DateTimePickerA; if (datePicker != null) { if (clsid == "dropdownbutton") { RibbonButton dropDownButton = new RibbonButton(); dropDownButton.ArrowType = 4; dropDownButton.DisplayOffset = false; int width = datePicker.Width; int height = datePicker.Height; POINT location = new POINT(width - 16, 0); dropDownButton.Location = location; SIZE size = new SIZE(16, height); dropDownButton.Size = size; return(dropDownButton); } else if (clsid == "dropdownmenu") { MenuA dropDownMenu = new MenuA(); dropDownMenu.Padding = new PADDING(1); dropDownMenu.Popup = true; SIZE size = new SIZE(200, 200); dropDownMenu.Size = size; return(dropDownMenu); } } //数字选择 SpinA spin = parent as SpinA; if (spin != null) { if (clsid == "downbutton") { RibbonButton downButton = new RibbonButton(); downButton.ArrowType = 4; downButton.DisplayOffset = false; SIZE size = new SIZE(16, 16); downButton.Size = size; return(downButton); } else if (clsid == "upbutton") { RibbonButton upButton = new RibbonButton(); upButton.ArrowType = 3; upButton.DisplayOffset = false; SIZE size = new SIZE(16, 16); upButton.Size = size; return(upButton); } } //容器层 DivA div = parent as DivA; if (div != null) { if (clsid == "hscrollbar") { HScrollBarA hScrollBar = new HScrollBarA(); hScrollBar.Visible = false; hScrollBar.Size = new SIZE(15, 15); return(hScrollBar); } else if (clsid == "vscrollbar") { VScrollBarA vScrollBar = new VScrollBarA(); vScrollBar.Visible = false; vScrollBar.Size = new SIZE(15, 15); return(vScrollBar); } } //表格 GridA grid = parent as GridA; if (grid != null) { if (clsid == "edittextbox") { TextBoxA textBox = new TextBoxA(); textBox.BackColor = CDraw.PCOLORS_BACKCOLOR; return(textBox); } } return(base.CreateInternalControl(parent, clsid)); }
/// <summary> /// 是否包含控件 /// </summary> /// <param name="control">控件</param> /// <returns>是否包含</returns> public override bool ContainsControl(ControlA control) { return(false); }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { ControlA.Focus(); }
/// <summary> /// 指标列表窗体关闭事件 /// </summary> /// <param name="sender">调用者</param> /// <param name="cancel">是否取消</param> public void IndicatorListWindowClosed(object sender, ref bool cancel) { ControlA control = sender as ControlA; OnIndicatorListWindowClosed(control.Tag as IndicatorList, ref cancel); }