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; * * } * } */ }
void MakeAColumn(int wid, ItemTypes itemType, String name, XmlNode prop, Actions ac1, Actions ac2, Actions ac3) { _columnTypes.Add(itemType); switch (itemType) { case ItemTypes.Button: { String headerText = ""; headerText = XmlGetter.Attribute(prop, "HeaderText"); String baseText = XmlGetter.Attribute(prop, "BaseText"); AddTitleButtonColumn(wid, name, headerText, baseText, ac1, ac2, ac3); break; } case ItemTypes.CheckBox: { bool isTriState = ValueParser.IsTrue(XmlGetter.Attribute(prop, "TriState")); //string initVal = XmlGetter.Attribute(prop, "InitValue"); //int initValue = (initVal.Length > 0) ? int.Parse(initVal) : 0; AddTitleCheckBoxColumn(wid, name, isTriState, ac1, ac2, ac3); break; } case ItemTypes.CheckBoxGroup: { String headerText = XmlGetter.Attribute(prop, "HeaderText"); if (prop.HasChildNodes) { List <String> items = new List <String>(); XmlNodeList xItems = prop.ChildNodes[0].ChildNodes; //ComboBoxProperties/SingleSelItems/SingleSelItem List <int> selected = new List <int>(); for (int i = 0; i < xItems.Count; i++) { if (xItems[i].NodeType == XmlNodeType.Comment) { continue; } if (ValueParser.IsTrue(XmlGetter.Attribute(xItems[i], "Checked"))) { selected.Add(i); } items.Add(xItems[i].InnerText); } if (selected.Count == 0) { selected = null; } AddTitleCheckBoxGroupColumn(wid, name, headerText, items.ToArray(), selected.ToArray(), ac1, ac2, ac3); } else { AddTitleCheckBoxGroupColumn(wid, name, headerText, null, null, ac1, ac2, ac3); } } break; case ItemTypes.CloseButton: { String headerText = XmlGetter.Attribute(prop, "HeaderText"); String baseText = XmlGetter.Attribute(prop, "BaseText"); AddTitleCloseButtonColumn(wid, name, headerText, baseText, ac1, ac2, ac3); break; } case ItemTypes.ComboBox: { String headerText = XmlGetter.Attribute(prop, "HeaderText"); String selIndexText = XmlGetter.Attribute(prop, "SelectedIndex"); int selIndex = (selIndexText.Length > 0) ? int.Parse(selIndexText) : -1; if (prop.HasChildNodes) { List <String> items = new List <String>(); XmlNodeList xItems = prop.ChildNodes[0].ChildNodes; //ComboBoxProperties/SingleSelItems/SingleSelItem for (int i = 0; i < xItems.Count; i++) { if (xItems[i].NodeType == XmlNodeType.Comment) { continue; } items.Add(xItems[i].InnerText); } AddTitleComboBoxColumn(wid, name, headerText, items.ToArray(), selIndex, ac1, ac2, ac3); } else { AddTitleComboBoxColumn(wid, name, headerText, null, -1, ac1, ac2, ac3); } } break; case ItemTypes.FileOpenBox: { String headerText = XmlGetter.Attribute(prop, "HeaderText"); bool editable = XmlGetter.Attribute(prop, "Editable").Equals("true"); // bool autoSort = XmlGetter.Attribute("IsAutoSort").Equals("true"); TextAlignModes mode = (TextAlignModes)(TextAlignModesText.ToList().IndexOf(XmlGetter.Attribute(prop, "TextAlignMode"))); AddTitleFileOpenBoxColumn(wid, name, headerText, editable, mode, ac1, ac2, ac3); break; } case ItemTypes.Image: { String headerText = XmlGetter.Attribute(prop, "HeaderText"); //int initValue = int.Parse(XmlGetter.Attribute(prop,"InitValue")); int titleShowImage = int.Parse(XmlGetter.Attribute(prop, "TitleShowImage")); if (prop.HasChildNodes) { try { XmlNode xImgs = XmlGetter.Child(prop, "ImageList"); if (xImgs != null && xImgs.ChildNodes.Count > 0) { XmlImageList imgs = new XmlImageList("ImageList"); imgs.LoadXml(_xDoc, xImgs); AddTitleImageColumn(wid, name, headerText, imgs, titleShowImage, ac1, ac2, ac3); } else { AddTitleImageColumn(wid, name, headerText, (Image[])null, -1, ac1, ac2, ac3); } /* * // List<Image> imgs = new List<Image>(); * //XmlNodeList xImgs = prop.ChildNodes[0].ChildNodes;//ImageCheckBoxProperties/CheckImageList/ * for (int i = 0; i < xImgs.Count; i++) * { * if (xImgs[i].NodeType == XmlNodeType.Comment) continue; * * imgs.Add(Image.FromFile(xImgs[i], "URL"))); * } * AddTitleImageColumn(wid, name, headerText, imgs.ToArray(), titleShowImage, ac1, ac2, ac3); */ } catch { AddTitleImageColumn(wid, name, headerText, (Image[])null, -1, ac1, ac2, ac3); } } else { AddTitleImageColumn(wid, name, headerText, (Image[])null, -1, ac1, ac2, ac3); } break; } case ItemTypes.ImageButton: { String headerText = XmlGetter.Attribute(prop, "HeaderText"); //int initValue = int.Parse(XmlGetter.Attribute("InitValue")); int titleShowImage = int.Parse(XmlGetter.Attribute(prop, "TitleShowImage")); bool showTitleText = (XmlGetter.Attribute(prop, "ShowTitleText").Equals("true")); bool useColumnTextForButtonValue = (XmlGetter.Attribute(prop, "UseColumnTextForButtonValue").Equals("true")); if (prop.HasChildNodes) { XmlNode xImgs = XmlGetter.Child(prop, "ImageList"); //( prop.SelectNodes("ImageList"); if (xImgs.ChildNodes.Count > 0) { XmlImageList imgs = new XmlImageList("ImageList"); try { imgs.LoadXml(_xDoc, xImgs); AddTitleImageButtonColumn(wid, name, headerText, imgs, titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3); } catch (Exception e) { MessageBox.Show(e.Message); AddTitleImageButtonColumn(wid, name, headerText, (Image[])null, titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3); } } else { AddTitleImageButtonColumn(wid, name, headerText, (Image[])null, titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3); } /* * try * { * List<Image> imgs = new List<Image>(); * XmlNodeList xImgs = prop.ChildNodes[0].ChildNodes;//ImageCheckBoxProperties/CheckImageList/ * for (int i = 0; i < xImgs.Count; i++) * { * if (xImgs[i].NodeType == XmlNodeType.Comment) continue; * * imgs.Add(Image.FromFile(xImgs[i], "URL"))); * } * AddTitleImageButtonColumn(wid, name, headerText, imgs.ToArray(), titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3); * } * catch * { * AddTitleImageButtonColumn(wid, name, headerText, (Image[])null, titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3); * } */ } else { AddTitleImageButtonColumn(wid, name, headerText, (Image[])null, titleShowImage, useColumnTextForButtonValue, showTitleText, ac1, ac2, ac3); } break; } case ItemTypes.ImageCheckBox: { String headerText = XmlGetter.Attribute(prop, "HeaderText"); //bool isTriState = XmlGetter.Attribute("TriState").Equals("true"); //int initValue = int.Parse(XmlGetter.Attribute(prop,"InitValue")); if (prop.HasChildNodes) { XmlNode xImgs = XmlGetter.Child(prop, "CheckImageList"); // prop.SelectNodes("CheckImageList"); if (xImgs.ChildNodes.Count > 0) { XmlCheckImageList imgs = new XmlCheckImageList("CheckImageList"); try { imgs.LoadXml(_xDoc, xImgs); AddTitleImageCheckColumn(wid, name, headerText, imgs, ac1, ac2, ac3); } catch (Exception e) { MessageBox.Show("XmlScenarioTable.MakeColumn:" + e.Message); AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Red, ac1, ac2, ac3); } } else { AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Red, ac1, ac2, ac3); } /* * List<Image> imgs = new List<Image>(); * XmlNodeList xImgs = prop.ChildNodes[0].ChildNodes;//ImageCheckBoxProperties/CheckImageList/ * try * { * for (int i = 0; i < xImgs.Count; i++) * { * if (xImgs[i].NodeType == XmlNodeType.Comment) continue; * * imgs.Add(Image.FromFile(xImgs[i], "URL"))); * } * AddTitleImageCheckColumn(wid, name, headerText, imgs, ac1, ac2, ac3); * } * catch (Exception e) * { * AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Red, ac1, ac2, ac3); * } */ } else { XmlAttribute attr = prop.Attributes["CheckColor"]; if (attr == null) { AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Red, ac1, ac2, ac3); } else if (attr.Value.Equals("Blue")) { AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Blue, ac1, ac2, ac3); } else { AddTitleImageCheckColumn(wid, name, headerText, CheckBoxColors.Red, ac1, ac2, ac3); } } break; } case ItemTypes.KeyValue: { String headerText = XmlGetter.Attribute(prop, "HeaderText"); TextAlignModes mode = (TextAlignModes)(TextAlignModesText.ToList().IndexOf(XmlGetter.Attribute(prop, "TextAlignMode"))); AddTitleKeyValueColumn(wid, name, headerText, mode, ac1, ac2, ac3); break; } case ItemTypes.RadioButton: { String headerText = XmlGetter.Attribute(prop, "HeaderText"); String selIndexText = XmlGetter.Attribute(prop, "SelectedIndex"); int selIndex = (selIndexText.Length > 0)? int.Parse(selIndexText) : -1; if (prop.HasChildNodes) { List <String> items = new List <String>(); XmlNodeList xItems = prop.ChildNodes[0].ChildNodes; //ComboBoxProperties/SingleSelItems/SingleSelItem for (int i = 0; i < xItems.Count; i++) { if (xItems[i].NodeType == XmlNodeType.Comment) { continue; } items.Add(xItems[i].InnerText); } AddTitleRadioButtonColumn(wid, name, headerText, items.ToArray(), selIndex, ac1, ac2, ac3); } else { AddTitleRadioButtonColumn(wid, name, headerText, null, -1, ac1, ac2, ac3); } } break; case ItemTypes.TextBox: { String headerText = XmlGetter.Attribute(prop, "HeaderText"); bool editable = XmlGetter.Attribute(prop, "Editable").Equals("true"); bool autoSort = XmlGetter.Attribute(prop, "IsAutoSort").Equals("true"); //String initValue = XmlGetter.Attribute(prop, "InitValue"); TextAlignModes mode = (TextAlignModes)(TextAlignModesText.ToList().IndexOf(XmlGetter.Attribute(prop, "TextAlignMode"))); EasyGridTextBoxColumn col = AddTitleTextBoxColumn(wid, name, headerText, editable, autoSort, mode, ac1, ac2, ac3); break; } case ItemTypes.Various: { String headerText = XmlGetter.Attribute(prop, "HeaderText"); AddTitleVariousColumn(wid, name, headerText, ac1, ac2, ac3); break; } } }
public void LoadXml(XmlDocument xDoc, XmlNode rootNode, Boolean refLoad = false) { if (rootNode == null) { return; } XmlControlHandler.GetDefaultControlAttributes(rootNode, xDoc, this); String ns = XmlGetter.Attribute(rootNode, "NameSpace"); if (ns.Length > 0) { if (_namespace != null && _namespace.Length > 0) { _namespace += GlobalVars.Seperator + ns; } else { _namespace = ns; } } XmlNode xInfo = XmlGetter.Child(rootNode, "TabControlInfo"); // rootNode.SelectSingleNode("TabControlInfo"); XmlNode xTabImages = XmlGetter.Child(rootNode, "TabImages"); //xInfo.SelectSingleNode("TabImages"); if (xTabImages != null) { XmlImageList xImgList = new XmlImageList("TabImages"); xImgList.LoadXml(xDoc, xTabImages); this.ImageList = xImgList; } XmlNodeList xTabs = XmlGetter.Children(rootNode, "Tabs/Tab"); for (int i = 0; i < xTabs.Count; i++) { XmlNode xTab = xTabs[i]; //if (xTab.NodeType != XmlNodeType.Element) continue; //주석을 거른다. if (xTab.Name.Equals("Tab") == false) { continue; //오직 자식으로는 Component만을 가진다. } XmlTab tab = new XmlTab(_idList, _namespace); tab.LoadXml(xDoc, xTab); this.TabPages.Add(tab); //_parent.Controls.Add(tab); Dictionary <String, IXmlComponent> idList = tab._idList; /* * for (int ids = 0; ids < idList.Count; ids++) * { * string name = idList.Keys.ElementAt(ids); * if (_namespace.Length > 0) name = _namespace + "." + name; //namespace가 있으면 붙여서 namepace.name 형식으로 다시 naming.. * Controls.Add(name, idList.Values.ElementAt(ids)); * } */ } }