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

📄 form1.cs

📁 《c#技术内幕代码》
💻 CS
字号:
namespace Ch8_18
{
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.WinForms;
    using System.Data;

    /// <summary>
    ///    Summary description for Form1.
    /// </summary>
    public class Form1 : System.WinForms.Form
    {
        /// <summary>
        ///    Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components;
		private System.WinForms.Button button1;
		private System.WinForms.PictureBox pictureBox1;
		private System.WinForms.CheckBox BitmapCheckbox;
		private System.WinForms.CheckBox TextCheckbox;
		private System.WinForms.Label TextLabel;

        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent 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()
		{
			this.components = new System.ComponentModel.Container ();
			this.button1 = new System.WinForms.Button ();
			this.pictureBox1 = new System.WinForms.PictureBox ();
			this.TextCheckbox = new System.WinForms.CheckBox ();
			this.TextLabel = new System.WinForms.Label ();
			this.BitmapCheckbox = new System.WinForms.CheckBox ();
			//@this.TrayHeight = 0;
			//@this.TrayLargeIcon = false;
			//@this.TrayAutoArrange = true;
			button1.Location = new System.Drawing.Point (312, 304);
			button1.Size = new System.Drawing.Size (75, 23);
			button1.TabIndex = 4;
			button1.Text = "&Close";
			button1.Click += new System.EventHandler (this.button1_Click);
			pictureBox1.Location = new System.Drawing.Point (192, 64);
			pictureBox1.Size = new System.Drawing.Size (448, 176);
			pictureBox1.TabIndex = 3;
			pictureBox1.TabStop = false;
			TextCheckbox.Location = new System.Drawing.Point (24, 24);
			TextCheckbox.Text = "Text Available:";
			TextCheckbox.Size = new System.Drawing.Size (160, 24);
			TextCheckbox.TabIndex = 1;
			TextLabel.Location = new System.Drawing.Point (200, 24);
			TextLabel.Size = new System.Drawing.Size (440, 24);
			TextLabel.TabIndex = 0;
			BitmapCheckbox.Location = new System.Drawing.Point (24, 64);
			BitmapCheckbox.Text = "Bitmap Available:";
			BitmapCheckbox.Size = new System.Drawing.Size (120, 24);
			BitmapCheckbox.TabIndex = 2;
			this.Text = "Clipboard Data";
			this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
			this.ClientSize = new System.Drawing.Size (672, 357);
			this.Controls.Add (this.button1);
			this.Controls.Add (this.pictureBox1);
			this.Controls.Add (this.BitmapCheckbox);
			this.Controls.Add (this.TextCheckbox);
			this.Controls.Add (this.TextLabel);

			// See if there is data available on the clipboard for our formats.
            IDataObject iData = Clipboard.GetDataObject();
          
            if (iData.GetDataPresent(DataFormats.Text)) 
			{
			   TextCheckbox.Checked = true;
               TextLabel.Text = (String)iData.GetData(DataFormats.Text); 
		    }
			if ( iData.GetDataPresent(DataFormats.Bitmap) )
			{
				BitmapCheckbox.Checked = true;
				pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage ;
				pictureBox1.Image = (Bitmap)iData.GetData(DataFormats.Bitmap);
      
			}
        }

		protected void button1_Click (object sender, System.EventArgs e)
		{
            Close();
		}

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

⌨️ 快捷键说明

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