| | |
| | | using DevExpress.XtraBars.Docking2010; |
| | | using DevExpress.XtraEditors.ButtonPanel; |
| | | using System.Collections.Generic; |
| | | using DevExpress.XtraBars.Ribbon; |
| | | using Yw.Dto; |
| | | using Yw.WinFrmUI; |
| | | using Yw.WinFrmUI.Page; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public static class PageAuthExtensions |
| | | { |
| | | /// <summary> |
| | | /// 验证权限 |
| | | /// </summary> |
| | | public static void VerifyAuth(this PageAuthHaveTree auth, RibbonControl panel) |
| | | { |
| | | if (auth == null || auth.Children == null || auth.Children.Count < 1) |
| | | return; |
| | | if (panel == null || panel.Items == null || panel.Items.Count < 1) |
| | | return; |
| | | |
| | | for (int i = 0; i < panel.Items.Count; i++) |
| | | { |
| | | var item = panel.Items[i]; |
| | | if (item.Tag != null && !string.IsNullOrEmpty(item.Tag.ToString())) |
| | | { |
| | | var authItem = auth.Children.Find(x => x.Permission == item.Tag.ToString()); |
| | | if (authItem != null) |
| | | { |
| | | item.Visibility = authItem.Have ? DevExpress.XtraBars.BarItemVisibility.Always : DevExpress.XtraBars.BarItemVisibility.Never; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 验证权限 |
| | | /// </summary> |
| | | public static void VerifyPeekForm(this MenuAuthorityHaveTreeDto auth, List<TilePeekItem> peekItems) |
| | | { |
| | | if (auth == null || auth.Children == null || auth.Children.Count < 1) |
| | | return; |
| | | if (peekItems == null || peekItems.Count < 1) |
| | | return; |
| | | |
| | | peekItems.ForEach(item => |
| | | { |
| | | if (item.Tag != null && !string.IsNullOrEmpty(item.Tag.ToString())) |
| | | { |
| | | var authItem = auth.Children.Find(x => x.Permission == item.Tag.ToString()); |
| | | if (item != null) |
| | | { |
| | | item.Visibility = authItem.Have; |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |