The Above works well.Why is CapCut the Best App for Mobile & PC Video Editing? If the mouse is passing over the text it is selected and will be dimmed otherwise nothing. TxtRect = new Rectangle( this.pointX, this.pointY, ( int)sz.Width + 1, ( int)sz.Height) Switch (_moving) // Implement the main Author's Code as it was before If( handleMove) // If Scrolling should be done HandleMove = false // Do not Move this.TextFitsLabel(sz) // Get the Rectangle to Display the Text in PointY = ( int)( this.Height - sz.Height) / 2 īool handleMove = true // By Default Assume that we need to Scroll the Text PointX = ( int)( this.Width - sz.Width ) / 2 So i must thank you t show me the way, it works perfect!ĭefaultValue(ShapeBorderStyles.ShapeBSNone),ĭescription( " Scroll Text Only When it Does not Fit the Label") / (1) using (Brush br = new SolidBrush(Color.FromArgb( 0, Color.White))) (2) /// protected override void OnPaint(PaintEventArgs pevent) ![]() (1) /// /// In order to let the label paint whatever it wants, after /// painting the background, I'm sending to the base /// de pevent on its OnPaint method. / /// Overriding the OnPaint method allows to paint /// the transparent background using Alpha = 0 and any color. | ControlStyles.SupportsTransparentBackColor / /// At the constructor the styles are setted /// to be able to paint correctly the label. / /// Inherits directly from Label so it is /// really a /// public class TransparentLabel : Label Now, reviewing your label, i'created this REAL transparent LABEL: Using (SolidBrush brush = new SolidBrush(ForeColor))Į.Graphics.DrawString(Text, Font, brush, -1, 0) īut this is a very poor solution because it doens't inherits from Label. protected override void OnPaint(PaintEventArgs e) protected override void OnPaintBackground(PaintEventArgs e) / protected override CreateParams CreateParams / public class TransparentLabel : Control If the mouse is passing over the text it will be dimmed, for that we use events OnMouseEnter and OnMouseLeave. ![]() The methods NoMove(), MoveRigntToLeft(), MoveDownToUp(), MoveLeftToRight() and MoveUpToDown()updates, for each MoveType, the coordinates of text rectangle. If the mouse is passing over the text it is selected and will be dimmed // otherwise nothing.īrush brText = new SolidBrush( base.ForeColor) īrush brTextDimmed = new SolidBrush(_dimmedColor) TxtRect = new Rectangle( this.pointX, this.pointY, SizeF sz = pe.Graphics.MeasureString(_text, base.Font) This is a workaround to get MeasureString to work properly // pe.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias Protected void DrawText(PaintEventArgs pe) The OnPaint call has three simple methods, DrawBorder, DrawLabelBackground, DrawText.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |