| | |
| | | public FrmMain() |
| | | { |
| | | InitializeComponent(); |
| | | this.Text = this.Text = System.Configuration.ConfigurationSettings.AppSettings.Get("ProductName").ToString(); |
| | | this.Text = System.Configuration.ConfigurationSettings.AppSettings.Get("ProductName").ToString(); |
| | | tab.CloseButtonClick += Tab_CloseButtonClick; |
| | | getTree(); |
| | | } |
| | | |
| | | private void Tab_CloseButtonClick(object sender, EventArgs e) |
| | | { |
| | | RemoveTabPage(tab,e); |
| | | } |
| | | |
| | | private void getTree() |
| | | { |
| | | toolTime.Text = "登录时间"+ LoginInfoModel.CurrentUser.LoginTime; |
| | | toolTime.Text = "登录时间" + LoginInfoModel.CurrentUser.LoginTime; |
| | | var _obj = new |
| | | { |
| | | userGuid = LoginInfoModel.CurrentUser.LoginUserGuid, |
| | |
| | | string strJson = ""; |
| | | try |
| | | { |
| | | strJson = UtilityHelper.HttpPost("", "User/GetUserInfo", JsonConvert.SerializeObject(_obj)); |
| | | strJson = UtilityHelper.HttpPost("", "User/GetUserLoginInfo", JsonConvert.SerializeObject(_obj)); |
| | | JObject _job = JObject.Parse(strJson); |
| | | string rtnCode = _job["rtnCode"].ToString(); |
| | | string rtnMsg = _job["rtnMsg"].ToString(); |
| | |
| | | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain)); |
| | | DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString()); |
| | | DataRow[] drGrp = dt.Select("upGuid is null"); |
| | | int idx = 0; |
| | | foreach (DataRow _dy in drGrp) |
| | | { |
| | | AccordionControlElement _grp = this.acrd.AddGroup(); |
| | | _grp.ImageOptions.Image = UtilityHelper.GetImgFromResource(_dy["icon"].ToString(),1); |
| | | _grp.ImageOptions.Image = UtilityHelper.GetImgFromResource(_dy["icon"].ToString(), 1); |
| | | _grp.Name = _dy["guid"].ToString(); |
| | | _grp.Style = DevExpress.XtraBars.Navigation.ElementStyle.Group; |
| | | _grp.Text = _dy["name"].ToString(); |
| | | _grp.Tag = _dy["fromPath"].ToString(); |
| | | _grp.Tag = _dy["formPath"].ToString();//存路径,类名 |
| | | _grp.Click += _grp_Click; |
| | | DataRow[] drItem = dt.Select("upGuid='" + _dy["guid"].ToString() + "'"); |
| | | foreach (DataRow _dy2 in drItem) |
| | | { |
| | | AccordionControlElement _itm = this.acrd.AddItem(); |
| | | _itm.ImageOptions.Image = UtilityHelper.GetImgFromResource(_dy2["icon"].ToString(),2); |
| | | _itm.ImageOptions.Image = UtilityHelper.GetImgFromResource(_dy2["icon"].ToString(), 2); |
| | | _itm.Name = _dy2["guid"].ToString(); |
| | | _itm.Style = DevExpress.XtraBars.Navigation.ElementStyle.Item; |
| | | _itm.Text = _dy2["name"].ToString(); |
| | | _itm.Appearance.Normal.Font = new System.Drawing.Font("Tahoma", 10F); |
| | | _itm.Tag = _dy2["fromPath"].ToString(); |
| | | _itm.Tag = _dy2["formPath"].ToString();//存路径,类名 |
| | | _itm.Click += _grp_Click; |
| | | _grp.Elements.Add(_itm); |
| | | // |
| | | if (idx == 0) { |
| | | string tabPageName = _itm.Name + "_page"; |
| | | string tabText = _itm.Text;//当前选项卡页Text标题 |
| | | string newFormName = _itm.Tag.ToString();//存路径,类名 |
| | | Image imgIcon = _itm.Image; |
| | | AddTabpage(tab, tabPageName, tabText, newFormName, imgIcon); |
| | | } |
| | | idx++; |
| | | // |
| | | }; |
| | | } |
| | | } |
| | |
| | | AccordionControlElement _acd = (AccordionControlElement)sender; |
| | | if (_acd.Elements.Count > 0) return; |
| | | string tabPageName = _acd.Name + "_page"; |
| | | string tabText = _acd.Text; |
| | | string newFormName = _acd.Tag.ToString(); |
| | | Image imgIcon= _acd.Image; |
| | | string tabText = _acd.Text;//当前选项卡页Text标题 |
| | | string newFormName = _acd.Tag.ToString();//存路径,类名 |
| | | Image imgIcon = _acd.Image; |
| | | AddTabpage(tab, tabPageName, tabText, newFormName, imgIcon); |
| | | } |
| | | |
| | |
| | | /// <param name="tabControl">选项卡控件</param> |
| | | /// <param name="tabPageName">当期选项卡页name名称</param> |
| | | /// <param name="tabText">当前选项卡页Text标题</param> |
| | | /// <param name="newFormName">当前选项卡中的新窗体</param> |
| | | public void AddTabpage(XtraTabControl tabControl, string tabPageName, string tabText, string newFormName,Image imgIcon) |
| | | /// <param name="newFormName">当前选项卡中的新窗体路径,类名</param> |
| | | public void AddTabpage(XtraTabControl tabControl, string tabPageName, string tabText, string newFormName, Image imgIcon) |
| | | { |
| | | if (IsTabpageExsit(tabControl, tabPageName)) |
| | | { |
| | |
| | | XtraTabPage newPage = new XtraTabPage(); |
| | | newPage.Name = tabPageName; |
| | | newPage.Text = tabText; |
| | | newPage.Tooltip = (tabText + ":" + tabPageName); |
| | | newPage.Tooltip = newPage.Name; |
| | | newPage.Appearance.Header.Font = (tab.Appearance.Font); |
| | | newPage.ImageOptions.Image = imgIcon; |
| | | if (AddNewForm(newFormName) != null) { |
| | | newPage.Controls.Add(AddNewForm(newFormName)); |
| | | Form fm = AddNewForm(newFormName); |
| | | if (fm != null) |
| | | { |
| | | newPage.Controls.Add(fm); |
| | | tabControl.TabPages.Add(newPage); |
| | | TabPageDic.Add(tabPageName, newPage); |
| | | tabControl.SelectedTabPage = newPage; |
| | |
| | | /// <param name="form">窗体名称</param> |
| | | private Form AddNewForm(string formName) |
| | | { |
| | | Form newForm = (Form)Assembly.GetExecutingAssembly().CreateInstance(formName); |
| | | if (newForm == null) |
| | | try |
| | | { |
| | | Form newForm = (Form)Assembly.GetExecutingAssembly().CreateInstance(formName); |
| | | if (newForm == null) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.ShowError("请检查是否开通了该模块!"); |
| | | return null; |
| | | } |
| | | newForm.FormBorderStyle = FormBorderStyle.None; |
| | | newForm.TopLevel = false; |
| | | newForm.ControlBox = false; |
| | | newForm.Dock = DockStyle.Fill; |
| | | newForm.Visible = true; |
| | | return newForm; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.ShowError("请检查是否开通了该模块!"); |
| | | return null; |
| | | } |
| | | newForm.FormBorderStyle = FormBorderStyle.None; |
| | | newForm.TopLevel = false; |
| | | //newForm.Parent = ((XtraTabControl)sender).SelectedTabPage; |
| | | newForm.ControlBox = false; |
| | | newForm.Dock = DockStyle.Fill; |
| | | newForm.Visible = true; |
| | | return newForm; |
| | | return null; |
| | | } |
| | | } |
| | | } |