Example #1
0
		private void AddCircularArcGraph(Point startPoint, Point endPoint, Size size)
		{
			PathFigure pf = new PathFigure();
			pf.StartPoint = new Point(startPoint.X, startPoint.Y);

			ArcSegment arcSegment = new ArcSegment();
			arcSegment.Point = new Point(endPoint.X, endPoint.Y);
			arcSegment.Size = size;
			arcSegment.SweepDirection = SweepDirection.Counterclockwise;

			PathSegmentCollection psc = new PathSegmentCollection();
			psc.Add(arcSegment);

			pf.Segments = psc;

			PathFigureCollection pfc = new PathFigureCollection();
			pfc.Add(pf);

			PathGeometry pg = new PathGeometry();
			pg.Figures = pfc;

			var path = new Path();
			path.Stroke = Brushes.Black;
			path.StrokeThickness = 1;
			path.Data = pg;
			path.Fill = Brushes.Orange;
			path.Stretch = Stretch.Fill;

			var viewportPanel = new ViewportHostPanel();
			ViewportPanel.SetViewportBounds(path, new DataRect(0, 0, 50, 50));
			viewportPanel.Children.Add(path);
			plotter.Children.Add(viewportPanel);
		}
Example #2
0
        protected void ForceUpdateContentBounds()
        {
            ViewportHostPanel viewportPanel = CurrentItemsPanel as ViewportHostPanel;

            if (viewportPanel != null)
            {
                viewportPanel.UpdateContentBounds();
            }
        }
Example #3
0
        private static void OnPlotterChanged(object sender, PlotterChangedEventArgs e)
        {
            ViewportHostPanel owner = (ViewportHostPanel)sender;

            if (owner.plotter != null && e.PreviousPlotter != null)
            {
                owner.viewport.PropertyChanged -= owner.Viewport_PropertyChanged;
                owner.viewport = null;
                owner.plotter  = null;
            }
            if (owner.plotter == null && e.CurrentPlotter != null)
            {
                owner.plotter  = (Plotter2D)e.CurrentPlotter;
                owner.viewport = owner.plotter.Viewport;
                owner.viewport.PropertyChanged += owner.Viewport_PropertyChanged;
            }
        }
        public void OnPlotterAttached(Plotter plotter)
        {
            if (Parent == null)
            {
                hostPanel = new ViewportHostPanel();
                Viewport2D.SetIsContentBoundsHost(hostPanel, false);
                hostPanel.Children.Add(this);

                plotter.Dispatcher.BeginInvoke(() =>
                {
                    plotter.Children.Add(hostPanel);
                }, DispatcherPriority.Send);
            }
#if !old
            Canvas hostCanvas = (Canvas)hostPanel.FindName(canvasName);
            if (hostCanvas == null)
            {
                hostCanvas = new Canvas {
                    ClipToBounds = true
                };
                Panel.SetZIndex(hostCanvas, 1);

                INameScope nameScope = NameScope.GetNameScope(hostPanel);
                if (nameScope == null)
                {
                    nameScope = new NameScope();
                    NameScope.SetNameScope(hostPanel, nameScope);
                }

                hostPanel.RegisterName(canvasName, hostCanvas);
                hostPanel.Children.Add(hostCanvas);
            }

            hostCanvas.Children.Add(this);
#else
#endif

            Plotter2D plotter2d = (Plotter2D)plotter;
            this.plotter = plotter2d;
        }
Example #5
0
        protected void DetachFromItemsPanel()
        {
            ViewportHostPanel viewportItemsPanel = currentItemsPanel as ViewportHostPanel;

            if (viewportItemsPanel != null)
            {
                viewportItemsPanel.ContentBoundsChanged -= viewportItemsPanel_ContentBoundsChanged;
            }
            if (viewportItemsPanel != null && plotter != null)
            {
                viewportItemsPanel.OnPlotterDetaching(plotter);
            }

            var notifyingChildren = currentItemsPanel.Children as INotifyCollectionChanged;

            if (notifyingChildren != null)
            {
                notifyingChildren.CollectionChanged -= new NotifyCollectionChangedEventHandler(OnItemsCollectionChanged);
            }

            Content = null;
        }
        protected virtual void DrawAllMarkers(bool reuseExisting, bool continueAfterDataPrepaired)
        {
            if (!IsReadyToDrawMarkers())
            {
                return;
            }

            var dataSource = DataSource;

            dataSource.Environment = new DataSourceEnvironment {
                Plotter = this.Plotter, FirstDraw = true
            };

            if (!continueAfterDataPrepaired)
            {
                dataSource.PrepairData(getDataAsyncronously);
                if (getDataAsyncronously)
                {
                    LongOperationsIndicator.BeginLongOperation(this);
                    return;
                }
            }

            CurrentItemsPanel.Children.Clear();

            BuildCommonBindings();

            startIndex = 0;
            lastIndex  = startIndex;

            IndividualArrangePanel panel = CurrentItemsPanel as IndividualArrangePanel;

            if (panel != null)
            {
                panel.BeginBatchAdd();
            }

            ViewportHostPanel viewportPanel = CurrentItemsPanel as ViewportHostPanel;

            if (viewportPanel != null)
            {
                viewportPanel.OverallViewportBounds = DataRect.Empty;
            }

            foreach (var dataItem in dataSource.GetData())
            {
                CreateAndAddMarker(dataItem, lastIndex);
                lastIndex++;

                if (showMarkersConsequently && lastIndex % 100 == 0)
                {
                    // make dispatcher execute all operations in its queue;
                    // so that markers will appear on the screen step-by-step,
                    // making application more responsive.

                    // This line is dangerous, it causes WI 1677
                    // Dispatcher.Invoke(() => { }, DispatcherPriority.Background);
                }
            }
            if (panel != null)
            {
                panel.EndBatchAdd();
            }

            int len = CurrentItemsPanel.Children.Count;

            if (lastIndex < len)
            {
                for (int i = lastIndex; i < len; i++)
                {
                    UIElement element = CurrentItemsPanel.Children[i];
                    element.Visibility = Visibility.Collapsed;
                }
            }

            LongOperationsIndicator.EndLongOperation(this);
        }
		public void OnPlotterAttached(Plotter plotter)
		{
			if (Parent == null)
			{
				hostPanel = new ViewportHostPanel();
                Viewport2D.SetIsContentBoundsHost(hostPanel, false);
				hostPanel.Children.Add(this);

				plotter.Dispatcher.BeginInvoke(() =>
				{
					plotter.Children.Add(hostPanel);
				}, DispatcherPriority.Send);
			}
#if !old
			Canvas hostCanvas = (Canvas)hostPanel.FindName(canvasName);
			if (hostCanvas == null)
			{
				hostCanvas = new Canvas { ClipToBounds = true };
				Panel.SetZIndex(hostCanvas, 1);

				INameScope nameScope = NameScope.GetNameScope(hostPanel);
				if (nameScope == null)
				{
					nameScope = new NameScope();
					NameScope.SetNameScope(hostPanel, nameScope);
				}

				hostPanel.RegisterName(canvasName, hostCanvas);
				hostPanel.Children.Add(hostCanvas);
			}

			hostCanvas.Children.Add(this);
#else
#endif

			Plotter2D plotter2d = (Plotter2D)plotter;
			this.plotter = plotter2d;
		}