Click here to Skip to main content
15,891,905 members
Articles / Multimedia / GDI+

Slide Show

Rate me:
Please Sign up or sign in to vote.
3.33/5 (8 votes)
12 Oct 2007CPOL 32.4K   1.4K   16  
This article describes how to create a simple presentation application
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace WindowsApplication1
{
   public class TextControl:MainObject
    {
    
        public TextControl()
            : base()
        {
            mForeColor = Color.Black;
        }
        private String mText;

        public String Caption
        {
            get { return mText; }
            set { mText = value; textBox.Text = mText; }
        }

        private Color mForeColor;

        public Color ForeColor
        {
            get { return mForeColor; }
            set { mForeColor = value; this.Invalidate(); }
        }


        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            StringFormat format1 = new StringFormat(StringFormatFlags.NoClip);
            format1.LineAlignment = StringAlignment.Near;
            format1.Alignment = StringAlignment.Center;


            Font fnt = new Font("arial", 18,FontStyle.Bold);


            SolidBrush drawBrush = new SolidBrush(mForeColor);
   
          
            Point pt = new Point(this.Width / 2 , 2);
            textBox.Top = 2;

        
            mText = textBox.Text;
            if (mText.Length < 1) { mText = "none"; }
            e.Graphics.DrawString(mText, fnt, drawBrush, pt, format1);
            createOutLine(e.Graphics,this.Width,this.Height);
            base.OnPaint(e);
        }

      
            
        protected override void OnDoubleClick(EventArgs e)
        {

            base.OnDoubleClick(e);
        }

        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // textBox
            // 
            this.textBox.Location = new System.Drawing.Point(4, 1);
            this.textBox.Size = new System.Drawing.Size(348, 56);
            this.textBox.DoubleClick += new System.EventHandler(this.textBox_DoubleClick);
            this.textBox.TextChanged += new System.EventHandler(this.textBox_TextChanged_2);
            // 
            // TextControl
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.Name = "TextControl";
            this.Size = new System.Drawing.Size(356, 90);
            this.Load += new System.EventHandler(this.TextControl_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }
       protected override void OnHeightChanged(EventArgs e)
       {
           this.Height = base.textBox.Height +4;// +4;
           this.Invalidate();
           base.OnHeightChanged(e);
       }
       
        protected override void OnMouseDoubleClick(System.Windows.Forms.MouseEventArgs e)
        {
            base.textBox.Visible = true;
            base.OnMouseDoubleClick(e);
        }
       
       
        private void TextControl_Load(object sender, EventArgs e)
        {

        }

        private void textBox_TextChanged(object sender, EventArgs e)
        {
         
        }

        private void textBox_DoubleClick(object sender, EventArgs e)
        {

        }

      

       private void textBox_TextChanged_2(object sender, EventArgs e)
       {

       }

       
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Pakistan Pakistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions