| | |
| | | using DevExpress.XtraEditors.Controls; |
| | | using DevExpress.XtraTreeList; |
| | | using DevExpress.XtraTreeList.Nodes; |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.XtraEditors.Controls; |
| | | using Gs.DevApp.Entity; |
| | | using Gs.DevApp.ToolBox; |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Drawing; |
| | | using System.Reflection; |
| | | using System.Resources; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace Gs.DevApp.DevFrm.User |
| | |
| | | public SysMenu() |
| | | { |
| | | InitializeComponent(); |
| | | getImg(); |
| | | txt_upGuid.Properties.PopupFormSize = new System.Drawing.Size(txt_upGuid.Width, 300); |
| | | //txt_upGuid.Properties.ImmediatePopup = true; |
| | | txt_upGuid.Properties.TextEditStyle = TextEditStyles.DisableTextEditor; |
| | | this.toolBarMenu1.btnAddClick += ToolBarMenu1_btnAddClick; |
| | | this.toolBarMenu1.btnEdtClick += ToolBarMenu1_btnEdtClick; |
| | |
| | | this.txt_formPath.Enabled = false; |
| | | this.txt_icon.Enabled = false; |
| | | this.txt_formPath.Text = ""; |
| | | this.txt_icon.Text = ""; |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | /// <param name="e"></param> |
| | | private void TlMenu_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e) |
| | | { |
| | | TreeListHitInfo info = tlMenu.CalcHitInfo(e.Location); |
| | | if (info.Node != null) |
| | | { |
| | | TreeListNode clickedNode = this.tlMenu.FocusedNode; |
| | | if (clickedNode.FirstNode == null) |
| | | { |
| | | string rowGuid = clickedNode.GetValue("guid").ToString(); |
| | | getModel(rowGuid, false, 999); |
| | | } |
| | | } |
| | | string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(tlMenu, e, "guid"); |
| | | if (!string.IsNullOrEmpty(rowGuid)) |
| | | getModel(rowGuid, false, 999); |
| | | } |
| | | /// <summary> |
| | | /// 取消事件 |
| | |
| | | { |
| | | return; |
| | | } |
| | | var _obj = new |
| | | { |
| | | guid = rowGuid,//主建 |
| | | }; |
| | | List<string> lst = new List<string>(); |
| | | lst.Add(rowGuid); |
| | | var _obj = lst; |
| | | try |
| | | { |
| | | string strJson = UtilityHelper.HttpPost("", "MenuAction/DeleteModel", JsonConvert.SerializeObject(_obj)); |
| | | ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); |
| | | if (_rtn.rtnCode > 0) { getTree(); } |
| | | if (_rtn.rtnCode > 0) |
| | | { |
| | | UtilityHelper.JumpToTab(xtraTabControl1, 0); |
| | | getTree(); |
| | | } |
| | | ToolBox.MsgHelper.Warning("提示:" + _rtn.rtnMsg); |
| | | } |
| | | catch (Exception ex) |
| | |
| | | txt_name.Focus(); |
| | | return; |
| | | } |
| | | if (string.IsNullOrEmpty(txt_isStatus.Text.Trim()) || txt_isStatus.SelectedIndex == 0) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("菜单状态不能为空!"); |
| | | txt_isStatus.Focus(); |
| | | return; |
| | | } |
| | | string _upGuid = txt_upGuid.EditValue.ToString(); |
| | | if (txt_category.SelectedIndex == 2 && string.IsNullOrEmpty(_upGuid)) |
| | | { |
| | | Gs.DevApp.ToolBox.MsgHelper.Warning("按钮类型必须选择父级菜单!"); |
| | | txt_isStatus.Focus(); |
| | | txt_upGuid.Focus(); |
| | | return; |
| | | } |
| | | var _obj = new |
| | |
| | | upGuid = _upGuid,//上级的主建 |
| | | name = txt_name.Text.Trim(),//名称 |
| | | icon = txt_icon.Text,//菜单图标 |
| | | isStatus = txt_isStatus.SelectedIndex,//状态 |
| | | isStatus = txt_isStatus.Checked,//状态 |
| | | formPath = txt_formPath.Text.Trim(),//窗体路径 |
| | | idx = int.Parse(txt_idx.Value.ToString()),//排序 |
| | | category = txt_category.SelectedIndex,//类型 |
| | |
| | | this.tlMenu.ParentFieldName = "upGuid"; |
| | | this.tlMenu.Tag = "name"; |
| | | this.tlMenu.EndUpdate(); |
| | | this.tlMenu.ExpandAll(); |
| | | // this.tlMenu.ExpandAll(); |
| | | tlMenu.OptionsView.CheckBoxStyle = DevExpress.XtraTreeList.DefaultNodeCheckBoxStyle.Default; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | private void getImg() |
| | | { |
| | | Assembly assembly = Assembly.GetExecutingAssembly(); |
| | | ResourceManager resourceManager = new ResourceManager("Gs.DevApp.Properties.Resources", assembly); |
| | | int i = 0; |
| | | DevExpress.Utils.ImageCollection dicImg = new DevExpress.Utils.ImageCollection(); |
| | | Properties.Resources res = new Properties.Resources(); |
| | | PropertyInfo[] properInfo = res.GetType().GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Instance); |
| | | foreach (PropertyInfo item in properInfo) |
| | | { |
| | | if (item.Name.Contains("_")) |
| | | { |
| | | Image image = resourceManager.GetObject(item.Name) as Image; |
| | | if (image != null) |
| | | { |
| | | dicImg.AddImage(image); |
| | | txt_icon.Properties.Items.Add(new DevExpress.XtraEditors.Controls.ImageComboBoxItem(item.Name, i, i)); |
| | | i++; |
| | | } |
| | | } |
| | | } |
| | | txt_icon.Properties.LargeImages = dicImg; |
| | | txt_icon.Properties.SmallImages = dicImg; |
| | | } |
| | | } |
| | | } |