public void VisitLabel(ShapeLabel shape)
        {
            if (shape.Text != null && shape.Text.Length > 0)
            {
                if (shape.IsChanged || shape.LabelImage == null) //has new text paint shape
                {
                    if (shape.FrameSizeFixed)
                    {
                        shape.FontMgrSetup(true, false, ShapeLabel.DrawMode.Normal);
                    }
                    else
                    {
                        shape.FontMgrSetup(true, true, ShapeLabel.DrawMode.Normal);
                    }

                    shape.PaintImageInShape(Graphics);
                    shape.IsChanged = false;
                }
                else
                {
                    Graphics.DrawImage(shape.LabelImage, new Rectangle(shape.VirtualInnerBounds.X - shape.BorderWidth, shape.VirtualInnerBounds.Y - shape.BorderWidth, shape.LabelImage.Width, shape.LabelImage.Height));
                }
            }
        }
示例#2
0
        public override void VisitLabel(ShapeLabel shape)
        {
            if (!shape.IsChanged ||
                string.IsNullOrEmpty(shape.Text))
            {
                return;
            }

            if (shape.LabelImage == null) //has new text paint shape
            {
                if (shape.FrameSizeFixed)
                {
                    shape.FontMgrSetup(true, false, ProWrite.Entity.Shape.ShapeLabel.DrawMode.Play);
                }
                else
                {
                    shape.FontMgrSetup(true, true, ProWrite.Entity.Shape.ShapeLabel.DrawMode.Play);
                }

                using (var g = GetGraphics())
                    shape.PaintImageInShape(g);
                shape.IsChanged = false;
            }
            else
            {
                using (var g = GetGraphics())
                    g.DrawImage(shape.LabelImage, new Rectangle(shape.VirtualInnerBounds.X - shape.BorderWidth, shape.VirtualInnerBounds.Y - shape.BorderWidth, shape.LabelImage.Width, shape.LabelImage.Height));
            }

            if (shape.LabelImage != null)
            {
                using (Bitmap bit = new Bitmap(shape.LabelImage))
                    shape.InnerImagePath = shape.SaveImage(bit);
            }
            shape.IsChanged = true;
        }
示例#3
0
        public override void VisitLabel(ShapeLabel shape)
        {
            try
            {
                var _labelImageActual = shape._labelImageActual;
                if (_labelImageActual == null &&
                    !string.IsNullOrEmpty(shape.Text) &&
                    (shape.IsChanged || shape.LabelImage == null))
                {
                    var FontMgr = shape.FontMgr;
                    FontMgr.ShowGrid = false;
                    //Zoom
                    FontMgr.ScaleIndex = 1;
                    //Paint type
                    FontMgr.SetStyle(shape.FrameSizeFixed, shape.FontSizeFixed);
                    //Font info
                    FontMgr.TextColor     = shape.ConveredForeColor(shape.SignType); //.SourceForeColor;
                    FontMgr.BackColor     = shape.ConveredBackColor(shape.SignType); //.SourceBackColor;
                    FontMgr.FontName      = shape.Font.Name;
                    FontMgr.FontHeight    = shape.Font.Size;
                    FontMgr.Alignment     = shape.TextAlignment;
                    FontMgr.LineAlignment = shape.TextVAlignment;
                    FontMgr.Bold          = (shape.Font.Style & FontStyle.Bold) == FontStyle.Bold;
                    FontMgr.Italic        = (shape.Font.Style & FontStyle.Italic) == FontStyle.Italic;
                    FontMgr.KernAmount    = shape.KernAmount;
                    FontMgr.LeadAmount    = shape.LeadAmount;

                    FontMgr.FrameSize = shape.Size;
                    FontMgr.Text      = shape.Text;

                    switch (shape.TextEffect.Effect)
                    {
                    case OutlineShadowType.SHADED:
                        FontMgr.SetShadowAttri(shape.TextEffect.EffectColor, shape.TextEffect.ShadowLateralShift, shape.TextEffect.ShadowVerticalShift);
                        break;

                    case OutlineShadowType.OUTLINE:
                        FontMgr.SetOutlineAttri(shape.TextEffect.EffectColor, (ushort)(shape.TextEffect.OutlineWidth));
                        break;

                    case OutlineShadowType.NONE:
                        FontMgr.CancelTextEffect();
                        break;
                    }

                    shape.PaintImageInShape(null);
                    shape.IsChanged = false;
                }

                try
                {
                    _labelImageActual = shape._labelImageActual;
                    _labelImageActual.Save(ImageFile, ImageFormat.Png);
                }
                catch (Exception e)
                {
                    ImageFile = string.Empty;
                    Log.Error("Shape GenerateUploadImage Error: " + e.Message, e);
                }
                finally
                {
                    _labelImageActual.Dispose();
                }
            }
            catch (Exception e)
            {
                Log.Error("Label GenerateUploadImage Error: " + e.Message, e);
            }
        }