public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false) { if (rootNode == null) { return; } _xDoc = xDoc; XmlControlHandler.GetDefaultXmlItemAttributes(rootNode, xDoc, this); NowLoading = this; try { _color = ValueParser.StringToColor(XmlGetter.Attribute(rootNode, "Color")); } catch { _color = Color.Black; } for (int i = 0; i < rootNode.ChildNodes.Count; i++) { XmlNode child = rootNode.ChildNodes[i]; if (child.Name.Equals("String")) { _formatItems.Add(new FormatItem(FormatItem.FormatItemType.String, child.InnerText)); } else if (child.Name.Equals("FieldItem")) { String parser = XmlGetter.Attribute(child, "Parser"); if (parser.Length > 0) { string[] args = ValueParser.GetArgs(parser, XmlGetter.Attribute(child, "Args")); _formatItems.Add(new FormatItem(FormatItem.FormatItemType.FieldItem, args)); } else { _formatItems.Add(new FormatItem(FormatItem.FormatItemType.FieldItem)); } } } }
public static void GetDefaultControlAttributes( XmlNode rootNode, XmlDocument document, IXmlComponent xmlComponent, bool refLoad = false, XmlItemInterface.GetRealTimeArgsFunc argFunc = null, XmlItemInterface.GetComponentValueFunc comValueFunc = null) { xmlComponent.Interface = new XmlItemInterface(rootNode, document, xmlComponent); xmlComponent.Interface.GetRealTimeArgCallback = argFunc; xmlComponent.Interface.GetComponentValueFuncCallBack = comValueFunc; if (refLoad == false) { String refPath = XmlGetter.Attribute(rootNode, "Ref"); if (refPath.Length > 0) { xmlComponent.LoadXml(refPath, true); } } Control targetControl = xmlComponent as Control; if (XmlGetter.Attribute(rootNode, "Margin").Length > 0) { targetControl.Margin = ValueParser.Padding(XmlGetter.Attribute(rootNode, "Margin")); } if (XmlGetter.Attribute(rootNode, "Padding").Length > 0) { targetControl.Padding = ValueParser.Padding(XmlGetter.Attribute(rootNode, "Padding")); } if (XmlGetter.Attribute(rootNode, "Enabled").Length > 0) { targetControl.Enabled = (XmlGetter.Attribute(rootNode, "Enabled").Equals("false") == false); } DockStyle dock = ValueParser.GetDockStyle(XmlGetter.Attribute(rootNode, "Dock")); switch (dock) { case DockStyle.Bottom: case DockStyle.Top: { String hgt = XmlGetter.Attribute(rootNode, "Height"); if (hgt.Length != 0) { targetControl.Height = int.Parse(hgt); } break; } case DockStyle.Left: case DockStyle.Right: { String wid = XmlGetter.Attribute(rootNode, "Width"); if (wid.Length != 0) { targetControl.Width = int.Parse(wid); } break; } case DockStyle.Fill: //필요없음.. break; case DockStyle.None: { String hgt = XmlGetter.Attribute(rootNode, "Height"); if (hgt.Length != 0) { targetControl.Height = int.Parse(hgt); } String wid = XmlGetter.Attribute(rootNode, "Width"); if (wid.Length != 0) { targetControl.Width = int.Parse(wid); } String x = XmlGetter.Attribute(rootNode, "X"); Point location = new Point(); if (x.Length != 0) { location.X = int.Parse(x); } String y = XmlGetter.Attribute(rootNode, "Y"); if (y.Length != 0) { location.Y = int.Parse(y); } targetControl.Location = location; break; } } targetControl.Dock = dock; //이 control이 붙을 parent에 docking하는 모드임.. if (dock != DockStyle.Fill) { targetControl.Anchor = ValueParser.GetAnchorStyles(XmlGetter.Attribute(rootNode, "Anchor")); } string txt; txt = XmlGetter.Attribute(rootNode, "Name"); if (txt.Length > 0) { targetControl.Name = txt; } txt = XmlGetter.Attribute(rootNode, "Text"); // attr.Value; if (txt.Length > 0) { targetControl.Text = txt; } string color = XmlGetter.Attribute(rootNode, "TextColor"); if (color.Length > 0) { targetControl.ForeColor = ValueParser.StringToColor(color); } color = XmlGetter.Attribute(rootNode, "BackColor"); if (color.Length == 0) { color = XmlGetter.Attribute(rootNode, "Background-Color"); } try { if (color.Length > 0) { targetControl.BackColor = ValueParser.StringToColor(color); } } catch (Exception e) { if (color.Length > 0) { if (color.Equals("Transparent")) { if (targetControl.Parent != null) { targetControl.BackColor = targetControl.Parent.BackColor; } else { targetControl.BackColor = Color.FromKnownColor(KnownColor.Control); } } else { throw new Exception("XmlControlHandler: 색 변환 중 에러.. color:" + color + "\r\n" + e.Message); } } } LoadInterface(xmlComponent, rootNode, document); }
public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false) { if (rootNode == null) { return; } XmlControlHandler.GetDefaultControlAttributes(rootNode, xDoc, this); this.TextAlign = GlobalVars.ContentAlignment(XmlGetter.Attribute(rootNode, "TextAlign")); string disIndex = XmlGetter.Attribute(rootNode, "DisabledImageIndex"); if (disIndex.Length > 0) { this.U_ButtonDisabledType = int.Parse(disIndex); } string color = XmlGetter.Attribute(rootNode, "ActivationColor"); if (color.Length > 0) { this.ActiveBackColor = ValueParser.StringToColor(color); } string imageLayout = XmlGetter.Attribute(rootNode, "ImageLayout"); if (imageLayout.Length > 0) { this.BackgroundImageLayout = (ImageLayout)GlobalVars.ImageLayouts.ToList().IndexOf(imageLayout); } else { this.BackgroundImageLayout = ImageLayout.Zoom; } //this.BackgroundImageLayout = ImageLayout.Stretch; XmlNode XImages = XmlGetter.Child(rootNode, "Images");// rootNode.SelectSingleNode("Images"); _imageList.LoadXml(xDoc, XImages); /* * * for (int i = 0; i < rootNode.ChildNodes.Count; i++) * { * XmlNode xChild = rootNode.ChildNodes[i]; * if (xChild.Name.Equals("Events")) * { * _events.LoadXml(xDoc, xChild); * } * else if (xChild.Name.Equals("Images")) * { * _imageList.LoadXml(xDoc, xChild); * //_imageList = new XmlImageList(); * this.U_ImageList = _imageList; * * } * } */ }