public PackImage(XmlControl parent, bool isRePack = true) { if (parent == null || parent.m_openedFile == null || !System.IO.File.Exists(parent.m_openedFile.m_path)) { return; } m_xmlPath = parent.m_openedFile.m_path; InitializeComponent(); System.Drawing.Bitmap tgaImg; BitmapSource imgSource; refreshImagePack(m_xmlPath, isRePack, out m_mapImgRect, out tgaImg, out m_imageWidth, out m_imageHeight); if (parent.m_parent != null) { parent.m_parent.itemFrame.Width = m_imageWidth; parent.m_parent.itemFrame.Height = m_imageHeight; } mx_canvas.Width = m_imageWidth; mx_canvas.Height = m_imageHeight; if (m_imageHeight > 4096) { Public.ResultLink.createResult("\r\n图片尺寸过大,不提供预览功能", Public.ResultType.RT_WARNING); return; } IntPtr ip = tgaImg.GetHbitmap(); imgSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( ip, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); MainWindow.DeleteObject(ip); System.Windows.Controls.Image cImg = new System.Windows.Controls.Image(); cImg.Source = imgSource; cImg.Stretch = Stretch.Uniform; mx_canvas.Children.Insert(0, cImg); }
public FileTabItem(OpenedFile fileDef, string skinName = "") { m_filePath = ""; InitializeComponent(); if (m_filePath == "") { UserControl tabContent; MainWindow parentWindow = Window.GetWindow(this) as MainWindow; m_fileDef = fileDef; m_filePath = fileDef.m_path; this.filePath.Text = m_filePath; m_fileType = StringDic.getFileType(m_filePath).ToLower(); switch (m_fileType) { case "bmp": case "cut": case "dcx": case "dds": case "ico": case "gif": case "jpg": case "lbm": case "lif": case "mdl": case "pcd": case "pcx": case "pic": case "png": case "pnm": case "psd": case "psp": case "raw": case "sgi": case "tga": case "tif": case "wal": case "act": case "pal": { tabContent = new PngControl(this, fileDef); MainWindow.s_pW.showGLCtrl(false); } break; case "xml": { tabContent = new XmlControl(this, fileDef, skinName); } break; case "htm": case "html": case "php": { tabContent = new HtmlControl(this, fileDef); } break; case "bolos": case "txt": { tabContent = new BoloScript.TextControl(this, fileDef); MainWindow.s_pW.showGLCtrl(false); } break; default: { tabContent = new UnknownControl(this, fileDef); MainWindow.s_pW.showGLCtrl(false); } break; } this.itemFrame.Children.Clear(); this.itemFrame.Children.Add(tabContent); m_child = tabContent; } mx_wsBckBrush.ImageSource = new BitmapImage(new Uri(@".\data\image\hyaline.png", UriKind.Relative)); }
public void addVidToMsgXml(XmlElement srcXe, XmlElement dstXe, XmlDocument dstDoc, XmlControl xmlCtrl) { foreach (XmlAttribute attr in srcXe.Attributes) { dstXe.SetAttribute(attr.Name, attr.Value); } foreach (XmlNode xn in srcXe.ChildNodes) { if (xn.NodeType == XmlNodeType.Element) { XmlElement xe = (XmlElement)xn; XmlItem item; XmlElement newXe = dstDoc.CreateElement(xe.Name); addVidToMsgXml(xe, newXe, dstDoc, xmlCtrl); if (xmlCtrl.m_mapXeItem.TryGetValue(xe, out item)) { if (item is Basic) { BoloUI.Basic uiCtrl = (BoloUI.Basic)item; if (uiCtrl.m_vId != null && uiCtrl.m_vId != "") { newXe.SetAttribute("baseID", uiCtrl.m_vId); } if (mx_isShowAll.IsChecked == true) { newXe.SetAttribute("visible", "true"); } } } dstXe.AppendChild(newXe); } } }
//立即更新GL端 public void updateXmlToGL(XmlControl xmlCtrl, XmlElement xePlus = null, bool isCtrlUI = false) { string path = xmlCtrl.m_openedFile.m_path; XmlDocument doc = xmlCtrl.m_xmlDoc; XmlDocument newDoc = new XmlDocument(); string fileName = StringDic.getFileNameWithoutPath(path); XmlElement newRootXe = newDoc.CreateElement(doc.DocumentElement.Name); addVidToMsgXml(doc.DocumentElement, newRootXe, newDoc, xmlCtrl); newDoc.AppendChild(newRootXe); XmlNodeList nodeList; if (xePlus != null) { if (isCtrlUI == false) { string strTmp = "<panel dock=\"4\" name=\"background\" skin=\"BackPure\"></panel>"; XmlElement xeTmp = newDoc.CreateElement("tmp"); xeTmp.InnerXml = strTmp; //xePlus.OuterXml xeTmp.FirstChild.InnerXml = xePlus.OuterXml; newRootXe.AppendChild(xeTmp.FirstChild); } else { XmlNode xn; XmlElement xe; for (xn = xePlus; xn.ParentNode != null && xn.ParentNode.NodeType == XmlNodeType.Element && xn.ParentNode.Name != "BoloUI"; xn = xn.ParentNode) { } if (xn.ParentNode != null && xn.ParentNode.NodeType == XmlNodeType.Element && xn.ParentNode.Name == "BoloUI") { xe = (XmlElement)xn; string strTmp = xe.OuterXml; XmlElement xeTmp = newDoc.CreateElement("tmp"); xeTmp.InnerXml = strTmp; newRootXe.AppendChild(xeTmp.FirstChild); } } } //去掉所有事件(<event>) //<inc>因为要测试新需求,所以这里不屏蔽。 // nodeList = newRootXe.SelectNodes("descendant::event"); // // foreach (XmlNode xnEvent in nodeList) // { // xnEvent.ParentNode.RemoveChild(xnEvent); // } string buffer = newDoc.InnerXml; updateGL(fileName, W2GTag.W2G_NORMAL_NAME); updateGL(buffer, W2GTag.W2G_NORMAL_DATA); xmlCtrl.refreshVRect(); }