private void LoadTemplates(XmlNode argNode, Screen argScr) { Debug.Assert(null != argNode && null != argScr); XmlNodeList templateList = argNode.SelectNodes(UIServiceCfgDefines.s_templateNode); ResourceDataTemplate item = null; foreach (XmlNode node in templateList) { item = LoadTemplate(node); if (null != item) { argScr.Templates.Add(item); } } }
public bool Initialize(ResourceDataTemplate argTemplate) { Debug.Assert(null != argTemplate && null != m_tableRow); try { HtmlElement tdElement = null; ListItemCellElement cellElement = null; foreach (var item in argTemplate.TDItems) { tdElement = m_tableRow.Document.CreateElement("td"); if (null == tdElement) { continue; } cellElement = new ListItemCellElement(tdElement); if (cellElement.Open(item.ClassName, item.StyleValue, item.InnerHtml)) { m_listCells.Add(cellElement); m_tableRow.AppendChild(tdElement); } else { cellElement.Dispose(); } tdElement = null; cellElement = null; } } catch (System.Exception ex) { Log.UIService.LogError("Failed to initlialize table row element", ex); return(false); } return(true); }
private ResourceDataTemplate LoadTemplate(XmlNode argNode) { Debug.Assert(null != argNode); XmlAttribute nameAttri = argNode.Attributes[UIServiceCfgDefines.s_nameAttri]; if (null == nameAttri || string.IsNullOrEmpty(nameAttri.Value)) { return(null); } XmlAttribute classAttri = null; XmlAttribute styleAttri = null; //XmlAttribute bindAttri = null; XmlNodeList listTd = argNode.SelectNodes("*"); ResourceDataTemplate template = new ResourceDataTemplate(nameAttri.Value); //string bindElement = null; //string bindProp = null; //BindingMode mode = BindingMode.OneWay; foreach (XmlNode node in listTd) { if (node.NodeType != XmlNodeType.Element) { continue; } if (!string.Equals(node.Name, "td", StringComparison.OrdinalIgnoreCase)) { continue; } if (!node.HasChildNodes) { continue; } classAttri = node.Attributes["class"]; styleAttri = node.Attributes["style"]; //bindAttri = node.Attributes["content"]; //if ( null == bindAttri || // string.IsNullOrEmpty(bindAttri.Value) ) //{ // continue; //} //bindValue = HtmlScreenElementBase.ParseBindValue(bindAttri.Value, ref bindElement, ref bindProp, ref mode); //if (string.IsNullOrEmpty(bindValue)) //{ // continue; //} template.TDItems.Add(new DataTemplateTDItem() { ClassName = null != classAttri ? classAttri.Value : null, StyleValue = null != styleAttri ? styleAttri.Value : null, InnerHtml = node.InnerXml }); } return(template); }