Esempio n. 1
0
 private static Brush GetFillBrush(ProjectLayoutElement zElement)
 {
     // prefer the background color
     return(CardRenderer.GetElementOpacityBrush(zElement,
                                                zElement.GetElementBackgroundColor() != CardMakerConstants.NoColor
             ? zElement.GetElementBackgroundColor()
             : zElement.GetElementColor()));
 }
 public string Render(Graphics zGraphics, ProjectLayoutElement zElement, Deck zDeck, string sInput, int nX, int nY, bool bExport)
 {
     // render the background color
     if (CardMakerConstants.NoColor != zElement.GetElementBackgroundColor())
     {
         var zBackgroundBrush = 255 != zElement.opacity
             ? new SolidBrush(Color.FromArgb(zElement.opacity, zElement.GetElementBackgroundColor()))
             : new SolidBrush(zElement.GetElementBackgroundColor());
         zGraphics.FillRectangle(zBackgroundBrush, 0, 0, zElement.width, zElement.height);
     }
     return(sInput);
 }
Esempio n. 3
0
 private void UpdatePanelColors(ProjectLayoutElement zElement)
 {
     if (zElement != ElementManager.Instance.GetSelectedElement())
     {
         return;
     }
     panelBorderColor.BackColor     = zElement.GetElementBorderColor();
     panelOutlineColor.BackColor    = zElement.GetElementOutlineColor();
     panelShapeColor.BackColor      = zElement.GetElementColor();
     panelFontColor.BackColor       = panelShapeColor.BackColor;
     panelBackgroundColor.BackColor = zElement.GetElementBackgroundColor() == CardMakerConstants.NoColor
         ? Control.DefaultBackColor
         : zElement.GetElementBackgroundColor();
 }
Esempio n. 4
0
        public void HandleShapeRender(Graphics zGraphics, string sShapeInfo, ProjectLayoutElement zElement, int nXOffset = 0, int nYOffset = 0)
        {
            if (!s_regexShapes.IsMatch(sShapeInfo))
            {
                return;
            }

            var           zMatch     = s_regexShapes.Match(sShapeInfo);
            ShapeInfo     zShapeInfo = null;
            var           bParse     = false;
            var           arraySplit = zMatch.Groups[3].ToString().Split(new char[] { ';' });
            var           sShapeName = arraySplit[(int)AbstractShape.ShapeInformationIndex.Name];
            AbstractShape zShape;

            if (s_dictionaryShapeByName.TryGetValue(sShapeName, out zShape))
            {
                // allow any shapes with extended settings to read in the values (ShapeInformationIndex extension)
                zShape.InitializeItem(sShapeInfo);

                if ((int)AbstractShape.ShapeInformationIndex.BasicShapeInformation < arraySplit.Length)
                {
                    int nThickness;
                    var nOverrideWidth  = Int32.MinValue;
                    var nOverrideHeight = Int32.MinValue;
                    bParse = Int32.TryParse(arraySplit[(int)AbstractShape.ShapeInformationIndex.Thickness], out nThickness);
                    if (!arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideWidth].Equals(AbstractShape.NO_SIZE_OVERRIDE))
                    {
                        bParse &= Int32.TryParse(arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideWidth], out nOverrideWidth);
                    }
                    if (!arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideHeight].Equals(AbstractShape.NO_SIZE_OVERRIDE))
                    {
                        bParse &= Int32.TryParse(arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideHeight], out nOverrideHeight);
                    }
                    zShapeInfo = new ShapeInfo(nThickness, nOverrideWidth, nOverrideHeight, arraySplit);
                }
                if (!bParse)
                {
                    return; // invalid (error?)
                }

                var previousTransform = zGraphics.Transform;
                var zPath             = new GraphicsPath();

                var targetRect = new Rectangle(0, 0, zElement.width - 1, zElement.height - 1);

                // internally int.MinValue indicates no override
                if (Int32.MinValue != zShapeInfo.OverrideWidth || Int32.MinValue != zShapeInfo.OverrideHeight)
                {
                    var nOverrideWidth  = Int32.MinValue == zShapeInfo.OverrideWidth ? zElement.width : zShapeInfo.OverrideWidth;
                    var nOverrideHeight = Int32.MinValue == zShapeInfo.OverrideHeight ? zElement.height : zShapeInfo.OverrideHeight;

                    if (0 == nOverrideWidth || 0 == nOverrideHeight)
                    {
                        // nothing to draw
                        return;
                    }
                    targetRect = GetZeroRectangle(nOverrideWidth, nOverrideHeight);
                    zGraphics.TranslateTransform(targetRect.X, targetRect.Y);
                    targetRect = new Rectangle(0, 0, Math.Abs(nOverrideWidth), Math.Abs(nOverrideHeight));
                }
                else if (nXOffset != 0 || nYOffset != 0)
                {
                    zGraphics.TranslateTransform(nXOffset, nYOffset);
                }

                zShape.DrawShape(zPath, targetRect, zShapeInfo);

                if (0 == zShapeInfo.Thickness)
                {
                    CardRenderer.DrawElementPath(zElement, zGraphics, zPath, GetFillBrush(zElement));
                }
                else
                {
                    var zFillBrush = zElement.GetElementBackgroundColor() != CardMakerConstants.NoColor
                        ? CardRenderer.GetElementOpacityBrush(zElement, zElement.GetElementBackgroundColor())
                        : null;

                    CardRenderer.DrawElementPath(zElement, zGraphics, zPath, zFillBrush);
                    zGraphics.DrawPath(CardRenderer.GetElementOpacityPen(zElement, zElement.GetElementColor(), zShapeInfo.Thickness), zPath);
                }
                zGraphics.Transform = previousTransform;
            }
        }