Esempio n. 1
0
        /// <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;
        }
Esempio n. 2
0
        /// <summary>
        /// 打开或添加页面片属性
        /// </summary>
        /// <param name="selectedRect"></param>
        private void ChangeSnipPerperty(SnipRect selectedRect)
        {
            if (selectedRect.HasSnip)
            {
                ///打开页面片
                Form snipForm = Service.Workbench.OpenWorkDocument(WorkDocumentType.SnipDesigner, selectedRect.SnipID, (TDPanel as TmpltDesignerPanel).TmpltID);
            }
            else
            {
                TmpltXmlDocument   doc     = TmpltDoc;
                TmpltDesignerPanel tDpanel = TDPanel as TmpltDesignerPanel;
                //tDpanel.SaveTmplt(doc);
                tDpanel.SaveRects();
                NewSnipSetupForm form = new NewSnipSetupForm(doc, selectedRect, GetHasContentSnip());
                if (form.ShowDialog() == DialogResult.OK)
                {
                    SnipXmlElement snipElement = doc.GetSnipElementById(selectedRect.SnipID);
                    snipElement.SnipName = form.SnipName;
                    snipElement.SnipType = form.SnipType;
                    snipElement.Width    = selectedRect.Width.ToString() + "px";
                    snipElement.Height   = selectedRect.Height.ToString() + "px";
                    snipElement.Title    = form.SnipName;
                    snipElement.HasSnip  = true;

                    tDpanel.SaveRects();
                    selectedRect.HasSnip  = true;
                    TDPanel.Modified      = true;
                    selectedRect.SnipType = form.IsContent ? PageSnipType.Content : PageSnipType.General;
                    if (form.IsContent)
                    {
                        if (!doc.HasContentSnip)
                        {
                            doc.HasContentSnip = true;
                        }
                    }
                    TDPanel.HasContentSnip = form.IsContent;
                    ///打开页面片
                    Form snipForm = Service.Workbench.OpenWorkDocument(WorkDocumentType.SnipDesigner, selectedRect.SnipID, (TDPanel as TmpltDesignerPanel).TmpltID);
                }
            }
        }