Click here to Skip to main content
15,896,118 members
Articles / Multimedia / GDI+

Controls of an arbitrary shape

Rate me:
Please Sign up or sign in to vote.
3.25/5 (7 votes)
6 Jul 20064 min read 42.8K   1.4K   31  
The article describes the use and the principle of operation of control of an arbitrary shape.
///////////////////////////////////////////////////////////////////////////////
//
//  File:           Form1.cs
//
//  Facility:		The unit contains the Form1 class.
//
//  Abstract:       The test application demonstrating the work of the controls
//                  of an arbitrary shape.
//
//  Environment:    VC 7.1
//
//  Author:         KBSoft
//
///////////////////////////////////////////////////////////////////////////////

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using KBSoft.Components;

namespace TestComponents
{
	/// <summary>
	/// The main window class.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		#region Fields

        /// <summary>
        /// the test button demonstrating the SkinButton class abilities.
        /// </summary>
		private KBSoft.Components.SkinButton skinButton1;
        /// <summary>
        /// the test textbox demonstrating the SkinTextbox class abilities.
        /// </summary>
		private KBSoft.Components.SkinTextbox skinTextbox1;
        /// <summary>
        /// the test pop-up window demonstrating the SkinTooltip class abilities.
        /// </summary>
		private KBSoft.Components.SkinTooltip skinTooltip1;
        /// <summary>
        /// the test button.
        /// </summary>
		private System.Windows.Forms.Button button3;
        /// <summary>
        /// the test button.
        /// </summary>
		private System.Windows.Forms.Button button4;
        /// <summary>
        /// the test combobox.
        /// </summary>
		private System.Windows.Forms.ComboBox comboBox1;

        /// <summary>
        /// the text field displaying the help text.
        /// </summary>
        private System.Windows.Forms.Label helpLabel;
        /// <summary>
        /// the button showing the pop-up window.
        /// </summary>
        private System.Windows.Forms.Button showButton;
        /// <summary>
        /// the button hiding the pop-up window.
        /// </summary>
        private System.Windows.Forms.Button hideButton;
        /// <summary>
        /// the button showing the help text field.
        /// </summary>
        private System.Windows.Forms.Button helpButton;

		

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		#endregion

		#region Constructors

        /// <summary>
        /// The class constructor.
        /// </summary>
		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
            helpLabel.Hide();

			helpLabel.Text = "Press Show tooltip to show the pop-up window." + System.Environment.NewLine + 
                "Press Hide tooltip to hide it and to repeat the test.";
		}

		#endregion

		#region Methods

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if ( components != null )  
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
            this.skinButton1 = new KBSoft.Components.SkinButton();
            this.skinTextbox1 = new KBSoft.Components.SkinTextbox();
            this.skinTooltip1 = new KBSoft.Components.SkinTooltip();
            this.comboBox1 = new System.Windows.Forms.ComboBox();
            this.button4 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.showButton = new System.Windows.Forms.Button();
            this.hideButton = new System.Windows.Forms.Button();
            this.helpButton = new System.Windows.Forms.Button();
            this.helpLabel = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.skinButton1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.skinTextbox1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.skinTooltip1)).BeginInit();
            this.skinTooltip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // skinButton1
            // 
            this.skinButton1.DisabledImage = ((System.Drawing.Bitmap)(resources.GetObject("skinButton1.DisabledImage")));
            this.skinButton1.HotImage = ((System.Drawing.Bitmap)(resources.GetObject("skinButton1.HotImage")));
            this.skinButton1.Location = new System.Drawing.Point(8, 24);
            this.skinButton1.Name = "skinButton1";
            this.skinButton1.NormalImage = ((System.Drawing.Bitmap)(resources.GetObject("skinButton1.NormalImage")));
            this.skinButton1.PatternBitmap = ((System.Drawing.Bitmap)(resources.GetObject("skinButton1.PatternBitmap")));
            this.skinButton1.PressedImage = ((System.Drawing.Bitmap)(resources.GetObject("skinButton1.PressedImage")));
            this.skinButton1.Size = new System.Drawing.Size(136, 136);
            this.skinButton1.TabIndex = 0;
            this.skinButton1.TransparentColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)));
            this.skinButton1.UseCashing = false;
            // 
            // skinTextbox1
            // 
            this.skinTextbox1.CaretColor = System.Drawing.Color.FromArgb(((System.Byte)(94)), ((System.Byte)(94)), ((System.Byte)(94)));
            this.skinTextbox1.CaretInterval = 300;
            this.skinTextbox1.CaretLength = 20;
            this.skinTextbox1.CaretPos = 0;
            this.skinTextbox1.CaretWidth = 3;
            this.skinTextbox1.FromntImage = ((System.Drawing.Bitmap)(resources.GetObject("skinTextbox1.FromntImage")));
            this.skinTextbox1.LabelText = "";
            this.skinTextbox1.Location = new System.Drawing.Point(8, 192);
            this.skinTextbox1.Name = "skinTextbox1";
            this.skinTextbox1.PatternBitmap = ((System.Drawing.Bitmap)(resources.GetObject("skinTextbox1.PatternBitmap")));
            this.skinTextbox1.ShowCaret = true;
            this.skinTextbox1.Size = new System.Drawing.Size(247, 66);
            this.skinTextbox1.TabIndex = 1;
            this.skinTextbox1.TextColor = System.Drawing.Color.FromArgb(((System.Byte)(94)), ((System.Byte)(94)), ((System.Byte)(94)));
            this.skinTextbox1.TextFont = new System.Drawing.Font("Microsoft Sans Serif", 30F);
            this.skinTextbox1.TextRectangle = new System.Drawing.Rectangle(7, 8, 233, 51);
            this.skinTextbox1.TransparentColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)));
            this.skinTextbox1.UseCashing = false;
            this.skinTextbox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.skinTextbox1_KeyPress);
            this.skinTextbox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.skinTextbox1_KeyDown);
            // 
            // skinTooltip1
            // 
            this.skinTooltip1.AlphaAnimation = true;
            this.skinTooltip1.AnimationInterval = 35;
            this.skinTooltip1.AnimationPosition = new System.Drawing.Point(24, 40);
            this.skinTooltip1.AnimationSteps = 10;
            this.skinTooltip1.BackgroundBitmap = null;
            this.skinTooltip1.Controls.Add(this.comboBox1);
            this.skinTooltip1.Controls.Add(this.button4);
            this.skinTooltip1.Controls.Add(this.button3);
            this.skinTooltip1.ExpandAnimation = false;
            this.skinTooltip1.ExpandType = KBSoft.Components.ExpandAnimationType.FromRightSide;
            this.skinTooltip1.FrontImage = ((System.Drawing.Bitmap)(resources.GetObject("skinTooltip1.FrontImage")));
            this.skinTooltip1.Location = new System.Drawing.Point(24, 40);
            this.skinTooltip1.Name = "skinTooltip1";
            this.skinTooltip1.ObtainBackground = true;
            this.skinTooltip1.PatternBitmap = ((System.Drawing.Bitmap)(resources.GetObject("skinTooltip1.PatternBitmap")));
            this.skinTooltip1.Size = new System.Drawing.Size(565, 355);
            this.skinTooltip1.TabIndex = 2;
            this.skinTooltip1.TransparentColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)));
            this.skinTooltip1.UpdateBitmapsOnce = false;
            this.skinTooltip1.UseCashing = false;
            // 
            // comboBox1
            // 
            this.comboBox1.Items.AddRange(new object[] {
                                                           "Item",
                                                           "Item1",
                                                           "Item2"});
            this.comboBox1.Location = new System.Drawing.Point(80, 168);
            this.comboBox1.Name = "comboBox1";
            this.comboBox1.Size = new System.Drawing.Size(128, 21);
            this.comboBox1.TabIndex = 2;
            this.comboBox1.Text = "comboBox";
            // 
            // button4
            // 
            this.button4.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.button4.Location = new System.Drawing.Point(80, 120);
            this.button4.Name = "button4";
            this.button4.Size = new System.Drawing.Size(128, 24);
            this.button4.TabIndex = 1;
            this.button4.Text = "button";
            // 
            // button3
            // 
            this.button3.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.button3.Location = new System.Drawing.Point(80, 32);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(128, 72);
            this.button3.TabIndex = 0;
            this.button3.Text = "Button";
            // 
            // showButton
            // 
            this.showButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.showButton.Location = new System.Drawing.Point(40, 416);
            this.showButton.Name = "showButton";
            this.showButton.Size = new System.Drawing.Size(80, 40);
            this.showButton.TabIndex = 3;
            this.showButton.Text = "Show tooltip";
            this.showButton.Click += new System.EventHandler(this.button1_Click);
            // 
            // hideButton
            // 
            this.hideButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.hideButton.Location = new System.Drawing.Point(136, 416);
            this.hideButton.Name = "hideButton";
            this.hideButton.Size = new System.Drawing.Size(80, 40);
            this.hideButton.TabIndex = 4;
            this.hideButton.Text = "Hide tooltip";
            this.hideButton.Click += new System.EventHandler(this.button2_Click);
            // 
            // helpButton
            // 
            this.helpButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.helpButton.Location = new System.Drawing.Point(232, 416);
            this.helpButton.Name = "helpButton";
            this.helpButton.Size = new System.Drawing.Size(80, 40);
            this.helpButton.TabIndex = 5;
            this.helpButton.Text = "Help";
            this.helpButton.Click += new System.EventHandler(this.button5_Click);
            // 
            // helpLabel
            // 
            this.helpLabel.BackColor = System.Drawing.SystemColors.Info;
            this.helpLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.helpLabel.FlatStyle = System.Windows.Forms.FlatStyle.System;
            this.helpLabel.Font = new System.Drawing.Font("Times New Roman", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(204)));
            this.helpLabel.Location = new System.Drawing.Point(40, 480);
            this.helpLabel.Name = "helpLabel";
            this.helpLabel.Size = new System.Drawing.Size(488, 56);
            this.helpLabel.TabIndex = 6;
            this.helpLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.BackColor = System.Drawing.SystemColors.Window;
            this.ClientSize = new System.Drawing.Size(592, 550);
            this.Controls.Add(this.skinTooltip1);
            this.Controls.Add(this.helpLabel);
            this.Controls.Add(this.helpButton);
            this.Controls.Add(this.hideButton);
            this.Controls.Add(this.showButton);
            this.Controls.Add(this.skinTextbox1);
            this.Controls.Add(this.skinButton1);
            this.Name = "Form1";
            this.Text = "KB_Soft Demo";
            ((System.ComponentModel.ISupportInitialize)(this.skinButton1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.skinTextbox1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.skinTooltip1)).EndInit();
            this.skinTooltip1.ResumeLayout(false);
            this.ResumeLayout(false);

        }
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

        /// <summary>
        /// Responses the button pressure. Deletes the symbol if backspace is pressed.
        /// </summary>
        /// <param name="sender">The object tha invoked the event.</param>
        /// <param name="e">The parameters of the event of pressing the button.</param>
		private void skinTextbox1_KeyDown( object sender, System.Windows.Forms.KeyEventArgs e )
		{
			if( e.KeyCode == Keys.Back )
				this.skinTextbox1.DeleteSymbol();
		}

        /// <summary>
        /// Responses the button pressure. Displays the symbol in the skinTextbox1 textbox.
        /// </summary>
        /// <param name="sender">The object that invoked the event.</param>
        /// <param name="e">The parameters of the event of pressing the button.</param>
		private void skinTextbox1_KeyPress( object sender, System.Windows.Forms.KeyPressEventArgs e )
		{
			if( (int)Keys.Space == (int)e.KeyChar )
			{
				skinTextbox1.AddSymbol(' ');
				return;
			}
			
			if( (int)Keys.Back != (int)e.KeyChar )
				this.skinTextbox1.AddSymbol( e.KeyChar );
		}

        /// <summary>
        /// The response to the showButton button pressure.
        /// </summary>
        /// <param name="sender">The object that invoked the event.</param>
        /// <param name="e">The event's parameters.</param>
		private void button1_Click( object sender, System.EventArgs e )
		{
			skinTooltip1.Animate();
		}

        /// <summary>
        /// The response to the hideButton button pressure.
        /// </summary>
        /// <param name="sender">The object that invoked the event.</param>
        /// <param name="e">The event's parameters.</param>
		private void button2_Click( object sender, System.EventArgs e )
		{
			skinTooltip1.Hide();
		}

		/// <summary>
		/// The response to the helpButton button pressure.
		/// </summary>
		/// <param name="sender">The object that invoked the event.</param>
		/// <param name="e">The event's parameters.</param>
        private void button5_Click( object sender, System.EventArgs e )
        {
            if( helpLabel.Visible )
                helpLabel.Hide();
            else
            {
                helpLabel.Show();
            }
        }

        #endregion
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Russian Federation Russian Federation
Alexandr Golovanov is a .NET developer at KB_Soft Group, an offshore software development company located in Russia, Novosibirsk. Here he has worked
on various .NET projects.

Comments and Discussions