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

📄 form1.h

📁 三次贝塞尔曲线的C程序,多于四点可通过连接保证C1连续
💻 H
📖 第 1 页 / 共 2 页
字号:
			__mcTemp__1[2] = 0;
			__mcTemp__1[3] = 0;
			this->spnFontSize->Value = System::Decimal(__mcTemp__1);
			// 
			// txtToDisplay
			// 
			this->txtToDisplay->Location = System::Drawing::Point(80, 24);
			this->txtToDisplay->Name = S"txtToDisplay";
			this->txtToDisplay->Size = System::Drawing::Size(224, 20);
			this->txtToDisplay->TabIndex = 1;
			this->txtToDisplay->Text = S"Tom Archer";
			// 
			// label1
			// 
			this->label1->Location = System::Drawing::Point(16, 24);
			this->label1->Name = S"label1";
			this->label1->Size = System::Drawing::Size(56, 23);
			this->label1->TabIndex = 0;
			this->label1->Text = S"Te&xt:";
			this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			// 
			// label2
			// 
			this->label2->Location = System::Drawing::Point(16, 88);
			this->label2->Name = S"label2";
			this->label2->Size = System::Drawing::Size(56, 23);
			this->label2->TabIndex = 6;
			this->label2->Text = S"&Font Size:";
			this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			// 
			// spnDepth
			// 
			this->spnDepth->Location = System::Drawing::Point(256, 88);
			this->spnDepth->Name = S"spnDepth";
			this->spnDepth->Size = System::Drawing::Size(48, 20);
			this->spnDepth->TabIndex = 9;
			System::Int32 __mcTemp__2[] = new System::Int32[4];
			__mcTemp__2[0] = 5;
			__mcTemp__2[1] = 0;
			__mcTemp__2[2] = 0;
			__mcTemp__2[3] = 0;
			this->spnDepth->Value = System::Decimal(__mcTemp__2);
			// 
			// label3
			// 
			this->label3->Location = System::Drawing::Point(192, 88);
			this->label3->Name = S"label3";
			this->label3->Size = System::Drawing::Size(56, 23);
			this->label3->TabIndex = 8;
			this->label3->Text = S"&Depth:";
			this->label3->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
			// 
			// label5
			// 
			this->label5->Location = System::Drawing::Point(16, 120);
			this->label5->Name = S"label5";
			this->label5->Size = System::Drawing::Size(128, 16);
			this->label5->TabIndex = 10;
			this->label5->Text = S"Text colour:";
			this->label5->TextAlign = System::Drawing::ContentAlignment::BottomLeft;
			// 
			// btnDisplayText
			// 
			this->btnDisplayText->Location = System::Drawing::Point(344, 152);
			this->btnDisplayText->Name = S"btnDisplayText";
			this->btnDisplayText->Size = System::Drawing::Size(80, 23);
			this->btnDisplayText->TabIndex = 1;
			this->btnDisplayText->Text = S"Display &Text";
			this->btnDisplayText->Click += new System::EventHandler(this, btnDisplayText_Click);
			// 
			// Form1
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
			this->CancelButton = this->btnClose;
			this->ClientSize = System::Drawing::Size(432, 333);
			this->Controls->Add(this->btnArticleList);
			this->Controls->Add(this->picText);
			this->Controls->Add(this->btnContactMe);
			this->Controls->Add(this->btnClose);
			this->Controls->Add(this->groupBox1);
			this->Controls->Add(this->btnDisplayText);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
			this->MaximizeBox = false;
			this->Name = S"Form1";
			this->Text = S"Managed Extensions - Using GDI+ to  Draw 3D Text";
			this->Load += new System::EventHandler(this, Form1_Load);
			this->groupBox1->ResumeLayout(false);
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->spnFontSize))->EndInit();
			(__try_cast<System::ComponentModel::ISupportInitialize *  >(this->spnDepth))->EndInit();
			this->ResumeLayout(false);

		}	
		private: System::Void Form1_Load(System::Object *  sender, System::EventArgs *  e)
		{
			for (int i = 1; i < 168; i++)
			{
				this->cbxShadowColour->Items->Add(__box(Color::FromKnownColor( (KnownColor)(i) )));
				this->cbxTextColour->Items->Add(__box(Color::FromKnownColor( (KnownColor)(i) )));
			}
			this->cbxShadowColour->SelectedIndex=34; // defaulting to black
			this->cbxTextColour->SelectedIndex=163;  // defaulting to white
		}

		private: System::Void btnClose_Click(System::Object *  sender, System::EventArgs *  e)
		{ this->Close(); }

		private: System::Void btnContactMe_Click(System::Object *  sender, System::EventArgs *  e)
		{
			System::Diagnostics::Process::Start(S"IExplore.exe", S"http://www.ArcherConsultingGroup.com/default.asp?id=1007");
		}

		private: System::Void btnArticleList_Click(System::Object *  sender, System::EventArgs *  e)
		{
			System::Diagnostics::Process::Start(S"IExplore.exe", S"http://www.codeguru.com/columns/DotNetTips");
		}

		private: System::Void btnDisplayText_Click(System::Object *  sender, System::EventArgs *  e)
		{
			// Set up internal display values
			textToDisplay = txtToDisplay->Text;
			
			if (rbtnShadow->Checked) style = TextStyle::Shadow;
			else if (rbtnBlock->Checked) style = TextStyle::Block;
			else if (rbtnEmboss->Checked) style = TextStyle::Emboss;
			else if (rbtnEngraved->Checked) style = TextStyle::Engrave;
			
			fontSize = spnFontSize->Value;
			shadowDepth = spnDepth->Value;

			textColour = Color::FromKnownColor( (KnownColor)(cbxTextColour->SelectedIndex+1));
			shadowColour = Color::FromKnownColor( (KnownColor)(cbxShadowColour->SelectedIndex+1));

			// Cause a repaint of the PictureBox
			picText->Invalidate();
		}

		private: System::Void rbtnShadow_CheckedChanged(System::Object *  sender, System::EventArgs *  e)
		{
			// Just some defaults that I think look good on shadowed text
			this->cbxShadowColour->SelectedIndex=34;
			this->cbxTextColour->SelectedIndex=163;
			this->spnDepth->Text = S"5";

			this->cbxTextColour->Enabled = true;
			this->cbxShadowColour->Enabled = true;
		}

		private: System::Void rbtnBlock_CheckedChanged(System::Object *  sender, System::EventArgs *  e)
		{
			// Just some defaults that I think look good on boxed text
			this->cbxShadowColour->SelectedIndex=34;
			this->cbxTextColour->SelectedIndex=163;
			this->spnDepth->Text = S"5";

			this->cbxTextColour->Enabled = true;
			this->cbxShadowColour->Enabled = true;
		}

		private: System::Void rbtnEmboss_CheckedChanged(System::Object *  sender, System::EventArgs *  e)
		{
			// embossing is usually used when the text
			// colour is the same as the background colour
			// and the depth is 1
			int i = this->cbxTextColour->FindStringExact(S"Color [Control]");
			if (-1 != i)
				this->cbxTextColour->SelectedIndex = i;
			this->spnDepth->Text = S"1";

			this->cbxTextColour->Enabled = false;
			this->cbxShadowColour->Enabled = false;
		}

		private: System::Void rbtnEngraved_CheckedChanged(System::Object *  sender, System::EventArgs *  e)
		{
			// engraving is usually used when the text
			// colour is the same as the background colour
			// and the depth is 1
			int i = this->cbxTextColour->FindStringExact(S"Color [Control]");
			if (-1 != i)
				this->cbxTextColour->SelectedIndex = i;
			this->spnDepth->Text = S"1";
			this->cbxTextColour->Enabled = false;
			this->cbxShadowColour->Enabled = false;
		}

		private: System::Void picText_Paint(System::Object *  sender, System::Windows::Forms::PaintEventArgs *  e)
		{
			if (textToDisplay)
			{
				// Obtain the Graphics object
				Graphics* g = e->Graphics;
	      
				// Instantiate the Font object based on the
				// user-supplied Font size
				System::Drawing::Font* font = 
					new System::Drawing::Font("Times New Roman", 
																		Convert::ToSingle(fontSize), 
																					 						FontStyle::Regular);

				// Obtain the size of the text to be rendered
				SizeF textSize = g->MeasureString(textToDisplay, font);

				// Create the text and shadow brushes
				SolidBrush* shadowBrush = new SolidBrush(shadowColour);
				SolidBrush* textBrush = new SolidBrush(textColour);

				// Clear the Picture Box control
				g->Clear(SystemColors::Control);

				// Text will be centered on Picture Box control
				Single x = (picText->Width - textSize.Width) / 2;
				Single y = (picText->Height - textSize.Height) / 2;

				// Draw the background text
				switch (style)
				{
					case TextStyle::Shadow:
						// Draw the underlying shadow first using 
						// user-supplied depth value
						g->DrawString(textToDisplay, 
													font, 
													shadowBrush,
													x + Convert::ToSingle(shadowDepth),
													y + Convert::ToSingle(shadowDepth));
					break;
					
					case TextStyle::Block:
						// Draw the background text first. Note that I'm drawing it once for 
						// every depth selected by the user. I also have the light source
						// coming from the upper-right for the simple reason that having it come
						// from the upper-left looks to much like shadow text. 
						for (int i = Convert::ToInt32(shadowDepth); i >= 0; i--)
						{
							g->DrawString(textToDisplay, 
														font, 
														shadowBrush,
														x - i, y + i);
						}
					break;
					
					case TextStyle::Emboss:
					case TextStyle::Engrave:
						g->DrawString(textToDisplay, 
													font, 
													shadowBrush,
													x + Convert::ToSingle( (style == TextStyle::Emboss ? shadowDepth : -shadowDepth) ),
													y + Convert::ToSingle( (style == TextStyle::Emboss ? shadowDepth : -shadowDepth) ) );
					break;
				}

				// Draw the foreground text
				g->DrawString(textToDisplay, font, textBrush, x, y);
			}
		}
	};
}

⌨️ 快捷键说明

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