Graphics.DrawImage 画图 如何反复重新绘制?

weixin_38065223 2016-09-09 10:37:04
public int img { get { return imgstyle; } set { imgstyle=value; imgPicBox psBox = new imgPicBox(); psBox.Location = new Point(10, 10); psBox.Size = new Size(40, 40); psBox.Image2Location = new Point(25, 25); psBox.Image2size = new Size(15,15); psBox.Image1 = avatar.Image; if (imgstyle == 0) { psBox.Image2 = Properties.Resources.a; } else if (imgstyle == 1) { psBox.Image2 = Properties.Resources.b; } else if (imgstyle == 2) { psBox.Image2 = Properties.Resources.c; } else if (imgstyle == 3) { psBox.Image2 = Properties.Resources.d; } else if (imgstyle == 4) { psBox.Image2 = Properties.Resources.e; } else if (imgstyle == 5) { psBox.Image2 = Properties.Resources.f; } else { psBox.Image2 = null; } avatar.Visible = false; this.Controls.Add(psBox); //psBox.Invalidate(); psBox.Refresh(); } } public class imgPicBox : UserControl { public imgPicBox() { this.Image2Opacity = 1f; base.DoubleBuffered = true; } public Image Image1 { get; set; } public Image Image2 { get; set; } public Point Image2Location { get; set; } public float Image2Opacity { get; set; } public Size Image2size { get; set; } protected override void OnPaint(PaintEventArgs e) { if (Image1 != null) { e.Graphics.DrawImage(Image1, new Rectangle(0,0,40,40), new Rectangle(Point.Empty, Image1.Size), GraphicsUnit.Pixel); } if (Image2 != null) { ImageAttributes attr = new ImageAttributes(); attr.SetColorMatrix(new ColorMatrix() { Matrix33 = Image2Opacity }); e.Graphics.DrawImage(Image2, new Rectangle(Image2Location.X, Image2Location.Y, Image2size.Width, Image2size.Height), 0, 0, Image2size.Width, Image2size.Height, GraphicsUnit.Pixel, attr); } } }

尝试改变 img 的自定义值 的时候重新绘制图片  如何改变一次重新绘制一次?
当img 值为0的时候 绘制一次  再次改变img的值为1的时候 重新绘制一张图  但是试过很多方法 只有第一次起作用 再修改丝毫不起作用????
...全文
44 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
内容概要:本文围绕基于风光储能和需求响应的微电网日前经济调度问题,提出了一套完整的Python代码实现方案。研究综合考虑风能、光伏等可再生能源的出力不确定性、储能系统的动态充放电特性以及需求侧响应机制,构建了以最小化系统综合运行成本为目标的优化调度模型。该模型充分体现了对可再生能源的高效消纳、系统经济性提升与供需平衡调控的能力,通过Python编程结合优化求解器实现了模型的求解与仿真验证,为微电网能量管理系统的设计与科研分析提供了可复现的技术路径与实践参考。; 适合人群:具备一定Python编程基础和电力系统优化调度知识的科研人员、工程技术人员及高校电气工程、能源系统等相关专业的研究生。; 使用场景及目标:①应用于微电网、智能配电网及综合能源系统的科研建模与仿真分析;②帮助读者深入理解含高比例可再生能源的电力系统日前调度建模方法、目标函数构造与约束条件处理技巧;③为实际工程中实现低碳、经济、可靠的微电网运行提供算法支持与决策依据。; 阅读建议:建议读者结合文档中的代码实例,系统学习优化模型的数学表达与编程实现过程,重点关注变量定义、目标函数构建、系统约束(如功率平衡、储能动态、机组出力等)的编码实现,并尝试调整负荷、新能源出力等输入数据进行多场景仿真,以深入掌握微电网调度策略的灵敏度分析与优化效果评估方法。

477

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