protected override ElementString TranslateToElementString(string sRawString, int nCardIndex, DeckLine zDeckLine, ProjectLayoutElement zElement)
 {
     using (var engine = new V8ScriptEngine())
     {
         var sScript = GetJavaScript(nCardIndex, zDeckLine, sRawString);
         try
         {
             var sValue = engine.Evaluate(sScript);
             if (sValue is string || sValue is int)
             {
                 return new ElementString()
                 {
                     String = sValue.ToString()
                 };
             }
             else
             {
                 Logger.AddLogLine(sValue.GetType().ToString());
             }
         }
         catch (Exception e)
         {
             Logger.AddLogLine(e.Message);
         }
     }
     return new ElementString()
     {
         String = string.Empty
     };
 }
        protected float GetLargestMarkupHeight(ProjectLayoutElement zElement, List<MarkupBase> listMarkups)
        {
            if (0 == listMarkups.Count)
            {
                return 0;
            }

            var zLastMarkup = listMarkups[listMarkups.Count - 1];
            var nLineNumber = zLastMarkup.LineNumber;
            // find the largest total height on the last row (inclusive of the Y position)
            var fLargestTotal = zLastMarkup.TargetRect.Y + zLastMarkup.TargetRect.Height;
            var nIdx = listMarkups.Count - 2;
            while (nIdx > -1)
            {
                var zMarkup = listMarkups[nIdx];
                if (nLineNumber == zMarkup.LineNumber)
                {
                    fLargestTotal = Math.Max(fLargestTotal, zMarkup.TargetRect.Y + zMarkup.TargetRect.Height);
                }
                else
                {
                    break;
                }
                nIdx--;
            }
            return fLargestTotal;
        }
Exemple #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());
        }
Exemple #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;
        }
Exemple #5
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;
        }
Exemple #6
0
        private static void DrawGraphic(Graphics zGraphics, string sFile, ProjectLayoutElement zElement)
        {
            string sPath = sFile;
            if (sPath.Equals("none", StringComparison.CurrentCultureIgnoreCase))
            {
                return;
            }
            if (!File.Exists(sPath))
            {
                sPath = CardMakerMDI.ProjectPath + sFile;
            }
            if (File.Exists(sPath))
            {
                var zBmp = 255 != zElement.opacity
                    ? LoadOpacityImageFromCache(sPath, zElement)
                    : LoadImageFromCache(sPath);

                int nWidth = zElement.width;
                int nHeight = zElement.height;

                if (zElement.keeporiginalsize)
                {
                    DrawGraphicOriginalSize(zGraphics, zBmp, zElement);
                    return;
                }

                if (zElement.lockaspect)
                {
                    var fAspect = (float)zBmp.Tag;

                    var nTargetHeight = (int)((float)nWidth / fAspect);
                    if (nTargetHeight < nHeight)
                    {
                        nHeight = (int)((float)nWidth / fAspect);
                    }
                    else
                    {
                        nWidth = (int)((float)nHeight * fAspect);
                    }
                }

                int nX = 0;
                int nY = 0;

                // standard alignment adjustment
                UpdateAlignmentValue(zElement.horizontalalign, ref nX, zElement.width, nWidth);
                UpdateAlignmentValue(zElement.verticalalign, ref nY, zElement.height, nHeight);

                zGraphics.DrawImage(zBmp, nX, nY, nWidth, nHeight);

            }
            else
            {
                MDIIssues.Instance.AddIssue("Image file not found: " + sFile);
            }
            // draw nothing
        }
        public override float GetVerticalAlignOffset(ProjectLayoutElement zElement, List<MarkupBase> listMarkups)
        {
            if (0 == listMarkups.Count)
            {
                return 0;
            }

            return (((float)zElement.height - GetLargestMarkupHeight(zElement, listMarkups))) / 2f;
        }
Exemple #8
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;
 }
Exemple #9
0
 public static void DrawElementDebugBorder(Graphics zGraphics, ProjectLayoutElement zElement, int nX, int nY, bool bSelected)
 {
     // note that the border is inclusive in the width/height consuming 2 pixels (0 to total-1)
     zGraphics.TranslateTransform(nX, nY);
     zGraphics.DrawRectangle(s_zPenDebugBorder, zElement.x, zElement.y, zElement.width - 1, zElement.height - 1);
     if (bSelected)
     {
         zGraphics.DrawRectangle(m_zPenElementSelect, zElement.x - 2, zElement.y - 2, zElement.width + 3, zElement.height + 3);
     }
 }
 public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     float fYOffset;
     if (float.TryParse(m_sVariable, out fYOffset))
     {
         m_fPreviousOffset = zProcessData.CurrentYOffset;
         zProcessData.CurrentYOffset = fYOffset;
     }
     return false;
 }
 /// <summary>
 /// Updates the position of the markups based on horizontal alignment
 /// </summary>
 /// <param name="nFirst"></param>
 /// <param name="nLast"></param>
 /// <param name="bLastLine"></param>
 /// <param name="zElement"></param>
 /// <param name="listMarkups">List of Markups (all must have Aligns set to true)</param>
 /// <param name="fVerticalOffset">Any vertical offset to apply</param>
 /// <param name="listAllMarkups"></param>
 public virtual void UpdateLineAlignment(int nFirst, int nLast, bool bLastLine, ProjectLayoutElement zElement,
     List<MarkupBase> listMarkups, float fVerticalOffset, IEnumerable<MarkupBase> listAllMarkups)
 {
     var fHorizontalOffset = GetHorizontalOffset(zElement, listMarkups[nLast].TargetRect);
     for (var nIdx = nFirst; nIdx <= nLast; nIdx++)
     {
         var rectCurrent = listMarkups[nIdx].TargetRect;
         listMarkups[nIdx].TargetRect = new RectangleF(rectCurrent.X + fHorizontalOffset, rectCurrent.Y + fVerticalOffset, rectCurrent.Width, rectCurrent.Height);
     }
 }
