官网

http://www.hzhcontrols.com

前提

入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。

GitHub:https://github.com/kwwwvagaa/NetWinformControl

码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git

如果觉得写的还行,请点个 star 支持一下吧

欢迎前来交流探讨: 企鹅群568015492 

idkey=6e08741ef16fe53bf0314c1c9e336c4f626047943a8b76bac062361bab6b4f8d">

目录

https://www.cnblogs.com/bfyx/p/11364884.html

准备工作

GDI+需要有一点了解,不知道的可以百度瞅瞅

开始

添加一个用户控件,命名UCSwitch

添加一个枚举用以控制样式

 public enum SwitchType
{
/// <summary>
/// 椭圆
/// </summary>
Ellipse,
/// <summary>
/// 四边形
/// </summary>
Quadrilateral,
/// <summary>
/// 横线
/// </summary>
Line
}

添加属性

   [Description("选中改变事件"), Category("自定义")]
public event EventHandler CheckedChanged;
private Color m_trueColor = Color.FromArgb(, , ); [Description("选中时颜色"), Category("自定义")]
public Color TrueColor
{
get { return m_trueColor; }
set
{
m_trueColor = value;
Refresh();
}
} private Color m_falseColor = Color.FromArgb(, , ); [Description("没有选中时颜色"), Category("自定义")]
public Color FalseColor
{
get { return m_falseColor; }
set
{
m_falseColor = value;
Refresh();
}
} private bool m_checked; [Description("是否选中"), Category("自定义")]
public bool Checked
{
get { return m_checked; }
set
{
m_checked = value;
Refresh();
if (CheckedChanged != null)
{
CheckedChanged(this, null);
}
}
} private string[] m_texts; [Description("文本值,当选中或没有选中时显示,必须是长度为2的数组"), Category("自定义")]
public string[] Texts
{
get { return m_texts; }
set
{
m_texts = value;
Refresh();
}
}
private SwitchType m_switchType = SwitchType.Ellipse; [Description("显示类型"), Category("自定义")]
public SwitchType SwitchType
{
get { return m_switchType; }
set
{
m_switchType = value;
Refresh();
}
} public override Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
Refresh();
}
}

重绘

  protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var g = e.Graphics;
g.SetGDIHigh();
if (m_switchType == HZH_Controls.Controls.SwitchType.Ellipse)
{
var fillColor = m_checked ? m_trueColor : m_falseColor;
GraphicsPath path = new GraphicsPath();
path.AddLine(new Point(this.Height / , ), new Point(this.Width - this.Height / , ));
path.AddArc(new Rectangle(this.Width - this.Height - , , this.Height - , this.Height - ), -, );
path.AddLine(new Point(this.Width - this.Height / , this.Height - ), new Point(this.Height / , this.Height - ));
path.AddArc(new Rectangle(, , this.Height - , this.Height - ), , );
g.FillPath(new SolidBrush(fillColor), path); string strText = string.Empty;
if (m_texts != null && m_texts.Length == )
{
if (m_checked)
{
strText = m_texts[];
}
else
{
strText = m_texts[];
}
} if (m_checked)
{
g.FillEllipse(Brushes.White, new Rectangle(this.Width - this.Height - + , + , this.Height - - , this.Height - - ));
if (string.IsNullOrEmpty(strText))
{
g.DrawEllipse(new Pen(Color.White, ), new Rectangle((this.Height - - ) / - ((this.Height - - ) / ) / , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
else
{
System.Drawing.SizeF sizeF = g.MeasureString(strText.Replace(" ", "A"), Font);
int intTextY = (this.Height - (int)sizeF.Height) / + ;
g.DrawString(strText, Font, Brushes.White, new Point((this.Height - - ) / , intTextY));
}
}
else
{
g.FillEllipse(Brushes.White, new Rectangle( + , + , this.Height - - , this.Height - - ));
if (string.IsNullOrEmpty(strText))
{
g.DrawEllipse(new Pen(Color.White, ), new Rectangle(this.Width - - (this.Height - - ) / - ((this.Height - - ) / ) / , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
else
{
System.Drawing.SizeF sizeF = g.MeasureString(strText.Replace(" ", "A"), Font);
int intTextY = (this.Height - (int)sizeF.Height) / + ;
g.DrawString(strText, Font, Brushes.White, new Point(this.Width - - (this.Height - - ) / - ((this.Height - - ) / ) / - (int)sizeF.Width / , intTextY));
}
}
}
else if (m_switchType == HZH_Controls.Controls.SwitchType.Quadrilateral)
{
var fillColor = m_checked ? m_trueColor : m_falseColor;
GraphicsPath path = new GraphicsPath();
int intRadius = ;
path.AddArc(, , intRadius, intRadius, 180f, 90f);
path.AddArc(this.Width - intRadius - , , intRadius, intRadius, 270f, 90f);
path.AddArc(this.Width - intRadius - , this.Height - intRadius - , intRadius, intRadius, 0f, 90f);
path.AddArc(, this.Height - intRadius - , intRadius, intRadius, 90f, 90f); g.FillPath(new SolidBrush(fillColor), path); string strText = string.Empty;
if (m_texts != null && m_texts.Length == )
{
if (m_checked)
{
strText = m_texts[];
}
else
{
strText = m_texts[];
}
} if (m_checked)
{
GraphicsPath path2 = new GraphicsPath();
path2.AddArc(this.Width - this.Height - + , + , intRadius, intRadius, 180f, 90f);
path2.AddArc(this.Width - - - intRadius, + , intRadius, intRadius, 270f, 90f);
path2.AddArc(this.Width - - - intRadius, this.Height - - intRadius - , intRadius, intRadius, 0f, 90f);
path2.AddArc(this.Width - this.Height - + , this.Height - - intRadius - , intRadius, intRadius, 90f, 90f);
g.FillPath(Brushes.White, path2); if (string.IsNullOrEmpty(strText))
{
g.DrawEllipse(new Pen(Color.White, ), new Rectangle((this.Height - - ) / - ((this.Height - - ) / ) / , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
else
{
System.Drawing.SizeF sizeF = g.MeasureString(strText.Replace(" ", "A"), Font);
int intTextY = (this.Height - (int)sizeF.Height) / + ;
g.DrawString(strText, Font, Brushes.White, new Point((this.Height - - ) / , intTextY));
}
}
else
{
GraphicsPath path2 = new GraphicsPath();
path2.AddArc( + , + , intRadius, intRadius, 180f, 90f);
path2.AddArc(this.Height - - intRadius, + , intRadius, intRadius, 270f, 90f);
path2.AddArc(this.Height - - intRadius, this.Height - - intRadius - , intRadius, intRadius, 0f, 90f);
path2.AddArc( + , this.Height - - intRadius - , intRadius, intRadius, 90f, 90f);
g.FillPath(Brushes.White, path2); //g.FillEllipse(Brushes.White, new Rectangle(1 + 2, 1 + 2, this.Height - 2 - 4, this.Height - 2 - 4));
if (string.IsNullOrEmpty(strText))
{
g.DrawEllipse(new Pen(Color.White, ), new Rectangle(this.Width - - (this.Height - - ) / - ((this.Height - - ) / ) / , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
else
{
System.Drawing.SizeF sizeF = g.MeasureString(strText.Replace(" ", "A"), Font);
int intTextY = (this.Height - (int)sizeF.Height) / + ;
g.DrawString(strText, Font, Brushes.White, new Point(this.Width - - (this.Height - - ) / - ((this.Height - - ) / ) / - (int)sizeF.Width / , intTextY));
}
}
}
else
{
var fillColor = m_checked ? m_trueColor : m_falseColor;
int intLineHeight = (this.Height - - ) / ; GraphicsPath path = new GraphicsPath();
path.AddLine(new Point(this.Height / , (this.Height - intLineHeight) / ), new Point(this.Width - this.Height / , (this.Height - intLineHeight) / ));
path.AddArc(new Rectangle(this.Width - this.Height / - intLineHeight - , (this.Height - intLineHeight) / , intLineHeight, intLineHeight), -, );
path.AddLine(new Point(this.Width - this.Height / , (this.Height - intLineHeight) / + intLineHeight), new Point(this.Width - this.Height / , (this.Height - intLineHeight) / + intLineHeight));
path.AddArc(new Rectangle(this.Height / , (this.Height - intLineHeight) / , intLineHeight, intLineHeight), , );
g.FillPath(new SolidBrush(fillColor), path); if (m_checked)
{
g.FillEllipse(new SolidBrush(fillColor), new Rectangle(this.Width - this.Height - + , + , this.Height - - , this.Height - - ));
g.FillEllipse(Brushes.White, new Rectangle(this.Width - - (this.Height - - ) / - ((this.Height - - ) / ) / - , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
else
{
g.FillEllipse(new SolidBrush(fillColor), new Rectangle( + , + , this.Height - - , this.Height - - ));
g.FillEllipse(Brushes.White, new Rectangle((this.Height - - ) / - ((this.Height - - ) / ) / + , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
}
}

处理一下点击事件

  void UCSwitch_MouseDown(object sender, MouseEventArgs e)
{
Checked = !Checked;
}

完整代码

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D; namespace HZH_Controls.Controls
{
[DefaultEvent("CheckedChanged")]
public partial class UCSwitch : UserControl
{
[Description("选中改变事件"), Category("自定义")]
public event EventHandler CheckedChanged;
private Color m_trueColor = Color.FromArgb(, , ); [Description("选中时颜色"), Category("自定义")]
public Color TrueColor
{
get { return m_trueColor; }
set
{
m_trueColor = value;
Refresh();
}
} private Color m_falseColor = Color.FromArgb(, , ); [Description("没有选中时颜色"), Category("自定义")]
public Color FalseColor
{
get { return m_falseColor; }
set
{
m_falseColor = value;
Refresh();
}
} private bool m_checked; [Description("是否选中"), Category("自定义")]
public bool Checked
{
get { return m_checked; }
set
{
m_checked = value;
Refresh();
if (CheckedChanged != null)
{
CheckedChanged(this, null);
}
}
} private string[] m_texts; [Description("文本值,当选中或没有选中时显示,必须是长度为2的数组"), Category("自定义")]
public string[] Texts
{
get { return m_texts; }
set
{
m_texts = value;
Refresh();
}
}
private SwitchType m_switchType = SwitchType.Ellipse; [Description("显示类型"), Category("自定义")]
public SwitchType SwitchType
{
get { return m_switchType; }
set
{
m_switchType = value;
Refresh();
}
} public override Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
Refresh();
}
} public UCSwitch()
{
InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.Selectable, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.MouseDown += UCSwitch_MouseDown;
} void UCSwitch_MouseDown(object sender, MouseEventArgs e)
{
Checked = !Checked;
} protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var g = e.Graphics;
g.SetGDIHigh();
if (m_switchType == HZH_Controls.Controls.SwitchType.Ellipse)
{
var fillColor = m_checked ? m_trueColor : m_falseColor;
GraphicsPath path = new GraphicsPath();
path.AddLine(new Point(this.Height / , ), new Point(this.Width - this.Height / , ));
path.AddArc(new Rectangle(this.Width - this.Height - , , this.Height - , this.Height - ), -, );
path.AddLine(new Point(this.Width - this.Height / , this.Height - ), new Point(this.Height / , this.Height - ));
path.AddArc(new Rectangle(, , this.Height - , this.Height - ), , );
g.FillPath(new SolidBrush(fillColor), path); string strText = string.Empty;
if (m_texts != null && m_texts.Length == )
{
if (m_checked)
{
strText = m_texts[];
}
else
{
strText = m_texts[];
}
} if (m_checked)
{
g.FillEllipse(Brushes.White, new Rectangle(this.Width - this.Height - + , + , this.Height - - , this.Height - - ));
if (string.IsNullOrEmpty(strText))
{
g.DrawEllipse(new Pen(Color.White, ), new Rectangle((this.Height - - ) / - ((this.Height - - ) / ) / , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
else
{
System.Drawing.SizeF sizeF = g.MeasureString(strText.Replace(" ", "A"), Font);
int intTextY = (this.Height - (int)sizeF.Height) / + ;
g.DrawString(strText, Font, Brushes.White, new Point((this.Height - - ) / , intTextY));
}
}
else
{
g.FillEllipse(Brushes.White, new Rectangle( + , + , this.Height - - , this.Height - - ));
if (string.IsNullOrEmpty(strText))
{
g.DrawEllipse(new Pen(Color.White, ), new Rectangle(this.Width - - (this.Height - - ) / - ((this.Height - - ) / ) / , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
else
{
System.Drawing.SizeF sizeF = g.MeasureString(strText.Replace(" ", "A"), Font);
int intTextY = (this.Height - (int)sizeF.Height) / + ;
g.DrawString(strText, Font, Brushes.White, new Point(this.Width - - (this.Height - - ) / - ((this.Height - - ) / ) / - (int)sizeF.Width / , intTextY));
}
}
}
else if (m_switchType == HZH_Controls.Controls.SwitchType.Quadrilateral)
{
var fillColor = m_checked ? m_trueColor : m_falseColor;
GraphicsPath path = new GraphicsPath();
int intRadius = ;
path.AddArc(, , intRadius, intRadius, 180f, 90f);
path.AddArc(this.Width - intRadius - , , intRadius, intRadius, 270f, 90f);
path.AddArc(this.Width - intRadius - , this.Height - intRadius - , intRadius, intRadius, 0f, 90f);
path.AddArc(, this.Height - intRadius - , intRadius, intRadius, 90f, 90f); g.FillPath(new SolidBrush(fillColor), path); string strText = string.Empty;
if (m_texts != null && m_texts.Length == )
{
if (m_checked)
{
strText = m_texts[];
}
else
{
strText = m_texts[];
}
} if (m_checked)
{
GraphicsPath path2 = new GraphicsPath();
path2.AddArc(this.Width - this.Height - + , + , intRadius, intRadius, 180f, 90f);
path2.AddArc(this.Width - - - intRadius, + , intRadius, intRadius, 270f, 90f);
path2.AddArc(this.Width - - - intRadius, this.Height - - intRadius - , intRadius, intRadius, 0f, 90f);
path2.AddArc(this.Width - this.Height - + , this.Height - - intRadius - , intRadius, intRadius, 90f, 90f);
g.FillPath(Brushes.White, path2); if (string.IsNullOrEmpty(strText))
{
g.DrawEllipse(new Pen(Color.White, ), new Rectangle((this.Height - - ) / - ((this.Height - - ) / ) / , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
else
{
System.Drawing.SizeF sizeF = g.MeasureString(strText.Replace(" ", "A"), Font);
int intTextY = (this.Height - (int)sizeF.Height) / + ;
g.DrawString(strText, Font, Brushes.White, new Point((this.Height - - ) / , intTextY));
}
}
else
{
GraphicsPath path2 = new GraphicsPath();
path2.AddArc( + , + , intRadius, intRadius, 180f, 90f);
path2.AddArc(this.Height - - intRadius, + , intRadius, intRadius, 270f, 90f);
path2.AddArc(this.Height - - intRadius, this.Height - - intRadius - , intRadius, intRadius, 0f, 90f);
path2.AddArc( + , this.Height - - intRadius - , intRadius, intRadius, 90f, 90f);
g.FillPath(Brushes.White, path2); //g.FillEllipse(Brushes.White, new Rectangle(1 + 2, 1 + 2, this.Height - 2 - 4, this.Height - 2 - 4));
if (string.IsNullOrEmpty(strText))
{
g.DrawEllipse(new Pen(Color.White, ), new Rectangle(this.Width - - (this.Height - - ) / - ((this.Height - - ) / ) / , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
else
{
System.Drawing.SizeF sizeF = g.MeasureString(strText.Replace(" ", "A"), Font);
int intTextY = (this.Height - (int)sizeF.Height) / + ;
g.DrawString(strText, Font, Brushes.White, new Point(this.Width - - (this.Height - - ) / - ((this.Height - - ) / ) / - (int)sizeF.Width / , intTextY));
}
}
}
else
{
var fillColor = m_checked ? m_trueColor : m_falseColor;
int intLineHeight = (this.Height - - ) / ; GraphicsPath path = new GraphicsPath();
path.AddLine(new Point(this.Height / , (this.Height - intLineHeight) / ), new Point(this.Width - this.Height / , (this.Height - intLineHeight) / ));
path.AddArc(new Rectangle(this.Width - this.Height / - intLineHeight - , (this.Height - intLineHeight) / , intLineHeight, intLineHeight), -, );
path.AddLine(new Point(this.Width - this.Height / , (this.Height - intLineHeight) / + intLineHeight), new Point(this.Width - this.Height / , (this.Height - intLineHeight) / + intLineHeight));
path.AddArc(new Rectangle(this.Height / , (this.Height - intLineHeight) / , intLineHeight, intLineHeight), , );
g.FillPath(new SolidBrush(fillColor), path); if (m_checked)
{
g.FillEllipse(new SolidBrush(fillColor), new Rectangle(this.Width - this.Height - + , + , this.Height - - , this.Height - - ));
g.FillEllipse(Brushes.White, new Rectangle(this.Width - - (this.Height - - ) / - ((this.Height - - ) / ) / - , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
else
{
g.FillEllipse(new SolidBrush(fillColor), new Rectangle( + , + , this.Height - - , this.Height - - ));
g.FillEllipse(Brushes.White, new Rectangle((this.Height - - ) / - ((this.Height - - ) / ) / + , (this.Height - - (this.Height - - ) / ) / + , (this.Height - - ) / , (this.Height - - ) / ));
}
}
} } public enum SwitchType
{
/// <summary>
/// 椭圆
/// </summary>
Ellipse,
/// <summary>
/// 四边形
/// </summary>
Quadrilateral,
/// <summary>
/// 横线
/// </summary>
Line
}
}
 namespace HZH_Controls.Controls
{
partial class UCSwitch
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null; /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
} #region 组件设计器生成的代码 /// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// UCSwitch
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.Transparent;
this.Name = "UCSwitch";
this.Size = new System.Drawing.Size(, );
this.ResumeLayout(false); } #endregion
}
}

用处及效果

最后的话

如果你喜欢的话,请到 https://gitee.com/kwwwvagaa/net_winform_custom_control 点个星 星吧

(四十)c#Winform自定义控件-开关-HZHControls的更多相关文章

  1. (四十四)c#Winform自定义控件-水波-HZHControls

    官网 http://www.hzhcontrols.com 前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kww ...

  2. (二十四)c#Winform自定义控件-单标题窗体

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  3. (四)c#Winform自定义控件-选择按钮组

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  4. (十四)c#Winform自定义控件-键盘(一)

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  5. (五十四)c#Winform自定义控件-仪表盘

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  6. (六十四)c#Winform自定义控件-温度计(工业)

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  7. (七十四)c#Winform自定义控件-金字塔图表

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  8. (八十四)c#Winform自定义控件-导航菜单(类Office菜单)

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  9. (四十六)c#Winform自定义控件-水波进度条-HZHControls

    官网 http://www.hzhcontrols.com 前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kww ...

随机推荐

  1. BeetleX之TCP服务应用详解

    BeetleX是.net core平台下的一个开源TCP 通讯组件,它不仅使用简便还提供了出色性能的支持,可以轻易让你实现上百万级别RPS吞吐的服务应用.组件所提供的基础功能也非常完善,可以让你轻易扩 ...

  2. 时间轮算法(TimingWheel)是如何实现的?

    前言 我在2. SOFAJRaft源码分析-JRaft的定时任务调度器是怎么做的?这篇文章里已经讲解过时间轮算法在JRaft中是怎么应用的,但是我感觉我并没有讲解清楚这个东西,导致看了这篇文章依然和没 ...

  3. AWS re:Invent 2019参会有感

    感谢AWS方面的邀请,以及公司给予的机会,近期有幸赴美参与了享有盛名的AWS re:Invent大会.会议期间自己还算勤勉,参加了尽可能多的session.现笔者也已回到国内,交个作业,写一篇短文作为 ...

  4. java8-详解Lamda表达式

    一回顾与说明     通过之前发布的"Java8Lamda和Stream原理引入"一文章中你已经了解了为什么会有Lamda表达式的由来,Lamda表达式的基本语法等:Lamda表达 ...

  5. SpringMVC 数据交互

    为什么使用JSON进行数据交互? JSON数据格式比较简单.解析比较方便,在接口调用及HTML页面Ajax调用时较常用. JSON交互方式 请求是Key/Value,响应是JSON(推荐使用) 请求是 ...

  6. centos基本信息和ssh

    CentOs系统基本配置,包括修改主机名,创建用户并授权,ssh免密登录 1 永久修改主机名 sudo vim /etc/hostname 把原主机名xxx改为master(在从主机上则改为相应的sl ...

  7. Get提交数据过大,tomcat报错,信息: Error parsing HTTP request header Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level

    原因 get提交的数据过大,超过了默认值. 解决办法 get提交配置 设置tomcat的server.xml.找到我们启动的端口,一般是8080,增加maxHttpHeaderSize= " ...

  8. 微信支付 第三篇 微信调用H5页面进行支付

    上一篇讲到拿到了 预支付交易标识 wx251xxxxxxxxxxxxxxxxxxxxxxxxxxxxx078700 第四步,是时候微信内H5调起支付了! 先准备网页端接口请求参数列表 微信文档中已经明 ...

  9. DataGridView右键菜单自定义显示及隐藏列

    WinForm程序中表单的列可自定义显示及隐藏,是一种常见的功能,对于用户体验来说是非常好的.笔者经过一段时间的摸索,终于实现了自己想要的功能及效果,现记录一下过程: 1.新建一个自定义控件,命名为: ...

  10. 教你用python假装黑客装逼,当着朋友的面破解他的网站密码!

    如何破解iphone登陆密码 今天看了一篇关于如何破解iphone手机密码的文章,瞬间觉得科学技术不是第一生产力,why? 根据“可靠消息”称,即便美国FBI也无法轻易的对iphone手机进行暴力破解 ...