收藏 分销(赏)

C#绘制渐变矩形代码.doc

上传人:pc****0 文档编号:9008434 上传时间:2025-03-11 格式:DOC 页数:4 大小:69KB
下载 相关 举报
C#绘制渐变矩形代码.doc_第1页
第1页 / 共4页
C#绘制渐变矩形代码.doc_第2页
第2页 / 共4页
点击查看更多>>
资源描述
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Windows.Forms; namespace gaolinglong35jianbiantuxing { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { ColorDialog dlg1 = new ColorDialog(); dlg1.Color = this.button3.BackColor; if (dlg1.ShowDialog() == DialogResult.OK) this.button3.BackColor = dlg1.Color; } private void button2_Click(object sender, EventArgs e) { ColorDialog dlg2 = new ColorDialog(); dlg2.Color = this.button4.BackColor; if (dlg2.ShowDialog() == DialogResult.OK) this.button4.BackColor = dlg2.Color; } private void Form1_Load(object sender, EventArgs e) { button3.Text = ""; button3.Enabled = false; button3.ForeColor = this.BackColor; button4.Text = ""; button4.Enabled = false; button4.ForeColor = this.BackColor; checkBox1.Checked = true; } private void Form1_Paint(object sender, PaintEventArgs e) { } private void radioButton1_Click(object sender, EventArgs e) { if (checkBox1.Checked) { if (radioButton1.Checked) { Brush brush1 = new LinearGradientBrush(new Point(10, 10), new Point(10, 50), this.button3.BackColor, this.button4.BackColor); Graphics g; g = this.CreateGraphics(); g.FillRectangle(brush1, 20, 60, 220, 180); brush1.Dispose(); } } } private void radioButton2_Click(object sender, EventArgs e) { if (checkBox1.Checked) { if (radioButton2.Checked) { Brush brush1 = new LinearGradientBrush(new Point(10, 10), new Point(50, 10), this.button3.BackColor, this.button4.BackColor); Graphics g; g = this.CreateGraphics(); g.FillRectangle(brush1, 20, 60, 220, 180); brush1.Dispose(); } } } private void radioButton3_Click(object sender, EventArgs e) { if (checkBox1.Checked) { if (radioButton3.Checked) { Brush brush1 = new LinearGradientBrush(new Point(10, 10), new Point(50, 50), this.button3.BackColor, this.button4.BackColor); Graphics g; g = this.CreateGraphics(); g.FillRectangle(brush1, 20, 60, 220, 180); brush1.Dispose(); } } } private void radioButton4_Click(object sender, EventArgs e) { if (checkBox1.Checked) { if (radioButton4.Checked) { Brush brush1 = new LinearGradientBrush(new Point(10, 10), new Point(50, 50), this.button4.BackColor, this.button3.BackColor); Graphics g; g = this.CreateGraphics(); g.FillRectangle(brush1, 20, 60, 220, 180); brush1.Dispose(); } } } } } 运行结果如下图:
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传
相似文档                                   自信AI助手自信AI助手

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:4009-655-100  投诉/维权电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服