0

Fastline シリーズと ColorBand ツールを備えた TChart コンポーネントがあります。フォームには、タイマーを開始するボタンもあります。タイマー経過イベントごとに、2048 サンプルのランダム データを生成し、Fasline シリーズを更新します。タイマーを開始すると、TChart にアニメーションが表示されません。ただし、ランダムに機能するようです...そして、フォームを非表示にして表示すると(最小化/最大化、またはtChart1.Hide()/ tChart1.Show()によって)、アニメーションが再び機能し始めます。タイマーを開始する前に ColorBand ラインの 1 つをドラッグすると、アニメーションが機能します。しかし、最初にタイマーを開始するとアニメーションが機能しません。さらに、動作しない場合、TChart はフリーズしているように見えます。つまり、パンやズームなどのマウス コマンドに応答しません。ここにいくつかのコードがあります:

私のform.designer.csでは:

partial class Form1
{
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows Form Designer generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.button1 = new System.Windows.Forms.Button();
        this.tChart1 = new Steema.TeeChart.TChart();
        this.checkBox1 = new System.Windows.Forms.CheckBox();
        this.SuspendLayout();
        // 
        // button1
        // 
        this.button1.BackColor = System.Drawing.SystemColors.Control;
        this.button1.Location = new System.Drawing.Point(12, 12);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(60, 23);
        this.button1.TabIndex = 1;
        this.button1.Text = "Start";
        this.button1.UseVisualStyleBackColor = false;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // tChart1
        // 
        // 
        // 
        // 
        // 
        // 
        // 
        this.tChart1.Axes.Depth.LabelsAsSeriesTitles = true;
        // 
        // 
        // 
        this.tChart1.Axes.DepthTop.LabelsAsSeriesTitles = true;
        this.tChart1.Location = new System.Drawing.Point(12, 41);
        this.tChart1.Name = "tChart1";
        this.tChart1.Size = new System.Drawing.Size(789, 318);
        this.tChart1.TabIndex = 2;
        // 
        // checkBox1
        // 
        this.checkBox1.AutoSize = true;
        this.checkBox1.Location = new System.Drawing.Point(78, 16);
        this.checkBox1.Name = "checkBox1";
        this.checkBox1.Size = new System.Drawing.Size(49, 17);
        this.checkBox1.TabIndex = 3;
        this.checkBox1.Text = "Drag";
        this.checkBox1.UseVisualStyleBackColor = true;
        this.checkBox1.Click += new System.EventHandler(this.checkBox1_Click);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(823, 371);
        this.Controls.Add(this.checkBox1);
        this.Controls.Add(this.tChart1);
        this.Controls.Add(this.button1);
        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
        this.Name = "Form1";
        this.Text = "Form1";
        this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
        this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    #endregion

    private System.Windows.Forms.Button button1;
    private Steema.TeeChart.TChart tChart1;
    private System.Windows.Forms.CheckBox checkBox1;
}

そして、私のform.csで:

public partial class Form1 : Form
{
    System.Timers.Timer timer;
    private Steema.TeeChart.Tools.ColorBand tool;
    Steema.TeeChart.Styles.FastLine primaryLine;
    double w = 0;
    bool enabled = false;

    public Form1()
    {
        InitializeComponent();
        initPrimaryGraph();
        initTool();

        timer = new System.Timers.Timer();
        timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
        timer.Interval = 50;
        timer.Stop();
    }

    private void timer_Elapsed(object sender, ElapsedEventArgs e)
    {
        Random rnd = new Random();
        for (int i = 0; i < 2048; i++)
        {
            primaryLine.XValues[i] = i;
            primaryLine.YValues[i] = 20 + rnd.Next(50);
        }
        primaryLine.BeginUpdate();
        primaryLine.EndUpdate();
    }

    private void initTool()
    {
        tool = new Steema.TeeChart.Tools.ColorBand();
        tChart1.Tools.Add(tool);
        tool.Axis = tChart1.Axes.Bottom;
        tool.Start = 300;
        tool.End = 400;
        tool.Brush.Color = Color.Yellow;
        tool.Pen.Color = Color.Blue;
        tool.Pen.Width = 2;
        tool.Transparency = 60;

        tool.StartLine.AllowDrag = true;
        tool.StartLine.DragRepaint = true;
        tool.ResizeStart = true;
        tool.StartLine.DragLine += new EventHandler(StartLine_DragLine);

        tool.EndLine.AllowDrag = true;
        tool.EndLine.DragRepaint = true;
        tool.ResizeEnd = true;
        tool.EndLine.DragLine += new EventHandler(EndLine_DragLine);
    }

    void StartLine_DragLine(object sender, EventArgs e)
    {
        if (enabled)
        {
            tool.End = tool.Start + w;
        }
    }

    void EndLine_DragLine(object sender, EventArgs e)
    {
        if (enabled)
        {
            tool.Start = tool.End - w;
        }
    }

    private void initPrimaryGraph()
    {
        tChart1.Header.Visible = true;

        tChart1.Axes.Bottom.Automatic = false;
        tChart1.Axes.Bottom.Minimum = 0;
        tChart1.Axes.Bottom.Maximum = 2048;
        tChart1.Axes.Bottom.Labels.Font.Color = Color.White;
        tChart1.Axes.Bottom.Grid.Visible = false;

        tChart1.Axes.Left.Automatic = false;
        tChart1.Axes.Left.Minimum = 0;
        tChart1.Axes.Left.Maximum = 300;
        tChart1.Axes.Left.Labels.Font.Color = Color.White;

        tChart1.Aspect.View3D = false;

        tChart1.Walls.Back.Visible = false;
        tChart1.Walls.Bottom.Visible = false;
        tChart1.Walls.Left.Visible = false;
        tChart1.Walls.Right.Visible = false;

        tChart1.Legend.Visible = false;
        tChart1.BackColor = Color.Black;
        tChart1.Panel.Visible = false;

        //PRIMARY GRAPH.....
        primaryLine = new Steema.TeeChart.Styles.FastLine();
        tChart1.Series.Add(primaryLine);
        Random rnd = new Random();
        for (int i = 0; i < 2048; i++)
        {
            double x = i;
            double y = 20 + rnd.Next(50);
            primaryLine.Add(x, y);
        }
        primaryLine.LinePen.Style = System.Drawing.Drawing2D.DashStyle.Solid;
        primaryLine.LinePen.Color = Color.White;
        primaryLine.LinePen.Width = 1;
        primaryLine.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left;
    }

    private void tool_DragLine(object sender, EventArgs e)
    {
        Steema.TeeChart.Tools.ColorLine t = sender as Steema.TeeChart.Tools.ColorLine;
        this.Text = t.Value.ToString();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if (timer.Enabled)
        {
            timer.Stop();
            button1.Text = "Start";
        }
        else
        {
            timer.Start();
            button1.Text = "Stop";
        }
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        timer.Stop();
    }

    private void checkBox1_Click(object sender, EventArgs e)
    {
        if (checkBox1.Checked)
        {
            w = tool.End - tool.Start;
        }
        enabled = checkBox1.Checked;
    }
}

別の質問があります。特定の機能を公開するカスタム API (カスタム ユーザー コントロール) を記述して、TeeChart コンポーネントのブラック ボックス実装を作成し、それを他のプロジェクトで使用できるようにしたいと考えています。プロジェクトで使用します。さまざまなプロジェクト/コンピューターで使用できるカスタム コンポーネント/dll に TeeChart 機能をラップできるようにするために、TeeChart のどのバージョン/ライセンスを購入すればよいですか?

前もって感謝します :-)

4

1 に答える 1

0

Fastline シリーズと ColorBand ツールを備えた TChart コンポーネントがあります。フォームには、タイマーを開始するボタンもあります。タイマー経過イベントごとに、2048 サンプルのランダム データを生成し、Fasline シリーズを更新します。タイマーを開始すると、TChart にアニメーションが表示されません。ただし、ランダムに機能するようです...そして、フォームを非表示にして表示すると(最小化/最大化、またはtChart1.Hide()/ tChart1.Show()によって)、アニメーションが再び機能し始めます。タイマーを開始する前に ColorBand ラインの 1 つをドラッグすると、アニメーションが機能します。しかし、最初にタイマーを開始するとアニメーションが機能しません。さらに、動作しない場合、TChart はフリーズしているように見えます。つまり、パンやズームなどのマウス コマンドに応答しません。ここにいくつかのコードがあります:

私はあなたのコードを少し変更しましたが、今では私の最後で動作します。次を参照してください。

 Timer timer;
    private Steema.TeeChart.Tools.ColorBand tool;
    Steema.TeeChart.Styles.FastLine primaryLine;
    double w = 0;
    bool enabled = false;

    public Form1()
    {
        InitializeComponent();
        initPrimaryGraph();
        initTool();

        timer = new Timer();
        //Enable Timer
        timer.Enabled = true;
        timer.Interval = 50;
        timer.Tick += timer_Tick;
    }

    void timer_Tick(object sender, EventArgs e)
    {

        AnimateSeries(tChart1);
    }

    private void AnimateSeries(TChart tChart)
    {
        Random rnd = new Random();
        tChart.AutoRepaint = false;
        primaryLine.BeginUpdate();
        foreach (Steema.TeeChart.Styles.Series s in tChart.Series)
        {         
            for (int i = 0; i < 2048; i++)
            {
                primaryLine.XValues[i] = i;
                primaryLine.YValues[i] = 20 + rnd.Next(50);
            }

        }

        tChart.AutoRepaint = true;
        primaryLine.EndUpdate();
    }
    private void initTool()
    {
        tool = new Steema.TeeChart.Tools.ColorBand();
        tChart1.Tools.Add(tool);
        tool.Axis = tChart1.Axes.Bottom;
        tool.Start = 300;
        tool.End = 400;
        tool.Brush.Color = Color.Yellow;
        tool.Pen.Color = Color.Blue;
        tool.Pen.Width = 2;
        tool.Transparency = 60;

        tool.StartLine.AllowDrag = true;
        tool.StartLine.DragRepaint = true;
        tool.ResizeStart = true;
        tool.StartLine.DragLine += new EventHandler(StartLine_DragLine);

        tool.EndLine.AllowDrag = true;
        tool.EndLine.DragRepaint = true;
        tool.ResizeEnd = true;
        tool.EndLine.DragLine += new EventHandler(EndLine_DragLine);
    }

    void StartLine_DragLine(object sender, EventArgs e)
    {
        if (enabled)
        {
            tool.End = tool.Start + w;
        }
    }

    void EndLine_DragLine(object sender, EventArgs e)
    {
        if (enabled)
        {
            tool.Start = tool.End - w;
        }
    }

    private void initPrimaryGraph()
    {
        tChart1.Header.Visible = true;
        tChart1.Aspect.View3D = false;

        tChart1.Walls.Back.Visible = false;
        tChart1.Walls.Bottom.Visible = false;
        tChart1.Walls.Left.Visible = false;
        tChart1.Walls.Right.Visible = false;

        tChart1.Legend.Visible = false;
        tChart1.BackColor = Color.Black;
        tChart1.Panel.Visible = false;

        //PRIMARY GRAPH.....
        primaryLine = new Steema.TeeChart.Styles.FastLine();
        tChart1.Series.Add(primaryLine);
        Random rnd = new Random();
        for (int i = 0; i < 2048; i++)
        {
            double x = i;
            double y = 20 + rnd.Next(50);
            primaryLine.Add(x, y);
        }
        primaryLine.LinePen.Style = System.Drawing.Drawing2D.DashStyle.Solid;
        primaryLine.LinePen.Color = Color.White;
        primaryLine.LinePen.Width = 1;
        //AXES
        tChart1.Axes.Bottom.Automatic = false;
        tChart1.Axes.Bottom.Minimum = primaryLine.XValues.Minimum;
        tChart1.Axes.Bottom.Maximum = primaryLine.XValues.Maximum;
        tChart1.Axes.Bottom.Increment = 200; 
        tChart1.Axes.Bottom.Labels.Font.Color = Color.White;
        tChart1.Axes.Bottom.Grid.Visible = false;
        tChart1.Axes.Left.Automatic = false;
        tChart1.Axes.Left.Minimum = 0;
        tChart1.Axes.Left.Maximum = 300;

        tChart1.Axes.Left.Labels.Font.Color = Color.White;
        primaryLine.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left;
        tChart1.Draw();
    }

    private void tool_DragLine(object sender, EventArgs e)
    {
        Steema.TeeChart.Tools.ColorLine t = sender as Steema.TeeChart.Tools.ColorLine;
        this.Text = t.Value.ToString();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if (timer.Enabled)
        {
            timer.Stop();
            button1.Text = "Start";
        }
        else
        {
            timer.Start();
            button1.Text = "Stop";
        }
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        timer.Stop();
    }

コードでわかるように、Timer のタイプを変更して、他の方が適切だと考えています。以前のコードが期待どおりに機能するかどうか教えていただけますか?

別の質問があります。特定の機能を公開するカスタム API (カスタム ユーザー コントロール) を記述して、TeeChart コンポーネントのブラック ボックス実装を作成し、それを他のプロジェクトで使用できるようにしたいと考えています。プロジェクトで使用します。TeeChart のどのバージョン/ライセンスを購入すれば、さまざまなプロジェクト/コンピューターで使用できるカスタム コンポーネント/dll に TeeChart 機能をラップできますか?

TeeChart は、teeChart の特定の特性を発行する別のデザインタイム アセンブリ (dll) によって再利用される場合があります。ただし、設計時にティー コンポーネントを再利用するマシンは、TeeChart Developer ライセンスもインストールする必要があります。

役立つことを願っています。

ありがとう、

于 2013-06-04T12:11:12.083 に答える