ToolStripItemTextRenderEventArgs.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / WinForms / Managed / System / WinForms / ToolStripItemTextRenderEventArgs.cs / 1 / ToolStripItemTextRenderEventArgs.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Windows.Forms { 
 
    using System.Drawing;
    using System.Windows.Forms.Internal; 
    using System.Windows.Forms.ButtonInternal;

    /// 
    ///  
    /// This class represents all the information to render the winbar
    ///  
    public class ToolStripItemTextRenderEventArgs : ToolStripItemRenderEventArgs { 

        private string                           text             = null; 
        private Rectangle                        textRectangle    = Rectangle.Empty;
        private Color                            textColor        = SystemColors.ControlText;
        private Font                             textFont         = null;
        private ContentAlignment                 textAlignment; 
        private ToolStripTextDirection           textDirection    = ToolStripTextDirection.Horizontal;
        private TextFormatFlags                  textFormat       = TextFormatFlags.Default; 
        private Color                            defaultTextColor = SystemColors.ControlText; 
        private bool                             textColorChanged = false;
 
        /// 
        /// 
        /// This class represents all the information to render the winbar
        ///  
        public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, TextFormatFlags format) : base(g, item) {
            this.text = text; 
            this.textRectangle = textRectangle; 
            this.defaultTextColor = textColor;
            this.textFont = textFont; 
            this.textAlignment = item.TextAlign;
            this.textFormat = format;
            textDirection = item.TextDirection;
 
        }
 
 
        /// 
        ///  
        /// This class represents all the information to render the winbar
        /// 
        public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, ContentAlignment textAlign) : base(g, item) {
            this.text = text; 
            this.textRectangle = textRectangle;
            this.defaultTextColor = textColor; 
            this.textFont = textFont; 
            this.textFormat = ToolStripItemInternalLayout.ContentAlignToTextFormat(textAlign, item.RightToLeft == RightToLeft.Yes);
 
            // in 2K and XP++ hide underlined &File unless ALT is pressed
            this.textFormat = (item.ShowKeyboardCues) ? textFormat : textFormat | TextFormatFlags.HidePrefix;
            textDirection = item.TextDirection;
        } 

 
        ///  
        /// 
        /// the string to draw 
        /// 
        public string Text  {
            get {
                return text; 
            }
            set { 
                text = value; 
            }
        } 

        /// 
        /// 
        /// the color to draw the text 
        /// 
        public Color TextColor { 
            get { 
                if (textColorChanged) {
                    return textColor; 
                }
                return DefaultTextColor;
            }
            set { 
                textColor = value;
                textColorChanged=true; 
            } 
        }
 
        //


        internal Color DefaultTextColor { 
           get {
               return defaultTextColor; 
           } 
           set {
               defaultTextColor = value; 
           }
       }

        ///  
        /// 
        /// the font to draw the text 
        ///  
        public Font TextFont {
            get { 
                return textFont;
            }
            set {
                textFont = value; 
            }
        } 
 
        /// 
        ///  
        /// the rectangle to draw the text in
        /// 
        public Rectangle TextRectangle {
            get { 
                return textRectangle;
            } 
            set { 
                textRectangle = value;
            } 
        }

        /// 
        ///  
        /// the rectangle to draw the text in
        ///  
        public TextFormatFlags TextFormat { 
            get {
                return textFormat; 
            }
            set {
                textFormat = value;
            } 
        }
 
 
        /// 
        ///  
        /// the angle at which the text should be drawn in tenths of degrees.
        /// 
        public ToolStripTextDirection TextDirection {
            get { 
                return textDirection;
            } 
            set { 
                textDirection = value;
            } 
        }


    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Windows.Forms { 
 
    using System.Drawing;
    using System.Windows.Forms.Internal; 
    using System.Windows.Forms.ButtonInternal;

    /// 
    ///  
    /// This class represents all the information to render the winbar
    ///  
    public class ToolStripItemTextRenderEventArgs : ToolStripItemRenderEventArgs { 

        private string                           text             = null; 
        private Rectangle                        textRectangle    = Rectangle.Empty;
        private Color                            textColor        = SystemColors.ControlText;
        private Font                             textFont         = null;
        private ContentAlignment                 textAlignment; 
        private ToolStripTextDirection           textDirection    = ToolStripTextDirection.Horizontal;
        private TextFormatFlags                  textFormat       = TextFormatFlags.Default; 
        private Color                            defaultTextColor = SystemColors.ControlText; 
        private bool                             textColorChanged = false;
 
        /// 
        /// 
        /// This class represents all the information to render the winbar
        ///  
        public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, TextFormatFlags format) : base(g, item) {
            this.text = text; 
            this.textRectangle = textRectangle; 
            this.defaultTextColor = textColor;
            this.textFont = textFont; 
            this.textAlignment = item.TextAlign;
            this.textFormat = format;
            textDirection = item.TextDirection;
 
        }
 
 
        /// 
        ///  
        /// This class represents all the information to render the winbar
        /// 
        public ToolStripItemTextRenderEventArgs(Graphics g, ToolStripItem item, string text, Rectangle textRectangle, Color textColor, Font textFont, ContentAlignment textAlign) : base(g, item) {
            this.text = text; 
            this.textRectangle = textRectangle;
            this.defaultTextColor = textColor; 
            this.textFont = textFont; 
            this.textFormat = ToolStripItemInternalLayout.ContentAlignToTextFormat(textAlign, item.RightToLeft == RightToLeft.Yes);
 
            // in 2K and XP++ hide underlined &File unless ALT is pressed
            this.textFormat = (item.ShowKeyboardCues) ? textFormat : textFormat | TextFormatFlags.HidePrefix;
            textDirection = item.TextDirection;
        } 

 
        ///  
        /// 
        /// the string to draw 
        /// 
        public string Text  {
            get {
                return text; 
            }
            set { 
                text = value; 
            }
        } 

        /// 
        /// 
        /// the color to draw the text 
        /// 
        public Color TextColor { 
            get { 
                if (textColorChanged) {
                    return textColor; 
                }
                return DefaultTextColor;
            }
            set { 
                textColor = value;
                textColorChanged=true; 
            } 
        }
 
        //


        internal Color DefaultTextColor { 
           get {
               return defaultTextColor; 
           } 
           set {
               defaultTextColor = value; 
           }
       }

        ///  
        /// 
        /// the font to draw the text 
        ///  
        public Font TextFont {
            get { 
                return textFont;
            }
            set {
                textFont = value; 
            }
        } 
 
        /// 
        ///  
        /// the rectangle to draw the text in
        /// 
        public Rectangle TextRectangle {
            get { 
                return textRectangle;
            } 
            set { 
                textRectangle = value;
            } 
        }

        /// 
        ///  
        /// the rectangle to draw the text in
        ///  
        public TextFormatFlags TextFormat { 
            get {
                return textFormat; 
            }
            set {
                textFormat = value;
            } 
        }
 
 
        /// 
        ///  
        /// the angle at which the text should be drawn in tenths of degrees.
        /// 
        public ToolStripTextDirection TextDirection {
            get { 
                return textDirection;
            } 
            set { 
                textDirection = value;
            } 
        }


    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK