GetElementColor() public method

public GetElementColor ( ) : Color
return Color
Beispiel #1
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;
 }
Beispiel #2
0
        public static void HandleShapeRender(Graphics zGraphics, string sShapeInfo, ProjectLayoutElement zElement)
        {
            if (s_regexShapes.IsMatch(sShapeInfo))
            {
                var zMatch = s_regexShapes.Match(sShapeInfo);
                ShapeInfo zInfo = 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 = int.MinValue;
                        var nOverrideHeight = int.MinValue;
                        bParse = int.TryParse(arraySplit[(int)AbstractShape.ShapeInformationIndex.Thickness], out nThickness);
                        if (!arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideWidth].Equals(AbstractShape.NO_SIZE_OVERRIDE))
                            bParse &= int.TryParse(arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideWidth], out nOverrideWidth);
                        if (!arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideHeight].Equals(AbstractShape.NO_SIZE_OVERRIDE))
                            bParse &= int.TryParse(arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideHeight], out nOverrideHeight);
                        zInfo = 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 (int.MinValue != zInfo.OverrideWidth || int.MinValue != zInfo.OverrideHeight)
                    {
                        var nOverrideWidth = int.MinValue == zInfo.OverrideWidth ? zElement.width : zInfo.OverrideWidth;
                        var nOverrideHeight = int.MinValue == zInfo.OverrideHeight ? zElement.height : zInfo.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));
                    }

                    zShape.DrawShape(zPath, targetRect, zInfo);
                    DrawItem.DrawOutline(zElement, zGraphics, zPath);

                    if (0 == zInfo.Thickness)
                    {
                        var zShapeBrush = 255 != zElement.opacity 
                            ? new SolidBrush(Color.FromArgb(zElement.opacity, zElement.GetElementColor()))
                            : new SolidBrush(zElement.GetElementColor());
                        zGraphics.FillPath(zShapeBrush, zPath);
                    }
                    else
                    {
                        var zShapePen = 255 != zElement.opacity
                            ? new Pen(Color.FromArgb(zElement.opacity, zElement.GetElementColor()), zInfo.Thickness)
                            : new Pen(zElement.GetElementColor(), zInfo.Thickness);
                        zGraphics.DrawPath(zShapePen, zPath);
                    }
                    zGraphics.Transform = previousTransform;
                }
            }
        }
Beispiel #3
0
        public static void DrawElement(Graphics zGraphics, Deck zDeck, ProjectLayoutElement zElement, ElementType eType, int nX, int nY, string sInput)
        {
            switch (eType)
            {
                case ElementType.Graphic:
                case ElementType.Shape:
                    sInput = sInput.Trim();
                    break;
            }

            Font zFont = null;
            Brush zBrush = null;
            Pen zBorderPen = null;

            Color colorFont = Color.Black;

            if (0 != zElement.borderthickness)
            {
                zBorderPen = 255 != zElement.opacity
                    ? new Pen(Color.FromArgb(zElement.opacity, zElement.GetElementBorderColor()), zElement.borderthickness)
                    : new Pen(zElement.GetElementBorderColor(), zElement.borderthickness);
            }

            // Setup
            switch (eType)
            {
                case ElementType.Text:
                case ElementType.FormattedText:
                    zFont = zElement.GetElementFont();
                    colorFont = zElement.GetElementColor();
                    zBrush = new SolidBrush(colorFont);
                    break;
                case ElementType.Graphic:
                case ElementType.Shape:
                    break;
                default:
                    return;
            }

            // NOTE: this is the first transform
            if (0 != zElement.rotation)
            {
                // center the internal element then rotate and restore
                zGraphics.TranslateTransform(zElement.x + nX + (zElement.width >> 1), zElement.y + nY + (zElement.height >> 1));
                zGraphics.RotateTransform(zElement.rotation);
                zGraphics.TranslateTransform(-(zElement.width >> 1), -(zElement.height >> 1));
            }
            else
            {
                zGraphics.TranslateTransform(zElement.x + nX, zElement.y + nY);
            }
            // TODO: an interface for all these would be more appropriate

            // Draw
            switch (eType)
            {
                case ElementType.Text:
                    DrawText(zGraphics, zElement, sInput, zBrush, zFont, colorFont);
                    break;
                case ElementType.FormattedText:
                    DrawFormattedText(zGraphics, zDeck, zElement, sInput, zBrush, zFont, colorFont);
                    break;
                case ElementType.Graphic:
                    DrawGraphic(zGraphics, sInput, zElement);
                    break;
                case ElementType.Shape:
                    ShapeManager.HandleShapeRender(zGraphics, sInput.ToLower(), zElement);
                    break;
            }

            if (null != zBorderPen)
            {
                // note that the border is inclusive in the width/height consuming 2 pixels (0 to total-1)
                zGraphics.DrawRectangle(zBorderPen, 0,0,zElement.width - 1, zElement.height - 1);
            }

            zGraphics.ResetTransform();
        }
 private void UpdatePanelColors(ProjectLayoutElement zElement)
 {
     if (zElement != MDILayoutControl.Instance.GetSelectedLayoutElement()) return;
     panelBorderColor.BackColor = zElement.GetElementBorderColor();
     panelOutlineColor.BackColor = zElement.GetElementOutlineColor();
     panelShapeColor.BackColor = zElement.GetElementColor();
     panelFontColor.BackColor = panelShapeColor.BackColor;
 }