private void dt_Tick(object sender, EventArgs e)
{
if (a == 0 || a < 9)
{
a++;
Label1.Content = a.ToString();
}
else if (a >= 9 || a > 9)
{
a--;
Label1.Content = a.ToString();
}
}
答案 0 :(得分:2)
以下可以是样本:
private void ChartSample_Load(object sender, EventArgs e)
{
var listChartItems = new List<PointChart>();
listChartItems.Add(new PointChart { SeryName = "Seri 1",XValue = 2,YValue = 3});
listChartItems.Add(new PointChart { SeryName = "Seri 1",XValue = 3,YValue = 5});
listChartItems.Add(new PointChart { SeryName = "Seri 1",XValue = 4,YValue = 7});
listChartItems.Add(new PointChart { SeryName = "Seri 1",XValue = 5,YValue = 9});
listChartItems.Add(new PointChart { SeryName = "Seri 2", XValue = 1, YValue = 10 });
listChartItems.Add(new PointChart { SeryName = "Seri 2", XValue = 8, YValue = 11 });
listChartItems.Add(new PointChart { SeryName = "Seri 2", XValue = 4, YValue = 5});
listChartItems.Add(new PointChart { SeryName = "Seri 2", XValue = 6, YValue = 3 });
BindDataToChart(listChartItems);
}
答案 1 :(得分:1)
有很多方法可以使用: -
Queue<int> queue =
new Queue<int>(Enumerable.Range(1, 10).Concat(Enumerable.Range(2, 8).Reverse()));
private void dt_Tick(object sender, EventArgs e)
{
var a = queue.Dequeue();
Label1.Content = a.ToString();
queue.Enqueue(a);
}
答案 2 :(得分:0)
如果整体滴答计数很重要,或者需要连续函数......一种形式的三角波在0到1之间,周期为2,由
给出 Triangle wave range 0-1, period 2
(6)
(Trott 2004,p.228),其中nint(x)是最接近的整数函数。
即。
给出了范围在0到10之间,周期为20的三角波Triangle wave range 0-10, period 20
ticks++;
var a = 10 - 20 * Math.Abs(Math.Round(((ticks + 10) / 20) - ((ticks + 10) / 20));
对于任何间隔(相同):
ticks = ticks + 0.25;
var a = 10 - 20 * Math.Abs(Math.Round(((ticks + 10) / 20) - ((ticks + 10) / 20));
mathworld.wolfram.com/TriangleWave.html