Beispiel #1
0
        internal void Config(WebCommand cmd)
        {
            if (Label != null)
            {
                //这句会同时设置 LabelModified 属性的值。
                cmd.HasLabel(Label);
            }

            if (IsVisible != null) { cmd.IsVisible = IsVisible.Value; }
        }
Beispiel #2
0
        private void AddCommands(WebEntityViewMeta evm, IList<ToolbarItem> toolbar)
        {
            //当不需要忽略命令,或者使用了扩展视图时,都需要加入命令列表。
            if (!this.Option.ignoreCommands || !string.IsNullOrEmpty(this.Option.viewName))
            {
                IEnumerable<WebCommand> commands = evm.Commands;

                //当使用了扩展视图时,只需要显示定制 UI 按钮就行了。
                if (this.Option.ignoreCommands)
                {
                    var customUI = commands.FirstOrDefault(c => c.Name == WebCommandNames.CustomizeUI);
                    if (customUI != null)
                    {
                        commands = new WebCommand[] { customUI };
                    }
                    else
                    {
                        commands = Enumerable.Empty<WebCommand>();
                    }
                }

                foreach (var jsCmd in commands)
                {
                    if (!jsCmd.IsVisible) continue;

                    var ti = new ToolbarItem
                    {
                        command = jsCmd.Name
                    };

                    if (jsCmd.LabelModified)
                    {
                        ti.text = jsCmd.Label;
                    }

                    //自定义属性都直接添加到 toolBarItem 的属性上。
                    foreach (var kv in jsCmd.GetExtendedProperties())
                    {
                        var name = kv.Key;
                        var value = kv.Value;

                        ti.SetProperty(name, value);
                    }

                    toolbar.Add(ti);
                }
            }
        }
Beispiel #3
0
 public static WebCommand HasLabel(this WebCommand meta, string label)
 {
     meta.Label         = label;
     meta.LabelModified = true;
     return(meta);
 }