| | |
| | | using DevExpress.XtraBars; |
| | | using DevExpress.XtraBars.Navigation; |
| | | using DevExpress.XtraBars.Navigation; |
| | | using DevExpress.XtraTab; |
| | | using GsDxApp.Properties; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Reflection; |
| | | using System.Resources; |
| | | using System.Text; |
| | | using System.Windows.Forms; |
| | | using Gs.DevApp.ToolBox; |
| | | using Newtonsoft.Json; |
| | | using Gs.DevApp.Models; |
| | | using Newtonsoft.Json.Linq; |
| | | |
| | | namespace Gs.DevApp.DevFrm |
| | | { |
| | | public partial class FrmMain : DevExpress.XtraBars.FluentDesignSystem.FluentDesignForm |
| | | { |
| | | private static Dictionary<string, XtraTabPage> TabPageDic = new Dictionary<string, XtraTabPage>(); |
| | | //private StatusStrip statusStrip; |
| | | //private ToolStripStatusLabel statusLabel; |
| | | public FrmMain() |
| | | { |
| | | InitializeComponent(); |
| | | getInit(); |
| | | this.Text = this.Text = System.Configuration.ConfigurationSettings.AppSettings.Get("ProductName").ToString(); |
| | | getTree(); |
| | | } |
| | | |
| | | private void getInit() |
| | | private void getTree() |
| | | { |
| | | string filePath = @"D:\GsMes\GsDXApp\GsDxApp\bin\Debug\menu.txt"; |
| | | string _strJson = File.ReadAllText(filePath); |
| | | toolTime.Text = "登录时间"+ LoginInfoModel.CurrentUser.LoginTime; |
| | | var _obj = new |
| | | { |
| | | rtnCode = 1, |
| | | rtnData = new { list = new[] { new { guid = "", name = "", pah= "", ico = "", list = new[] { new { guid = "", name = "", pah= "", ico = "" } } } } }, |
| | | rtnMsg = "" |
| | | userGuid = LoginInfoModel.CurrentUser.LoginUserGuid, |
| | | orgGuid = LoginInfoModel.CurrentUser.LoginOrgGuid, |
| | | }; |
| | | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain)); |
| | | _obj = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(_strJson, _obj); |
| | | foreach (dynamic _dy in _obj.rtnData.list) |
| | | string strJson = ""; |
| | | try |
| | | { |
| | | AccordionControlElement _grp = this.acrd.AddGroup(); |
| | | _grp.ImageOptions.Image = Utility.GetImgFromResource(_dy.ico); |
| | | _grp.Name = Guid.NewGuid().ToString(); |
| | | _grp.Style = DevExpress.XtraBars.Navigation.ElementStyle.Group; |
| | | _grp.Text = _dy.name; |
| | | _grp.Click += _grp_Click; |
| | | foreach (dynamic _dy2 in _dy.list) |
| | | strJson = UtilityHelper.HttpPost("", "User/GetUserInfo", JsonConvert.SerializeObject(_obj)); |
| | | JObject _job = JObject.Parse(strJson); |
| | | string rtnCode = _job["rtnCode"].ToString(); |
| | | string rtnMsg = _job["rtnMsg"].ToString(); |
| | | barMsg.Caption = rtnMsg; |
| | | JArray array = new JArray(); |
| | | var d = _job["rtnData"]["list"]; |
| | | foreach (var a in d) |
| | | { |
| | | AccordionControlElement _itm = this.acrd.AddItem(); |
| | | _itm.Name = Guid.NewGuid().ToString(); |
| | | _itm.ImageOptions.Image =Utility.GetImgFromResource(_dy2.ico); |
| | | _itm.Style = DevExpress.XtraBars.Navigation.ElementStyle.Item; |
| | | _itm.Text = _dy2.name; |
| | | _itm.Appearance.Normal.Font = new System.Drawing.Font("Tahoma", 10F); |
| | | _itm.Tag = _dy2.pah; |
| | | _itm.Click += _grp_Click; |
| | | _grp.Elements.Add(_itm); |
| | | }; |
| | | array.Add(a); |
| | | } |
| | | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMain)); |
| | | DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString()); |
| | | DataRow[] drGrp = dt.Select("upGuid is null"); |
| | | foreach (DataRow _dy in drGrp) |
| | | { |
| | | AccordionControlElement _grp = this.acrd.AddGroup(); |
| | | _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.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.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.Click += _grp_Click; |
| | | _grp.Elements.Add(_itm); |
| | | }; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ToolBox.MsgHelper.ShowError("提示:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | |
| | | if (_acd.Elements.Count > 0) return; |
| | | string tabPageName = _acd.Name + "_page"; |
| | | string tabText = _acd.Text; |
| | | //string newFormName = "GsDxApp.test.ToolbarForm1"; |
| | | string newFormName = _acd.Tag.ToString(); |
| | | AddTabpage(tab, tabPageName, tabText, newFormName); |
| | | Image imgIcon= _acd.Image; |
| | | AddTabpage(tab, tabPageName, tabText, newFormName, imgIcon); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <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) |
| | | public void AddTabpage(XtraTabControl tabControl, string tabPageName, string tabText, string newFormName,Image imgIcon) |
| | | { |
| | | if (IsTabpageExsit(tabControl, tabPageName)) |
| | | { |
| | |
| | | newPage.Name = tabPageName; |
| | | newPage.Text = tabText; |
| | | newPage.Tooltip = (tabText + ":" + tabPageName); |
| | | newPage.Controls.Add(AddNewForm(newFormName)); |
| | | tabControl.TabPages.Add(newPage); |
| | | TabPageDic.Add(tabPageName, newPage); |
| | | tabControl.SelectedTabPage = newPage; |
| | | newPage.ImageOptions.Image = imgIcon; |
| | | if (AddNewForm(newFormName) != null) { |
| | | newPage.Controls.Add(AddNewForm(newFormName)); |
| | | tabControl.TabPages.Add(newPage); |
| | | TabPageDic.Add(tabPageName, newPage); |
| | | tabControl.SelectedTabPage = newPage; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | private Form AddNewForm(string formName) |
| | | { |
| | | 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.Parent = ((XtraTabControl)sender).SelectedTabPage; |
| | |
| | | newForm.Visible = true; |
| | | return newForm; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |