コード例 #1
0
 /// <summary>
 /// The constructor of the GUILabelControl class.
 /// </summary>
 /// <param name="dwParentID">The parent of this control.</param>
 /// <param name="dwControlId">The ID of this control.</param>
 /// <param name="dwPosX">The X position of this control.</param>
 /// <param name="dwPosY">The Y position of this control.</param>
 /// <param name="dwWidth">The width of this control.</param>
 /// <param name="dwHeight">The height of this control.</param>
 /// <param name="strFont">The indication of the font of this control.</param>
 /// <param name="strLabel">The text of this control.</param>
 /// <param name="dwTextColor">The color of this control.</param>
 /// <param name="dwTextAlign">The alignment of this control.</param>
 /// <param name="dwTextVAlign">The vertical alignment of this control.</param>
 /// <param name="bHasPath">Indicates if the label is containing a path.</param>
 /// <param name="dwShadowAngle">The angle of the shadow; zero degress along x-axis.</param>
 /// <param name="dwShadowDistance">The distance of the shadow.</param>
 /// <param name="dwShadowColor">The color of the shadow.</param>
 public GUILabelControl(int dwParentID, int dwControlId, int dwPosX, int dwPosY, int dwWidth, int dwHeight,
                        string strFont, string strLabel, long dwTextColor, Alignment dwTextAlign,
                        VAlignment dwTextVAlign, bool bHasPath,
                        int dwShadowAngle, int dwShadowDistance, long dwShadowColor)
     : this(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight,
            strFont, strLabel, dwTextColor, dwTextAlign, dwTextVAlign, bHasPath,
            dwShadowAngle, dwShadowDistance, dwShadowColor, 0, 0)
 {
 }
コード例 #2
0
 /// <summary>
 /// The constructor of the GUIFadeLabel class.
 /// </summary>
 /// <param name="dwParentID">The parent of this control.</param>
 /// <param name="dwControlId">The ID of this control.</param>
 /// <param name="dwPosX">The X position of this control.</param>
 /// <param name="dwPosY">The Y position of this control.</param>
 /// <param name="dwWidth">The width of this control.</param>
 /// <param name="dwHeight">The height of this control.</param>
 /// <param name="strFont">The indication of the font of this control.</param>
 /// <param name="dwTextColor">The color of this control.</param>
 /// <param name="dwTextAlign">The alignment of this control.</param>
 /// <param name="dwTextVAlign">The vertical alignment of this control.</param>
 /// <param name="dwShadowAngle">The angle of the shadow; zero degrees along x-axis.</param>
 /// <param name="dwShadowDistance">The distance of the shadow.</param>
 /// <param name="dwShadowColor">The color of the shadow.</param>
 /// <param name="strUserWrapString">The string used to connect a wrapped fade label.</param>
 public GUIFadeLabel(int dwParentID, int dwControlId, int dwPosX, int dwPosY, int dwWidth, int dwHeight,
                     string strFont, long dwTextColor, Alignment dwTextAlign, VAlignment dwTextVAlign,
                     int dwShadowAngle, int dwShadowDistance, long dwShadowColor,
                     string strUserWrapString)
     : this(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight,
            strFont, dwTextColor, dwTextAlign, dwTextVAlign,
            dwShadowAngle, dwShadowDistance, dwShadowColor,
            strUserWrapString, 0, 0)
 {
 }
コード例 #3
0
        public override Vector2D OffsetFont(float unitSize, VAlignment vAlignment)
        {
            switch (vAlignment)
            {
            case VAlignment.VA_BOTTOM:  return(0.75 * new Vector2D(0.0, -0.49 * unitSize));

            case VAlignment.VA_TOP: return(new Vector2D(0.0, 0.2 * unitSize));

            default:
                return(Vector2D.Zero);
            }
        }
コード例 #4
0
 /// <summary>
 /// The constructor of the GUIFadeLabel class.
 /// </summary>
 /// <param name="dwParentID">The parent of this control.</param>
 /// <param name="dwControlId">The ID of this control.</param>
 /// <param name="dwPosX">The X position of this control.</param>
 /// <param name="dwPosY">The Y position of this control.</param>
 /// <param name="dwWidth">The width of this control.</param>
 /// <param name="dwHeight">The height of this control.</param>
 /// <param name="strFont">The indication of the font of this control.</param>
 /// <param name="dwTextColor">The color of this control.</param>
 /// <param name="dwTextAlign">The alignment of this control.</param>
 /// <param name="dwTextVAlign">The vertical alignment of this control.</param>
 /// <param name="dwShadowAngle">The angle of the shadow; zero degrees along x-axis.</param>
 /// <param name="dwShadowDistance">The distance of the shadow.</param>
 /// <param name="dwShadowColor">The color of the shadow.</param>
 /// <param name="strUserWrapString">The string used to connect a wrapped fade label.</param>
 public GUIFadeLabel(int dwParentID, int dwControlId, int dwPosX, int dwPosY, int dwWidth, int dwHeight,
                     string strFont, long dwTextColor, Alignment dwTextAlign, VAlignment dwTextVAlign,
                     int dwShadowAngle, int dwShadowDistance, long dwShadowColor,
                     string strUserWrapString)
     : base(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight)
 {
     _fontName       = strFont;
     _textColor      = dwTextColor;
     _textAlignment  = dwTextAlign;
     _textVAlignment = dwTextVAlign;
     _shadowAngle    = dwShadowAngle;
     _shadowDistance = dwShadowDistance;
     _shadowColor    = dwShadowColor;
     _userWrapString = strUserWrapString;
     FinalizeConstruction();
 }
コード例 #5
0
        /// <summary>
        /// The constructor of the GUILabelControl class.
        /// </summary>
        /// <param name="dwParentID">The parent of this control.</param>
        /// <param name="dwControlId">The ID of this control.</param>
        /// <param name="dwPosX">The X position of this control.</param>
        /// <param name="dwPosY">The Y position of this control.</param>
        /// <param name="dwWidth">The width of this control.</param>
        /// <param name="dwHeight">The height of this control.</param>
        /// <param name="strFont">The indication of the font of this control.</param>
        /// <param name="strLabel">The text of this control.</param>
        /// <param name="dwTextColor">The color of this control.</param>
        /// <param name="dwTextAlign">The alignment of this control.</param>
        /// <param name="dwTextVAlign">The vertical alignment of this control.</param>
        /// <param name="bHasPath">Indicates if the label is containing a path.</param>
        /// <param name="dwShadowAngle">The angle of the shadow; zero degress along x-axis.</param>
        /// <param name="dwShadowDistance">The distance of the shadow.</param>
        /// <param name="dwShadowColor">The color of the shadow.</param>
        public GUILabelControl(int dwParentID, int dwControlId, int dwPosX, int dwPosY, int dwWidth, int dwHeight,
                               string strFont, string strLabel, long dwTextColor, Alignment dwTextAlign,
                               VAlignment dwTextVAlign, bool bHasPath,
                               int dwShadowAngle, int dwShadowDistance, long dwShadowColor)
            : base(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight)
        {
            _labelText      = strLabel;
            _fontName       = strFont;
            _textColor      = dwTextColor;
            _textAlignment  = dwTextAlign;
            _textVAlignment = dwTextVAlign;
            _shadowAngle    = dwShadowAngle;
            _shadowDistance = dwShadowDistance;
            _shadowColor    = dwShadowColor;

            FinalizeConstruction();
        }
コード例 #6
0
        private static Excel.XlVAlign ToMsExcelVerticalAlignment(VAlignment vAlign)
        {
            switch (vAlign)
            {
            case VAlignment.Bottom:
                return(Excel.XlVAlign.xlVAlignBottom);

            case VAlignment.Center:
                return(Excel.XlVAlign.xlVAlignCenter);

            case VAlignment.Top:
                return(Excel.XlVAlign.xlVAlignTop);

            default:
                return(Excel.XlVAlign.xlVAlignBottom);
            }
        }
コード例 #7
0
    /// <summary>
    /// The constructor of the GUILabelControl class.
    /// </summary>
    /// <param name="dwParentID">The parent of this control.</param>
    /// <param name="dwControlId">The ID of this control.</param>
    /// <param name="dwPosX">The X position of this control.</param>
    /// <param name="dwPosY">The Y position of this control.</param>
    /// <param name="dwWidth">The width of this control.</param>
    /// <param name="dwHeight">The height of this control.</param>
    /// <param name="strFont">The indication of the font of this control.</param>
    /// <param name="strLabel">The text of this control.</param>
    /// <param name="dwTextColor">The color of this control.</param>
    /// <param name="dwTextAlign">The alignment of this control.</param>
    /// <param name="dwTextVAlign">The vertical alignment of this control.</param>
    /// <param name="bHasPath">Indicates if the label is containing a path.</param>
    /// <param name="dwShadowAngle">The angle of the shadow; zero degress along x-axis.</param>
    /// <param name="dwShadowDistance">The distance of the shadow.</param>
    /// <param name="dwShadowColor">The color of the shadow.</param>
    public GUILabelControl(int dwParentID, int dwControlId, int dwPosX, int dwPosY, int dwWidth, int dwHeight,
                           string strFont, string strLabel, long dwTextColor, Alignment dwTextAlign,
                           VAlignment dwTextVAlign, bool bHasPath,
                           int dwShadowAngle, int dwShadowDistance, long dwShadowColor)
      : base(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight)
    {
      _labelText = strLabel;
      _fontName = strFont;
      _textColor = dwTextColor;
      _textAlignment = dwTextAlign;
      _textVAlignment = dwTextVAlign;
      _shadowAngle = dwShadowAngle;
      _shadowDistance = dwShadowDistance;
      _shadowColor = dwShadowColor;

      FinalizeConstruction();
    }
コード例 #8
0
 public RCell()
 {
     CellType     = CellType.ctData;
     RowSpan      = 1;
     ColSpan      = 1;
     Row          = 0;
     Col          = 0;
     HAlign       = HAlignment.NotSet;
     VAlign       = VAlignment.NotSet;
     FontSize     = -1;
     IsItalic     = false;
     IsBold       = false;
     IsUnderline  = false;
     IsStrikeout  = false;
     IsTotal      = false;
     DrillActions = 0;
     CellIndex    = -1;
 }
コード例 #9
0
ファイル: PicGraphics.cs プロジェクト: minrogi/PLMPack
 public abstract void DrawText(string text, TextType font, Vector2D pt, HAlignment hAlignment, VAlignment vAlignment, float fAngle);
コード例 #10
0
        public void Render(SpriteList[] spriteLists, Vector2 area, HAlignment hAlign, VAlignment vAlign, int maxCharacters = -1)
        {
            if (overflowMode == TextOverflowMode.Minify)
            {
                FitTextInsideArea(area);
            }
            List <int> lines;
            float      totalHeight;
            float      longestLineWidth;

            PrepareWordsAndLines(area.X, area.Y, out lines, out totalHeight, out longestLineWidth);
            // Draw all lines.
            int   b = 0;
            float y = 0;
            int   c = 0;

            foreach (int count in lines)
            {
                // Calculate height and width of line in pixels.
                float maxHeight  = 0;
                float totalWidth = 0;
                for (int j = 0; j < count; j++)
                {
                    var word  = fittedWords[b + j];
                    var style = Styles[word.Style];
                    maxHeight = Math.Max(maxHeight, ScaleSize(style.Size + style.SpaceAfter));
                    if (word.IsTagBegin)
                    {
                        maxHeight = Math.Max(maxHeight, ScaleSize(style.ImageSize.Y + style.SpaceAfter));
                    }
                    var ch = texts[word.TextIndex].Length > 0 ? texts[word.TextIndex][word.Start] : 0;
                    if (!(j == count - 1 && (ch == ' ' || ch == '\n') && !IsBullet(word)))
                    {
                        totalWidth += word.Width;
                    }
                }
                // Calculate offset for horizontal alignment.
                var offset = new Vector2();
                if (hAlign == HAlignment.Right)
                {
                    offset.X = area.X - totalWidth;
                }
                else if (hAlign == HAlignment.Center)
                {
                    offset.X = ((area.X - totalWidth) * 0.5f).Round();
                }
                // Calculate offset for vertical alignment.
                if (vAlign == VAlignment.Bottom)
                {
                    offset.Y = area.Y - totalHeight;
                }
                else if (vAlign == VAlignment.Center)
                {
                    offset.Y = ((area.Y - totalHeight) * 0.5f).Round();
                }
                // Draw string.
                for (int j = 0; j < count; j++)
                {
                    var       word     = fittedWords[b + j];
                    var       t        = texts[word.TextIndex];
                    TextStyle style    = Styles[word.Style];
                    Vector2   position = new Vector2(word.X, y) + offset;
                    if (IsBullet(word))
                    {
                        if (maxCharacters >= 0 && c >= maxCharacters)
                        {
                            break;
                        }
                        var sz = style.ImageSize * scaleFactor;
                        spriteLists[word.Style].Add(
                            style.ImageTexture, Color4.White, position + new Vector2(0, (maxHeight - sz.Y) * 0.5f),
                            sz, Vector2.Zero, Vector2.One, tag: word.Style);
                        position.X += sz.X;
                        c++;
                    }
                    var yOffset = new Vector2(0, (maxHeight - ScaleSize(style.Size)) * 0.5f);
                    var font    = style.Font;
                    if (style.CastShadow)
                    {
                        for (int k = 0; k < (style.Bold ? 2 : 1); k++)
                        {
                            Renderer.DrawTextLine(
                                font, position + style.ShadowOffset + yOffset, t, style.ShadowColor, ScaleSize(style.Size),
                                word.Start, word.Length, font.Spacing + style.LetterSpacing, spriteLists[word.Style], tag: word.Style
                                );
                        }
                    }
                    int wordLength = word.Length;
                    if (maxCharacters >= 0)
                    {
                        if (c >= maxCharacters)
                        {
                            break;
                        }
                        wordLength = wordLength.Min(maxCharacters - c);
                    }
                    for (int k = 0; k < (style.Bold ? 2 : 1); k++)
                    {
                        Renderer.DrawTextLine(
                            font, position + yOffset, t, style.TextColor, ScaleSize(style.Size),
                            word.Start, wordLength, font.Spacing + style.LetterSpacing, spriteLists[word.Style], tag: word.Style
                            );
                    }
                    c += wordLength;
                }
                // Draw overlays
                for (int j = 0; j < count; j++)
                {
                    var       word  = fittedWords[b + j];
                    TextStyle style = Styles[word.Style];
                    if (IsOverlay(word))
                    {
                        int k = j + 1;
                        for (; k < count; k++)
                        {
                            if (fittedWords[b + k].IsTagBegin)
                            {
                                break;
                            }
                        }
                        k -= 1;
                        var font       = Styles[word.Style].Font;
                        var fontHeight = Styles[word.Style].Size;
                        var fontChar   = font.CharSource.Get(texts[word.TextIndex][word.Start], fontHeight);
                        if (fontChar == FontChar.Null)
                        {
                            continue;
                        }
                        float   scale   = fontChar.Height != 0.0f ? fontHeight / fontChar.Height : 0.0f;
                        Vector2 lt      = new Vector2(word.X + (word.X > 0 ? scale * Styles[word.Style].LetterSpacing : 0.0f), y) + offset;
                        Vector2 rb      = new Vector2(fittedWords[b + k].X + fittedWords[b + k].Width, y) + offset;
                        float   yOffset = (maxHeight - ScaleSize(style.ImageSize.Y)) * 0.5f;
                        spriteLists[word.Style].Add(style.ImageTexture, Color4.White, lt + new Vector2(0, yOffset),
                                                    rb - lt + new Vector2(0, style.ImageSize.Y),
                                                    Vector2.Zero, Vector2.One, tag: word.Style);
                        j = k;
                    }
                }
                y += maxHeight;
                b += count;
            }
        }
コード例 #11
0
ファイル: BitmapText.cs プロジェクト: dellis1972/graffiti
 public static IBitmapText Build(this IBitmapFont font, string text, IBrush brush, TexcoordGenerationMode uMappingMode = TexcoordGenerationMode.FullBoundingBox, TexcoordGenerationMode vMappingMode = TexcoordGenerationMode.FullBoundingBox, HAlignment hAlignment = HAlignment.Middle, VAlignment vAlignment = VAlignment.Middle)
 {
     return new BitmapText(font as BitmapFont, brush, text, uMappingMode, vMappingMode, hAlignment, vAlignment);
 }
コード例 #12
0
ファイル: fbUI.cs プロジェクト: Koneke/Farbase
 public Widget SetAlign(HAlignment ha, VAlignment va)
 {
     HAlignment = ha;
     VAlignment = va;
     return(this);
 }
コード例 #13
0
ファイル: BitmapText.cs プロジェクト: dellis1972/graffiti
        public BitmapText(IBitmapFont bitmapFont, IBrush brush, string text, TexcoordGenerationMode uMappingMode = TexcoordGenerationMode.FullBoundingBox, TexcoordGenerationMode vMappingMode = TexcoordGenerationMode.FullBoundingBox, HAlignment hAlignment = HAlignment.Middle, VAlignment vAlignment = VAlignment.Middle)
        {
            Transform = (ConstantMatrix) Matrix.Identity;
            Rectangle fullRect = bitmapFont.Measure(text);

            Vector3 centerOffset = Vector3.Zero;
            switch (hAlignment)
            {
                case HAlignment.Left:
                    centerOffset.X = 0;
                    break;

                case HAlignment.Middle:
                    centerOffset.X = fullRect.Width / 2f;
                    break;

                case HAlignment.Right:
                    centerOffset.X = fullRect.Width;
                    break;
            }

            switch (vAlignment)
            {
                case VAlignment.Top:
                    centerOffset.Y = 0;
                    break;

                case VAlignment.Middle:
                    centerOffset.Y = fullRect.Height / 2f;
                    break;

                case VAlignment.Bottom:
                    centerOffset.Y = fullRect.Height;

                    break;
            }

            _bitmapFont = bitmapFont as BitmapFont;
            var pageCount = _bitmapFont.PageLayers.Count;
            _text = text;
            Brush = brush;

            _textQuads = new IIndexedMesh[pageCount];

            var charactersByPage = (from char ch in text
                                   select new KeyValuePair<int, char>(_bitmapFont.Chars[ch].Page, ch)).ToMultiValueDictionary();

            var w = (float)_bitmapFont.ScaleW;
            var h = (float)_bitmapFont.ScaleH;
            var xPos = 0f;

            foreach (var kvp in charactersByPage)
            {
                var charCount = kvp.Value.Count;
                _textQuads[kvp.Key] = new IndexedMesh(charCount * 4, charCount * 6)
                                          {
                                              Brush = new TextBrush { TextLayer = _bitmapFont.PageLayers[kvp.Key], SubBrush = Brush }
                                          };
            }

            var vertexIndexCounts = (from i in Enumerable.Range(0, _bitmapFont.Pages.Count)
                                    select Tuple.Create(0, 0)).ToArray();

            foreach (var ch in text)
            {
                var ci = _bitmapFont.Chars[ch];

                var vertices = _textQuads[ci.Page].Vertices;
                var indices = _textQuads[ci.Page].Indices;

                var vertexCount = vertexIndexCounts[ci.Page].Item1;
                var indexCount = vertexIndexCounts[ci.Page].Item2;

                var saveVertexCount = vertexCount;

                Vector2 quadTopLeft;
                Vector2 quadTopRight;
                Vector2 quadBottomRight;
                Vector2 quadBottomLeft;

                var left = xPos + ci.XOffset;
                var top = 0f + ci.YOffset;

                switch (uMappingMode)
                {
                    case TexcoordGenerationMode.PerQuad:
                        quadTopLeft.X = 0f;
                        quadTopRight.X = 1f;
                        quadBottomRight.X = 1f;
                        quadBottomLeft.X = 0f;

                        break;

                    // These two modes are the same in this case
                    case TexcoordGenerationMode.FullBoundingBox:
                    case TexcoordGenerationMode.Unwrapped_Linear:
                        quadTopLeft.X = left / fullRect.Width;
                        quadTopRight.X = (left + ci.Width) / fullRect.Width;
                        quadBottomRight.X = (left + ci.Width) / fullRect.Width;
                        quadBottomLeft.X = left / fullRect.Width;

                        break;

                    default:
                        throw new NotSupportedException(string.Format("Unsupported texture mapping mode along X-Axis: {0}", uMappingMode));
                }

                switch (vMappingMode)
                {
                    case TexcoordGenerationMode.PerQuad:
                        quadTopLeft.Y = 0f;
                        quadTopRight.Y = 0f;
                        quadBottomRight.Y = 1f;
                        quadBottomLeft.Y = 1f;

                        break;

                    // These two modes are the same in this case
                    case TexcoordGenerationMode.FullBoundingBox:
                    case TexcoordGenerationMode.Unwrapped_Linear:
                        quadTopLeft.Y = top / fullRect.Height;
                        quadTopRight.Y = top / fullRect.Height;
                        quadBottomRight.Y = (top + ci.Height) / fullRect.Height;
                        quadBottomLeft.Y = (top + ci.Height) / fullRect.Height;

                        break;

                    default:
                        throw new NotSupportedException(string.Format("Unsupported texture mapping mode along Y-Axis: {0}", vMappingMode));
                }

                var topLeft = new Texcoords(quadTopLeft, new Vector2(ci.X / w, ci.Y / h));
                var topRight = new Texcoords(quadTopRight, new Vector2(((ci.X + ci.Width) / w), ci.Y / h));
                var bottomRight = new Texcoords(quadBottomRight, new Vector2(((ci.X + ci.Width) / w), ((ci.Y + ci.Height) / h)));
                var bottomLeft = new Texcoords(quadBottomLeft, new Vector2(ci.X / w, ((ci.Y + ci.Height) / h)));

                vertices[vertexCount++] = new Vertex
                {
                    Position = new Vector3(left - centerOffset.X, top - centerOffset.Y, 0f),
                    Texcoords = topLeft,
                    Color = Color.White
                };

                vertices[vertexCount++] = new Vertex
                {
                    Position = new Vector3(left + ci.Width - centerOffset.X, top - centerOffset.Y, 0f),
                    Texcoords = topRight,
                    Color = Color.White
                };

                vertices[vertexCount++] = new Vertex
                {
                    Position = new Vector3(left + ci.Width - centerOffset.X, top + ci.Height - centerOffset.Y, 0f),
                    Texcoords = bottomRight,
                    Color = Color.White
                };

                vertices[vertexCount++] = new Vertex
                {
                    Position = new Vector3(left - centerOffset.X, top + ci.Height - centerOffset.Y, 0f),
                    Texcoords = bottomLeft,
                    Color = Color.White
                };

                xPos += ci.XAdvance;

                indices[indexCount++] = (short)(saveVertexCount + 0);
                indices[indexCount++] = (short)(saveVertexCount + 1);
                indices[indexCount++] = (short)(saveVertexCount + 2);
                indices[indexCount++] = (short)(saveVertexCount + 0);
                indices[indexCount++] = (short)(saveVertexCount + 2);
                indices[indexCount++] = (short)(saveVertexCount + 3);

                vertexIndexCounts[ci.Page] = Tuple.Create(vertexCount, indexCount);
            }
        }
コード例 #14
0
ファイル: Box.cs プロジェクト: jpx/blazera
        public void AddItem(List<Widget> widgets, UInt32 level = DEFAULT_ITEM_LEVEL, VAlignment vAlignement = DEFAULT_VALIGNMENT)
        {
            foreach (Widget widget in widgets)
            {
                base.AddWidget(widget);

                Levels.Add(widget, level);

                VAlignments.Add(widget, vAlignement);
            }
        }
コード例 #15
0
ファイル: PicGraphicsPdf.cs プロジェクト: minrogi/PLMPack
 public override void DrawText(string text, TextType font, Vector2D pt, HAlignment hAlignment, VAlignment vAlignment, float fAngle)
 {
     XStringFormat format = new XStringFormat();
     switch (hAlignment)
     {
         case HAlignment.HA_CENTER: format.Alignment = XStringAlignment.Center; break;
         case HAlignment.HA_LEFT: format.Alignment = XStringAlignment.Near; break;
         case HAlignment.HA_RIGHT: format.Alignment = XStringAlignment.Far; break;
         default: break;
     }
     switch (vAlignment)
     {
         case VAlignment.VA_BOTTOM: format.LineAlignment = XLineAlignment.Far; break;
         case VAlignment.VA_MIDDLE: format.LineAlignment = XLineAlignment.Center; break;
         case VAlignment.VA_TOP: format.LineAlignment = XLineAlignment.Near; break;
         default: break;
     }
     this.pdfGfx.DrawString(
         text
         , ToFont(font)
         , LineTypeToPdfBrush(PicGraphics.LT.LT_COTATION)
         , new XPoint(DX(pt.X), DY(pt.Y))
         , format);
 }
コード例 #16
0
ファイル: PicGraphicsGdiPlus.cs プロジェクト: minrogi/PLMPack
        public override void DrawText(string text, TextType font, Vector2D pt, HAlignment hAlignment, VAlignment vAlignment, float fAngle)
        {
            // string format
            StringFormat sf = new StringFormat();
            switch (hAlignment)
            {
                case HAlignment.HA_RIGHT:
                    sf.LineAlignment = StringAlignment.Far;
                    break;
                case HAlignment.HA_CENTER:
                    sf.LineAlignment = StringAlignment.Center;
                    break;
                case HAlignment.HA_LEFT:
                    sf.LineAlignment = StringAlignment.Near;
                    break;
                default:
                    throw new Exception("Unknown horizontal alignment");
            }
            switch (vAlignment)
            { 
                case VAlignment.VA_BOTTOM:
                    sf.Alignment = StringAlignment.Far;
                    break;
                case VAlignment.VA_MIDDLE:
                    sf.Alignment = StringAlignment.Center;
                    break;
                case VAlignment.VA_TOP:
                    sf.Alignment = StringAlignment.Near;
                    break;
                default:
                    throw new Exception("Unknown vertical alignment");
            }
            // font & brush
            Brush tb;
            switch (font)
            { 
                case TextType.FT_COTATION:
                    tb = new SolidBrush(System.Drawing.Color.FromArgb(0,140,0));
                    break;
                default:
                    throw new Exception("Unknown text type");
            }

            _gdiGraphics.TranslateTransform(ToPointF(pt).X, ToPointF(pt).Y);
            _gdiGraphics.RotateTransform(fAngle); 
            
            // draw text
            _gdiGraphics.DrawString(text, ToFont(font), tb, new PointF(0, 0), sf);

            _gdiGraphics.ResetTransform();
         }
コード例 #17
0
ファイル: PicGraphics.cs プロジェクト: treeDiM/PackLib4ES
 public abstract Vector2D OffsetFont(float unitSize, VAlignment vAlignment);
