示例#1
0
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            int nSpaces;
            if (!int.TryParse(m_sVariable, out nSpaces))
            {
                return false;
            }

            LineNumber = zProcessData.CurrentLine;

            float fWidth = (float)nSpaces * ((float)zProcessData.FontSpaceWidth + (float)zElement.wordspace);

            if (0 == fWidth)
            {
                return false;
            }

            if (zProcessData.CurrentX + fWidth >= zElement.width)
            {
                if (Optional)
                {
                    return false;
                }
                zProcessData.MoveToNextLine(zElement);
            }

            TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, fWidth, zProcessData.FontSpaceHeight);

            zProcessData.CurrentX += fWidth;
            return true;
        }
示例#2
0
 public override void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     if (null != m_zPreviousFont)
     {
         zProcessData.SetFont(m_zPreviousFont, zGraphics);
     }
 }
示例#3
0
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            MarkupToClose.CloseMarkup(zData, zProcessData, zGraphics);

            // keep only the necessary markups
            return s_dictionaryKeepTypesOnProcess.ContainsKey(MarkupToClose.GetType());
        }
示例#4
0
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            var arrayComponents = m_sVariable.Split(new char[] { ';' });
            if (1 > arrayComponents.Length)
            {
                return false;
            }

            int nXPush;
            if (!int.TryParse(arrayComponents[0], out nXPush))
            {
                return false;
            }

            var nYPush = 0;
            if (2 <= arrayComponents.Length)
            {
                if (!int.TryParse(arrayComponents[1], out nYPush))
                {
                    return false;
                }
            }

            zProcessData.CurrentX += nXPush;
            zProcessData.CurrentY += nYPush;
            if (zProcessData.CurrentX > zElement.width)
            {
                zProcessData.MoveToNextLine(zElement);
            }

            return false;
        }
示例#5
0
 public override void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     if (null != m_zPreviousFont)
     {
         zProcessData.SetFont(m_zPreviousFont, zGraphics);
     }
 }
示例#6
0
 public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     float fXOffset;
     if (float.TryParse(m_sVariable, out fXOffset))
     {
         m_fPreviousOffset = zProcessData.CurrentXOffset;
         zProcessData.CurrentXOffset = fXOffset;
     }
     return false;
 }
示例#7
0
 public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     float fNewSize;
     if (float.TryParse(m_sVariable, out fNewSize) && fNewSize > 0)
     {
         m_zPreviousFont = zProcessData.Font;
         zProcessData.SetFont(new Font(zProcessData.Font.FontFamily, fNewSize, zProcessData.Font.Style), zGraphics);
     }
     return false;
 }
示例#8
0
 public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     var zNewFont = ProjectLayoutElement.TranslateFontString(m_sVariable);
     if (zNewFont != null)
     {
         m_zPreviousFont = zProcessData.Font;
         zProcessData.SetFont(zNewFont, zGraphics);
         return true;
     }
     return false;
 }
        /// <summary>
        /// Processes the image markup and if the image is valid associates it with the current process data.
        /// </summary>
        /// <param name="zElement"></param>
        /// <param name="zData"></param>
        /// <param name="zProcessData"></param>
        /// <param name="zGraphics"></param>
        /// <returns>false -  The BackgroundImageMarkup.Render is called as part of a TextMarkup</returns>
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            var arrayComponents = m_sVariable.Split(new char[] { ';' });
            if (1 > arrayComponents.Length)
            {
                return false;
            }
            LineNumber = zProcessData.CurrentLine;

            m_sImageFile = arrayComponents[0];

            var zBmp = DrawItem.LoadImageFromCache(m_sImageFile);

            m_fXOffset = zProcessData.CurrentXOffset;
            m_fYOffset = zProcessData.CurrentYOffset;

            if (null != zBmp)
            {
                switch (arrayComponents.Length)
                {
                    case 1:
                        m_nWidth = zBmp.Width;
                        m_nHeight = zBmp.Height;
                        TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, 0, 0);
                        return true;
                    case 5:
                        {
                            if (float.TryParse(arrayComponents[1], out m_fXOffset) &&
                                float.TryParse(arrayComponents[2], out m_fYOffset) &&
                                int.TryParse(arrayComponents[3], out m_nWidth) &&
                                int.TryParse(arrayComponents[4], out m_nHeight))
                            {
                                TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, 0, 0);
                                return true;
                            }
                        }
                        break;
                }
            }

            return false;
        }
 public override void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.FontBrush = m_zPreviousBrush;
 }
示例#11
0
        protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData,
                                                     Graphics zGraphics)
        {
            var arrayComponents = m_sVariable.Split(new char[] { ';' });

            var fMarkupXOffset      = 0f;
            var fMarkupYOffset      = 0f;
            var fMarkupHeightAdjust = 0f;
            var fMarkupYWidthAdjust = 0f;

            m_fAdditionalVerticalPixels = 0f;

            if (arrayComponents.Length > 0)
            {
                m_zBrush = new SolidBrush(ProjectLayoutElement.TranslateColorString(arrayComponents[0], zElement.opacity));

                if (arrayComponents.Length == 2)
                {
                    ParseUtil.ParseFloat(arrayComponents[1], out m_fAdditionalVerticalPixels);
                }
                else if (arrayComponents.Length > 4)
                {
                    ParseUtil.ParseFloat(arrayComponents[1], out fMarkupXOffset);
                    ParseUtil.ParseFloat(arrayComponents[2], out fMarkupYOffset);
                    ParseUtil.ParseFloat(arrayComponents[3], out m_fAdditionalHorizontalPixels);
                    ParseUtil.ParseFloat(arrayComponents[4], out m_fAdditionalVerticalPixels);
                }
            }

            m_fXOffset = zProcessData.CurrentXOffset + fMarkupXOffset;
            m_fYOffset = zProcessData.CurrentYOffset + fMarkupYOffset;
            return(true);
        }
示例#12
0
 public virtual void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
 }
示例#13
0
 public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.AddFontStyle(Style, zGraphics);
     return false;
 }
示例#14
0
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            float fNewSize;

            if (ParseUtil.ParseFloat(m_sVariable, out fNewSize) && fNewSize > 0)
            {
                m_zPreviousFont = zProcessData.Font;
                zProcessData.SetFont(new Font(zProcessData.Font.FontFamily, fNewSize, zProcessData.Font.Style), zGraphics);
            }
            return(false);
        }
示例#15
0
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            var arrayComponents = m_sVariable.Split(new char[] { ';' });
            if (1 > arrayComponents.Length)
            {
                return false;
            }
            LineNumber = zProcessData.CurrentLine;

            m_sImageFile = arrayComponents[0];

            var zBmp = DrawItem.LoadImageFromCache(m_sImageFile);

            if (null == zBmp)
            {
                return false;
            }

            var fLineHeightPercent = -1f;

            // SOOOOO much duplication
            switch (arrayComponents.Length)
            {
                case 1:
                    TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, zBmp.Width, zBmp.Height);
                    break;
                case 2:
                    float.TryParse(arrayComponents[1], out fLineHeightPercent);
                    TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, zBmp.Width, zBmp.Height);
                    break;
                case 3:
                    if (float.TryParse(arrayComponents[1], out m_fXOffset) &&
                        float.TryParse(arrayComponents[2], out m_fYOffset))
                    {
                        TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, zBmp.Width, zBmp.Height);
                    }
                    break;
                case 4:
                    float.TryParse(arrayComponents[1], out fLineHeightPercent);
                    if (float.TryParse(arrayComponents[2], out m_fXOffset) &&
                        float.TryParse(arrayComponents[3], out m_fYOffset))
                    {
                        TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, zBmp.Width, zBmp.Height);
                    }
                    break;
                case 5: // width and height are absolute (even overlapping drawing)
                    {
                        int nWidth;
                        int nHeight;
                        if (float.TryParse(arrayComponents[1], out m_fXOffset) &&
                            float.TryParse(arrayComponents[2], out m_fYOffset) &&
                            int.TryParse(arrayComponents[3], out nWidth) &&
                            int.TryParse(arrayComponents[4], out nHeight))
                        {
                            TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, nWidth, nHeight);
                        }
                    }
                    break;
            }

            if (TargetRect == RectangleF.Empty)
            {
                return false;
            }

            m_fXOffset += zProcessData.CurrentXOffset;
            m_fYOffset += zProcessData.CurrentYOffset;

            if (-1f != fLineHeightPercent)
            {
                var aspectRatio = TargetRect.Width / TargetRect.Height;
                var fNewHeight = fLineHeightPercent * (zProcessData.FontHeight == 0f ? 1f : (float)zProcessData.FontHeight);
                var fNewWidth = fNewHeight * aspectRatio;
                TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, fNewWidth, fNewHeight);
            }

            // newline eval
            if (TargetRect.Width + TargetRect.X > zElement.width)
            {
                zProcessData.MoveToNextLine(zElement);
                TargetRect = new RectangleF(0, zProcessData.CurrentY, TargetRect.Width, TargetRect.Height);
            }

            // cap off excessively wide images
            if (TargetRect.Width + TargetRect.X > zElement.width)
            {
                TargetRect = new RectangleF(TargetRect.X, TargetRect.Y, zElement.width, TargetRect.Height);
            }

            // Center the image on the line based on font height or line height (todo figure out which...)
            TargetRect = new RectangleF(TargetRect.X,
                TargetRect.Y + (((float)zProcessData.FontHeight - (float)TargetRect.Height) / 2f), TargetRect.Width, TargetRect.Height);

            zProcessData.CurrentX += TargetRect.Width;

            return true;
        }
示例#16
0
 public override void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.CurrentXOffset = m_fPreviousOffset;
 }
示例#17
0
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            var arrayComponents = m_sVariable.Split(new char[] { ';' });

            if (1 > arrayComponents.Length)
            {
                return(false);
            }

            int nX;

            if (!int.TryParse(arrayComponents[0], out nX))
            {
                return(false);
            }
            else if (-1 == nX)
            {
                nX = (int)zProcessData.CurrentX;
            }

            int nY = (int)zProcessData.CurrentY;

            if (2 <= arrayComponents.Length)
            {
                if (!int.TryParse(arrayComponents[1], out nY))
                {
                    return(false);
                }
                else if (-1 == nY)
                {
                    nY = (int)zProcessData.CurrentY;
                }
            }

            zProcessData.CurrentX = Math.Max(0, Math.Min(nX, zElement.width));
            zProcessData.CurrentY = Math.Max(0, Math.Min(nY, zElement.height));
            return(false);
        }
示例#18
0
        protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            // TODO: adjust the TranslateFontString method (or add a sibling) to not double up on the string split
            var arrayComponents = m_sVariable.Split(CardMakerConstants.FORMATTED_TEXT_PARAM_SEPARATOR_ARRAY, StringSplitOptions.None);

            if (1 > arrayComponents.Length)
            {
                return(false);
            }

            var sNewFont = m_sVariable;

            if (arrayComponents.Length == 1)
            {
                sNewFont = string.Join(CardMakerConstants.FORMATTED_TEXT_PARAM_SEPARATOR, new string[]
                {
                    arrayComponents[0],
                    zProcessData.Font.Size.ToString(),
                    ProjectLayoutElement.BoolToNumericString(zProcessData.Font.Bold),
                    ProjectLayoutElement.BoolToNumericString(zProcessData.Font.Underline),
                    ProjectLayoutElement.BoolToNumericString(zProcessData.Font.Italic),
                    ProjectLayoutElement.BoolToNumericString(zProcessData.Font.Strikeout)
                });
            }
            else if (arrayComponents.Length == 2)
            {
                sNewFont = string.Join(CardMakerConstants.FORMATTED_TEXT_PARAM_SEPARATOR, new string[]
                {
                    arrayComponents[0],
                    string.IsNullOrWhiteSpace(arrayComponents[1]) ? zProcessData.Font.Size.ToString(): arrayComponents[1],
                    ProjectLayoutElement.BoolToNumericString(zProcessData.Font.Bold),
                    ProjectLayoutElement.BoolToNumericString(zProcessData.Font.Underline),
                    ProjectLayoutElement.BoolToNumericString(zProcessData.Font.Italic),
                    ProjectLayoutElement.BoolToNumericString(zProcessData.Font.Strikeout)
                });
            }
            else if (arrayComponents.Length == 6)
            {
                sNewFont = string.Join(CardMakerConstants.FORMATTED_TEXT_PARAM_SEPARATOR, new string[]
                {
                    arrayComponents[0],
                    string.IsNullOrWhiteSpace(arrayComponents[1]) ? zProcessData.Font.Size.ToString(): arrayComponents[1],
                    arrayComponents[2],
                    arrayComponents[3],
                    arrayComponents[4],
                    arrayComponents[5]
                });
            }
            else
            {
                sNewFont = m_sVariable;
            }

            var zNewFont = ProjectLayoutElement.TranslateFontString(sNewFont);

            if (zNewFont != null)
            {
                m_zPreviousFont = zProcessData.Font;
                zProcessData.SetFont(zNewFont, zGraphics);
                return(true);
            }
            return(false);
        }
示例#19
0
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            m_zFontBrush = zProcessData.FontBrush;
            m_zFont = zProcessData.Font;
            m_fFontHeight = zProcessData.FontHeight;
            m_fXOffset = zProcessData.CurrentXOffset;
            m_fYOffset = zProcessData.CurrentYOffset;

            LineNumber = zProcessData.CurrentLine;

            m_fFontOutlineSize = m_zFont.Size;

            // TODO: stop recalculating this, store it in the processData
            if (0 != zElement.outlinethickness)
            {
                switch (m_zFont.Unit)
                {
                    case GraphicsUnit.Point:
                        m_fFontOutlineSize = zGraphics.DpiY * (m_zFont.Size / 72f);
                        break;
                    default:
                        Logger.AddLogLine("This font is using the Unit: {0} (not currently supported)".FormatString(m_zFont.Unit.ToString()));
                        break;
                }
            }

            m_rectMeasuredRectangle = MeasureDisplayStringWidth(zGraphics, m_sVariable, m_zFont);

            var fMeasuredWidth = m_rectMeasuredRectangle.Width;

            var fMeasuredHeight = Math.Max(m_rectMeasuredRectangle.Height, m_fFontHeight);

            if (zProcessData.CurrentX + fMeasuredWidth > zElement.width)
            {
                zProcessData.MoveToNextLine(zElement);
            }

            TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, fMeasuredWidth, fMeasuredHeight);

            zProcessData.CurrentX += fMeasuredWidth;

            return true;
        }
示例#20
0
 public override void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.CurrentStringAlignment = m_ePreviousStringAlignment;
 }
示例#21
0
 protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     m_ePreviousStringAlignment          = zProcessData.CurrentStringAlignment;
     zProcessData.CurrentStringAlignment = MarkupAlignment;
     return(false);
 }
示例#22
0
        protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            var arrayComponents = m_sVariable.Split(new char[] { ';' });

            if (1 > arrayComponents.Length)
            {
                return(false);
            }
            LineNumber = zProcessData.CurrentLine;

            m_sImageFile = arrayComponents[0];

            m_zBmp = ImageCache.LoadCustomImageFromCache(m_sImageFile, zElement);

            if (null == m_zBmp ||
                m_zBmp.Width == 0 ||
                m_zBmp.Height == 0)
            {
                return(false);
            }

            var fLineHeightPercent = -1f;

            // SOOOOO much duplication
            switch (arrayComponents.Length)
            {
            case 1:     // <img=[filename]>
                fLineHeightPercent = 1.0f;
                TargetRect         = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, m_zBmp.Width, m_zBmp.Height);
                break;

            case 2:     // <img=[filename];[percent]>
                ParseUtil.ParseFloat(arrayComponents[1], out fLineHeightPercent);
                TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, m_zBmp.Width, m_zBmp.Height);
                break;

            case 3:     // <img=[filename];[xoffset];[yoffset]>
                if (ParseUtil.ParseFloat(arrayComponents[1], out m_fXOffset) &&
                    ParseUtil.ParseFloat(arrayComponents[2], out m_fYOffset))
                {
                    TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, m_zBmp.Width, m_zBmp.Height);
                }
                break;

            case 4:     // <img=[filename];[percent];[xoffset];[yoffset]>
                ParseUtil.ParseFloat(arrayComponents[1], out fLineHeightPercent);
                if (ParseUtil.ParseFloat(arrayComponents[2], out m_fXOffset) &&
                    ParseUtil.ParseFloat(arrayComponents[3], out m_fYOffset))
                {
                    TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, m_zBmp.Width, m_zBmp.Height);
                }
                break;

            case 5:     // <img=[filename];[xoffset];[yoffset];[width];[height]>
            {
                int nWidth;
                int nHeight;
                if (ParseUtil.ParseFloat(arrayComponents[1], out m_fXOffset) &&
                    ParseUtil.ParseFloat(arrayComponents[2], out m_fYOffset) &&
                    int.TryParse(arrayComponents[3], out nWidth) &&
                    int.TryParse(arrayComponents[4], out nHeight))
                {
                    TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, nWidth, nHeight);
                }
            }
            break;
            }

            if (TargetRect == RectangleF.Empty)
            {
                return(false);
            }

            m_fXOffset += zProcessData.CurrentXOffset;
            m_fYOffset += zProcessData.CurrentYOffset;

            var fAspectRatio = (float)m_zBmp.Width / (float)m_zBmp.Height;

            if (-1f != fLineHeightPercent)
            {
                var fNewHeight = fLineHeightPercent * (zProcessData.FontHeight == 0f ? 1f : (float)zProcessData.FontHeight);
                var fNewWidth  = fNewHeight * fAspectRatio;
                TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, fNewWidth, fNewHeight);
            }

            // newline eval
            if (TargetRect.Width + TargetRect.X > zElement.width)
            {
                zProcessData.MoveToNextLine(zElement);
                TargetRect = new RectangleF(0, zProcessData.CurrentY, TargetRect.Width, TargetRect.Height);
            }

            // cap off excessively wide images
            if (TargetRect.Width + TargetRect.X > zElement.width)
            {
                var fNewHeight = zElement.width / fAspectRatio;
                TargetRect = new RectangleF(TargetRect.X, TargetRect.Y, zElement.width, fNewHeight);
            }

            // Center the image on the line based on font height or line height (todo figure out which...)
            TargetRect = new RectangleF(TargetRect.X,
                                        TargetRect.Y + (((float)zProcessData.FontHeight - (float)TargetRect.Height) / 2f), TargetRect.Width, TargetRect.Height);

            zProcessData.CurrentX += TargetRect.Width;

            return(true);
        }
