private void OnPositionChanged(DependencyPropertyChangedEventArgs e)
        {
            PositionChanged.Raise(this, new PositionChangedEventArgs {
                Position = (Point)e.NewValue, PreviousPosition = (Point)e.OldValue
            });

            ViewportPanel.SetX(this, Position.X);
            ViewportPanel.SetY(this, Position.Y);
        }
Пример #2
0
        private void UpdateUI()
        {
            panel.Children.Clear();

            if (plotter == null)
            {
                return;
            }

            var grid = Grid;

            if (grid == null)
            {
                return;
            }

            var bounds = grid.Grid.GetGridBounds();

            Viewport2D.SetContentBounds(this, bounds);

            int width  = grid.Width;
            int height = grid.Height;

            // todo not the best way to determine size of markers in case of warped grids.
            double deltaX = (grid.Grid[width - 1, 0].X - grid.Grid[0, 0].X) / width;
            double deltaY = (grid.Grid[0, height - 1].Y - grid.Grid[0, 0].Y) / height;

            for (int ix = 0; ix < width; ix++)
            {
                int localX = ix;
                Dispatcher.BeginInvoke(() =>
                {
                    for (int iy = 0; iy < height; iy++)
                    {
                        Ellipse ellipse = new Ellipse {
                            MaxWidth = 10, MaxHeight = 10
                        };
                        var position = grid.Grid[localX, iy];
                        ViewportPanel.SetX(ellipse, position.X);
                        ViewportPanel.SetY(ellipse, position.Y);
                        ViewportPanel.SetViewportWidth(ellipse, deltaX / 2);
                        ViewportPanel.SetViewportHeight(ellipse, deltaY / 2);

                        if (localX % 10 == 0 && iy % 10 == 0)
                        {
                            ellipse.Fill = Brushes.Black;
                        }
                        else
                        {
                            ellipse.Fill = Brushes.Gray.MakeTransparent(0.7);
                        }

                        panel.Children.Add(ellipse);
                    }
                }, DispatcherPriority.Background);
            }
        }
        protected static void OnLayoutPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FrameworkElement uiElement = d as FrameworkElement;

            if (uiElement != null)
            {
                ViewportPanel panel = VisualTreeHelper.GetParent(uiElement) as ViewportPanel;
                if (panel != null)
                {
                    // invalidating not self arrange, but calling Arrange method of only that uiElement which has changed position
                    panel.InvalidatePosition(uiElement);
                }
            }
        }
		private void SetBindings(FrameworkElement marker, ViewportPanel panel)
		{
			panel.SetBinding(ViewportPanel.ViewportBoundsProperty, boundsMultiBinding);

			var crown = (Shape)marker;
			crown.SetBinding(ViewportPanel.ViewportWidthProperty, crownWidthBinding);
			crown.SetBinding(ViewportPanel.ViewportHeightProperty, crownHeightBinding);
			crown.SetBinding(ViewportPanel.YProperty, crownYBinding);
			crown.SetBinding(ViewportPanel.XProperty, xBinding);
			crown.SetBinding(Shape.FillProperty, fillBinding);
			crown.SetBinding(Shape.StrokeProperty, strokeBinding);
			panel.Children.Add(crown);

			var trunk = (Shape)trunkTemplate.LoadContent();
			trunk.SetBinding(ViewportPanel.XProperty, xBinding);
			trunk.SetBinding(ViewportPanel.ViewportWidthProperty, trunkWidthBinding);
			trunk.SetBinding(ViewportPanel.ViewportHeightProperty, trunkHeightBinding);
			trunk.SetBinding(Shape.FillProperty, fillBinding);
			panel.Children.Add(trunk);
		}
Пример #5
0
 private CoordinateTransform GetTransform(Size size)
 {
     return(viewport.Transform.WithRects(ViewportPanel.GetViewportBounds(this), new Rect(size)));
 }
Пример #6
0
        private static void OnPlotterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ViewportPanel panel = (ViewportPanel)d;

            panel.OnPlotterChanged((Plotter)e.NewValue, (Plotter)e.OldValue);
        }
Пример #7
0
 public RenderingChart()
 {
     //renderingCanvas.SetBinding(ViewportPanel.ViewportBoundsProperty, new Binding { Path = new PropertyPath("(0)", Viewport2D.ContentBoundsProperty), Source = this });
     ViewportPanel.SetViewportBounds(renderingCanvas, new DataRect(0, 0, 1, 1));
     CurrentItemsPanel.Children.Add(renderingCanvas);
 }
		protected override FrameworkElement CreateMarkerCore(object dataItem)
		{
			var panel = new ViewportPanel { DataContext = dataItem };

			panel.SetBinding(ViewportPanel.ViewportBoundsProperty, boundsMultiBinding);

			var trunk = (Rectangle)trunkTemplate.LoadContent();
			trunk.DataContext = dataItem;
			trunk.SetBinding(Shape.FillProperty, fillBinding);
			trunk.SetBinding(ViewportPanel.XProperty, xBinding);
			trunk.SetBinding(ViewportPanel.ViewportWidthProperty, trunkWidthBinding);
			trunk.SetBinding(ViewportPanel.ViewportHeightProperty, trunkHeightBinding);
			trunk.SetBinding(Shape.FillProperty, fillBinding);
			panel.Children.Add(trunk);

			var crown = (Path)crownTemplate.LoadContent();
			crown.DataContext = dataItem;
			crown.SetBinding(Shape.FillProperty, fillBinding);
			crown.SetBinding(Shape.StrokeProperty, strokeBinding);
			crown.SetBinding(Path.DataProperty, crownPathDataBinding);
			crown.SetBinding(ViewportPanel.ViewportWidthProperty, crownWidthBinding);
			crown.SetBinding(ViewportPanel.ViewportHeightProperty, crownHeightBinding);
			crown.SetBinding(ViewportPanel.YProperty, crownYBinding);
			crown.SetBinding(ViewportPanel.XProperty, xBinding);
			crown.SetBinding(Shape.FillProperty, fillBinding);
			crown.SetBinding(Shape.StrokeProperty, strokeBinding);
			panel.Children.Add(crown);

			panel.SetBinding(ToolTipService.ToolTipProperty, speciesBinding);
			//LiveToolTip toolTip = new LiveToolTip();
			//toolTip.SetBinding(LiveToolTip.BackgroundProperty, fillBinding);
			//toolTip.SetBinding(LiveToolTip.ContentProperty, speciesBinding);
			//toolTip.SetBinding(TextBlock.ForegroundProperty, foregroundBinding);
			//LiveToolTipService.SetToolTip(panel, toolTip);

			return panel;
		}