1

在 ZedGraph 窗格中,可以将 a 设置CurveItem为“已选择”。

zedGraphControl.GraphPane.CurveList[0].IsSelected = true;
zedGraphControl.Refresh();

这将改变它的颜色,Color.Gray就我所见。

是否可以更改此选定状态颜色?

4

2 回答 2

4

我不知道这样的属性,但您可以通过手动覆盖 ZedGraphControl 的 MouseClick 事件并设置“选定”CurveItem 的颜色来完成此操作,例如:

private void zedGraphControl1_MouseClick(object sender, MouseEventArgs e)
    {
        foreach (var curve in zedGraphControl1.GraphPane.CurveList)
        {
            curve.Color = Color.Black;
        }

        CurveItem nearestItem;
        int nearestPoint;
        zedGraphControl1.GraphPane.FindNearestPoint(e.Location, out nearestItem, out nearestPoint);
        if (nearestItem != null)
        {
            nearestItem.Color = Color.Red;
        }
        zedGraphControl1.Refresh();
    }

更新:查看http://www.opensourcejavaphp.net/csharp/zedgraph/Line.cs.htmlhttp://www.opensourcejavaphp.net/csharp/zedgraph/Selection.cs.html的源代码似乎Line.DrawCurve 使用静态属性 Selection.Line。如果不修改源,就很难改变这种行为。

Line.cs 的一部分:

public void DrawCurve( Graphics g, GraphPane pane, CurveItem curve, float scaleFactor )
{
    Line source = this;
    if ( curve.IsSelected )
        source = Selection.Line;

选择.cs:

/// The <see cref="Line" /> type to be used for drawing "selected"
/// <see cref="LineItem" /> and <see cref="StickItem" /> types
 /// </summary>
public static Line Line = new Line( Color.Gray );
于 2012-08-09T07:30:47.033 回答
0

选定的行是静态属性,但不是只读的。可以通过重置 Selection.Line 属性来更改格式:

public Form1()
{
   InitializeComponent();
   ZedGraph.Selection.Line.Width = 3;
   ZedGraph.Selection.Line.Color = Color.Red;
   ...
}

重置选择线后,所有选定的线将按指定绘制。

于 2017-03-21T14:38:19.547 回答