示例#23
0
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            m_zFontBrush    = zProcessData.FontBrush;
            m_zFont         = zProcessData.Font;
            m_fFontHeight   = zProcessData.FontHeight;
            m_fXOffset      = zProcessData.CurrentXOffset;
            m_fYOffset      = zProcessData.CurrentYOffset;
            StringAlignment = zProcessData.CurrentStringAlignment;

            LineNumber = zProcessData.CurrentLine;

            m_fFontOutlineSize = m_zFont.Size;

            // TODO: stop recalculating this, store it in the processData
            if (0 != zElement.outlinethickness)
            {
                switch (m_zFont.Unit)
                {
                case GraphicsUnit.Point:
                    m_fFontOutlineSize = zGraphics.DpiY * (m_zFont.Size / 72f);
                    break;

                default:
                    Logger.AddLogLine("This font is using the Unit: {0} (not currently supported)".FormatString(m_zFont.Unit.ToString()));
                    break;
                }
            }

            m_rectMeasuredRectangle = MeasureDisplayStringWidth(zGraphics, m_sVariable, m_zFont);

            var fMeasuredWidth = m_rectMeasuredRectangle.Width;

            var fMeasuredHeight = Math.Max(m_rectMeasuredRectangle.Height, m_fFontHeight);

            if (zProcessData.CurrentX + fMeasuredWidth > zElement.width)
            {
                zProcessData.MoveToNextLine(zElement);
            }

            TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, fMeasuredWidth, fMeasuredHeight);

            zProcessData.CurrentX += fMeasuredWidth;

            return(true);
        }
示例#24
0
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            float fXOffset;

            if (ParseUtil.ParseFloat(m_sVariable, out fXOffset))
            {
                m_fPreviousOffset           = zProcessData.CurrentXOffset;
                zProcessData.CurrentXOffset = fXOffset;
            }
            return(false);
        }
示例#25
0
        /// <summary>
        /// Processes the formatted text data into rendered markups.
        /// </summary>
        /// <param name="zGraphics">The graphics to use to plan the render</param>
        /// <param name="zElement">The element</param>
        /// <param name="fMainFontSize">The font size to use for the default font</param>
        /// <param name="zFormattedTextData">The processed formatted text data</param>
        /// <returns>List of markups to be rendered</returns>
        protected List <MarkupBase> processMarkupDefinition(Graphics zGraphics, ProjectLayoutElement zElement, float fMainFontSize, FormattedTextData zFormattedTextData)
        {
            var colorFont = zElement.GetElementColor();
            var zBrush    = 255 == zElement.opacity
                ? new SolidBrush(colorFont)
                : new SolidBrush(Color.FromArgb(zElement.opacity, colorFont));

            var zProcessData = new FormattedTextProcessData
            {
                FontBrush              = zBrush,
                CurrentLineHeight      = zElement.lineheight,
                CurrentStringAlignment = zElement.GetHorizontalAlignment()
            };

            var zFont = zElement.GetElementFont();

            if (null == zFont) // default to something!
            {
                // font will show up in red if it's not yet set
                zFont = FontLoader.DefaultFont;
            }

            var zScaledFont = FontLoader.GetFont(zFont.FontFamily, fMainFontSize, zFont.Style);

            // set the initial font
            zProcessData.SetFont(zScaledFont, zGraphics);

            var listPassMarkups =
                new List <MarkupBase>(); // only contains the markups that will be actively drawn (for caching)

            // Pass 1:
            // - Create rectangles
            // - Configure per-markup settings based on state of markup stack
            // - Generate list of markups to continue to process (those that are used in the next pass)
            // - Specify Markup rectanlges
            // - Generate markup rows (LineNumber is usable AFTER this process)
            int        nIdx;
            MarkupBase zMarkup;

            for (nIdx = 0; nIdx < zFormattedTextData.AllMarkups.Count; nIdx++)
            {
                zMarkup = zFormattedTextData.AllMarkups[nIdx];
                if (zMarkup.ProcessMarkup(zElement, zFormattedTextData, zProcessData, zGraphics))
                {
                    zMarkup.LineNumber = zProcessData.CurrentLine;
                    listPassMarkups.Add(zMarkup);
                }
            }

            // Pass 2:
            // - Trim spaces from line endings
            if (listPassMarkups.Count > 0)
            {
                nIdx    = listPassMarkups.Count - 1;
                zMarkup = listPassMarkups[nIdx];
                var currentLineNumber = zMarkup.LineNumber;
                var bFindNextLine     = false;
                while (nIdx > -1)
                {
                    zMarkup = listPassMarkups[nIdx];
                    if (zMarkup.LineNumber != currentLineNumber)
                    {
                        currentLineNumber = zMarkup.LineNumber;
                        bFindNextLine     = false;
                    }

                    if (!bFindNextLine && zMarkup is SpaceMarkup && ((SpaceMarkup)zMarkup).Optional)
                    {
                        listPassMarkups.RemoveAt(nIdx);
                    }
                    else
                    {
                        bFindNextLine = true;
                    }

                    nIdx--;
                }
            }

            // Pass 3:
            // - Align lines (horizontal/vertical)

            // Reprocess for align (before backgroundcolor is configured)
            AlignmentController.UpdateAlignment(zElement, listPassMarkups);

            // Pass 4: process the remaining items
            nIdx = 0;
            while (nIdx < listPassMarkups.Count)
            {
                zMarkup = listPassMarkups[nIdx];
                if (!zMarkup.PostProcessMarkupRectangle(zElement, listPassMarkups, nIdx))
                {
                    listPassMarkups.RemoveAt(nIdx);
                    continue;
                }
                nIdx++;
            }

            return(listPassMarkups);
        }