コード例 #18
0
ファイル: GdiPlusEx.cs プロジェクト: CecleCW/ProductMan
        public static void DrawString( Graphics g, string text, Font font, Color color, Rectangle rect, Alignment alignment, VAlignment valignment, TextSplitting textSplitting, Ampersands ampersands )
        {
            if( g == null )
            {
                throw new ArgumentNullException( "g" );
            }
            if( text == null )
            {
                throw new ArgumentNullException( "text" );
            }
            if( font == null )
            {
                throw new ArgumentNullException( "font" );
            }

            if( ampersands == Ampersands.Display )
            {
                text = text.Replace( "&", "&&" );
            }

            float[] txValues = g.Transform.Elements;
            IntPtr hClipRgn = g.Clip.GetHrgn( g );
            IntPtr hDC = g.GetHdc();

            Gdi.SelectClipRgn( hDC, hClipRgn );

            int oldGraphicsMode = Gdi.SetGraphicsMode( hDC, 2 );
            XFORM oldXForm = new XFORM();

            Gdi.GetWorldTransform( hDC, ref oldXForm );

            XFORM newXForm = new XFORM();

            newXForm.eM11 = txValues[0];
            newXForm.eM12 = txValues[1];
            newXForm.eM21 = txValues[2];
            newXForm.eM22 = txValues[3];
            newXForm.eDx = txValues[4];
            newXForm.eDy = txValues[5];

            Gdi.SetWorldTransform( hDC, ref newXForm );

            try
            {
                IntPtr hFont = font.ToHfont();
                IntPtr hOldFont = Gdi.SelectObject( hDC, hFont );

                try
                {
                    BinaryComponents.Utility.Win32.Common.RECT r = new BinaryComponents.Utility.Win32.Common.RECT( rect );
                    User.DrawTextFlags uFormat;

                    switch( textSplitting )
                    {
                        case TextSplitting.SingleLineEllipsis:
                            uFormat
                                    = User.DrawTextFlags.DT_WORD_ELLIPSIS
                                        | User.DrawTextFlags.DT_END_ELLIPSIS;
                            break;
                        case TextSplitting.MultiLine:
                            uFormat
                                    = User.DrawTextFlags.DT_WORDBREAK;
                            break;
                        default:
                            throw new InvalidOperationException();
                    }

                    switch( alignment )
                    {
                        case Alignment.Left:
                            break;
                        case Alignment.Center:
                            uFormat
                                    = User.DrawTextFlags.DT_CENTER;
                            break;
                        case Alignment.Right:
                            uFormat
                                    = User.DrawTextFlags.DT_RIGHT;
                            break;
                        default:
                            throw new InvalidOperationException();
                    }
                    switch( valignment )
                    {
                        case VAlignment.Top:
                            break;
                        case VAlignment.Bottom:
                            uFormat |= User.DrawTextFlags.DT_BOTTOM | User.DrawTextFlags.DT_SINGLELINE;
                            break;
                        case VAlignment.Center:
                            uFormat |= User.DrawTextFlags.DT_VCENTER | User.DrawTextFlags.DT_SINGLELINE;
                            break;
                    }

                    uint bgr = (uint)((color.B << 16) | (color.G << 8) | (color.R));
                    uint oldColor = Gdi.SetTextColor( hDC, bgr );

                    try
                    {
                        BackgroundMode oldBackgroundMode = Gdi.SetBkMode( hDC, BackgroundMode.TRANSPARENT );

                        try
                        {
                            User.DrawText( hDC, text, text.Length, ref r, uFormat );
                        }
                        finally
                        {
                            Gdi.SetBkMode( hDC, oldBackgroundMode );
                        }
                    }
                    finally
                    {
                        Gdi.SetTextColor( hDC, oldColor );
                    }
                }
                finally
                {
                    Gdi.SelectObject( hDC, hOldFont );
                    Gdi.DeleteObject( hFont );
                }
            }
            finally
            {
                if( oldGraphicsMode == 1 )
                {
                    oldXForm.eM11 = 1;
                    oldXForm.eM12 = 0;
                    oldXForm.eM21 = 0;
                    oldXForm.eM22 = 1;
                    oldXForm.eDx = 0;
                    oldXForm.eDx = 0;
                }

                Gdi.SetWorldTransform( hDC, ref oldXForm );
                Gdi.SetGraphicsMode( hDC, oldGraphicsMode );

                g.ReleaseHdc( hDC );

                if( hClipRgn != IntPtr.Zero )
                {
                    g.Clip.ReleaseHrgn( hClipRgn );
                }
            }
        }
コード例 #19
0
ファイル: GdiPlusEx.cs プロジェクト: korneliuscode/Superlist
        public static void DrawString(Graphics g, string text, Font font, Color color, Rectangle rect, Alignment alignment, VAlignment valignment, TextSplitting textSplitting, Ampersands ampersands)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }
            if (font == null)
            {
                throw new ArgumentNullException("font");
            }

            if (ampersands == Ampersands.Display)
            {
                text = text.Replace("&", "&&");
            }

            float[] txValues = g.Transform.Elements;
            IntPtr  hClipRgn = g.Clip.GetHrgn(g);
            IntPtr  hDC      = g.GetHdc();

            Gdi.SelectClipRgn(hDC, hClipRgn);

            int   oldGraphicsMode = Gdi.SetGraphicsMode(hDC, 2);
            XFORM oldXForm        = new XFORM();

            Gdi.GetWorldTransform(hDC, ref oldXForm);

            XFORM newXForm = new XFORM();

            newXForm.eM11 = txValues[0];
            newXForm.eM12 = txValues[1];
            newXForm.eM21 = txValues[2];
            newXForm.eM22 = txValues[3];
            newXForm.eDx  = txValues[4];
            newXForm.eDy  = txValues[5];

            Gdi.SetWorldTransform(hDC, ref newXForm);

            try
            {
                IntPtr hFont    = font.ToHfont();
                IntPtr hOldFont = Gdi.SelectObject(hDC, hFont);

                try
                {
                    RECT r = new RECT(rect);
                    User.DrawTextFlags uFormat;

                    switch (textSplitting)
                    {
                    case TextSplitting.SingleLineEllipsis:
                        uFormat
                            = User.DrawTextFlags.DT_WORD_ELLIPSIS
                              | User.DrawTextFlags.DT_END_ELLIPSIS;
                        break;

                    case TextSplitting.MultiLine:
                        uFormat
                            = User.DrawTextFlags.DT_WORDBREAK;
                        break;

                    default:
                        throw new InvalidOperationException();
                    }

                    switch (alignment)
                    {
                    case Alignment.Left:
                        break;

                    case Alignment.Center:
                        uFormat
                            = User.DrawTextFlags.DT_CENTER;
                        break;

                    case Alignment.Right:
                        uFormat
                            = User.DrawTextFlags.DT_RIGHT;
                        break;

                    default:
                        throw new InvalidOperationException();
                    }
                    switch (valignment)
                    {
                    case VAlignment.Top:
                        break;

                    case VAlignment.Bottom:
                        uFormat |= User.DrawTextFlags.DT_BOTTOM | User.DrawTextFlags.DT_SINGLELINE;
                        break;

                    case VAlignment.Center:
                        uFormat |= User.DrawTextFlags.DT_VCENTER | User.DrawTextFlags.DT_SINGLELINE;
                        break;
                    }

                    uint bgr      = (uint)((color.B << 16) | (color.G << 8) | (color.R));
                    uint oldColor = Gdi.SetTextColor(hDC, bgr);

                    try
                    {
                        BackgroundMode oldBackgroundMode = Gdi.SetBkMode(hDC, BackgroundMode.TRANSPARENT);

                        try
                        {
                            User.DrawText(hDC, text, text.Length, ref r, uFormat);
                        }
                        finally
                        {
                            Gdi.SetBkMode(hDC, oldBackgroundMode);
                        }
                    }
                    finally
                    {
                        Gdi.SetTextColor(hDC, oldColor);
                    }
                }
                finally
                {
                    Gdi.SelectObject(hDC, hOldFont);
                    Gdi.DeleteObject(hFont);
                }
            }
            finally
            {
                if (oldGraphicsMode == 1)
                {
                    oldXForm.eM11 = 1;
                    oldXForm.eM12 = 0;
                    oldXForm.eM21 = 0;
                    oldXForm.eM22 = 1;
                    oldXForm.eDx  = 0;
                    oldXForm.eDx  = 0;
                }

                Gdi.SetWorldTransform(hDC, ref oldXForm);
                Gdi.SetGraphicsMode(hDC, oldGraphicsMode);

                g.ReleaseHdc(hDC);

                if (hClipRgn != IntPtr.Zero)
                {
                    g.Clip.ReleaseHrgn(hClipRgn);
                }
            }
        }
コード例 #20
0
ファイル: Box.cs プロジェクト: jpx/blazera
        public void AddItemFirst(Widget widget, UInt32 level = DEFAULT_ITEM_LEVEL, VAlignment vAlignement = DEFAULT_VALIGNMENT)
        {
            base.AddFirst(widget);

            Levels.Add(widget, level);

            VAlignments.Add(widget, vAlignement);
        }
コード例 #21
0
ファイル: GUIFadeLabel.cs プロジェクト: akhilgt/MediaPortal-1
 /// <summary>
 /// The constructor of the GUIFadeLabel class.
 /// </summary>
 /// <param name="dwParentID">The parent of this control.</param>
 /// <param name="dwControlId">The ID of this control.</param>
 /// <param name="dwPosX">The X position of this control.</param>
 /// <param name="dwPosY">The Y position of this control.</param>
 /// <param name="dwWidth">The width of this control.</param>
 /// <param name="dwHeight">The height of this control.</param>
 /// <param name="strFont">The indication of the font of this control.</param>
 /// <param name="dwTextColor">The color of this control.</param>
 /// <param name="dwTextAlign">The alignment of this control.</param>
 /// <param name="dwTextVAlign">The vertical alignment of this control.</param>
 /// <param name="dwShadowAngle">The angle of the shadow; zero degrees along x-axis.</param>
 /// <param name="dwShadowDistance">The distance of the shadow.</param>
 /// <param name="dwShadowColor">The color of the shadow.</param>
 /// <param name="strUserWrapString">The string used to connect a wrapped fade label.</param>
 public GUIFadeLabel(int dwParentID, int dwControlId, int dwPosX, int dwPosY, int dwWidth, int dwHeight,
                     string strFont, long dwTextColor, Alignment dwTextAlign, VAlignment dwTextVAlign,
                     int dwShadowAngle, int dwShadowDistance, long dwShadowColor,
                     string strUserWrapString)
   : base(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight)
 {
   _fontName = strFont;
   _textColor = dwTextColor;
   _textAlignment = dwTextAlign;
   _textVAlignment = dwTextVAlign;
   _shadowAngle = dwShadowAngle;
   _shadowDistance = dwShadowDistance;
   _shadowColor = dwShadowColor;
   _userWrapString = strUserWrapString;
   FinalizeConstruction();
 }
