Commit 37dc0035 HZH

新增分隔标签线

1 个父辈 b31801cb
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
namespace HZH_Controls.Controls
{
public class UCSplitLabel : Label
{
[Localizable(true)]
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
ResetMaxSize();
}
}
[Localizable(true)]
public override Font Font
{
get
{
return base.Font;
}
set
{
base.Font = value;
ResetMaxSize();
}
}
[Localizable(true)]
public override Size MinimumSize
{
get
{
return base.MinimumSize;
}
set
{
base.MinimumSize = value;
ResetMaxSize();
}
}
[Localizable(true)]
public override Size MaximumSize
{
get
{
return base.MaximumSize;
}
set
{
base.MaximumSize = value;
ResetMaxSize();
}
}
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public override bool AutoSize
{
get
{
return base.AutoSize;
}
set
{
base.AutoSize = value;
}
}
private Color lineColor = LineColors.Light;
public Color LineColor
{
get { return lineColor; }
set
{
lineColor = value;
Invalidate();
}
}
private void ResetMaxSize()
{
using (var g = this.CreateGraphics())
{
var _width = Width;
var size = g.MeasureString(string.IsNullOrEmpty(Text) ? "A" : Text, Font);
if (MinimumSize.Height != (int)size.Height)
MinimumSize = new Size(base.MinimumSize.Width, (int)size.Height);
if (MaximumSize.Height != (int)size.Height)
MaximumSize = new Size(base.MaximumSize.Width, (int)size.Height);
this.Width = _width;
}
}
public UCSplitLabel()
: base()
{
if (ControlHelper.IsDesignMode())
{
Text = "分割线";
Font = new Font("微软雅黑", 8f);
}
this.AutoSize = false;
Padding = new Padding(20, 0, 0, 0);
MinimumSize = new System.Drawing.Size(150, 10);
PaddingChanged += UCSplitLabel_PaddingChanged;
this.Width = 200;
}
void UCSplitLabel_PaddingChanged(object sender, EventArgs e)
{
if (Padding.Left < 20)
{
Padding = new Padding(20, Padding.Top, Padding.Right, Padding.Bottom);
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
var g = e.Graphics;
g.SetGDIHigh();
var size = g.MeasureString(Text, Font);
g.DrawLine(new Pen(new SolidBrush(lineColor)), new PointF(1, Padding.Top + (this.Height - Padding.Top - Padding.Bottom) / 2), new PointF(Padding.Left - 2, Padding.Top + (this.Height - Padding.Top - Padding.Bottom) / 2));
g.DrawLine(new Pen(new SolidBrush(lineColor)), new PointF(Padding.Left + size.Width + 1, Padding.Top + (this.Height - Padding.Top - Padding.Bottom) / 2), new PointF(Width - Padding.Right, Padding.Top + (this.Height - Padding.Top - Padding.Bottom) / 2));
}
}
}
...@@ -322,37 +322,24 @@ namespace HZH_Controls.Forms ...@@ -322,37 +322,24 @@ namespace HZH_Controls.Forms
FrmAnchorTips frm = new FrmAnchorTips(rectControl, strMsg, location, background, foreColor, fontSize, autoCloseTime); FrmAnchorTips frm = new FrmAnchorTips(rectControl, strMsg, location, background, foreColor, fontSize, autoCloseTime);
frm.TopMost = blnTopMost; frm.TopMost = blnTopMost;
frm.Show(parentControl); frm.Show(parentControl);
if (parentControl != null) //if (parentControl != null)
{ //{
parentControl.Disposed += (a, b) => // parentControl.VisibleChanged += (a, b) =>
{ // {
// try
}; // {
parentControl.VisibleChanged += (a, b) => // Control c = a as Control;
{ // if (CheckControlClose(c))
try // {
{ // frm.Close();
Control c = a as Control; // }
if (CheckControlClose(c)) // }
{ // catch (Exception ex)
frm.Close(); // {
}
} // }
catch (Exception ex) // };
{ //}
}
};
parentControl.ParentChanged += (a, b) =>
{
};
parentControl.HandleDestroyed += (a, b) =>
{
};
}
return frm; return frm;
} }
......
...@@ -104,6 +104,9 @@ ...@@ -104,6 +104,9 @@
<Compile Include="Controls\Shadow\ShadowComponent.cs"> <Compile Include="Controls\Shadow\ShadowComponent.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="Controls\SplitLabel\UCSplitLabel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\Verification\VerificationAttribute.cs" /> <Compile Include="Controls\Verification\VerificationAttribute.cs" />
<Compile Include="Controls\Verification\VerificationComponent.cs"> <Compile Include="Controls\Verification\VerificationComponent.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
......
...@@ -65,6 +65,7 @@ namespace Test ...@@ -65,6 +65,7 @@ namespace Test
tnControl.Nodes.Add("倒影"); tnControl.Nodes.Add("倒影");
tnControl.Nodes.Add("内置颜色"); tnControl.Nodes.Add("内置颜色");
tnControl.Nodes.Add("导航菜单"); tnControl.Nodes.Add("导航菜单");
tnControl.Nodes.Add("分割线标签");
this.tvMenu.Nodes.Add(tnControl); this.tvMenu.Nodes.Add(tnControl);
TreeNode tnCharts = new TreeNode(" 图表"); TreeNode tnCharts = new TreeNode(" 图表");
...@@ -99,6 +100,7 @@ namespace Test ...@@ -99,6 +100,7 @@ namespace Test
{ {
panControl.Controls.Clear(); panControl.Controls.Clear();
string strName = e.Node.Text.Trim(); string strName = e.Node.Text.Trim();
this.Title = "控件DEMO--" + strName;
switch (strName) switch (strName)
{ {
#region 窗体 English:forms #region 窗体 English:forms
...@@ -266,6 +268,9 @@ namespace Test ...@@ -266,6 +268,9 @@ namespace Test
case "导航菜单": case "导航菜单":
AddControl(new UC.UCTestNavigationMenu()); AddControl(new UC.UCTestNavigationMenu());
break; break;
case "分割线标签":
AddControl(new UC.UCTestSplitLabel());
break;
#endregion #endregion
#region 图表 English:Chart #region 图表 English:Chart
......
...@@ -278,6 +278,12 @@ ...@@ -278,6 +278,12 @@
<Compile Include="UC\UCTestSignalLamp.Designer.cs"> <Compile Include="UC\UCTestSignalLamp.Designer.cs">
<DependentUpon>UCTestSignalLamp.cs</DependentUpon> <DependentUpon>UCTestSignalLamp.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="UC\UCTestSplitLabel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UC\UCTestSplitLabel.Designer.cs">
<DependentUpon>UCTestSplitLabel.cs</DependentUpon>
</Compile>
<Compile Include="UC\UCTestStep.cs"> <Compile Include="UC\UCTestStep.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
...@@ -467,6 +473,9 @@ ...@@ -467,6 +473,9 @@
<EmbeddedResource Include="UC\UCTestSignalLamp.resx"> <EmbeddedResource Include="UC\UCTestSignalLamp.resx">
<DependentUpon>UCTestSignalLamp.cs</DependentUpon> <DependentUpon>UCTestSignalLamp.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="UC\UCTestSplitLabel.resx">
<DependentUpon>UCTestSplitLabel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UC\UCTestStep.resx"> <EmbeddedResource Include="UC\UCTestStep.resx">
<DependentUpon>UCTestStep.cs</DependentUpon> <DependentUpon>UCTestStep.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
namespace Test.UC
{
partial class UCTestSplitLabel
{
/// <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.ucSplitLabel8 = new HZH_Controls.Controls.UCSplitLabel();
this.ucSplitLabel4 = new HZH_Controls.Controls.UCSplitLabel();
this.ucSplitLabel7 = new HZH_Controls.Controls.UCSplitLabel();
this.ucSplitLabel3 = new HZH_Controls.Controls.UCSplitLabel();
this.ucSplitLabel6 = new HZH_Controls.Controls.UCSplitLabel();
this.ucSplitLabel2 = new HZH_Controls.Controls.UCSplitLabel();
this.ucSplitLabel5 = new HZH_Controls.Controls.UCSplitLabel();
this.ucSplitLabel1 = new HZH_Controls.Controls.UCSplitLabel();
this.SuspendLayout();
//
// ucSplitLabel8
//
this.ucSplitLabel8.Font = new System.Drawing.Font("微软雅黑", 22F);
this.ucSplitLabel8.LineColor = System.Drawing.Color.Blue;
this.ucSplitLabel8.Location = new System.Drawing.Point(18, 305);
this.ucSplitLabel8.MaximumSize = new System.Drawing.Size(0, 42);
this.ucSplitLabel8.MinimumSize = new System.Drawing.Size(150, 42);
this.ucSplitLabel8.Name = "ucSplitLabel8";
this.ucSplitLabel8.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0);
this.ucSplitLabel8.Size = new System.Drawing.Size(465, 42);
this.ucSplitLabel8.TabIndex = 0;
this.ucSplitLabel8.Text = "22号大小";
//
// ucSplitLabel4
//
this.ucSplitLabel4.Font = new System.Drawing.Font("微软雅黑", 8F);
this.ucSplitLabel4.LineColor = System.Drawing.Color.Blue;
this.ucSplitLabel4.Location = new System.Drawing.Point(18, 145);
this.ucSplitLabel4.MaximumSize = new System.Drawing.Size(0, 15);
this.ucSplitLabel4.MinimumSize = new System.Drawing.Size(150, 15);
this.ucSplitLabel4.Name = "ucSplitLabel4";
this.ucSplitLabel4.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0);
this.ucSplitLabel4.Size = new System.Drawing.Size(465, 15);
this.ucSplitLabel4.TabIndex = 0;
this.ucSplitLabel4.Text = "颜色分隔";
//
// ucSplitLabel7
//
this.ucSplitLabel7.Font = new System.Drawing.Font("微软雅黑", 18F);
this.ucSplitLabel7.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
this.ucSplitLabel7.Location = new System.Drawing.Point(18, 264);
this.ucSplitLabel7.MaximumSize = new System.Drawing.Size(0, 34);
this.ucSplitLabel7.MinimumSize = new System.Drawing.Size(150, 34);
this.ucSplitLabel7.Name = "ucSplitLabel7";
this.ucSplitLabel7.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0);
this.ucSplitLabel7.Size = new System.Drawing.Size(465, 34);
this.ucSplitLabel7.TabIndex = 0;
this.ucSplitLabel7.Text = "18号大小";
//
// ucSplitLabel3
//
this.ucSplitLabel3.Font = new System.Drawing.Font("微软雅黑", 8F);
this.ucSplitLabel3.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
this.ucSplitLabel3.Location = new System.Drawing.Point(18, 104);
this.ucSplitLabel3.MaximumSize = new System.Drawing.Size(0, 15);
this.ucSplitLabel3.MinimumSize = new System.Drawing.Size(150, 15);
this.ucSplitLabel3.Name = "ucSplitLabel3";
this.ucSplitLabel3.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0);
this.ucSplitLabel3.Size = new System.Drawing.Size(465, 15);
this.ucSplitLabel3.TabIndex = 0;
this.ucSplitLabel3.Text = "绿色分隔";
//
// ucSplitLabel6
//
this.ucSplitLabel6.Font = new System.Drawing.Font("微软雅黑", 12F);
this.ucSplitLabel6.LineColor = System.Drawing.Color.Red;
this.ucSplitLabel6.Location = new System.Drawing.Point(20, 223);
this.ucSplitLabel6.MaximumSize = new System.Drawing.Size(0, 23);
this.ucSplitLabel6.MinimumSize = new System.Drawing.Size(0, 23);
this.ucSplitLabel6.Name = "ucSplitLabel6";
this.ucSplitLabel6.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0);
this.ucSplitLabel6.Size = new System.Drawing.Size(463, 23);
this.ucSplitLabel6.TabIndex = 0;
this.ucSplitLabel6.Text = "12号大小";
//
// ucSplitLabel2
//
this.ucSplitLabel2.Font = new System.Drawing.Font("微软雅黑", 8F);
this.ucSplitLabel2.LineColor = System.Drawing.Color.Red;
this.ucSplitLabel2.Location = new System.Drawing.Point(18, 63);
this.ucSplitLabel2.MaximumSize = new System.Drawing.Size(0, 15);
this.ucSplitLabel2.MinimumSize = new System.Drawing.Size(0, 15);
this.ucSplitLabel2.Name = "ucSplitLabel2";
this.ucSplitLabel2.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0);
this.ucSplitLabel2.Size = new System.Drawing.Size(465, 15);
this.ucSplitLabel2.TabIndex = 0;
this.ucSplitLabel2.Text = "红色分隔";
//
// ucSplitLabel5
//
this.ucSplitLabel5.Font = new System.Drawing.Font("微软雅黑", 8F);
this.ucSplitLabel5.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(238)))), ((int)(((byte)(245)))));
this.ucSplitLabel5.Location = new System.Drawing.Point(18, 182);
this.ucSplitLabel5.MaximumSize = new System.Drawing.Size(0, 15);
this.ucSplitLabel5.MinimumSize = new System.Drawing.Size(0, 15);
this.ucSplitLabel5.Name = "ucSplitLabel5";
this.ucSplitLabel5.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0);
this.ucSplitLabel5.Size = new System.Drawing.Size(465, 15);
this.ucSplitLabel5.TabIndex = 0;
this.ucSplitLabel5.Text = "默认大小";
//
// ucSplitLabel1
//
this.ucSplitLabel1.Font = new System.Drawing.Font("微软雅黑", 8F);
this.ucSplitLabel1.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(238)))), ((int)(((byte)(245)))));
this.ucSplitLabel1.Location = new System.Drawing.Point(18, 22);
this.ucSplitLabel1.MaximumSize = new System.Drawing.Size(0, 15);
this.ucSplitLabel1.MinimumSize = new System.Drawing.Size(0, 15);
this.ucSplitLabel1.Name = "ucSplitLabel1";
this.ucSplitLabel1.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0);
this.ucSplitLabel1.Size = new System.Drawing.Size(465, 15);
this.ucSplitLabel1.TabIndex = 0;
this.ucSplitLabel1.Text = "默认颜色";
//
// UCTestSplitLabel
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.Controls.Add(this.ucSplitLabel8);
this.Controls.Add(this.ucSplitLabel4);
this.Controls.Add(this.ucSplitLabel7);
this.Controls.Add(this.ucSplitLabel3);
this.Controls.Add(this.ucSplitLabel6);
this.Controls.Add(this.ucSplitLabel2);
this.Controls.Add(this.ucSplitLabel5);
this.Controls.Add(this.ucSplitLabel1);
this.Name = "UCTestSplitLabel";
this.Size = new System.Drawing.Size(814, 426);
this.ResumeLayout(false);
}
#endregion
private HZH_Controls.Controls.UCSplitLabel ucSplitLabel1;
private HZH_Controls.Controls.UCSplitLabel ucSplitLabel2;
private HZH_Controls.Controls.UCSplitLabel ucSplitLabel3;
private HZH_Controls.Controls.UCSplitLabel ucSplitLabel4;
private HZH_Controls.Controls.UCSplitLabel ucSplitLabel5;
private HZH_Controls.Controls.UCSplitLabel ucSplitLabel6;
private HZH_Controls.Controls.UCSplitLabel ucSplitLabel7;
private HZH_Controls.Controls.UCSplitLabel ucSplitLabel8;
}
}
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 Test.UC
{
public partial class UCTestSplitLabel : UserControl
{
public UCTestSplitLabel()
{
InitializeComponent();
}
}
}
<?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 \ No newline at end of file
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!