Commit c1f46219 HZH

增加按钮组

1 个父辈 9bab6adb
namespace HZH_Controls.Controls
{
partial class UCBtnsGroup
{
/// <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.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.SuspendLayout();
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(420, 50);
this.flowLayoutPanel1.TabIndex = 0;
//
// UCBtnsGroup
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.flowLayoutPanel1);
this.MinimumSize = new System.Drawing.Size(0, 50);
this.Name = "UCBtnsGroup";
this.Size = new System.Drawing.Size(420, 50);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
}
}
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;
namespace HZH_Controls.Controls
{
public partial class UCBtnsGroup : UserControl
{
/// <summary>
/// 选中改变事件
/// </summary>
public event EventHandler SelectedItemChanged;
private Dictionary<string, string> m_dataSource = new Dictionary<string, string>();
/// <summary>
/// 数据源
/// </summary>
public Dictionary<string, string> DataSource
{
get { return m_dataSource; }
set
{
m_dataSource = value;
Reload();
}
}
private List<string> m_selectItem = new List<string>();
/// <summary>
/// 选中项
/// </summary>
public List<string> SelectItem
{
get { return m_selectItem; }
set
{
m_selectItem = value;
if (m_selectItem == null)
m_selectItem = new List<string>();
}
}
private bool m_isMultiple = false;
/// <summary>
/// 是否多选
/// </summary>
public bool IsMultiple
{
get { return m_isMultiple; }
set { m_isMultiple = value; }
}
public UCBtnsGroup()
{
InitializeComponent();
}
private void Reload()
{
try
{
ControlHelper.FreezeControl(flowLayoutPanel1, true);
this.flowLayoutPanel1.Controls.Clear();
if (DataSource != null)
{
foreach (var item in DataSource)
{
UCBtnExt btn = new UCBtnExt();
btn.BackColor = System.Drawing.Color.Transparent;
btn.BtnBackColor = System.Drawing.Color.White;
btn.BtnFont = new System.Drawing.Font("微软雅黑", 10F);
btn.BtnForeColor = System.Drawing.Color.Gray;
btn.BtnText = item.Value;
btn.ConerRadius = 5;
btn.Cursor = System.Windows.Forms.Cursors.Hand;
btn.FillColor = System.Drawing.Color.White;
btn.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
btn.IsRadius = true;
btn.IsShowRect = true;
btn.IsShowTips = false;
btn.Location = new System.Drawing.Point(5, 5);
btn.Margin = new System.Windows.Forms.Padding(5);
btn.Name = item.Key;
btn.RectColor = System.Drawing.Color.FromArgb(224, 224, 224);
btn.RectWidth = 1;
btn.Size = new System.Drawing.Size(72, 38);
btn.TabStop = false;
btn.BtnClick += btn_BtnClick;
this.flowLayoutPanel1.Controls.Add(btn);
}
}
}
finally
{
ControlHelper.FreezeControl(flowLayoutPanel1, false);
}
SetSelected();
}
void btn_BtnClick(object sender, EventArgs e)
{
var btn = sender as UCBtnExt;
if (m_selectItem.Contains(btn.Name))
{
btn.RectColor = System.Drawing.Color.FromArgb(224, 224, 224);
m_selectItem.Remove(btn.Name);
}
else
{
if (!m_isMultiple)
{
foreach (var item in m_selectItem)
{
var lst = this.flowLayoutPanel1.Controls.Find(item, false);
if (lst.Length == 1)
{
var _btn = lst[0] as UCBtnExt;
_btn.RectColor = System.Drawing.Color.FromArgb(224, 224, 224);
}
}
m_selectItem.Clear();
}
btn.RectColor = System.Drawing.Color.FromArgb(255, 77, 59);
m_selectItem.Add(btn.Name);
}
if (SelectedItemChanged != null)
SelectedItemChanged(this, e);
}
private void SetSelected()
{
if (m_selectItem != null && m_selectItem.Count > 0 && DataSource != null && DataSource.Count > 0)
{
try
{
ControlHelper.FreezeControl(flowLayoutPanel1, true);
if (m_isMultiple)
{
foreach (var item in m_selectItem)
{
var lst = this.flowLayoutPanel1.Controls.Find(item, false);
if (lst.Length == 1)
{
var btn = lst[0] as UCBtnExt;
btn.RectColor = System.Drawing.Color.FromArgb(255, 77, 59);
}
}
}
else
{
UCBtnExt btn = null;
foreach (var item in m_selectItem)
{
var lst = this.flowLayoutPanel1.Controls.Find(item, false);
if (lst.Length == 1)
{
btn = lst[0] as UCBtnExt;
break;
}
}
if (btn != null)
{
m_selectItem = new List<string>() { btn.Name };
btn.RectColor = System.Drawing.Color.FromArgb(255, 77, 59);
}
}
}
finally
{
ControlHelper.FreezeControl(flowLayoutPanel1, false);
}
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -41,6 +41,12 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\BtnsGroup\UCBtnsGroup.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\BtnsGroup\UCBtnsGroup.Designer.cs">
<DependentUpon>UCBtnsGroup.cs</DependentUpon>
</Compile>
<Compile Include="Controls\DataGridView\DataGridViewCellEntity.cs" />
<Compile Include="Controls\DataGridView\DataGridViewCellEventArgs.cs" />
<Compile Include="Controls\DataGridView\DataGridViewCellEventHandler.cs" />
......@@ -321,6 +327,9 @@
<Compile Include="Helpers\TextInputType.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Controls\BtnsGroup\UCBtnsGroup.resx">
<DependentUpon>UCBtnsGroup.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Controls\Btn\UCBtnExt.resx">
<DependentUpon>UCBtnExt.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -50,6 +50,7 @@
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.button9 = new System.Windows.Forms.Button();
this.groupBox10 = new System.Windows.Forms.GroupBox();
this.ucPagerControl21 = new HZH_Controls.Controls.List.UCPagerControl2();
this.ucMenu1 = new HZH_Controls.Controls.UCMenu();
this.ucHorizontalList1 = new HZH_Controls.Controls.UCHorizontalList();
this.ucDatePickerExt3 = new HZH_Controls.Controls.UCDatePickerExt();
......@@ -77,7 +78,9 @@
this.ucBtnFillet1 = new HZH_Controls.Controls.UCBtnFillet();
this.ucBtnExt2 = new HZH_Controls.Controls.UCBtnExt();
this.ucBtnExt1 = new HZH_Controls.Controls.UCBtnExt();
this.ucPagerControl21 = new HZH_Controls.Controls.List.UCPagerControl2();
this.groupBox11 = new System.Windows.Forms.GroupBox();
this.groupBox12 = new System.Windows.Forms.GroupBox();
this.ucBtnsGroup1 = new HZH_Controls.Controls.UCBtnsGroup();
this.groupBox1.SuspendLayout();
this.groupBox9.SuspendLayout();
this.groupBox7.SuspendLayout();
......@@ -88,6 +91,8 @@
this.groupBox3.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox10.SuspendLayout();
this.groupBox11.SuspendLayout();
this.groupBox12.SuspendLayout();
this.SuspendLayout();
//
// timer1
......@@ -310,6 +315,20 @@
this.groupBox10.TabStop = false;
this.groupBox10.Text = "导航";
//
// ucPagerControl21
//
this.ucPagerControl21.BackColor = System.Drawing.Color.White;
this.ucPagerControl21.DataSource = ((System.Collections.Generic.List<object>)(resources.GetObject("ucPagerControl21.DataSource")));
this.ucPagerControl21.Dock = System.Windows.Forms.DockStyle.Fill;
this.ucPagerControl21.Location = new System.Drawing.Point(3, 17);
this.ucPagerControl21.Name = "ucPagerControl21";
this.ucPagerControl21.PageCount = 0;
this.ucPagerControl21.PageIndex = 1;
this.ucPagerControl21.PageSize = 0;
this.ucPagerControl21.Size = new System.Drawing.Size(709, 41);
this.ucPagerControl21.StartIndex = 0;
this.ucPagerControl21.TabIndex = 4;
//
// ucMenu1
//
this.ucMenu1.AutoScroll = true;
......@@ -889,26 +908,45 @@
this.ucBtnExt1.TabStop = false;
this.ucBtnExt1.TipsText = "";
//
// ucPagerControl21
//
this.ucPagerControl21.BackColor = System.Drawing.Color.White;
this.ucPagerControl21.DataSource = null;
this.ucPagerControl21.Dock = System.Windows.Forms.DockStyle.Bottom;
this.ucPagerControl21.Location = new System.Drawing.Point(0, 599);
this.ucPagerControl21.Name = "ucPagerControl21";
this.ucPagerControl21.PageCount = 0;
this.ucPagerControl21.PageIndex = 1;
this.ucPagerControl21.PageSize = 0;
this.ucPagerControl21.Size = new System.Drawing.Size(1374, 41);
this.ucPagerControl21.StartIndex = 0;
this.ucPagerControl21.TabIndex = 4;
// groupBox11
//
this.groupBox11.Controls.Add(this.ucPagerControl21);
this.groupBox11.Location = new System.Drawing.Point(19, 584);
this.groupBox11.Name = "groupBox11";
this.groupBox11.Size = new System.Drawing.Size(715, 61);
this.groupBox11.TabIndex = 5;
this.groupBox11.TabStop = false;
this.groupBox11.Text = "分页控件";
//
// groupBox12
//
this.groupBox12.Controls.Add(this.ucBtnsGroup1);
this.groupBox12.Location = new System.Drawing.Point(749, 584);
this.groupBox12.Name = "groupBox12";
this.groupBox12.Size = new System.Drawing.Size(221, 68);
this.groupBox12.TabIndex = 6;
this.groupBox12.TabStop = false;
this.groupBox12.Text = "按钮组";
//
// ucBtnsGroup1
//
this.ucBtnsGroup1.BackColor = System.Drawing.Color.White;
this.ucBtnsGroup1.DataSource = ((System.Collections.Generic.Dictionary<string, string>)(resources.GetObject("ucBtnsGroup1.DataSource")));
this.ucBtnsGroup1.IsMultiple = false;
this.ucBtnsGroup1.Location = new System.Drawing.Point(6, 14);
this.ucBtnsGroup1.MinimumSize = new System.Drawing.Size(0, 50);
this.ucBtnsGroup1.Name = "ucBtnsGroup1";
this.ucBtnsGroup1.SelectItem = ((System.Collections.Generic.List<string>)(resources.GetObject("ucBtnsGroup1.SelectItem")));
this.ucBtnsGroup1.Size = new System.Drawing.Size(194, 50);
this.ucBtnsGroup1.TabIndex = 0;
//
// Form1
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1374, 640);
this.Controls.Add(this.ucPagerControl21);
this.ClientSize = new System.Drawing.Size(1374, 709);
this.Controls.Add(this.groupBox12);
this.Controls.Add(this.groupBox11);
this.Controls.Add(this.groupBox10);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.button5);
......@@ -934,6 +972,8 @@
this.groupBox3.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox10.ResumeLayout(false);
this.groupBox11.ResumeLayout(false);
this.groupBox12.ResumeLayout(false);
this.ResumeLayout(false);
}
......@@ -988,6 +1028,9 @@
private System.Windows.Forms.GroupBox groupBox10;
private HZH_Controls.Controls.UCMenu ucMenu1;
private HZH_Controls.Controls.List.UCPagerControl2 ucPagerControl21;
private System.Windows.Forms.GroupBox groupBox11;
private System.Windows.Forms.GroupBox groupBox12;
private HZH_Controls.Controls.UCBtnsGroup ucBtnsGroup1;
}
}
......@@ -98,6 +98,8 @@ namespace Test
}
ucPagerControl21.PageSize = 10;
ucPagerControl21.DataSource = lstPage2;
ucBtnsGroup1.DataSource = new Dictionary<string, string>() { { "1", "男" }, { "0", "女" } };
}
private void timer1_Tick(object sender, EventArgs e)
......
......@@ -197,4 +197,38 @@
QmCC
</value>
</data>
<data name="ucPagerControl21.DataSource" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u
ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u
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WxpdHlDb21wYXJlcmAxW1tTeXN0ZW0uU3RyaW5nAwAAAAgC
AAAAAAAAAAkEAAAAAAAAAAUEAAAAQ1N5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkdlbmVyaWNFcXVh
bGl0eUNvbXBhcmVyYDFbW1N5c3RlbS5TdHJpbmcAAAAAAwAAAAs=
</value>
</data>
<data name="ucBtnsGroup1.SelectItem" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAJoBbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1u
ZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0sIG1zY29ybGliLCBWZXJzaW9u
PTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQUB
AAAAMFN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkxpc3RgMVtbU3lzdGVtLlN0cmluZwMAAAAGX2l0
ZW1zBV9zaXplCF92ZXJzaW9uBgAACAgCAAAACQMAAAAAAAAAAAAAABEDAAAAAAAAAAs=
</value>
</data>
</root>
\ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!