Пример #1
0
        /// <summary>
        /// 初始化模板的信息
        /// </summary>
        private void InitTmpltInfo()
        {
            XmlElement ele = TmpltDoc.DocumentElement;

            if (Utility.Convert.StringToBool(ele.GetAttribute("hasBackImg")))
            {
                int           w        = Convert.ToInt32(TmpltDoc.Width);
                int           h        = Convert.ToInt32(TmpltDoc.Height);
                Bitmap        _backBmp = new Bitmap(w, h);
                AnyXmlElement imgEle   = (AnyXmlElement)ele.SelectSingleNode("backImage");
                _drawPanelBack = Utility.Convert.Base64ToImage(imgEle.CDataValue);
                Graphics g  = Graphics.FromImage(_backBmp);
                int      _w = _drawPanelBack.Width <= w ? _drawPanelBack.Width : w;
                int      _h = _drawPanelBack.Height <= h ? _drawPanelBack.Height : h;
                g.DrawImageUnscaledAndClipped(_drawPanelBack, new Rectangle(0, 0, _w, _h));
                Image    _backImg = _backBmp;
                Graphics gImg     = Graphics.FromImage(_backImg);
                gImg.FillRectangle(new SolidBrush(Color.FromArgb(70, Color.White)), new Rectangle(0, 0, w, h));
                TmpltDesign = new TmpltDesignerPanel(w, h, _backImg, TmpltDoc);
            }
            else
            {
                TmpltDesign = new TmpltDesignerPanel(
                    Utility.Convert.PxStringToInt(ele.GetAttribute("width")),
                    Utility.Convert.PxStringToInt(ele.GetAttribute("height")),
                    null, TmpltDoc);
            }
            TmpltDesign.DrawPanel.ChangDrawTypeEvent += new Jeelu.SimplusD.Client.Win.DrawPanel.ChangDrawTypeEventHandler(DrawPanel_ChangDrawTypeEvent);
            TmpltDesign.DrawPanel.SelectingRectEvent += new EventHandler(DrawPanel_SelectingRectEvent);
        }
Пример #2
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;
        }
Пример #3
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);
                }
            }
        }