当前位置: 首页 > news >正文

做产品的往这看:国外工业设计网站大全!吉林seo外包

做产品的往这看:国外工业设计网站大全!,吉林seo外包,网页游戏排行榜前十名射击,长沙网站制造WinForm所见即所得的UI设计框架#xff0c;开发效率确实有所提升#xff0c;同时降低了编程门槛#xff0c;让WinForm更普及。拖拖拽拽就能设计出一个界面#xff0c;那么我们拖拽的这些东西是什么#xff1f;它们是什么原理#xff1f;。WinForm我觉得很好的一点是… WinForm所见即所得的UI设计框架开发效率确实有所提升同时降低了编程门槛让WinForm更普及。拖拖拽拽就能设计出一个界面那么我们拖拽的这些东西是什么它们是什么原理。WinForm我觉得很好的一点是把所有东西都对像化毕竟C#是面向对象的语言,包括可视化的窗体控件等当然有的控件在运行时是能看见的比如按钮文本框下拉列表框等等还有一类是在运时看不见的比如TimersFileSystemWatcher等。这些全都构建成了对象那么看得见的控件是怎么看得见的呢答案是绘制出来的画出来才能看得见。是用GDI技术画出来的。为了能够让大家更深入的理解我们现在画一个Switch控件Switch是苹果体系里的控件在WinForm中系统控件是没有的。Switch的作用非常像CheckBox所以我们就参照CheckBoxRenderer来画只不过画的形状不一样具体代码如下using System; using System.Collections.Generic; using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms.VisualStyles;namespace WinFormDemo02 {public class Switch : Control{private Rectangle textRectangleValue new Rectangle();private CheckBoxState state  CheckBoxState.UncheckedNormal;public Switch(): base(){this.Location new Point(50, 50);this.Size new Size(50, 25);this.Font SystemFonts.IconTitleFont;DoubleBuffered true;SetStyle(ControlStyles.OptimizedDoubleBuffer |ControlStyles.ResizeRedraw |ControlStyles.AllPaintingInWmPaint, true);}public bool Checked{get; set;} false;void DrawSwitch(Graphics g){var x 0;var y 0;var width 25;g.SmoothingMode SmoothingMode.HighQuality;g.PixelOffsetMode PixelOffsetMode.HighQuality;g.InterpolationMode InterpolationMode.High;g.CompositingQuality CompositingQuality.HighQuality;SolidBrush brush;if (Checked){brush new SolidBrush(Color.MediumSeaGreen);}else{brush new SolidBrush(Color.DarkRed);}g.FillPie(brush, new Rectangle(x, y, width, width), 90, 180);g.FillRectangle(brush, new Rectangle(x  width / 2 - 1, y, width, width));g.FillPie(brush, new Rectangle(x  width - 2, y, width, width), -90, 180);if (Checked){var selectBrush new SolidBrush(Color.White);g.FillEllipse(selectBrush, new Rectangle(x 2, y 2, width - 4, width - 4));}else{var selectBrush new SolidBrush(Color.White);g.FillEllipse(selectBrush, new Rectangle(x width, y 2, width - 4, width - 4));}}public Rectangle TextRectangle{get{using (Graphics g this.CreateGraphics()){textRectangleValue.X ClientRectangle.X CheckBoxRenderer.GetGlyphSize(g,CheckBoxState.UncheckedNormal).Width;textRectangleValue.Y ClientRectangle.Y;textRectangleValue.Width ClientRectangle.Width -CheckBoxRenderer.GetGlyphSize(g,CheckBoxState.UncheckedNormal).Width;textRectangleValue.Height ClientRectangle.Height;}return textRectangleValue;}}protected override void OnPaint(PaintEventArgs e){DrawSwitch(e.Graphics);base.OnPaint(e);}public event EventHandler CheckedChanged;protected override void OnMouseDown(MouseEventArgs e){base.OnMouseDown(e);if (!Checked){Checked true;state CheckBoxState.CheckedPressed;Invalidate();}else{Checked false;state CheckBoxState.UncheckedNormal;Invalidate();}CheckedChanged(this,new EventArgs());}protected override void OnMouseHover(EventArgs e){base.OnMouseHover(e);state Checked ? CheckBoxState.CheckedHot :CheckBoxState.UncheckedHot;Invalidate();}protected override void OnMouseUp(MouseEventArgs e){base.OnMouseUp(e);this.OnMouseHover(e);}protected override void OnMouseLeave(EventArgs e){base.OnMouseLeave(e);state Checked ? CheckBoxState.CheckedNormal :CheckBoxState.UncheckedNormal;Invalidate();}} }我只是简单的实现了一下重点在DrawSwitch这个方法就是画两个半圆中间是一个正方形然后在上面画一个白圆根据Checked属性最上面的白圆在两边切换仅此而以。看一下运行结果吧自行点击播放通过上面例子不知你是否了解了可视化控件的实现方式。如果你是初学者完整的思路不太通没关系理解到控件是画出来的就够了后面应该会说到GDI的详细技术点。如果你是WinForm老手可以自己实现一套自己的专用控件把Window上的应用Run出Mac的感觉甚至IOS的感觉。
http://wiki.neutronadmin.com/news/180161/

相关文章:

  • 网站层级淮北建设网站
  • 网站图标素材图片套模板网站价格
  • 移动网站建设动态广告设计与制作是做什么的
  • 重庆网站建设 吧手机主题制作网站
  • 网站建设结课小论文微信小商店和小程序商城的区别
  • 基于php的电商网站开发wordpress mysql优化
  • 我做淘宝网站卖东西怎么激活石桥铺做网站
  • 长安英文网站建设关于加强门户网站建设的通知
  • 增加网站和接入备案吗专业网站开发哪里好
  • 网站更新问题pageadmin建站系统破解版
  • 公司网站建设比较好的公司做网站如何写代码
  • 太原优化网站排名怎么把别人网站源码弄出来
  • 网站下载链接怎么做网站页面设计服务
  • 上海电子商城网站乐陵网络推广seo优化
  • 鞍山招聘网站网站建设需什么软件
  • 西安网站开发公司有哪家好最好用的网站开发软件
  • 网站建设模板一次收费网页设计图片边框怎么设置
  • 电影网站做淘客2021年最新企业所得税政策
  • 建立自己的公司网站建设网站的基本知识
  • 京山网站设计汕头建设银行
  • 唐山网站开发30天网站建设
  • 文件传输协议登陆网站建筑公司名字大全20000个
  • 怎么做扒代码网站网站租金可以做办公费吗
  • 做百度移动网站二手车为什么做网站
  • 如何做php分页网站很强大的网站运营方案1
  • asp个人网站wordpress福利源码
  • 自建国际网站做电商wordpress让评论内容
  • 可视化网站开发软件企业网页设计制作
  • 昆明网站搭建网站运营建站源码
  • 牛人网络网站网站自动适应屏幕