在ZedGraph窗格上,可以將CurveItem
設置爲「已選中」。更改zedgraph選擇的曲線顏色
zedGraphControl.GraphPane.CurveList[0].IsSelected = true;
zedGraphControl.Refresh();
據我所知,這將改變它的顏色爲Color.Gray
。
是否可以更改此選定狀態顏色?
在ZedGraph窗格上,可以將CurveItem
設置爲「已選中」。更改zedgraph選擇的曲線顏色
zedGraphControl.GraphPane.CurveList[0].IsSelected = true;
zedGraphControl.Refresh();
據我所知,這將改變它的顏色爲Color.Gray
。
是否可以更改此選定狀態顏色?
我不知道這樣的屬性,但你可以通過手動重寫ZedGraphControl的鼠標點擊事件做到這一點,並設置「選擇」 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();
}
UPDATE:看看http://www.opensourcejavaphp.net/csharp/zedgraph/Line.cs.html和http://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;
Selection.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);
所選擇的線路靜態屬性,而不是隻讀的。可以通過重置Selection.Line屬性來更改格式:
public Form1()
{
InitializeComponent();
ZedGraph.Selection.Line.Width = 3;
ZedGraph.Selection.Line.Color = Color.Red;
...
}
重置選擇行後,所有選定的行將按指定繪製。
是的,謝謝,這就是我已經做的。後來我發現了IsSelected屬性,所以我想知道我是否可以使用它。 – Otiel 2012-08-09 07:35:14
請參閱更新。 – HischT 2012-08-10 11:35:17
因此,修改源代碼不會改變。我可以接受:) – Otiel 2012-08-10 12:07:33