/// <summary> /// Constructs a toolbar from its JSON data. /// </summary> private Toolbar BuildToolbarFromData(object data, ToolbarBuildContext context) { JSObject toolbarElement = DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.TOOLBAR); if (CUIUtility.IsNullOrUndefined(toolbarElement)) { throw new ArgumentNullException("No toolbar element was present in the data"); } bool hasJewel = !CUIUtility.IsNullOrUndefined(DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.JEWEL)); Toolbar = new Toolbar( DataNodeWrapper.GetAttribute(toolbarElement, DataNodeWrapper.ID), DataNodeWrapper.GetNodeAttributes(toolbarElement).To <ToolbarProperties>(), this, hasJewel); Toolbar.ClientID = Options.ClientID; Toolbar.UseDataCookie = true; Toolbar.RefreshInternal(); // We need to refresh before we can attach the jewel. if (hasJewel) { Toolbar.AttachAndBuildJewelFromData(data); } // Build the ButtonDocks (the Docks will build their subcontrols). JSObject docks = DataNodeWrapper.GetFirstChildNodeWithName(toolbarElement, DataNodeWrapper.BUTTONDOCKS); JSObject[] dockChildren = DataNodeWrapper.GetNodeChildren(docks); for (int i = 0; i < dockChildren.Length; i++) { ButtonDock dock = BuildButtonDock(dockChildren[i], context); Toolbar.AddChild(dock); } return(Toolbar); }
/// <summary> /// Constructs a toolbar from its JSON data. /// </summary> private Toolbar BuildToolbarFromData(object data, ToolbarBuildContext context) { JSObject toolbarElement = DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.TOOLBAR); if (CUIUtility.IsNullOrUndefined(toolbarElement)) throw new ArgumentNullException("No toolbar element was present in the data"); bool hasJewel = !CUIUtility.IsNullOrUndefined(DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.JEWEL)); Toolbar = new Toolbar( DataNodeWrapper.GetAttribute(toolbarElement, DataNodeWrapper.ID), DataNodeWrapper.GetNodeAttributes(toolbarElement).To<ToolbarProperties>(), this, hasJewel); Toolbar.ClientID = Options.ClientID; Toolbar.UseDataCookie = true; Toolbar.RefreshInternal(); // We need to refresh before we can attach the jewel. if (hasJewel) { Toolbar.AttachAndBuildJewelFromData(data); } // Build the ButtonDocks (the Docks will build their subcontrols). JSObject docks = DataNodeWrapper.GetFirstChildNodeWithName(toolbarElement, DataNodeWrapper.BUTTONDOCKS); JSObject[] dockChildren = DataNodeWrapper.GetNodeChildren(docks); for (int i = 0; i < dockChildren.Length; i++) { ButtonDock dock = BuildButtonDock(dockChildren[i], context); Toolbar.AddChild(dock); } return Toolbar; }