Beispiel #1
0
        public string ProcessInlineShape(IShapeRenderer zShapeRenderer, Graphics zGraphics, ProjectLayoutElement zElement, string sInput)
        {
            var   zExtendedMatch = regexShapeExtendedBG.Match(sInput);
            Match zMatch         = null;

            if (!zExtendedMatch.Success)
            {
                zMatch = regexShapeBG.Match(sInput);
                if (!zMatch.Success)
                {
                    return(sInput);
                }
            }

            var sToReplace = String.Empty;
            int nXOffset = 0, nYOffset = 0;

            var zBgShapeElement = new ProjectLayoutElement(Guid.NewGuid().ToString());

            if (zExtendedMatch.Success)
            {
                nXOffset                         = ParseUtil.ParseDefault(zExtendedMatch.Groups[6].Value, 0);
                nYOffset                         = ParseUtil.ParseDefault(zExtendedMatch.Groups[8].Value, 0);
                zBgShapeElement.x                = zElement.x;
                zBgShapeElement.y                = zElement.y;
                zBgShapeElement.width            = zElement.width + ParseUtil.ParseDefault(zExtendedMatch.Groups[10].Value, 0);
                zBgShapeElement.height           = zElement.height + ParseUtil.ParseDefault(zExtendedMatch.Groups[12].Value, 0);
                zBgShapeElement.outlinethickness = ParseUtil.ParseDefault(zExtendedMatch.Groups[14].Value, 0);
                zBgShapeElement.outlinecolor     = zExtendedMatch.Groups[16].Value;
                zBgShapeElement.elementcolor     = zExtendedMatch.Groups[4].Value;
                zBgShapeElement.variable         = zExtendedMatch.Groups[2].Value;
                zBgShapeElement.type             = ElementType.Shape.ToString();
                sToReplace                       = zExtendedMatch.Groups[0].Value;
            }
            else if (zMatch.Success)
            {
                zBgShapeElement.x            = zElement.x;
                zBgShapeElement.y            = zElement.y;
                zBgShapeElement.width        = zElement.width;
                zBgShapeElement.height       = zElement.height;
                zBgShapeElement.elementcolor = zMatch.Groups[4].Value;
                zBgShapeElement.variable     = zMatch.Groups[2].Value;
                zBgShapeElement.type         = ElementType.Shape.ToString();
                sToReplace = zMatch.Groups[0].Value;
            }

            zBgShapeElement.InitializeTranslatedFields();
            zBgShapeElement.opacity = zBgShapeElement.GetElementColor().A;

            zShapeRenderer.HandleShapeRender(zGraphics, zBgShapeElement.variable, zBgShapeElement, nXOffset, nYOffset);

            return(sInput.Replace(sToReplace, string.Empty));
        }
Beispiel #2
0
        public string ProcessInlineShape(IShapeRenderer zShapeRenderer, Graphics zGraphics, ProjectLayoutElement zElement, string sInput)
        {
            var   kvpMatchedProcessor = new KeyValuePair <Regex, Action <Match, ProjectLayoutElement, ProjectLayoutElement, PointOffset> >();
            Match zMatch = null;

            foreach (var kvpShapeProcessor in listShapeProcessingPairs)
            {
                zMatch = kvpShapeProcessor.Key.Match(sInput);
                if (zMatch.Success)
                {
                    kvpMatchedProcessor = kvpShapeProcessor;
                    break;
                }
            }

            if (kvpMatchedProcessor.Key == null ||
                zMatch == null ||
                !zMatch.Success)
            {
                return(sInput);
            }

            var sToReplace      = zMatch.Groups[0].Value;
            var pointOffset     = new PointOffset();
            var zBgShapeElement = new ProjectLayoutElement(Guid.NewGuid().ToString());

            zBgShapeElement.opacity = -1;

            kvpMatchedProcessor.Value(zMatch, zBgShapeElement, zElement, pointOffset);

            zBgShapeElement.InitializeTranslatedFields();

            // the processor method didn't tweak the opacity, default to the element color alpha channel
            if (zBgShapeElement.opacity == -1)
            {
                zBgShapeElement.opacity = zBgShapeElement.GetElementColor().A;
            }

            zShapeRenderer.HandleShapeRender(zGraphics, zBgShapeElement.variable, zBgShapeElement, pointOffset.X, pointOffset.Y);

            return(sInput.Replace(sToReplace, string.Empty));
        }
        public string Render(Graphics zGraphics, ProjectLayoutElement zElement, Deck zDeck, string sInput, int nX, int nY, bool bExport)
        {
            switch (EnumUtil.GetElementType(zElement.type))
            {
            case ElementType.Text:
                m_zDrawText.DrawText(zGraphics, zElement, sInput);
                break;

            case ElementType.FormattedText:
                m_zDrawFormattedText.Draw(zGraphics, zDeck, zElement, sInput);
                break;

            case ElementType.Graphic:
                m_zDrawGraphic.DrawGraphicFile(zGraphics, sInput, zElement);
                break;

            case ElementType.Shape:
                m_zShapeRenderer.HandleShapeRender(zGraphics, sInput.ToLower(), zElement);
                break;
            }
            return(sInput);
        }