本文整理匯總了C#中OxyPlot.PlotModel.RefreshPlot方法的典型用法代碼示例。如果您正苦於以下問題:C# PlotModel.RefreshPlot方法的具體用法?C# PlotModel.RefreshPlot怎麽用?C# PlotModel.RefreshPlot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OxyPlot.PlotModel
的用法示例。
在下文中一共展示了PlotModel.RefreshPlot方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: MouseEvents
public static PlotModel MouseEvents()
{
var model = new PlotModel("Mouse events", "Left click and drag");
var yaxis = new LinearAxis(AxisPosition.Left, -1, 1);
var xaxis = new LinearAxis(AxisPosition.Bottom, -1, 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("LineSeries" + (model.Series.Count + 1))
{
// Color = OxyColors.SkyBlue,
MarkerType = MarkerType.None,
StrokeThickness = 2
};
s1.Points.Add(Axis.InverseTransform(e.Position, xaxis, yaxis));
model.Series.Add(s1);
model.RefreshPlot(false);
e.Handled = true;
}
};
model.MouseMove += (s, e) =>
{
if (s1 != null)
{
s1.Points.Add(Axis.InverseTransform(e.Position, xaxis, yaxis));
model.RefreshPlot(false);
e.Handled = true;
}
};
model.MouseUp += (s, e) =>
{
if (s1 != null)
{
s1 = null;
e.Handled = true;
}
};
return model;
}
示例2: Window4
public Window4()
{
InitializeComponent();
this.PlotModel = new PlotModel();
this.PlotModel.Series.Add(new FunctionSeries());
DataContext = this;
var worker = new BackgroundWorker { WorkerSupportsCancellation = true };
double x = 0;
worker.DoWork += (s, e) =>
{
while (!worker.CancellationPending)
{
PlotModel.Title = "Plot updated: " + DateTime.Now;
this.PlotModel.Series[0] = new FunctionSeries(Math.Sin, x, x + 4, 0.01);
x += 0.1;
PlotModel.RefreshPlot(true);
Thread.Sleep(100);
}
};
worker.RunWorkerAsync();
this.Closed += (s, e) => worker.CancelAsync();
}
示例3: MouseDownEvent
public static PlotModel MouseDownEvent()
{
var model = new PlotModel("MouseDown", "Left click to edit or add points.") { LegendSymbolLength = 40 };
// Add a line series
var s1 = new LineSeries("LineSeries1")
{
Color = OxyColors.SkyBlue,
MarkerType = MarkerType.Circle,
MarkerSize = 6,
MarkerStroke = OxyColors.White,
MarkerFill = OxyColors.SkyBlue,
MarkerStrokeThickness = 1.5
};
s1.Points.Add(new DataPoint(0, 10));
s1.Points.Add(new DataPoint(10, 40));
s1.Points.Add(new DataPoint(40, 20));
s1.Points.Add(new DataPoint(60, 30));
model.Series.Add(s1);
int indexOfPointToMove = -1;
// Subscribe to the mouse down event on the line series
s1.MouseDown += (s, e) =>
{
// only handle the left mouse button (right button can still be used to pan)
if (e.ChangedButton == OxyMouseButton.Left)
{
int indexOfNearestPoint = (int)Math.Round(e.HitTestResult.Index);
var nearestPoint = s1.Transform(s1.Points[indexOfNearestPoint]);
// Check if we are near a point
if ((nearestPoint - e.Position).Length < 10)
{
// Start editing this point
indexOfPointToMove = indexOfNearestPoint;
}
else
{
// otherwise create a point on the current line segment
int i = (int)e.HitTestResult.Index + 1;
s1.Points.Insert(i, s1.InverseTransform(e.Position));
indexOfPointToMove = i;
}
// Change the linestyle while editing
s1.LineStyle = LineStyle.DashDot;
// Remember to refresh/invalidate of the plot
model.RefreshPlot(false);
// Set the event arguments to handled - no other handlers will be called.
e.Handled = true;
}
};
s1.MouseMove += (s, e) =>
{
if (indexOfPointToMove >= 0)
{
// Move the point being edited.
s1.Points[indexOfPointToMove] = s1.InverseTransform(e.Position);
model.RefreshPlot(false);
e.Handled = true;
}
};
s1.MouseUp += (s, e) =>
{
// Stop editing
indexOfPointToMove = -1;
s1.LineStyle = LineStyle.Solid;
model.RefreshPlot(false);
e.Handled = true;
};
model.MouseDown += (s, e) =>
{
if (e.ChangedButton == OxyMouseButton.Left)
{
// Add a point to the line series.
s1.Points.Add(s1.InverseTransform(e.Position));
indexOfPointToMove = s1.Points.Count - 1;
model.RefreshPlot(false);
e.Handled = true;
}
};
return model;
}
示例4: SelectRange
public static PlotModel SelectRange()
{
var model = new PlotModel("Select range", "Left click and drag to select a range.");
model.Series.Add(new FunctionSeries(Math.Cos, 0, 40, 0.1));
RectangleAnnotation range = null;
double startx = double.NaN;
model.MouseDown += (s, e) =>
{
if (e.ChangedButton == OxyMouseButton.Left)
{
if (range == null)
{
// Create and add the annotation to the plot
range = new RectangleAnnotation { Fill = OxyColors.SkyBlue.ChangeAlpha(120) };
model.Annotations.Add(range);
model.RefreshPlot(true);
}
startx = range.InverseTransform(e.Position).X;
range.MinimumX = startx;
range.MaximumX = startx;
model.RefreshPlot(true);
e.Handled = true;
}
};
model.MouseMove += (s, e) =>
{
if (e.ChangedButton == OxyMouseButton.Left && !double.IsNaN(startx))
{
var x = range.InverseTransform(e.Position).X;
range.MinimumX = Math.Min(x, startx);
range.MaximumX = Math.Max(x, startx);
range.Text = string.Format("∫ cos(x) dx = {0:0.00}", Math.Sin(range.MaximumX) - Math.Sin(range.MinimumX));
model.Subtitle = string.Format("Integrating from {0:0.00} to {1:0.00}", range.MinimumX, range.MaximumX);
model.RefreshPlot(true);
e.Handled = true;
}
};
model.MouseUp += (s, e) =>
{
startx = double.NaN;
};
return model;
}
示例5: AddSeriesByMouseDownEvent
public static PlotModel AddSeriesByMouseDownEvent()
{
var model = new PlotModel("MouseDown", "Left click to add series.") { LegendSymbolLength = 40 };
model.MouseDown += (s, e) =>
{
if (e.ChangedButton == OxyMouseButton.Left)
{
double a = model.Series.Count + 1;
model.Series.Add(new FunctionSeries(x => Math.Sin(a * x), 0, 10, 1000));
model.RefreshPlot(true);
e.Handled = true;
}
};
return model;
}
示例6: AddAnnotations
public static PlotModel AddAnnotations()
{
var model = new PlotModel("Add arrow annotations", "Press and drag the left mouse button");
var xaxis = new LinearAxis(AxisPosition.Bottom);
var yaxis = new LinearAxis(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 = Axis.InverseTransform(e.Position, xaxis, 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 = Axis.InverseTransform(e.Position, xaxis, yaxis);
tmp.Text = string.Format("Y = {0:0.###}", tmp.EndPoint.Y);
// Redraw the plot
model.RefreshPlot(false);
e.Handled = true;
}
};
model.MouseUp += (s, e) =>
{
if (tmp != null)
{
tmp = null;
e.Handled = true;
}
};
return model;
}
示例7: LineAnnotation
public static PlotModel LineAnnotation()
{
var model = new PlotModel("LineAnnotation", "Click and drag the annotation line.");
model.Axes.Add(new LinearAxis(AxisPosition.Bottom, -20, 80));
model.Axes.Add(new LinearAxis(AxisPosition.Left, -10, 10));
var la = new LineAnnotation { Type = LineAnnotationType.Vertical, X = 4 };
la.MouseDown += (s, e) =>
{
if (e.ChangedButton != OxyMouseButton.Left)
{
return;
}
la.StrokeThickness *= 5;
model.RefreshPlot(false);
e.Handled = true;
};
// Handle mouse movements (note: this is only called when the mousedown event was handled)
la.MouseMove += (s, e) =>
{
la.X = la.InverseTransform(e.Position).X;
model.RefreshPlot(false);
e.Handled = true;
};
la.MouseUp += (s, e) =>
{
la.StrokeThickness /= 5;
model.RefreshPlot(false);
e.Handled = true;
};
model.Annotations.Add(la);
return model;
}
示例8: SetAxisType
private static void SetAxisType(PlotModel plotModel, EAxisType axisType)
{
var oldAxis = plotModel.Axes.FirstOrDefault(x => x.Position == AxisPosition.Left);
if (oldAxis != null)
{
plotModel.Axes.Remove(oldAxis);
}
if (axisType == EAxisType.Linear)
{
plotModel.Axes.Add(new LinearAxis(AxisPosition.Left));
}
else
{
plotModel.Axes.Add(new LogarithmicAxis(AxisPosition.Left));
}
plotModel.RefreshPlot(true);
}
示例9: Remove
private static void Remove(IDictionary<TestInfo, LineSeries> dict, PlotModel plotModel, TestInfo test)
{
if (dict.ContainsKey(test))
{
plotModel.Series.Remove(dict[test]);
dict.Remove(test);
plotModel.RefreshPlot(true);
}
}
示例10: AddPoint
private static void AddPoint(IDictionary<TestInfo, LineSeries> dict, PlotModel plotModel, TestInfo test,
double xValue, double yValue)
{
if (dict.ContainsKey(test))
{
dict[test].Points.Add(new DataPoint(xValue, yValue));
plotModel.RefreshPlot(true);
}
}
示例11: Add
private static void Add(IDictionary<TestInfo, LineSeries> dict, PlotModel plotModel, TestInfo test)
{
if (!dict.ContainsKey(test))
{
var series = new LineSeries(test.ToString());
dict.Add(test, series);
plotModel.Series.Add(series);
plotModel.RefreshPlot(true);
}
}
示例12: OnViewLoaded
protected override void OnViewLoaded(object theView)
{
base.OnViewLoaded(theView);
view = (GraphInputPopupView)theView;
model = new PlotModel(Title);
view.Plot.Model = model;
s1.Title = Title;
firstAxis.Key = "Left";
firstAxis.Title = Title;
firstAxis.MajorGridlineStyle = LineStyle.Solid;
firstAxis.MinorGridlineStyle = LineStyle.Solid;
firstAxis.Minimum = MinimumY;
firstAxis.Maximum = MaximumY;
firstAxis.Zoom(MinimumY,MaximumY);
firstAxis.IsZoomEnabled = false;
firstAxis.IsPanEnabled = false;
bottomAxis.Key = "Bottom";
bottomAxis.MajorGridlineStyle = LineStyle.Solid;
bottomAxis.MinorGridlineStyle = LineStyle.Solid;
bottomAxis.Minimum = MinimumX;
bottomAxis.Maximum = MaximumX;
bottomAxis.Zoom(MinimumX,MaximumX);
bottomAxis.IsZoomEnabled = false;
bottomAxis.IsPanEnabled = false;
model.Axes.Clear();
model.Axes.Add(firstAxis);
model.Axes.Add(bottomAxis);
model.Series.Add(s1);
if (!s1.Points.Any())
for (int i = (int)Math.Round(MinimumX,0); i <= Math.Round(MaximumX,0); i++)
{
s1.Points.Add(new DataPoint(i,MinimumY));
}
model.RefreshPlot(false);
UpdatePosition();
view.PreviewMouseLeftButtonDown += _view_PreviewMouseLeftButtonDown;
view.PreviewMouseLeftButtonUp += _view_PreviewMouseLeftButtonUp;
view.PreviewTouchDown += view_PreviewTouchDown;
view.PreviewTouchUp += view_PreviewTouchUp;
//Items = new BindableCollection<System.Windows.Controls.MenuItem>();
if (TimeOut.HasValue)
{
toTimer = new DispatcherTimer();
toTimer.Interval = TimeOut.Value;
toTimer.Tick += toTimer_Tick;
toTimer.Start();
}
}