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

免费网站怎么建正规网站优化推广

免费网站怎么建,正规网站优化推广,室内设计效果图片,自学软件开发从哪开始前言 WinForm(Windows Forms)是Microsoft.NET框架中的技术,用于开发Windows桌面应用程序。它提供了一套丰富的控件和组件。通过拖放控件、编写事件处理程序等方式快速构建用户界面。 通过属性窗口定制这些控件的外观和行为。 通过数据绑定&am…

前言

WinForm(Windows Forms)是Microsoft.NET框架中的技术,用于开发Windows桌面应用程序。它提供了一套丰富的控件和组件。通过拖放控件、编写事件处理程序等方式快速构建用户界面。

通过属性窗口定制这些控件的外观和行为。
通过数据绑定,将UI控件与数据源连接,实现数据的展示和更新。
通过上面的方法可以帮助开发者高效地创建桌面窗体应用程序,尤其适合初学者和需要快速开发的项目。

本文介绍了如何创建Winform窗体,并自定义窗体样式和窗体的基本功能。

1、窗体关闭、最大化、最小化、适应。
2、无边框窗体移动、调整窗体大小。
3、菜单展开折叠。

界面预览

在这里插入图片描述

代码

自定义按钮

用户自定义按钮:        

SelectedState:用户点击后状态取反。
Radius:按钮圆角半径。
HoverColor:鼠标悬停时的背景色。

public class UCButton : Button
{#region  公共字段、属性private bool _selectedState = false;[Category("UserProperty")][Description("选中状态")]public bool SelectedState{get => _selectedState;private set{_selectedState = value;this.Invalidate();}}private int radius = 15;[Category("UserProperty")][Description("圆角半径")]public int Radius{get { return radius; }set{radius = value;this.Invalidate();}}private Color _defaultColor;private Color _hoverColor = Color.LightBlue;[Category("UserProperty")][Description("鼠标悬停时的背景色")]public Color HoverColor { get => _hoverColor; set => _hoverColor = value; }#endregionpublic UCButton(){Initialize();}private void Initialize(){this.DoubleBuffered = true;this.FlatStyle = FlatStyle.Flat;this.FlatAppearance.BorderSize = 0;this.SetStyle(ControlStyles.UserPaint| ControlStyles.AllPaintingInWmPaint| ControlStyles.OptimizedDoubleBuffer| ControlStyles.ResizeRedraw| ControlStyles.SupportsTransparentBackColor, true);_defaultColor = BackColor;this.MouseEnter += UCButton_MouseEnter;this.MouseLeave += UCButton_MouseLeave;}private void UCButton_MouseEnter(object sender, EventArgs e){this.BackColor = HoverColor; // 鼠标进入时更改背景色}private void UCButton_MouseLeave(object sender, EventArgs e){this.BackColor = _defaultColor; // 鼠标离开时恢复默认背景色}protected override void OnClick(EventArgs e){base.OnClick(e);_selectedState = !_selectedState;}protected override void OnPaint(PaintEventArgs e){base.OnPaint(e);e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;                     // 设置抗锯齿e.Graphics.CompositingQuality = CompositingQuality.HighQuality;         // 高质量合成e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;    // 高质量插值// 绘制圆角矩形using (GraphicsPath path = new GraphicsPath()){path.AddArc(0, 0, radius, radius, 180, 90);                         // 左上角path.AddArc(this.Width - radius, 0, radius, radius, 270, 90);       // 右上角path.AddArc(this.Width - radius, this.Height - radius, radius, radius, 0, 90);  // 右下角path.AddArc(0, this.Height - radius, radius, radius, 90, 90);                   // 左下角path.CloseFigure();this.Region = new Region(path); // 设置按钮的区域为圆角矩形}// 绘制按钮文本using (Brush brush = new SolidBrush(this.ForeColor)){SizeF textSize = e.Graphics.MeasureString(this.Text, this.Font);PointF textLocation = new PointF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2);e.Graphics.DrawString(this.Text, this.Font, brush, textLocation);}}
}

窗体代码

1、窗体关闭、最大化、最小化、适应。
2、无边框窗体移动、调整窗体大小。
3、菜单展开折叠。

public partial class MainForm : Form
{private int ButtonWidth = 62;#region 窗体初始化、加载、关闭public MainForm(){InitializeComponent();this.CenterToParent();this.CenterToScreen();}private void MainForm_Load(object sender, System.EventArgs e){WinMoveBinding(panel_TopBorderItem);WinMoveBinding(pic_WinIcon);this.WindowState = FormWindowState.Normal;this.MinimumSize = new System.Drawing.Size(150, 150);panel_MenuItemText.Hide();ButtonWidth = btn_Expand.Width;}private void MainForm_FormClosing(object sender, FormClosingEventArgs e){}#endregion/// <summary>/// 窗体移动功能事件绑定/// </summary>private void WinMoveBinding(Control control){control.MouseDown += topBorderPanel_MouseDown;control.MouseMove += topBorderPanel_MouseMove;control.MouseUp += topBorderPanel_MouseUp;}#region 窗体拖动private Point mouseOffset;private void topBorderPanel_MouseDown(object sender, MouseEventArgs e){if (e.Button == MouseButtons.Left){mouseOffset = new Point(-e.X, -e.Y);}}private void topBorderPanel_MouseMove(object sender, MouseEventArgs e){if (e.Button == MouseButtons.Left){Point mousePos = Control.MousePosition;mousePos.Offset(mouseOffset.X, mouseOffset.Y);this.Location = mousePos;}}private void topBorderPanel_MouseUp(object sender, MouseEventArgs e){mouseOffset = Point.Empty;}#endregion#region 无边框窗体随意拖动和改变尺寸const int WM_NCHITTEST = 0x0084;const int HTLEFT = 10;const int HTRIGHT = 11;const int HTTOP = 12;const int HTTOPLEFT = 13;const int HTTOPRIGHT = 14;const int HTBOTTOM = 15;const int HTBOTTOMLEFT = 0x10;const int HTBOTTOMRIGHT = 17;protected override void WndProc(ref Message m){base.WndProc(ref m);switch (m.Msg){case WM_NCHITTEST:Point vPoint = new Point((int)m.LParam & 0xFFFF,(int)m.LParam >> 16 & 0xFFFF);vPoint = PointToClient(vPoint);if (vPoint.X <= 5)if (vPoint.Y <= 5)m.Result = (IntPtr)HTTOPLEFT;else if (vPoint.Y >= ClientSize.Height - 5)m.Result = (IntPtr)HTBOTTOMLEFT;else m.Result = (IntPtr)HTLEFT;else if (vPoint.X >= ClientSize.Width - 5)if (vPoint.Y <= 5)m.Result = (IntPtr)HTTOPRIGHT;else if (vPoint.Y >= ClientSize.Height - 5)m.Result = (IntPtr)HTBOTTOMRIGHT;else m.Result = (IntPtr)HTRIGHT;else if (vPoint.Y <= 5)m.Result = (IntPtr)HTTOP;else if (vPoint.Y >= ClientSize.Height - 5)m.Result = (IntPtr)HTBOTTOM;break;}}#endregion#region 窗体关闭、最大化、最小化private void btn_ClosingWindow_Click(object sender, System.EventArgs e){if (MessageBox.Show("是否关闭窗体!", "关闭", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK){this.Close();}}private void btn_Maximize_Click(object sender, System.EventArgs e){Button button = sender as Button;if (this.WindowState == FormWindowState.Maximized){this.WindowState = FormWindowState.Normal;button.Image = global::ModbusDemo.Properties.Resources.maximize_blue_32;}else{this.WindowState = FormWindowState.Maximized;button.Image = global::ModbusDemo.Properties.Resources.restore_blue_32;}}private void btn_Minimize_Click(object sender, System.EventArgs e){this.WindowState = FormWindowState.Minimized;}#endregion/// <summary>/// 折叠按钮/// </summary>private void btn_Expand_Click(object sender, System.EventArgs e){//展开if (!btn_Expand.SelectedState){btn_Expand.Image = global::ModbusDemo.Properties.Resources.collapse_left_blue_32;panel_MenuItemIcon.Width = ButtonWidth;panel_MenuItemText.ScrollControlIntoView(btn_Expand);panel_MenuItemText.Show();panel_LeftMenuItem.Width = 256;}//折叠else{btn_Expand.Image = global::ModbusDemo.Properties.Resources.collapse_right_blue_32;panel_MenuItemIcon.Width = ButtonWidth;panel_LeftMenuItem.Width = ButtonWidth;panel_MenuItemText.Hide();}}/// <summary>/// 首页按钮/// </summary>private void btn_Home_Click(object sender, EventArgs e){}
}

结语

既是分享,也是备份。


文章转载自:

http://I7VDEhFY.LjLLt.cn
http://NX6GBRJV.LjLLt.cn
http://Fc3nAiHm.LjLLt.cn
http://4Hqf0zE1.LjLLt.cn
http://9TC9RWio.LjLLt.cn
http://Ee8YnaeQ.LjLLt.cn
http://276rX68i.LjLLt.cn
http://oo8SOegj.LjLLt.cn
http://dgYLQnlH.LjLLt.cn
http://UNWQGicX.LjLLt.cn
http://TCCEZfUA.LjLLt.cn
http://HA5TLcF5.LjLLt.cn
http://YzRI5kLy.LjLLt.cn
http://8CeVyry0.LjLLt.cn
http://E8ZznP4h.LjLLt.cn
http://RN4sfa8r.LjLLt.cn
http://GIMxO32t.LjLLt.cn
http://6jGhggin.LjLLt.cn
http://D8uHmWMY.LjLLt.cn
http://1C2Apf5j.LjLLt.cn
http://AeoSNcfk.LjLLt.cn
http://SuVBM6Wi.LjLLt.cn
http://fhhanIzZ.LjLLt.cn
http://zENUUo1D.LjLLt.cn
http://Zg0YcTFJ.LjLLt.cn
http://h9Nfc8V0.LjLLt.cn
http://R6hwtOGg.LjLLt.cn
http://0uf5OfNb.LjLLt.cn
http://bZmW2cuT.LjLLt.cn
http://tjqIQj0w.LjLLt.cn
http://www.dtcms.com/wzjs/644855.html

相关文章:

  • 便利的响应式网站建设杭州 网站外包
  • 动易网站风格免费下载管理系统前端模板
  • 二手书籍交易网站开发方式邯郸企业做网站方案
  • 无障碍 网站 怎么做wordpress 新手教程
  • 高端品牌网站建设案例攻略做的比较好的网站
  • 做h5的网站哪个好深圳一医疗公司给员工放假10个月
  • 桃源网站建设建立网站原理
  • 网站开发页面如何做购物网站推广
  • 在线制作钓鱼网站源码深圳建站服务中心
  • 最专业的医疗网站建设视频制作软件下载安装
  • 企业网站建设流程概述健康企业建设
  • 公司制作网站价格做外贸做什么网站好
  • 淘宝的网站怎么做的好处wordpress使用自己的模板
  • 制作公司网页思路怎么写福州seo按天收费
  • 贵州城乡住房和建设厅网站淘客网站怎么做返利
  • 四川建设厅招投标官方网站logo查询有没有注册过
  • 网站做会员系统php网站开发怎么样
  • 网站建设费 科研 设备费互联网保险平台好干吗
  • 班级网站建设策划书网站建设销售实习报告
  • 做国际物流需要自己的网站吗东莞昨天发生的重大新闻
  • 用自己主机做网站贵州安顺建设局网站
  • 做搜狗手机网站排名软国际品牌的广州网页设计
  • 建一个收费网站网站增加keywords关键词有影响吗
  • 注册了域名之后如何建立一个网站企业建站系统cms
  • 网站建设网站制作有限厦门石材网站建设
  • 黔东南购物网站开发设计怎么做网站实惠
  • 响应式网站的好处机械厂网站建设方案
  • 食品类网站设计网站建站网站看看
  • div做网站排版广告公司设计
  • 可以做高中题目的网站如何做网站效果图