本文整理汇总了C#中LinearAxis.InverseTransform方法的典型用法代码示例。如果您正苦于以下问题:C# LinearAxis.InverseTransform方法的具体用法?C# LinearAxis.InverseTransform怎么用?C# LinearAxis.InverseTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinearAxis
的用法示例。
在下文中一共展示了LinearAxis.InverseTransform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MouseEvents
public static PlotModel MouseEvents()
{
var model = new PlotModel { Title = "Mouse events", Subtitle = "Left click and drag" };
var yaxis = new LinearAxis { Position = AxisPosition.Left, Minimum = -1, Maximum = 1 };
var xaxis = new LinearAxis { Position = AxisPosition.Bottom, Minimum = -1, Maximum = 1 };
model.Axes.Add(yaxis);
model.Axes.Add(xaxis);
LineSeries s1 = null;
// Subscribe to the mouse down event on the line series
model.MouseDown += (s, e) =>
{
// only handle the left mouse button (right button can still be used to pan)
if (e.ChangedButton == OxyMouseButton.Left)
{
// Add a line series
s1 = new LineSeries
{
Title = "LineSeries" + (model.Series.Count + 1),
MarkerType = MarkerType.None,
StrokeThickness = 2
};
s1.Points.Add(xaxis.InverseTransform(e.Position.X, e.Position.Y, yaxis));
model.Series.Add(s1);
model.InvalidatePlot(false);
e.Handled = true;
}
};
model.MouseMove += (s, e) =>
{
if (s1 != null)
{
s1.Points.Add(xaxis.InverseTransform(e.Position.X, e.Position.Y, yaxis));
model.InvalidatePlot(false);
e.Handled = true;
}
};
model.MouseUp += (s, e) =>
{
if (s1 != null)
{
s1 = null;
e.Handled = true;
}
};
return model;
}
示例2: AddAnnotations
public static PlotModel AddAnnotations()
{
var model = new PlotModel { Title = "Add arrow annotations", Subtitle = "Press and drag the left mouse button" };
var xaxis = new LinearAxis { Position = AxisPosition.Bottom };
var yaxis = new LinearAxis { Position = AxisPosition.Left };
model.Axes.Add(xaxis);
model.Axes.Add(yaxis);
model.Series.Add(new FunctionSeries(x => Math.Sin(x / 4) * Math.Acos(Math.Sin(x)), 0, Math.PI * 8, 2000, "sin(x/4)*acos(sin(x))"));
ArrowAnnotation tmp = null;
// Add handlers to the PlotModel's mouse events
model.MouseDown += (s, e) =>
{
if (e.ChangedButton == OxyMouseButton.Left)
{
// Create a new arrow annotation
tmp = new ArrowAnnotation();
tmp.StartPoint = tmp.EndPoint = xaxis.InverseTransform(e.Position.X, e.Position.Y, yaxis);
model.Annotations.Add(tmp);
e.Handled = true;
}
};
// Handle mouse movements (note: this is only called when the mousedown event was handled)
model.MouseMove += (s, e) =>
{
if (tmp != null)
{
// Modify the end point
tmp.EndPoint = xaxis.InverseTransform(e.Position.X, e.Position.Y, yaxis);
tmp.Text = string.Format("Y = {0:0.###}", tmp.EndPoint.Y);
// Redraw the plot
model.InvalidatePlot(false);
e.Handled = true;
}
};
model.MouseUp += (s, e) =>
{
if (tmp != null)
{
tmp = null;
e.Handled = true;
}
};
return model;
}