示例#26
0
 public override void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.FontBrush = m_zPreviousBrush;
 }
示例#27
0
        protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            float fLineHeight;

            if (ParseUtil.ParseFloat(m_sVariable, out fLineHeight))
            {
                m_fPreviousLineHeight          = zProcessData.CurrentLineHeight;
                zProcessData.CurrentLineHeight = fLineHeight;
            }
            return(false);
        }
示例#28
0
 /// <summary>
 /// Processes the markup to determine the markup stack information (font settings, rectangle sizes/settings)
 /// </summary>
 /// <param name="zElement"></param>
 /// <param name="zData"></param>
 /// <param name="zProcessData"></param>
 /// <param name="zGraphics"></param>
 /// <returns>true if this markup is to be further processed</returns>
 public bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     if (Aligns)
     {
         StringAlignment = zProcessData.CurrentStringAlignment;
     }
     return(ProcessMarkupHandler(zElement, zData, zProcessData, zGraphics));
 }
示例#29
0
 protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.AddFontStyle(Style, zGraphics);
     return(false);
 }
示例#30
0
 public override void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.RemoveFontStyle(Style, zGraphics);
 }
示例#31
0
 public override void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.CurrentXOffset = m_fPreviousOffset;
 }
示例#32
0
 public override void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.RemoveFontStyle(Style, zGraphics);
 }
示例#33
0
 public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     m_zPreviousBrush = zProcessData.FontBrush;
     zProcessData.FontBrush = new SolidBrush(ProjectLayoutElement.TranslateColorString(m_sVariable));
     return false;
 }
示例#34
0
 public virtual void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
 }
示例#35
0
 public override void CloseMarkup(FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.CurrentLineHeight = m_fPreviousLineHeight;
 }
示例#36
0
 /// <summary>
 /// Processes the markup to determine the markup stack information (font settings, rectangle sizes/settings)
 /// </summary>
 /// <param name="zElement"></param>
 /// <param name="zData"></param>
 /// <param name="zProcessData"></param>
 /// <param name="zGraphics"></param>
 /// <returns>true if this markup is to be further processed</returns>
 public virtual bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     return false;
 }
示例#37
0
 /// <summary>
 /// Processes the markup to determine the markup stack information (font settings, rectangle sizes/settings)
 /// </summary>
 /// <param name="zElement"></param>
 /// <param name="zData"></param>
 /// <param name="zProcessData"></param>
 /// <param name="zGraphics"></param>
 /// <returns>true if this markup is to be further processed</returns>
 protected virtual bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     return(false);
 }
示例#38
0
        protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            MarkupToClose.CloseMarkup(zData, zProcessData, zGraphics);

            // keep only the necessary markups
            return(s_dictionaryKeepTypesOnProcess.ContainsKey(MarkupToClose.GetType()));
        }
示例#39
0
 public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData,
     Graphics zGraphics)
 {
     return true;
 }
示例#40
0
        protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            m_fXOffset = zProcessData.CurrentXOffset;
            m_fYOffset = zProcessData.CurrentYOffset;

            var arrayComponents = m_sVariable.Split(new char[] { ';' });

            if (1 > arrayComponents.Length)
            {
                return(false);
            }

            int nX;

            if (!int.TryParse(arrayComponents[0], out nX))
            {
                return(false);
            }
            else if (-1 == nX)
            {
                nX = (int)zProcessData.CurrentX;
            }

            int nY = (int)zProcessData.CurrentY;

            if (2 <= arrayComponents.Length)
            {
                if (!int.TryParse(arrayComponents[1], out nY))
                {
                    return(false);
                }
                else if (-1 == nY)
                {
                    nY = (int)zProcessData.CurrentY;
                }
            }

            nX = Math.Max(0, Math.Min(nX, zElement.width));
            nY = Math.Max(0, Math.Min(nY, zElement.height));

            TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY,
                                        Math.Max(0, nX - zProcessData.CurrentX),
                                        Math.Max(0, nY - zProcessData.CurrentY));

            zProcessData.CurrentX = nX;
            zProcessData.CurrentY = nY;
            return(true);
        }
 public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     m_zPreviousBrush       = zProcessData.FontBrush;
     zProcessData.FontBrush = new SolidBrush(ProjectLayoutElement.TranslateColorString(m_sVariable));
     return(false);
 }
示例#42
0
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData,
                                           Graphics zGraphics)
        {
            var arrayComponents = m_sVariable.Split(new char[] { ';' });

            if (arrayComponents.Length > 0)
            {
                m_zBrush = new SolidBrush(ProjectLayoutElement.TranslateColorString(arrayComponents[0], zElement.opacity));

                if (arrayComponents.Length > 1)
                {
                    ParseUtil.ParseFloat(arrayComponents[1], out m_fAdditionalPixels);
                }
            }

            m_fXOffset = zProcessData.CurrentXOffset;
            m_fYOffset = zProcessData.CurrentYOffset;
            return(true);
        }
示例#43
0
        public static void DrawFormattedText(Graphics zGraphics, Deck zDeck, ProjectLayoutElement zElement, string sInput, Brush zBrush, Font zFont, Color colorFont)
        {
            // check the cache for this item
            var zDataFormattedCache = zDeck.GetCachedMarkup(zElement.name);

            if (null == zDataFormattedCache)
            {
                if (null == zFont) // default to something!
                {
                    // font will show up in red if it's not yet set
                    zFont  = s_zDefaultFont;
                    zBrush = Brushes.Red;
                }

                if (255 != zElement.opacity)
                {
                    zBrush = new SolidBrush(Color.FromArgb(zElement.opacity, colorFont));
                }

                zDataFormattedCache = new FormattedTextDataCache();
                var zFormattedData = new FormattedTextData(FormattedTextParser.GetMarkups(sInput));
                var zProcessData   = new FormattedTextProcessData {
                    FontBrush = zBrush
                };

                // set the initial font
                zProcessData.SetFont(zFont, zGraphics);

                var listPassMarkups = new List <MarkupBase>(); // only contains the markups that will be actively drawn (for caching)

                // Pass 1:
                // - Create rectangles
                // - Configure per-markup settings based on state of markup stack
                // - Generate list of markups to continue to process (those that are used in the next pass)
                // - Specify Markup rectanlges
                // - Generate markup rows
                int        nIdx;
                MarkupBase zMarkup;
                for (nIdx = 0; nIdx < zFormattedData.AllMarkups.Count; nIdx++)
                {
                    zMarkup = zFormattedData.AllMarkups[nIdx];
                    if (zMarkup.ProcessMarkup(zElement, zFormattedData, zProcessData, zGraphics))
                    {
                        zMarkup.LineNumber = zProcessData.CurrentLine;
                        listPassMarkups.Add(zMarkup);
                    }
                }

                // Pass 2:
                // - Trim spaces from line endings
                if (listPassMarkups.Count > 0)
                {
                    nIdx    = listPassMarkups.Count - 1;
                    zMarkup = listPassMarkups[nIdx];
                    var currentLineNumber = zMarkup.LineNumber;
                    var bFindNextLine     = false;
                    while (nIdx > -1)
                    {
                        zMarkup = listPassMarkups[nIdx];
                        if (zMarkup.LineNumber != currentLineNumber)
                        {
                            currentLineNumber = zMarkup.LineNumber;
                            bFindNextLine     = false;
                        }

                        if (!bFindNextLine && zMarkup is SpaceMarkup && ((SpaceMarkup)zMarkup).Optional)
                        {
                            listPassMarkups.RemoveAt(nIdx);
                        }
                        else
                        {
                            bFindNextLine = true;
                        }
                        nIdx--;
                    }
                }

                // Pass 3:
                // - Align lines (horizontal/vertical)

                // Reprocess for align (before backgroundcolor is configured)
                AlignmentController.UpdateAlignment(zElement, listPassMarkups);

                // Pass 4: process the remaining items
                nIdx = 0;
                while (nIdx < listPassMarkups.Count)
                {
                    zMarkup = listPassMarkups[nIdx];
                    if (!zMarkup.PostProcessMarkupRectangle(zElement, listPassMarkups, nIdx))
                    {
                        listPassMarkups.RemoveAt(nIdx);
                        nIdx--;
                    }
                    else
                    {
                        zDataFormattedCache.AddMarkup(zMarkup);
                    }
                    nIdx++;
                }

                // update the cache
                zDeck.AddCachedMarkup(zElement.name, zDataFormattedCache);
            }

            zDataFormattedCache.Render(zElement, zGraphics);
        }
