コード例 #1
0
		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
0
		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
0
        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
0
        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;
                }
            }
        }