⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control1.cs

📁 c#精彩编程百例(源代码)
💻 CS
字号:
namespace WinControl
{
    using System;
    using System.Collections;
    using System.Core;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.WinForms;
	using System.Drawing.Drawing2D;
    using System.Timers;
    /// <summary>
    ///    Summary description for Control1.
    /// </summary>
    public class Control1 : System.WinForms.RichControl
    {
        /// <summary>
        ///    Required designer variable.
        /// </summary>
        // Add Property
	    [
          Category("Gradient"),
          Description("First Gradient Color")
         ]
        private System.Drawing.Color gradColor1;
		public System.Drawing.Color Gradient1
		{
			
			set
			{
				this.gradColor1=value;
			}
			get
			{
				return this.gradColor1;
			}
		}
       [
        Category("Gradient"),
        Description("Seeond Gradient Color")
       ]

        private System.Drawing.Color gradColor2;
		public System.Drawing.Color Gradient2
		{
			
			set
			{
				this.gradColor2=value;
			}
			get
			{
				return this.gradColor2;
			}
		}
		// Add method
		private System.Timers.Timer rotateTimer=null;
		public void StartRotation(bool state)
		{
			rotateTimer=new System.Timers.Timer();
			rotateTimer.Tick +=new EventHandler(OnTimedEvent);
			rotateTimer.Interval=500;
			rotateTimer.Enabled=true;
		}
		private int gradAngle=0;
        public void OnTimedEvent(object source,EventArgs e)
		{
			gradAngle+=10;
			if (gradAngle>=360)
			{
              gradAngle=0;
			}
			this.Refresh();
			if (OnAngleChange!=null)
			{
				OnAngleChange();
			}
		}
		public delegate void angleChange();
        public event angleChange OnAngleChange;
        private System.ComponentModel.Container components;
		protected override void OnPaint(PaintEventArgs pe)
       {
          SolidBrush b=new SolidBrush(this.BackColor);
          pe.Graphics.FillRectangle(b,this.ClientRectangle);
       }
        public Control1()
        {
            // This call is required by the WinForms Form Designer.
            InitializeComponent();
            // TODO: Add any initialization after the InitForm call

        }
        /// <summary>
        ///    Clean up any resources being used.
        /// </summary>
        public override void Dispose()
        {
            base.Dispose();
            components.Dispose();
        }

        /// <summary>
        ///    Required method for Designer support - do not modify 
        ///    the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            components = new System.ComponentModel.Container();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -