扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
private void Blog_DemoForm002_Load(object sender, EventArgs e) { AssemblyInfoClass myAssembly = new AssemblyInfoClass(); this.Text = myAssembly.AsmFQName; // 指派数组成员。 arrImages[0] = Properties.Resources.Eye1; arrImages[1] = Properties.Resources.Eye2; arrImages[2] = Properties.Resources.Eye3; arrImages[3] = Properties.Resources.Eye4; } |
private void AboutBox_Load(object sender, EventArgs e) { AssemblyInfoClass myAssembly = new AssemblyInfoClass(); labelProductName.Text = "产品名称:" + myAssembly.Product; labelVersion.Text = "版本:" + myAssembly.Version; labelCopyright.Text = "版权宣告:" + myAssembly.Copyright; labelCompanyName.Text = "公司名称:" + myAssembly.Company; textBoxDescription.Text = "细部描述:" + myAssembly.Description; } |
private void toolStripMenuItem4_Click(object sender, EventArgs e) { // 显示关于对话框。 AboutBox MyAboutBox = new AboutBox(); // 设定关于对话框的启始位置。 MyAboutBox.StartPosition = FormStartPosition.CenterScreen; MyAboutBox.Show(); } |
private void RadioButtons_CheckedChanged(object sender, EventArgs e) { if(optWink.Checked) { tmrAnimation.Interval = WINK_TIMER_INTERVAL; } else if(optBall.Checked) { tmrAnimation.Interval = BALL_TIMER_INTERVAL; } else if(optText.Checked) { tmrAnimation.Interval = TEXT_TIMER_INTERVAL; } OnResize(EventArgs.Empty); } |
protected override void OnResize(EventArgs ea) { if (optWink.Checked) { Graphics grfx = CreateGraphics(); // 重绘窗体。 this.Refresh(); } else if (optBall.Checked) { Graphics grfx = CreateGraphics(); grfx.Clear(BackColor); double dblRadius = Math.Min(ClientSize.Width / grfx.DpiX,ClientSize.Height / grfx.DpiY) / intBallSize; intBallRadiusX = (int)(dblRadius * grfx.DpiX); intBallRadiusY = (int)(dblRadius * grfx.DpiY); intBallMoveX = (int)(Math.Max(1, intBallRadiusX / intMoveSize)); intBallMoveY = (int)(Math.Max(1, intBallRadiusY / intMoveSize)); intBitmapWidthMargin = intBallMoveX; intBitmapHeightMargin = intBallMoveY; intBallBitmapWidth = 2 * (intBallRadiusX + intBitmapWidthMargin); intBallBitmapHeight = 2 * (intBallRadiusY + intBitmapHeightMargin); bitmap = new Bitmap(intBallBitmapWidth, intBallBitmapHeight); grfx = Graphics.FromImage(bitmap); grfx.Clear(BackColor); // 绘制球形。 grfx.FillEllipse(Brushes.Red, new Rectangle(intBallMoveX,intBallMoveY, 2 * intBallRadiusX, 2 * intBallRadiusY)); intBallPositionX = (int)(ClientSize.Width / 2); intBallPositionY = (int)(ClientSize.Height / 2); } else if (optText.Checked) { Graphics grfx = CreateGraphics(); grfx.Clear(BackColor); } } |
private void tmrAnimation_Tick(object sender, EventArgs e) { // 眨眼效果。 if(optWink.Checked) { Graphics grfx = CreateGraphics(); // 将数组中之图形绘制在画面上。 grfx.DrawImage(arrImages[intCurrentImage],(int)( (ClientSize.Width - arrImages[intCurrentImage].Width) / 2), (int)((ClientSize.Height - arrImages[intCurrentImage].Height) / 2), arrImages[intCurrentImage].Width,arrImages[intCurrentImage].Height); intCurrentImage += j; if(intCurrentImage == 3) { j = -1; } else if(intCurrentImage == 0) { j = 1; } } else if(optBall.Checked) // 弹跳的球。 { Graphics grfx = CreateGraphics(); // 将球绘制在画面上。 grfx.DrawImage(bitmap,(int)(intBallPositionX - intBallBitmapWidth / 2), (int)(intBallPositionY - intBallBitmapHeight / 2), intBallBitmapWidth, intBallBitmapHeight); // 移动球的位置。 intBallPositionX += intBallMoveX; intBallPositionY += intBallMoveY; // 球碰到左右边界。 if(intBallPositionX + intBallRadiusX >= ClientSize.Width || intBallPositionX - intBallRadiusX <= 0) { intBallMoveX = -intBallMoveX; SystemSounds.Beep.Play(); } // 球碰到上下边界。 if(intBallPositionY + intBallRadiusY >= ClientSize.Height || intBallPositionY - intBallRadiusY <= 75) { intBallMoveY = -intBallMoveY; SystemSounds.Beep.Play(); } } else if (optText.Checked) // 闪动文字。 { Graphics grfx = CreateGraphics(); // 设定文字的字型与大小。 Font font = new Font("Microsoft Sans Serif", 48, FontStyle.Bold, GraphicsUnit.Point); // 设定要显示的文字。 string strText = "章立民研究室"; SizeF sizfText = new SizeF(grfx.MeasureString(strText, font)); // X坐标与Y坐标的配对。 PointF ptfTextStart = new PointF((float)(ClientSize.Width - sizfText.Width) / 2, (float)(ClientSize.Height - sizfText.Height) / 2); PointF ptfGradientStart = new PointF(0, 0); PointF ptfGradientEnd = new PointF(intCurrentGradientShift, 200); // 设定笔刷。 LinearGradientBrush grBrush = new LinearGradientBrush(ptfGradientStart, ptfGradientEnd, Color.Blue, BackColor); // 将文字绘制在画面上。 grfx.DrawString(strText, font, grBrush, ptfTextStart); // 以不同的坐标绘制文字,造成闪动效果。 intCurrentGradientShift += intGradiantStep; if (intCurrentGradientShift == 500) { intGradiantStep = -5; } else if (intCurrentGradientShift == -50) { intGradiantStep = 5; } } } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者