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

📄 mainform.cs

📁 c#的学习资料 书上的东西 很难找到的啊
💻 CS
📖 第 1 页 / 共 4 页
字号:
			this.txtMessage.TextChanged += new System.EventHandler(this.OnMessageBoxChanged);
			// 
			// cbnUseMFC
			// 
			this.cbnUseMFC.Enabled = false;
			this.cbnUseMFC.Location = new System.Drawing.Point(128, 36);
			this.cbnUseMFC.Name = "cbnUseMFC";
			this.cbnUseMFC.Size = new System.Drawing.Size(95, 14);
			this.cbnUseMFC.TabIndex = 17;
			this.cbnUseMFC.Text = "Use MFC";
			this.cbnUseMFC.CheckedChanged += new System.EventHandler(this.OnMessageBoxChanged);
			// 
			// cbnDeclareIt
			// 
			this.cbnDeclareIt.Enabled = false;
			this.cbnDeclareIt.Location = new System.Drawing.Point(22, 77);
			this.cbnDeclareIt.Name = "cbnDeclareIt";
			this.cbnDeclareIt.Size = new System.Drawing.Size(95, 17);
			this.cbnDeclareIt.TabIndex = 5;
			this.cbnDeclareIt.Text = "Declare It?";
			this.cbnDeclareIt.CheckedChanged += new System.EventHandler(this.OnMessageBoxChanged);
			// 
			// btnDefault3
			// 
			this.btnDefault3.Location = new System.Drawing.Point(77, 109);
			this.btnDefault3.Name = "btnDefault3";
			this.btnDefault3.Size = new System.Drawing.Size(68, 24);
			this.btnDefault3.TabIndex = 5;
			this.btnDefault3.Text = "button3";
			this.btnDefault3.Visible = false;
			this.btnDefault3.Click += new System.EventHandler(this.btnDefault3_OnClick);
			// 
			// lblCaption
			// 
			this.lblCaption.BackColor = System.Drawing.SystemColors.ActiveCaption;
			this.lblCaption.ForeColor = System.Drawing.SystemColors.HighlightText;
			this.lblCaption.Location = new System.Drawing.Point(9, 22);
			this.lblCaption.Name = "lblCaption";
			this.lblCaption.Size = new System.Drawing.Size(279, 19);
			this.lblCaption.TabIndex = 1;
			this.lblCaption.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
			// 
			// lblVariable
			// 
			this.lblVariable.Enabled = false;
			this.lblVariable.Location = new System.Drawing.Point(7, 50);
			this.lblVariable.Name = "lblVariable";
			this.lblVariable.Size = new System.Drawing.Size(89, 21);
			this.lblVariable.TabIndex = 3;
			this.lblVariable.Text = "Variable Name";
			this.lblVariable.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// btnPreview
			// 
			this.btnPreview.Location = new System.Drawing.Point(328, 504);
			this.btnPreview.Name = "btnPreview";
			this.btnPreview.Size = new System.Drawing.Size(103, 28);
			this.btnPreview.TabIndex = 10;
			this.btnPreview.Text = "Test";
			this.btnPreview.Click += new System.EventHandler(this.btnPreview_Click);
			// 
			// cbnVisualCPP
			// 
			this.cbnVisualCPP.AutoCheck = false;
			this.cbnVisualCPP.Location = new System.Drawing.Point(128, 16);
			this.cbnVisualCPP.Name = "cbnVisualCPP";
			this.cbnVisualCPP.Size = new System.Drawing.Size(102, 15);
			this.cbnVisualCPP.TabIndex = 15;
			this.cbnVisualCPP.Text = "Visual C++";
			this.cbnVisualCPP.Click += new System.EventHandler(this.OnLanguageChanged);
			// 
			// cbnDefault1
			// 
			this.cbnDefault1.AutoCheck = false;
			this.cbnDefault1.Location = new System.Drawing.Point(34, 37);
			this.cbnDefault1.Name = "cbnDefault1";
			this.cbnDefault1.Size = new System.Drawing.Size(17, 17);
			this.cbnDefault1.TabIndex = 0;
			this.cbnDefault1.Click += new System.EventHandler(this.btnDefault1_Clicked);
			// 
			// btnDefault1
			// 
			this.btnDefault1.Location = new System.Drawing.Point(77, 34);
			this.btnDefault1.Name = "btnDefault1";
			this.btnDefault1.Size = new System.Drawing.Size(68, 25);
			this.btnDefault1.TabIndex = 3;
			this.btnDefault1.Text = "OK";
			this.btnDefault1.Click += new System.EventHandler(this.btnDefault1_OnClick);
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.listBox1});
			this.groupBox1.Location = new System.Drawing.Point(8, 336);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(214, 187);
			this.groupBox1.TabIndex = 12;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Message Box Icon";
			// 
			// btnDefault2
			// 
			this.btnDefault2.Location = new System.Drawing.Point(77, 71);
			this.btnDefault2.Name = "btnDefault2";
			this.btnDefault2.Size = new System.Drawing.Size(68, 24);
			this.btnDefault2.TabIndex = 4;
			this.btnDefault2.Text = "button2";
			this.btnDefault2.Visible = false;
			this.btnDefault2.Click += new System.EventHandler(this.btnDefault2_OnClick);
			// 
			// cbnUseReturnVar
			// 
			this.cbnUseReturnVar.Location = new System.Drawing.Point(22, 25);
			this.cbnUseReturnVar.Name = "cbnUseReturnVar";
			this.cbnUseReturnVar.Size = new System.Drawing.Size(197, 17);
			this.cbnUseReturnVar.TabIndex = 2;
			this.cbnUseReturnVar.Text = "Use return variable";
			this.cbnUseReturnVar.CheckedChanged += new System.EventHandler(this.cbnUseReturnVar_OnCheckChanged);
			// 
			// txtVariable
			// 
			this.txtVariable.Enabled = false;
			this.txtVariable.Location = new System.Drawing.Point(104, 50);
			this.txtVariable.Name = "txtVariable";
			this.txtVariable.Size = new System.Drawing.Size(90, 20);
			this.txtVariable.TabIndex = 1;
			this.txtVariable.Text = "mbResult";
			this.txtVariable.TextChanged += new System.EventHandler(this.OnMessageBoxChanged);
			// 
			// grpDefault
			// 
			this.grpDefault.Controls.AddRange(new System.Windows.Forms.Control[] {
																					 this.btnDefault3,
																					 this.btnDefault2,
																					 this.btnDefault1,
																					 this.cbnDefault3,
																					 this.cbnDefault2,
																					 this.cbnDefault1});
			this.grpDefault.Enabled = false;
			this.grpDefault.Location = new System.Drawing.Point(11, 59);
			this.grpDefault.Name = "grpDefault";
			this.grpDefault.Size = new System.Drawing.Size(185, 141);
			this.grpDefault.TabIndex = 2;
			this.grpDefault.TabStop = false;
			this.grpDefault.Text = "Select Default Button";
			// 
			// grpButtons
			// 
			this.grpButtons.Controls.AddRange(new System.Windows.Forms.Control[] {
																					 this.grpDefault,
																					 this.cboButtons});
			this.grpButtons.Location = new System.Drawing.Point(8, 128);
			this.grpButtons.Name = "grpButtons";
			this.grpButtons.Size = new System.Drawing.Size(207, 205);
			this.grpButtons.TabIndex = 1;
			this.grpButtons.TabStop = false;
			this.grpButtons.Text = "Buttons";
			// 
			// cboButtons
			// 
			this.cboButtons.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboButtons.DropDownWidth = 174;
			this.cboButtons.Items.AddRange(new object[] {
															"OK",
															"OK/Cancel",
															"Retry/Cancel",
															"Abort/Retry/Ignore",
															"Yes/No",
															"Yes/No/Cancel"});
			this.cboButtons.Location = new System.Drawing.Point(11, 25);
			this.cboButtons.Name = "cboButtons";
			this.cboButtons.Size = new System.Drawing.Size(185, 21);
			this.cboButtons.TabIndex = 0;
			this.cboButtons.SelectedIndexChanged += new System.EventHandler(this.cboButtons_OnSelectedIndexChanged);
			// 
			// grpOptions
			// 
			this.grpOptions.Controls.AddRange(new System.Windows.Forms.Control[] {
																					 this.cbnDeclareIt,
																					 this.cbnBuildSwitch,
																					 this.lblVariable,
																					 this.cbnUseReturnVar,
																					 this.txtVariable});
			this.grpOptions.Location = new System.Drawing.Point(544, 128);
			this.grpOptions.Name = "grpOptions";
			this.grpOptions.Size = new System.Drawing.Size(208, 131);
			this.grpOptions.TabIndex = 0;
			this.grpOptions.TabStop = false;
			this.grpOptions.Text = "Options";
			// 
			// cbnVisualBasic
			// 
			this.cbnVisualBasic.AutoCheck = false;
			this.cbnVisualBasic.Location = new System.Drawing.Point(234, 16);
			this.cbnVisualBasic.Name = "cbnVisualBasic";
			this.cbnVisualBasic.Size = new System.Drawing.Size(102, 15);
			this.cbnVisualBasic.TabIndex = 16;
			this.cbnVisualBasic.Text = "Visual Basic";
			this.cbnVisualBasic.Click += new System.EventHandler(this.OnLanguageChanged);
			// 
			// grpSample
			// 
			this.grpSample.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.btnSample4,
																					this.btnSample2,
																					this.btnSample5,
																					this.btnSample3,
																					this.btnSample1,
																					this.lblSampleText,
																					this.pbIcon,
																					this.lblCaption,
																					this.pictureBox1});
			this.grpSample.Location = new System.Drawing.Point(232, 128);
			this.grpSample.Name = "grpSample";
			this.grpSample.Size = new System.Drawing.Size(299, 196);
			this.grpSample.TabIndex = 13;
			this.grpSample.TabStop = false;
			this.grpSample.Text = "Preview";
			// 
			// imageList1
			// 
			this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
			this.imageList1.ImageSize = new System.Drawing.Size(32, 32);
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(760, 541);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.cbnUseMFC,
																		  this.cbnVisualBasic,
																		  this.cbnVisualCPP,
																		  this.cbnVisualCSharp,
																		  this.groupBox1,
																		  this.btnPreview,
																		  this.btnCancel,
																		  this.btnOK,
																		  this.grpCaption,
																		  this.grpMessage,
																		  this.grpButtons,
																		  this.grpSend,
																		  this.grpOptions,
																		  this.grpCode,
																		  this.grpSample});
			this.MaximizeBox = false;
			this.Name = "MainForm";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Message Box Builder";
			this.grpSend.ResumeLayout(false);
			this.grpCaption.ResumeLayout(false);
			this.grpCode.ResumeLayout(false);
			this.grpMessage.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.grpDefault.ResumeLayout(false);
			this.grpButtons.ResumeLayout(false);
			this.grpOptions.ResumeLayout(false);
			this.grpSample.ResumeLayout(false);
			this.ResumeLayout(false);

		}

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

		int SelectedIcon = 0;
		private void InitForm ()
		{
			cboButtons.SelectedIndex = 0;
			listBox1.SelectedIndex = SelectedIcon;
			txtCode.BackColor = Color.White;
			imageList1.Images.Add (System.Drawing.SystemIcons.Information);
			imageList1.Images.Add (System.Drawing.SystemIcons.Question);
			imageList1.Images.Add (System.Drawing.SystemIcons.Exclamation);
			imageList1.Images.Add (System.Drawing.SystemIcons.Error);
		}

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

		protected void btnOK_Click (object sender, System.EventArgs e)
		{			
			if (rdoClipboard.Checked)
			{
// Copy the generated code to the clipboard.
				Clipboard.SetDataObject (txtCode.Text, true);
			}
			else
			{
// Write the generated code to a file.
				SaveFileDialog dlg = new SaveFileDialog();
				dlg.OverwritePrompt = true;
				if (dlg.ShowDialog() == DialogResult.Cancel)
					return;
				string strName=dlg.FileName;
				FileStream strm = null;
				StreamWriter writer = null;
				while (true)
				{
					try
					{
						strm = new FileStream(strName,FileMode.Create,FileAccess.Write);
					}
					catch (Exception)
					{
						DialogResult result = MessageBox.Show("Cannot open file. Press Ignore to exit without saving.","Warning", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
						switch(result)
						{
							case DialogResult.Abort:
								return;
							case DialogResult.Retry:
								continue;
							case DialogResult.Ignore:
								this.Close();
								return;
						}						
					}
					try
					{
						writer = new StreamWriter(strm);
						writer.WriteLine(txtCode.Text);
						writer.Flush();
					}
					catch
					{
						DialogResult result = MessageBox.Show("Could not write to file. Press Ignore to exit anyway","Write failed", MessageBoxButtons.AbortRetryIgnore);
						switch(result)
						{
							case DialogResult.Abort:
								writer.Close();
								strm.Close();
								return;
							case DialogResult.Retry:
								writer.Close();
								strm.Close();
								continue;
							case DialogResult.Ignore:
								break;
						}						
					}
					writer.Close();
					strm.Close();
					break;
				}
			}
			this.Close();
		}
		private void btnDefault1_Clicked(object sender, System.EventArgs e)
		{
			cbnDefault1.Checked ^= true;
			cbnDefault2.Checked = false;
			cbnDefault3.Checked = false;
			OnMessageBoxChanged (sender, e);
		}

		private void btnDefault2_Clicked(object sender, System.EventArgs e)
		{
			cbnDefault1.Checked = false;
			cbnDefault2.Checked ^= true;
			cbnDefault3.Checked = false;
			OnMessageBoxChanged (sender, e);
		}

		private void btnDefault3_Clicked(object sender, System.EventArgs e)
		{
			cbnDefault1.Checked = false;
			cbnDefault2.Checked = false;
			cbnDefault3.Checked ^= true;
			OnMessageBoxChanged (sender, e);
		}

		private void OnMessageBoxChanged(object sender, System.EventArgs e)
		{
			txtCode.Text = BuildMessageBox();	
			txtCode.SelectionStart = 0;
			txtCode.SelectionLength = 0;
			lblSampleText.Text = txtMessage.Text;
		}

		protected void txtCaption_TextChanged (object sender, System.EventArgs e)
		{
			lblCaption.Text = txtCaption.Text;
			OnMessageBoxChanged (sender, e);
		}

		protected void txtMessage_TextChanged (object sender, System.EventArgs e)
		{
			lblSampleText.Text = txtMessage.Text;
			OnMessageBoxChanged (sender, e);
		}

⌨️ 快捷键说明

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