/// <summary> /// 实现执行函数 /// </summary> override public void Execute() { if (NewSnipData == null) { return; } TmpltDesignerPanel tDpanel = dPanel as TmpltDesignerPanel; tDpanel.SaveRects(); foreach (Rect rect in PastedSnipRects) { rect.SnipData = new SnipData(NewSnipData); SnipXmlElement newEle = (SnipXmlElement)Doc.ParseElement(rect.SnipData.SnipElementText); if (Doc.HasContentSnip && newEle.SnipType == PageSnipType.Content) { MessageService.Show("${res:tmpltDesign.tmpltDrawPanel.message.hasContentSnip}"); return; } SnipXmlElement ele = Doc.GetSnipElementById(rect.SnipID); ele.SelectSingleNode("parts").RemoveAll(); ele.SetAttribute("hasSnip", newEle.GetAttribute("hasSnip")); ele.SetAttribute("type", newEle.GetAttribute("type")); XmlNodeList nodes = newEle.SelectSingleNode("parts").SelectNodes("//part"); foreach (XmlNode partNode in nodes) { (partNode as XmlElement).SetAttribute("partId", XmlUtilService.CreateIncreaseId()); ele.SelectSingleNode("parts").AppendChild(partNode); } rect.HasSnip = true; } dPanel.Modified = true; }
/// <summary> /// 保存矩形 /// </summary> public void SaveRects() { float x = DrawPanel.CurZoom; DrawPanel.CurZoom = 1; Dictionary <string, XmlElement> _tempSnips = TmpltDoc.GetAllSnipElementClone(); XmlElement docEle = (XmlElement)TmpltDoc.DocumentElement.SelectSingleNode("rects"); docEle.RemoveAll(); RectLayer boundaryRect = new RectLayer(0, 0, DrawPanel.Width, DrawPanel.Height, TmpltDoc.TmpltCss); LineToRect(boundaryRect); AddRectToXml(docEle, new RectTreeNode(boundaryRect, null)); XmlNodeList snipNodes = docEle.SelectNodes(@"//snip"); foreach (XmlNode snipNode in snipNodes) { if (snipNode.NodeType == XmlNodeType.Element) { SnipXmlElement snipEle = (SnipXmlElement)snipNode; string id = snipEle.Id; if (_tempSnips.ContainsKey(id)) { CssSection tempCss = CssSection.Parse(snipEle.GetAttribute("css")); XmlUtilService.CopyXmlElement(_tempSnips[id], snipEle); snipEle.Width = tempCss.Properties["width"]; snipEle.Height = tempCss.Properties["height"]; snipEle.Css = tempCss.ToString(); } } } DrawPanel.CurZoom = x; TmpltDoc.Reseted = true; }