Exemple #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;
        }
Exemple #2
0
        /// <summary>
        /// 简单工厂,创建不同SnipPartType的Part
        /// </summary>
        static public SnipPagePart Create(SnipPageDesigner designer, SnipPartType type)
        {
            SnipPagePart part;

            switch (type)
            {
            case SnipPartType.None:
            case SnipPartType.Static:
            {
                part       = new StaticPart(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.staticPartText}");
                break;
            }

            case SnipPartType.Box:
            {
                part       = new SnipPagePart(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.box}");
                break;
            }

            case SnipPartType.Navigation:
            {
                part       = new NavigationPart(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.navigationPartText}");
                break;
            }

            case SnipPartType.List:
            {
                part       = ListPart.Create(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.listPartText}");
                break;
            }

            case SnipPartType.ListBox:
            {
                part       = ListBoxPart.Create(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.listBoxPartText}");
                break;
            }

            case SnipPartType.Attribute:
            {
                part       = AttributePart.Create(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.attributePartText}");
                break;
            }

            case SnipPartType.Path:
            {
                part       = new PathPart(designer);
                part.Title = StringParserService.Parse("${res:snipDesign.text.pathPartText}");
                break;
            }

            default:
                throw new Exception("开发期异常。未知的SnipPartType:" + type);
            }
            part.PartID   = XmlUtilService.CreateIncreaseId();
            part.PartType = type;
            return(part);
        }