本文整理汇总了C#中System.Windows.Point.DataToScreen方法的典型用法代码示例。如果您正苦于以下问题:C# Point.DataToScreen方法的具体用法?C# Point.DataToScreen怎么用?C# Point.DataToScreen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Point
的用法示例。
在下文中一共展示了Point.DataToScreen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnRenderCore
protected override void OnRenderCore(DrawingContext dc, RenderState state)
{
if (DataSource == null) return;
if (Marker == null) return;
var transform = Plotter2D.Viewport.Transform;
DataRect bounds = DataRect.Empty;
using (IPointEnumerator enumerator = DataSource.GetEnumerator(GetContext()))
{
Point point = new Point();
while (enumerator.MoveNext())
{
enumerator.GetCurrent(ref point);
enumerator.ApplyMappings(Marker);
//Point screenPoint = point.Transform(state.Visible, state.Output);
Point screenPoint = point.DataToScreen(transform);
bounds = DataRect.Union(bounds, point);
Marker.Render(dc, screenPoint);
}
}
Viewport2D.SetContentBounds(this, bounds);
}
示例2: OnRenderCore
protected override void OnRenderCore(DrawingContext dc, RenderState state)
{
if (DataSource == null)
{
markers.Clear();
canvas.Children.Clear();
return;
}
if (Marker == null) return;
var transform = Viewport.Transform;
if (markers.Count == 0)
{
Rect bounds = Rect.Empty;
using (IPointEnumerator enumerator = DataSource.GetEnumerator(GetContext()))
{
Point point = new Point();
while (enumerator.MoveNext())
{
enumerator.GetCurrent(ref point);
enumerator.ApplyMappings(Marker);
Point screenPoint = point.DataToScreen(transform);
if (!screenPoint.IsFinite())
continue;
bounds = Rect.Union(bounds, point);
UIElement marker = Marker.CreateMarker();
Marker.SetPosition(marker, screenPoint);
// todo было раскомментировано. Сделать хранение маркеров и добавление их на плоттер.
canvas.Children.Add(marker);
markers.Add(marker);
}
}
ContentBounds = bounds;
}
else
{
int index = 0;
using (IPointEnumerator enumerator = DataSource.GetEnumerator(GetContext()))
{
Point point = new Point();
while (enumerator.MoveNext())
{
enumerator.GetCurrent(ref point);
Point screenPoint = point.DataToScreen(transform);
Marker.SetPosition(markers[index++], screenPoint);
}
}
}
}
示例3: OnRenderCore
protected override void OnRenderCore(DrawingContext dc, RenderState state)
{
if (Marker == null)
return;
if (DataSource == null) // No data is specified
{
if (canvas != null)
{
foreach (UIElement child in canvas.Children)
unused.Add(child);
canvas.Children.Clear();
}
}
else // There is some data
{
int index = 0;
var transform = GetTransform();
using (IPointEnumerator enumerator = DataSource.GetEnumerator(GetContext()))
{
Point point = new Point();
DataRect bounds = DataRect.Empty;
while (enumerator.MoveNext())
{
enumerator.GetCurrent(ref point);
enumerator.ApplyMappings(Marker);
if (index >= canvas.Children.Count)
{
UIElement newMarker;
if (unused.Count > 0)
{
newMarker = unused[unused.Count - 1];
unused.RemoveAt(unused.Count - 1);
}
else
newMarker = Marker.CreateMarker();
canvas.Children.Add(newMarker);
}
Marker.SetMarkerProperties(canvas.Children[index]);
bounds.Union(point);
Point screenPoint = point.DataToScreen(transform);
Marker.SetPosition(canvas.Children[index], screenPoint);
index++;
}
Viewport2D.SetContentBounds(this, bounds);
while (index < canvas.Children.Count)
{
unused.Add(canvas.Children[index]);
canvas.Children.RemoveAt(index);
}
}
}
}
示例4: DataChangeStatus
void DataChangeStatus()
{
if (LeftIsPlaying && RightIsPlaying)
{
#region customizeTime
if (RightVideo.Position.Seconds < 10)
DataSec = "0" + RightVideo.Position.Seconds.ToString();
else
DataSec = RightVideo.Position.Seconds.ToString();
if (RightVideo.Position.Minutes < 10)
DataMin = "0" + RightVideo.Position.Minutes.ToString();
else
DataMin = RightVideo.Position.Minutes.ToString();
if (RightVideo.Position.Hours < 10)
DataHours = "0" + RightVideo.Position.Hours.ToString();
else
DataHours = RightVideo.Position.Hours.ToString();
#endregion customizeTime
var Transform = Plotter.Viewport.Transform;
System.Windows.Point CurrentPosition = new System.Windows.Point(RightVideo.Position.TotalMilliseconds, 0);
if (GraphLine.Visibility == Visibility.Hidden)
{
GraphLine.Visibility = Visibility.Visible;
}
if (!hasTicked)
{
Canvas.SetLeft(GraphLine, 113);
hasTicked = true;
}
//var mouseScreenPosition = Mouse.GetPosition(Plotter.CentralGrid);
//var mousePositionInData = mouseScreenPosition.ScreenToData(Transform);
double screenPos = 0;
if (ZoomedIn)
{
screenPos = ((CurrentPosition.DataToScreen(Transform).X) / 1000) - 2*Math.Abs(xMinWindowWhenZoomed);
//System.Diagnostics.Debug.WriteLine("ZoomedIn, position: " + screenPos + ", xclick: " + xValue + ", current: " + CurrentPosition);
}
else if(!ZoomedIn)
{
screenPos = (CurrentPosition.DataToScreen(Transform).X) / 1000;
//System.Diagnostics.Debug.WriteLine("ZoomedOut, position: " + screenPos);
}
//Canvas.SetLeft(GraphLine, 60 + mouseScreenPosition.X);
Canvas.SetLeft(GraphLine, 113 + screenPos);
if (ZoomedIn)
{
mouseScreenPosition.X += 12.02;
}
else if (!ZoomedIn)
{
mouseScreenPosition.X += 6.01;
}
DataSeekSlider.Value = RightVideo.Position.TotalMilliseconds;
if (RightVideo.Position.Hours == 0)
{
DataCurrentTimeTextBlock.Text = DataMin + ":" + DataSec;
}
else
{
DataCurrentTimeTextBlock.Text = DataHours + ":" + DataMin + ":" + DataSec;
}
}
}