示例#44
0
        protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            m_fXOffset = zProcessData.CurrentXOffset;
            m_fYOffset = zProcessData.CurrentYOffset;

            var arrayComponents = m_sVariable.Split(new char[] { ';' });

            if (1 > arrayComponents.Length)
            {
                return(false);
            }

            int nXPush;

            if (!int.TryParse(arrayComponents[0], out nXPush))
            {
                return(false);
            }

            var nYPush = 0;

            if (2 <= arrayComponents.Length)
            {
                if (!int.TryParse(arrayComponents[1], out nYPush))
                {
                    return(false);
                }
            }

            TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY,
                                        Math.Max(0, nXPush),
                                        Math.Max(0, nYPush));

            zProcessData.CurrentX += nXPush;
            zProcessData.CurrentY += nYPush;

            if (zProcessData.IsXPositionOutsideBounds(zProcessData.CurrentX))
            {
                zProcessData.MoveToNextLine(zElement);
            }

            return(true);
        }
示例#45
0
        /// <summary>
        /// Processes the image markup and if the image is valid associates it with the current process data.
        /// </summary>
        /// <param name="zElement"></param>
        /// <param name="zData"></param>
        /// <param name="zProcessData"></param>
        /// <param name="zGraphics"></param>
        /// <returns>false -  The BackgroundImageMarkup.Render is called as part of a TextMarkup</returns>
        protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            var arrayComponents = m_sVariable.Split(new char[] { ';' });

            if (1 > arrayComponents.Length)
            {
                return(false);
            }

            LineNumber = zProcessData.CurrentLine;

            m_sImageFile = arrayComponents[0];
            m_colorImage = zProcessData.ImageColor;

            var zBmp = LoadImage(zElement);

            m_fXOffset = zProcessData.CurrentXOffset;
            m_fYOffset = zProcessData.CurrentYOffset;

            if (null != zBmp)
            {
                switch (arrayComponents.Length)
                {
                case 1:
                    m_nWidth   = zBmp.Width;
                    m_nHeight  = zBmp.Height;
                    TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, 0, 0);
                    return(true);

                case 5:
                {
                    if (ParseUtil.ParseFloat(arrayComponents[1], out m_fXOffset) &&
                        ParseUtil.ParseFloat(arrayComponents[2], out m_fYOffset) &&
                        int.TryParse(arrayComponents[3], out m_nWidth) &&
                        int.TryParse(arrayComponents[4], out m_nHeight))
                    {
                        TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, 0, 0);
                        return(true);
                    }
                }
                break;
                }
            }

            return(false);
        }
示例#46
0
        protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            var zNewFont = ProjectLayoutElement.TranslateFontString(m_sVariable);

            if (zNewFont != null)
            {
                m_zPreviousFont = zProcessData.Font;
                zProcessData.SetFont(zNewFont, zGraphics);
                return(true);
            }
            return(false);
        }
示例#47
0
        public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
        {
            int nSpaces;

            if (!int.TryParse(m_sVariable, out nSpaces))
            {
                return(false);
            }

            StringAlignment = zProcessData.CurrentStringAlignment;
            LineNumber      = zProcessData.CurrentLine;

            float fWidth = (float)nSpaces * ((float)zProcessData.FontSpaceWidth + (float)zElement.wordspace);

            if (0 == fWidth)
            {
                return(false);
            }

            if (zProcessData.CurrentX + fWidth >= zElement.width)
            {
                if (Optional)
                {
                    return(false);
                }
                zProcessData.MoveToNextLine(zElement);
            }

            TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, fWidth, zProcessData.FontSpaceHeight);

            zProcessData.CurrentX += fWidth;
            return(true);
        }
示例#48
0
 protected override bool ProcessMarkupHandler(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.MoveToNextLine(zElement);
     return(true);
 }