Commit a383feea 冰封一夏 Gitee 提交于

!11 修改ucRollText控件添加改变文本是否重置位置

修改ucRollText控件添加改变文本是否重置位置
2 个父辈 856be76e 541e7118
...@@ -14,13 +14,9 @@ ...@@ -14,13 +14,9 @@
// If you use this code, please keep this note. // If you use this code, please keep this note.
// *********************************************************************** // ***********************************************************************
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace HZH_Controls.Controls namespace HZH_Controls.Controls
{ {
...@@ -100,7 +96,8 @@ namespace HZH_Controls.Controls ...@@ -100,7 +96,8 @@ namespace HZH_Controls.Controls
{ {
Graphics g = this.CreateGraphics(); Graphics g = this.CreateGraphics();
var size = g.MeasureString(value, this.Font); var size = g.MeasureString(value, this.Font);
rectText = new Rectangle(0, (this.Height - rectText.Height) / 2 + 1, (int)size.Width, (int)size.Height); rectText = new Rectangle(_ISChangeReset ? 0 : rectText.X, (this.Height - rectText.Height) / 2 + 1, (int)size.Width, (int)size.Height);
} }
else else
{ {
...@@ -115,6 +112,14 @@ namespace HZH_Controls.Controls ...@@ -115,6 +112,14 @@ namespace HZH_Controls.Controls
private RollStyle _RollStyle = RollStyle.LeftToRight; private RollStyle _RollStyle = RollStyle.LeftToRight;
/// <summary> /// <summary>
/// 文本改变是否重新从边缘运动
/// </summary>
private bool _ISChangeReset = false;
/// <summary>
/// Gets or sets the roll style. /// Gets or sets the roll style.
/// </summary> /// </summary>
/// <value>The roll style.</value> /// <value>The roll style.</value>
...@@ -137,6 +142,20 @@ namespace HZH_Controls.Controls ...@@ -137,6 +142,20 @@ namespace HZH_Controls.Controls
} }
} }
[Description("文本改变是否重新从边缘运动"), Category("自定义")]
public bool ISChangeReset
{
get { return _ISChangeReset; }
set
{
_ISChangeReset = value;
}
}
/// <summary> /// <summary>
/// The move step /// The move step
/// </summary> /// </summary>
...@@ -158,7 +177,9 @@ namespace HZH_Controls.Controls ...@@ -158,7 +177,9 @@ namespace HZH_Controls.Controls
set set
{ {
if (value <= 0) if (value <= 0)
{
return; return;
}
_moveSleepTime = value; _moveSleepTime = value;
m_timer.Interval = value; m_timer.Interval = value;
...@@ -213,7 +234,10 @@ namespace HZH_Controls.Controls ...@@ -213,7 +234,10 @@ namespace HZH_Controls.Controls
void m_timer_Tick(object sender, EventArgs e) void m_timer_Tick(object sender, EventArgs e)
{ {
if (rectText == Rectangle.Empty) if (rectText == Rectangle.Empty)
{
return; return;
}
if (_RollStyle == HZH_Controls.Controls.RollStyle.BackAndForth && rectText.Width >= this.Width) if (_RollStyle == HZH_Controls.Controls.RollStyle.BackAndForth && rectText.Width >= this.Width)
{ {
return; return;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!