forked from xuxiaowei007/FoxOne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToolbar.cs
81 lines (73 loc) · 2.05 KB
/
Toolbar.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using FoxOne.Business;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FoxOne.Core;
using System.ComponentModel;
using System.Web.Script.Serialization;
using FoxOne.Data.Mapping;
using FoxOne.Business.Security;
namespace FoxOne.Controls
{
/// <summary>
/// 工具栏组件
/// </summary>
[DisplayName("工具栏组件")]
public class Toolbar : PageControlBase,ITargetId,IAuthorityComponent
{
public Toolbar()
{
Buttons = new List<Button>();
CssClass = "toolbar";
}
/// <summary>
/// 工具栏按钮
/// </summary>
[DisplayName("工具栏按钮")]
public IList<Button> Buttons { get; set; }
public void SetTarget(IList<IControl> components)
{
}
public override string Render()
{
if (Buttons.Count(o=>o.Visiable)==0)
{
return string.Empty;
}
return base.Render();
}
public override string RenderContent()
{
if (Buttons.IsNullOrEmpty())
{
throw new FoxOneException("Buttons不能为空");
}
StringBuilder sb = new StringBuilder();
foreach (var button in Buttons.OrderBy(o=>o.Rank))
{
sb.AppendLine(button.Render());
}
return sb.ToString();
}
public void Authority(IDictionary<string, UISecurityBehaviour> behaviour)
{
foreach (var button in Buttons)
{
if (behaviour.Keys.Contains(button.Id))
{
button.Visiable = !behaviour[button.Id].IsInvisible;
}
}
}
/// <summary>
/// 目标控件ID
/// </summary>
[DisplayName("目标控件ID")]
public string TargetControlId
{
get;
set;
}
}
}