public void LoadXml(XmlDocument xDoc, XmlNode rootNode, bool refLoad = false) { if (rootNode == null) { return; } string refPath = XmlGetter.Attribute(rootNode, "Ref"); bool refExist = refPath.Length > 0; XmlNode comNode; if (refExist) { if (XmlLayoutCollection.NowLoadingPath.Length > 0) { refPath = XmlLayoutCollection.NowLoadingPath + XmlLayoutCollection.PathSeperator + refPath; } comNode = XmlGetter.RootNode(out _xDoc, refPath, null, XmlSchemaValidation); _filePath = refPath; } else { if (rootNode.ChildNodes.Count == 0) { throw new Exception("Component 태그의 정의가 완전하지 않습니다. Ref로 xml파일을 불러오거나 직접 내부에 정의해야 합니다.\r\n name:" + XmlGetter.Attribute(rootNode, "Name")); } comNode = rootNode.ChildNodes[0]; } string nameText; nameText = XmlGetter.Attribute(rootNode, "Name"); XmlControlHandler.LoadInterface(this, rootNode, xDoc); Control control = XmlControlHandler.AddControl(nameText, xDoc, comNode, _panel, _idList, _namespace);; _realComponent = control; NowLoading = control as IXmlComponent; //if (txt.Length > 0) control.Name = txt; if (XmlGetter.Attribute(rootNode, "Margin").Length > 0) { control.Margin = ValueParser.Padding(XmlGetter.Attribute(rootNode, "Margin")); } if (XmlGetter.Attribute(rootNode, "Padding").Length > 0) { control.Padding = ValueParser.Padding(XmlGetter.Attribute(rootNode, "Padding")); } if (XmlGetter.Attribute(rootNode, "Enabled").Length > 0) { control.Enabled = (XmlGetter.Attribute(rootNode, "Enabled").Equals("false") == false); } String hgt = XmlGetter.Attribute(rootNode, "Height"); if (hgt.Length != 0) { control.Height = int.Parse(hgt); } String wid = XmlGetter.Attribute(rootNode, "Width"); if (wid.Length != 0) { control.Width = int.Parse(wid); } if (_panel is FlowLayoutPanel) { } else if (_panel is Panel) { 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); } control.Location = location; } }
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); }