Exemple #12
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;
 }
 public void Render(ProjectLayoutElement zElement, Graphics zGraphics)
 {
     foreach (var zRenderType in s_zTypeRenderOrder)
     {
         foreach (var zMarkup in m_dictionaryTypeMarkupList[zRenderType])
         {
             if (!zMarkup.Render(zElement, zGraphics))
             {
                 RenderLackOfSpaceWarning(zElement, zGraphics);
             }
         }
     }         
 }
        public override void UpdateLineAlignment(int nFirst, int nLast, bool bLastLine, ProjectLayoutElement zElement, List<MarkupBase> listMarkups, float fVerticalOffset, IEnumerable<MarkupBase> listAllMarkups)
        {
            // detect if this is the last line of markups - if so don't bother with jusity alignment
            if (bLastLine)
            {
                base.UpdateLineAlignment(nFirst, nLast, bLastLine, zElement, listMarkups, fVerticalOffset, listAllMarkups);
                return;
            }
            // detect if this line is followed by a line break - if so don't bother with justify alignment on this line
            var lastLineMarkup = listMarkups[nLast];
            var theBigList = listAllMarkups.ToList();
            var lastLineMarkupIndex = theBigList.IndexOf(lastLineMarkup);
            for (var nIdx = lastLineMarkupIndex + 1; nIdx < theBigList.Count; nIdx++)
            {
                if (theBigList[nIdx] is NewlineMarkup)
                {
                    // no justified alignment due to this line ending with an explicit line break
                    base.UpdateLineAlignment(nFirst, nLast, bLastLine, zElement, listMarkups, fVerticalOffset, listAllMarkups);
                    return;
                }
                if (theBigList[nIdx].Aligns)
                {
                    // the next rendered thing aligns so treat this line as though it is part of a paragraph
                    break;
                }
                // default to justify alignment
            }

            // TODO: the space markups are completely ignored by justified (who cares?)
            var listTextMarkups = listMarkups.GetRange(nFirst, (nLast - nFirst) + 1).Where(zMarkup => !(zMarkup is SpaceMarkup)).ToList();
            var fTotalTextWidth = listTextMarkups.Sum(zMarkup => zMarkup.TargetRect.Width);
            var fDifference = (float)zElement.width - fTotalTextWidth;

            var fXOffset = fDifference / ((float)listTextMarkups.Count - 1);

            //Logger.AddLogLine("TotalTextWidth: {0} Difference: {1} SpaceSize: {2} listTextMarkups: {3}".FormatString(fTotalTextWidth, fDifference, fXOffset, listTextMarkups.Count));
            var fCurrentPosition = listMarkups[nFirst].TargetRect.X;
            for (var nIdx = nFirst; nIdx <= nLast; nIdx++)
            {
                if (listMarkups[nIdx].Aligns && !(listMarkups[nIdx] is SpaceMarkup))
                {
                    var rectCurrent = listMarkups[nIdx].TargetRect;
                    listMarkups[nIdx].TargetRect = new RectangleF(fCurrentPosition,
                        rectCurrent.Y + fVerticalOffset, rectCurrent.Width, rectCurrent.Height);
                    fCurrentPosition += listMarkups[nIdx].TargetRect.Width + fXOffset;
                }
            }
        }
 public override bool Render(ProjectLayoutElement zElement, Graphics zGraphics)
 {
     // Custom Graphics Setting
     // disable smoothing so the background color has a sharp edge
     SmoothingMode ePreviousSmoothingMode = zGraphics.SmoothingMode;
     zGraphics.SmoothingMode = SmoothingMode.None;
     foreach (var rect in m_listRectangles)
     {
         var rectAdjusted = rect;
         // do not draw any rectangles outside of the element
         rectAdjusted.Height = Math.Min(rect.Bottom - rect.Top, zElement.y + zElement.height);
         zGraphics.FillRectangle(m_zBrush, rectAdjusted);
     }
     zGraphics.SmoothingMode = ePreviousSmoothingMode;
     return true;
 }
        public override bool PostProcessMarkupRectangle(ProjectLayoutElement zElement, List<MarkupBase> listAllMarkups, int nMarkup)
        {
            m_listRectangles = new List<RectangleF>();
            for (var nIdx = nMarkup + 1; nIdx < listAllMarkups.Count; nIdx++)
            {
                var zMarkup = listAllMarkups[nIdx];

                // check if the markup is closed
                if (typeof(CloseTagMarkup) == zMarkup.GetType() &&
                    this == ((CloseTagMarkup)zMarkup).MarkupToClose)
                    break;

                m_listRectangles.Add(zMarkup.TargetRect);
            }

            return true;
        }
Exemple #17
0
 public static void DrawElementDebugBorder(Graphics zGraphics, ProjectLayoutElement zElement, int nX, int nY, bool bSelected)
 {
     // note that the border is inclusive in the width/height consuming 2 pixels (0 to total-1)
     zGraphics.TranslateTransform(nX, nY);
     if (bSelected && CardMakerInstance.DrawSelectedElementGuides)
     {
         zGraphics.DrawLine(s_zPenDebugGuides, new PointF(0, zElement.y), new PointF(zGraphics.ClipBounds.Width, zElement.y));
         zGraphics.DrawLine(s_zPenDebugGuides, new PointF(0, zElement.y + zElement.height - 1),
             new PointF(zGraphics.ClipBounds.Width, zElement.y + zElement.height));
         zGraphics.DrawLine(s_zPenDebugGuides, new PointF(zElement.x, 0), new PointF(zElement.x, zGraphics.ClipBounds.Height));
         zGraphics.DrawLine(s_zPenDebugGuides, new PointF(zElement.x + zElement.width - 1, 0),
             new PointF(zElement.x + zElement.width, zGraphics.ClipBounds.Height));
     }
     zGraphics.DrawRectangle(s_zPenDebugBorder, zElement.x, zElement.y, zElement.width - 1, zElement.height - 1);
     if (bSelected)
     {
         zGraphics.DrawRectangle(m_zPenElementSelect, zElement.x - 2, zElement.y - 2, zElement.width + 3, zElement.height + 3);
     }
 }
Exemple #18
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;
        }
        /// <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;
        }
Exemple #20
0
        public ElementString TranslateString(string sRawString, int nCardIndex, DeckLine zDeckLine,
            ProjectLayoutElement zElement, string sCacheSuffix = "")
        {
            string sCacheKey = zElement.name + sCacheSuffix;
            ElementString zCached;
            if (m_dictionaryElementStringCache.TryGetValue(sCacheKey, out zCached))
            {
                return zCached;
            }

            var zElementString = TranslateToElementString(sRawString, nCardIndex, zDeckLine, zElement);

            if (zElementString.String.Contains("#nodraw"))
            {
                zElementString.DrawElement = false;
            }

            // all translators perform this post replacement operation
            switch ((ElementType)Enum.Parse(typeof(ElementType), zElement.type))
            {
                case ElementType.Text:
                    zElementString.String = zElementString.String.Replace("\\n", Environment.NewLine);
                    zElementString.String = zElementString.String.Replace("\\q", "\"");
                    zElementString.String = zElementString.String.Replace("\\c", ",");
                    zElementString.String = zElementString.String.Replace("&gt;", ">");
                    zElementString.String = zElementString.String.Replace("&lt;", "<");
                    break;
                case ElementType.FormattedText:
                    zElementString.String = zElementString.String.Replace("<c>", ",");
                    zElementString.String = zElementString.String.Replace("<q>", "\"");
                    zElementString.String = zElementString.String.Replace("&gt;", ">");
                    zElementString.String = zElementString.String.Replace("&lt;", "<");
                    break;
            }

            AddStringToTranslationCache(sCacheKey, zElementString);

            return zElementString;
        }
Exemple #21
0
 public override bool Render(ProjectLayoutElement zElement, Graphics zGraphics)
 {
     // draw border (debugging)
     if (CardMakerMDI.Instance.DrawCardCanvas.CardRenderer.DrawFormattedTextBorder)
     {
         zGraphics.FillRectangle(Optional ? Brushes.DarkBlue : Brushes.DeepSkyBlue, TargetRect.X, TargetRect.Y, TargetRect.Width, TargetRect.Height);
     }
     return true;
 }
Exemple #22
0
        /// <summary>
        /// Draws the image cropped based on alignment. The image is always drawn in proper aspect by this method
        /// </summary>
        /// <param name="zGraphics"></param>
        /// <param name="zBmp"></param>
        /// <param name="zElement"></param>
        private static void DrawGraphicOriginalSize(Graphics zGraphics, Bitmap zBmp, ProjectLayoutElement zElement)
        {
            int nSourceX = 0;
            int nSourceY = 0;

            int nX = 0;
            int nY = 0;

            // determine if the update is needed for drawing source X or target X
            if (zBmp.Width > zElement.width)
            {
                UpdateAlignmentValue(zElement.horizontalalign, ref nSourceX, zBmp.Width, zElement.width);
            }
            else
            {
                UpdateAlignmentValue(zElement.horizontalalign, ref nX, zElement.width, zBmp.Width);
            }
            // determine if the update is needed for drawing source Y or target Y
            if (zBmp.Height > zElement.height)
            {
                UpdateAlignmentValue(zElement.verticalalign, ref nSourceY, zBmp.Height, zElement.height);
            }
            else
            {
                UpdateAlignmentValue(zElement.verticalalign, ref nY, zElement.height, zBmp.Height);
            }
            zGraphics.DrawImage(zBmp, nX, nY, new Rectangle(nSourceX, nSourceY, zElement.width, zElement.height), GraphicsUnit.Pixel);
        }
Exemple #23
0
 public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics)
 {
     zProcessData.MoveToNextLine(zElement);
     return false;
 }
 public void Setup()
 {
     _testDeck = new TestDeck(new JavaScriptTranslatorFactory());
     _testLine = new DeckLine(new List<string>());
     _testElement = new ProjectLayoutElement("testElement");
 }
Exemple #25
0
 public override bool PostProcessMarkupRectangle(ProjectLayoutElement zElement, List<MarkupBase> listAllMarkups, int nMarkup)
 {
     return true;
 }
