private void mx_root_Unloaded(object sender, RoutedEventArgs e) { s_pW = null; }
public SelSkin(string path, string xmlData, IAttrRow iRowSkin) { s_pW = this; m_isInitPath = false; m_path = path; m_iRowSkin = iRowSkin; m_curSkin = null; InitializeComponent(); m_docView = new XmlDocument(); XmlElement xeRoot = m_docView.CreateElement("BoloUI"); XmlElement xePanel = m_docView.CreateElement("panel"); xePanel.SetAttribute("w", "960"); xePanel.SetAttribute("h", "540"); xePanel.SetAttribute("dock", "4"); xePanel.InnerXml = xmlData; m_testCtrl = (XmlElement)xePanel.FirstChild; string attrW = m_testCtrl.GetAttribute("w"); string attrH = m_testCtrl.GetAttribute("h"); string attrText = m_testCtrl.GetAttribute("text"); m_testCtrl.RemoveAllAttributes(); m_testCtrl.SetAttribute("baseID", "selSkinTestCtrl"); if (attrW == "") { attrW = "300"; } if (attrH == "") { attrH = "200"; } if (attrText == "") { attrText = "测试Test123"; } m_testCtrl.SetAttribute("w", attrW); m_testCtrl.SetAttribute("h", attrH); m_testCtrl.SetAttribute("text", attrText); m_docView.AppendChild(xeRoot); #region 显示皮肤树 OpenedFile fileDef; if(MainWindow.s_pW.m_mapOpenedFiles.TryGetValue(m_path, out fileDef)) { if(fileDef != null && fileDef.m_frame != null && fileDef.m_frame is XmlControl) { XmlControl xmlCtrl = (XmlControl)fileDef.m_frame; Dictionary<string, string> mapLocalGroup = new Dictionary<string,string>(); if(xmlCtrl.m_xmlDoc != null && xmlCtrl.m_xmlDoc.DocumentElement.Name == "BoloUI") { XmlDocument xmlDoc = xmlCtrl.m_xmlDoc; foreach(XmlNode xn in xmlDoc.DocumentElement.ChildNodes) { if(xn.NodeType == XmlNodeType.Element) { XmlElement xe = (XmlElement)xn; switch(xe.Name) { case "skingroup": { #region 本地皮肤组 string groupName = xe.GetAttribute("Name"); string tmp; if (!mapLocalGroup.TryGetValue(groupName, out tmp)) { mapLocalGroup.Add(groupName, ""); } addItemByGroupName(groupName, mx_localGroup); #endregion } break; case "publicskin": case "skin": { #region 本地皮肤 string skinName = xe.GetAttribute("Name"); if(skinName != "") { TreeViewItem skinItem = new TreeViewItem(); skinItem.Header = skinName; skinItem.ToolTip = m_path; skinItem.Selected += skinItem_Selected; mx_localSkin.Items.Add(skinItem); XmlElement xeSkin = m_docView.CreateElement(xe.Name); xeSkin.SetAttribute("Name", skinName); xeSkin.InnerXml = xe.InnerXml; xeRoot.AppendChild(xeSkin); } #endregion } break; default: break; } } } #region 未包含的皮肤组 DirectoryInfo di = new DirectoryInfo(Project.Setting.s_projPath + "\\skin\\"); FileInfo[] arrFi = di.GetFiles("*.xml"); foreach(FileInfo fi in arrFi) { string groupName = System.IO.Path.GetFileNameWithoutExtension(fi.Name); string tmp; if (!mapLocalGroup.TryGetValue(groupName, out tmp)) { addItemByGroupName(groupName, mx_otherGroup); } XmlElement xeGroup = m_docView.CreateElement("skingroup"); xeGroup.SetAttribute("Name", groupName); xeRoot.AppendChild(xeGroup); } #endregion } } } #endregion xeRoot.AppendChild(xePanel); this.Owner = MainWindow.s_pW; }
private void mx_sel_Click(object sender, RoutedEventArgs e) { if (m_parent.m_basic != null && m_parent.m_basic is Basic) { switch(m_name) { case "skin": { BoloUI.SelSkin winSkin = new BoloUI.SelSkin(m_parent.m_xmlCtrl.m_openedFile.m_path, m_parent.m_basic.m_xe.OuterXml, this); winSkin.ShowDialog(); if (!BoloUI.SelSkin.s_pW.m_msgMng.m_GLHost.m_process.HasExited) { BoloUI.SelSkin.s_pW.m_msgMng.m_GLHost.m_process.Kill(); BoloUI.SelSkin.s_pW = null; } } break; default: break; } } if (m_parent.m_basic != null && m_parent.m_basic is ResBasic) { switch (m_name) { case "image": { BoloUI.SelImage winImage = new BoloUI.SelImage(this); winImage.ShowDialog(); } break; case "ImageName": { BoloUI.SelImage winImage = new BoloUI.SelImage(this); winImage.ShowDialog(); } break; case "particleName": { BoloUI.SelParticle winParticle = new BoloUI.SelParticle(this); winParticle.ShowDialog(); } break; default: break; } } }