예제 #1
0
        public string ProcessInlineBackgroundGraphic(IDrawGraphic zDrawGraphic, Graphics zGraphics, ProjectLayoutElement zElement, string sInput)
        {
            var   kvpMatchedProcessor = new KeyValuePair <Regex, Action <Match, ProjectLayoutElement, ProjectLayoutElement, PointOffset> >();
            Match zMatch = null;

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

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

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

            zBgGraphicElement.opacity = -1;

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

            zDrawGraphic.DrawGraphicFile(zGraphics, zBgGraphicElement.variable, zBgGraphicElement, pointOffset.X, pointOffset.Y);

            return(sInput.Replace(sToReplace, string.Empty));
        }
예제 #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));
        }