public bool refreshAppr(string apprName) { mx_treeAppr.Items.Clear(); if (m_curSkin != null && apprName != null && apprName != "") { if(m_curSkin is XmlElement) { XmlElement xeSkin = (XmlElement)m_curSkin; deleteEmptyApprElement(xeSkin); foreach(XmlNode xnAppr in xeSkin.ChildNodes) { if(xnAppr is XmlElement) { XmlElement xeAppr = (XmlElement)xnAppr; if (xeAppr.Name == "apperance" && xeAppr.GetAttribute("id") == apprName) { DataNode dataNode; if (DataNodeGroup.tryGetDataNode("BoloUI", "Skin", xeAppr.Name, out dataNode) && dataNode != null && dataNode is SkinDef_T) { ResBasic apprCtrl = new ResBasic(xeAppr, XmlControl.getCurXmlControl(), (SkinDef_T)dataNode, true); mx_treeAppr.Items.Add(apprCtrl); return true; } } } } XmlElement xeNewAppr = xeSkin.OwnerDocument.CreateElement("apperance"); xeNewAppr.SetAttribute("id", apprName); xeSkin.AppendChild(xeNewAppr); SkinDef_T skinDef; if(SkinDef_T.tryGetSkinDef(xeNewAppr.Name, out skinDef)) { ResBasic newApprCtrl = new ResBasic(xeNewAppr, XmlControl.getCurXmlControl(), skinDef, true); mx_treeAppr.Items.Add(newApprCtrl); } } else if(m_curSkin is ResBasic) { //todo } } return false; }
public void refreshControl(string skinName = "") { m_mapCtrlUI = new Dictionary<string, BoloUI.Basic>(); m_mapImageSize = new Dictionary<string, long>(); m_mapSkin = new Dictionary<string, BoloUI.ResBasic>(); m_mapXeItem = new Dictionary<XmlElement, XmlItem>(); m_isOnlySkin = true; clearNodeTreeFrame(); m_xeRoot = m_xmlDoc.DocumentElement; if (m_xeRoot != null) { switch (m_xeRoot.Name) { case "BoloUI": { m_showGL = true; m_treeUI = new BoloUI.Basic(m_xeRoot, this, true); m_treeSkin = new BoloUI.ResBasic(m_xeRoot, this, null); MainWindow.s_pW.mx_treeCtrlFrame.Items.Add(m_treeUI); m_treeUI.mx_text.Text = StringDic.getFileNameWithoutPath(m_openedFile.m_path); m_treeUI.ToolTip = m_openedFile.m_path; MainWindow.s_pW.mx_treeSkinFrame.Items.Add(m_treeSkin); m_treeSkin.mx_text.Text = StringDic.getFileNameWithoutPath(m_openedFile.m_path); m_treeSkin.ToolTip = m_openedFile.m_path; m_treeUI.Items.Clear(); m_treeSkin.Items.Clear(); XmlNodeList xnl = m_xeRoot.ChildNodes; foreach (XmlNode xnf in xnl) { if (xnf.NodeType == XmlNodeType.Element) { XmlElement xe = (XmlElement)xnf; CtrlDef_T ctrlPtr; SkinDef_T skinPtr; if (CtrlDef_T.tryGetCtrlDef(xe.Name, out ctrlPtr)) { m_treeUI.Items.Add(new Basic(xe, this, false)); m_isOnlySkin = false; m_xeRootCtrl = xe; } else if (SkinDef_T.tryGetSkinDef(xe.Name, out skinPtr)) { if (skinName == "" || ((xe.Name == "skin" || xe.Name == "publicskin") && xe.GetAttribute("Name") == skinName)) { ResBasic treeChild = new ResBasic(xe, this, skinPtr); //显示或隐藏皮肤节点 // if (xe.Name != "skin" && xe.Name != "publicskin") // { // m_treeSkin.Items.Add(treeChild); // } m_treeSkin.Items.Add(treeChild); if (xe.Name == "skingroup") { refreshSkinDicByGroupName(xe.GetAttribute("Name")); } } } } } refreshSkinDicByGroupName("publicskin"); MainWindow.s_pW.updateXmlToGL(this); if (m_openedFile.m_preViewSkinName != null && m_openedFile.m_preViewSkinName != "") { BoloUI.ResBasic skinBasic; if (m_mapSkin.TryGetValue(m_openedFile.m_preViewSkinName, out skinBasic)) { skinBasic.changeSelectItem(m_openedFile.m_prePlusCtrlUI); } else { Public.ResultLink.createResult("\r\n没有找到该皮肤。(" + m_openedFile.m_preViewSkinName + ")", Public.ResultType.RT_WARNING); } } } break; case "UIImageResource": { m_showGL = false; if (ImageTools.ImageNesting.s_pW != null) { mx_root.AddChild(new PackImage(this, true)); } else { mx_root.AddChild(new PackImage(this, false)); } } break; default: Public.ResultLink.createResult("\r\n这不是一个有效的BoloUI或UIImageResource文件。", Public.ResultType.RT_ERROR); break; } if(m_showGL) { MainWindow.s_pW.showGLCtrl(true, true); } else { MainWindow.s_pW.showGLCtrl(false, true); } } else { Public.ResultLink.createResult("\r\nxml文件格式错误。", Public.ResultType.RT_ERROR); } checkAllUICtrlBaseId(); refreshSkinDicForAll(); }
public static bool insertItemByXe(MainWindow pW, XmlControl xmlCtrl, XmlElement dstXe, XmlElement srcXe,ref int index) { CtrlDef_T nullCtrlDef; if (xmlCtrl != null) { XmlItem dstItem; XmlItem srcItem = null; Project.PlugIn.DataNode skinPtr; if (srcXe.Name != "BoloUI") { if (!(xmlCtrl.m_mapXeItem.TryGetValue(srcXe, out srcItem) && srcItem != null)) { return false; } } if (CtrlDef_T.tryGetCtrlDef(dstXe.Name, out nullCtrlDef)) { dstItem = new Basic(dstXe, xmlCtrl, false); } else if (Project.PlugIn.DataNodeGroup.s_mapDataNodesDef["BoloUI"]["Skin"].m_mapDataNode.TryGetValue(dstXe.Name, out skinPtr) && skinPtr is SkinDef_T) { if (srcItem != null && srcItem is ResBasic && ((ResBasic)srcItem).m_isSkinEditor) { dstItem = new ResBasic(dstXe, xmlCtrl, (SkinDef_T)skinPtr, true); } else { dstItem = new ResBasic(dstXe, xmlCtrl, (SkinDef_T)skinPtr, false); } } else { return false; } if (srcItem != null && index > srcItem.Items.Count) { index = srcItem.Items.Count; } else { if(index < 0) { index = 0; } } if (srcXe.Name != "BoloUI") { if (srcItem != null) { srcItem.Items.Insert(index, dstItem); srcItem.mx_imgFolder.Visibility = System.Windows.Visibility.Visible; } else { return false; } } else { if (dstItem.m_type == "CtrlUI") { if (index > xmlCtrl.m_treeUI.Items.Count) { index = xmlCtrl.m_treeUI.Items.Count; } xmlCtrl.m_treeUI.Items.Insert(index, dstItem); } else if (dstItem.m_type == "Skin") { if (index > xmlCtrl.m_treeSkin.Items.Count) { index = xmlCtrl.m_treeSkin.Items.Count; } xmlCtrl.m_treeSkin.Items.Insert(index, dstItem); } } return true; } return false; }
public void addSkinGroup(string groupName) { Dictionary<string, XmlElement> mapXeGroup = getSkinGroupMap(); XmlItem lastItem = m_curItem; if (groupName != null && groupName != "") { XmlElement xeOut; if (!mapXeGroup.TryGetValue(groupName, out xeOut)) { XmlElement newXe = m_xmlDoc.CreateElement("skingroup"); newXe.SetAttribute("Name", groupName); SkinDef_T skinDef; if(SkinDef_T.tryGetSkinDef("skingroup", out skinDef) && skinDef != null) { BoloUI.ResBasic treeChild = new BoloUI.ResBasic(newXe, this, skinDef); m_openedFile.m_lstOpt.addOperation( new XmlOperation.HistoryNode( XmlOperation.XmlOptType.NODE_INSERT, treeChild.m_xe, m_xmlDoc.DocumentElement) ); if(lastItem != null) { lastItem.changeSelectItem(); } } } } }