Exemple #26
0
        public override bool Render(ProjectLayoutElement zElement, Graphics zGraphics)
        {
            var zFormat = new StringFormat
            {
                Alignment = StringAlignment.Near,
                LineAlignment = StringAlignment.Near,
            };
            // indicate any text being cut off
            if (zElement.height < (TargetRect.Y + m_fFontHeight))
            {
                // completely end the draw
                return false;
            }

            // NOTE: when rendering there is no need for a target rect as that information has already been processed
            float targetX = TargetRect.X + m_fXOffset;
            float targetY = TargetRect.Y + m_fYOffset;

            // draw border (debugging)
            if (CardMakerMDI.Instance.DrawCardCanvas.CardRenderer.DrawFormattedTextBorder)
            {
                zGraphics.DrawRectangle(Pens.Green, targetX, targetY, TargetRect.Width, TargetRect.Height);
            }

            // when a string is measured there is a bit of an offset to where it renders (into the target rect a few pixels right ---->)
            targetX -= m_rectMeasuredRectangle.X;

            if (0 == zElement.outlinethickness)
            {
                try
                {
                    zGraphics.DrawString(m_sVariable, m_zFont, m_zFontBrush, targetX, targetY, zFormat);
                }
                catch (Exception)
                {
                    Logger.AddLogLine("Unable to render text (font issue?)");
                }
            }
            else
            {
                // prepare to draw text
                var zPath = new GraphicsPath();

                try
                {
                    zPath.AddString(m_sVariable, m_zFont.FontFamily, (int) m_zFont.Style, m_fFontOutlineSize,
                        new PointF(targetX, targetY), zFormat);

                    DrawItem.DrawOutline(zElement, zGraphics, zPath);
                }
                catch (Exception)
                {
                    Logger.AddLogLine("Unable to render text (font issue?)");
                }
                // fill in the outline
                zGraphics.FillPath(m_zFontBrush, zPath);
            }
            return true;
        }
Exemple #27
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;

            // TODO: stop recalculating this, store it in the processData
            if (0 != zElement.outlinethickness)
            {
                m_fFontOutlineSize = zGraphics.DpiY * (m_zFont.Size / CardMakerMDI.Instance.ApplicationDPI);
            }

            m_rectMeasuredRectangle = MeasureDisplayStringWidth(zGraphics, m_sVariable, m_zFont);

            var fMeasuredWidth = m_rectMeasuredRectangle.Width;

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

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

            zProcessData.CurrentX += fMeasuredWidth;

            return true;
        }
Exemple #28
0
 /// <summary>
 /// Performs a partial deepy copy based on the input element, the name field is left unchanged
 /// </summary>
 /// <param name="zLayout">The layout to copy from</param>
 /// <param name="bCopyRefs">Flag indicating whether to copy the refereces</param>
 public void DeepCopy(ProjectLayout zLayout, bool bCopyRefs = true)
 {
     width = zLayout.width;
     height = zLayout.height;
     defaultCount = zLayout.defaultCount;
     dpi = zLayout.dpi;
     drawBorder = zLayout.drawBorder;
     buffer = zLayout.buffer;
     combineReferences = zLayout.combineReferences;
     exportNameFormat = zLayout.exportNameFormat;
     exportRotation = zLayout.exportRotation;
     exportWidth = zLayout.exportWidth;
     exportHeight = zLayout.exportHeight;
     exportTransparentBackground = zLayout.exportTransparentBackground;
     if (null != zLayout.Element)
     {
         var listElements = new List<ProjectLayoutElement>();
         foreach (ProjectLayoutElement zElement in zLayout.Element)
         {
             var zElementCopy = new ProjectLayoutElement(zElement.name);
             zElementCopy.DeepCopy(zElement, true);
             listElements.Add(zElementCopy);
         }
         Element = listElements.ToArray();
     }
     if (bCopyRefs && null != zLayout.Reference)
     {
         var listReferences = new List<ProjectLayoutReference>();
         foreach (var zReference in zLayout.Reference)
         {
             var zReferenceCopy = new ProjectLayoutReference();
             zReferenceCopy.DeepCopy(zReference);
             listReferences.Add(zReferenceCopy);
         }
         Reference = listReferences.ToArray();
     }
 }
 public void MoveToNextLine(ProjectLayoutElement zElement)
 {
     CurrentLine++;
     CurrentX = 0;
     CurrentY += zElement.lineheight;            
 }
 public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData,
     Graphics zGraphics)
 {
     return true;
 }