コード例 #22
0
ファイル: PicGraphicsPdf.cs プロジェクト: treeDiM/PackLib4ES
        public override void DrawText(string text, TextType font, Vector2D pt, HAlignment hAlignment, VAlignment vAlignment, float fAngle)
        {
            int alignment = 0;

            switch (hAlignment)
            {
            case HAlignment.VA_CENTER: alignment = PdfContentByte.ALIGN_CENTER; break;

            case HAlignment.VA_LEFT:   alignment = PdfContentByte.ALIGN_LEFT;   break;

            case HAlignment.VA_RIGHT:  alignment = PdfContentByte.ALIGN_RIGHT;  break;

            default: break;
            }

            float fontSize = FontSize(font);
            float fontRise = 0.0f;

            switch (vAlignment)
            {
            case VAlignment.VA_BOTTOM: fontRise = 0.5f; break;

            case VAlignment.VA_MIDDLE: fontRise = 0.0f * fontSize; break;

            case VAlignment.VA_TOP: fontRise = -0.5f * fontSize; break;

            default: break;
            }

            _cb.BeginText();
            BaseFont bf = ToBaseFont(font);

            _cb.SetTextRise(fontRise);
            _cb.SetTextMatrix(1.0f, 0.0f, 0.0f, 1.0f, DX(pt.X), DY(pt.Y) - 1.0f * (bf.GetAscentPoint(text, fontSize) - bf.GetDescentPoint(text, fontSize)) * 25.4f / 72.0f);
            _cb.ShowTextAligned(alignment, text, DX(pt.X), DY(pt.Y) - 1.0f * (bf.GetAscentPoint(text, fontSize) - bf.GetDescentPoint(text, fontSize)) * 25.4f / 72.0f, 0.0f);
            _cb.EndText();
        }
コード例 #23
0
ファイル: PicGraphicsPdf.cs プロジェクト: minrogi/PLMPack
        public override void DrawText(string text, TextType font, Vector2D pt, HAlignment hAlignment, VAlignment vAlignment, float fAngle)
        {
            int alignment = 0;
            switch (hAlignment)
            {
                case HAlignment.VA_CENTER: alignment = PdfContentByte.ALIGN_CENTER; break;
                case HAlignment.VA_LEFT:   alignment = PdfContentByte.ALIGN_LEFT;   break;
                case HAlignment.VA_RIGHT:  alignment = PdfContentByte.ALIGN_RIGHT;  break;
                default: break;
            }

            float fontSize = FontSize(font);
            float fontRise = 0.0f;
            switch (vAlignment)
            {
                case VAlignment.VA_BOTTOM: fontRise =0.5f; break;
                case VAlignment.VA_MIDDLE: fontRise = 0.0f * fontSize; break;
                case VAlignment.VA_TOP: fontRise = -0.5f * fontSize; break;
                default: break;
            }

            _cb.BeginText();
            BaseFont bf = ToBaseFont(font);
            _cb.SetTextRise(fontRise);
            _cb.SetTextMatrix(1.0f, 0.0f, 0.0f, 1.0f, DX(pt.X), DY(pt.Y) - 1.0f * (bf.GetAscentPoint(text, fontSize) - bf.GetDescentPoint(text, fontSize)) * 25.4f/72.0f);
            _cb.ShowTextAligned(alignment, text, DX(pt.X), DY(pt.Y) - 1.0f * (bf.GetAscentPoint(text, fontSize) - bf.GetDescentPoint(text, fontSize)) * 25.4f / 72.0f, 0.0f);
            _cb.EndText();
        }
コード例 #24
0
 public abstract void DrawText(string text, TextType font, Vector2D pt, HAlignment hAlignment, VAlignment vAlignment, float fAngle);
コード例 #25
0
        public override void DrawText(string text, TextType font, float emSize, Vector2D pt, HAlignment hAlignment, VAlignment vAlignment, float fAngle)
        {
            // string format
            var sf = new StringFormat();

            switch (hAlignment)
            {
            case HAlignment.HA_RIGHT:
                sf.Alignment = StringAlignment.Far;
                break;

            case HAlignment.HA_CENTER:
                sf.Alignment = StringAlignment.Center;
                break;

            case HAlignment.HA_LEFT:
                sf.Alignment = StringAlignment.Near;
                break;

            default:
                throw new Exception("Unknown horizontal alignment");
            }
            switch (vAlignment)
            {
            case VAlignment.VA_BOTTOM:
                sf.LineAlignment = StringAlignment.Far;
                break;

            case VAlignment.VA_MIDDLE:
                sf.LineAlignment = StringAlignment.Center;
                break;

            case VAlignment.VA_TOP:
                sf.LineAlignment = StringAlignment.Near;
                break;

            default:
                throw new Exception("Unknown vertical alignment");
            }
            // font & brush
            Brush tb;

            switch (font)
            {
            case TextType.FT_COTATION:
            case TextType.FT_STRING:
                tb = new SolidBrush(Color.FromArgb(0, 140, 0));
                break;

            default:
                throw new Exception("Unknown text type");
            }

            var ptF = ToPointF(pt /*- 0.5/0.75 * (emSize) * Vector2D.YAxis*/);

            _gdiGraphics.TranslateTransform(ptF.X, ptF.Y);
            _gdiGraphics.RotateTransform(fAngle);

            // draw text
            _gdiGraphics.DrawString(text, ToFont(font, emSize), tb, new PointF(0, 0), sf);

            _gdiGraphics.ResetTransform();
        }