コード例 #1
0
        protected override BitmapSource RenderFrame(DataRect dataRect, Rect output)
        {
            Grid grid = new Grid();
            grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
            grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
            TextBlock lt = new TextBlock
            {
                VerticalAlignment = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Text = String.Format("({0},{1})", dataRect.XMin, dataRect.YMax)
            };
            grid.Children.Add(lt);
            Grid.SetRow(lt, 0);
            TextBlock rb = new TextBlock
            {
                VerticalAlignment = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Right,
                Text = String.Format("({0},{1})", dataRect.XMax, dataRect.YMin)
            };
            grid.Children.Add(rb);
            Grid.SetRow(rb, 1);
            Border border = new Border();
            border.BorderThickness = new Thickness(3);
            border.BorderBrush = Brushes.Blue;
            border.Child = grid;

            RenderTargetBitmap rtb = new RenderTargetBitmap((int)output.Width, (int)output.Height, 96, 96, PixelFormats.Default);
            border.Measure(new Size(output.Width, output.Height));
            border.Arrange(output);
            rtb.Render(border);

            Thread.Sleep(1000);

            return rtb;
        }
コード例 #2
0
		public static void DrawRectangle(string name, DataRect bounds, Brush stroke = null, Brush fill = null, double strokeThickness = 1.0)
		{
			Contract.Assert(name != null);

			if (stroke == null)
				stroke = Brushes.Blue;

			Rectangle rect;
			if (objects.ContainsKey(name))
				rect = (Rectangle)objects[name];
			else
			{
				rect = new Rectangle();
				objects.Add(name, rect);
			}

			rect.Stroke = stroke;
			rect.StrokeThickness = strokeThickness;
			rect.Fill = fill;

			ViewportPanel.SetViewportBounds(rect, bounds);

			if (rect.Parent == null)
				panel.Children.Add(rect);

			EnsurePanelAdded();
		}
コード例 #3
0
		private void Viewport_PropertyChanged(object sender, ExtendedPropertyChangedEventArgs e)
		{
			if (e.PropertyName == "Visible")
			{
				DataRect currVisible = (DataRect)e.NewValue;
				if (increasedVisible.Contains(currVisible))
				{
					var increasedSquare = increasedVisible.GetSquare();
					if (increasedSquare > 0)
					{
						var squareRatio = increasedSquare / currVisible.GetSquare();
						if (2 < squareRatio && squareRatio < 6)
						{
							// keeping old value of increasedVisible
							return;
						}
					}
				}

				increasedVisible = currVisible.ZoomOutFromCenter(2.0);
				chart.OnReset();
			}
			else if (e.PropertyName == "Output")
			{
				chart.OnReset();
			}
		}
コード例 #4
0
		/// <summary>
		/// Applies the restriction.
		/// </summary>
		/// <param name="previousDataRect">Previous data rectangle.</param>
		/// <param name="proposedDataRect">Proposed data rectangle.</param>
		/// <param name="viewport">The viewport, to which current restriction is being applied.</param>
		/// <returns>New changed visible rectangle.</returns>
		public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
		{
			if (proposedDataRect.Width < minSize || proposedDataRect.Height < minSize)
				return previousDataRect;

			return proposedDataRect;
		}
コード例 #5
0
		/// <summary>
		/// Applies the specified old data rect.
		/// </summary>
		/// <param name="oldDataRect">The old data rect.</param>
		/// <param name="newDataRect">The new data rect.</param>
		/// <param name="viewport">The viewport.</param>
		/// <returns></returns>
		public override DataRect Apply(DataRect oldDataRect, DataRect newDataRect, Viewport2D viewport)
		{
			bool decreasing = newDataRect.Width < oldDataRect.Width || newDataRect.Height < oldDataRect.Height;
			if (!decreasing && (newDataRect.Width > maxSize || newDataRect.Height > maxSize))
				return oldDataRect;

			return newDataRect;
		}
コード例 #6
0
		protected override DataRect CoerceVisible(DataRect newVisible)
		{
			DataRect baseValue = base.CoerceVisible(newVisible);
			if (CoerceVisibleFunc != null)
				return CoerceVisibleFunc(newVisible, baseValue);
			else
				return baseValue;
		}
コード例 #7
0
 public override DataRect Apply( DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport )
 {
     DataRect dataRect = proposedDataRect.WithY(other.Visible.YMin, other.Visible.YMax);
     if (dataRect != other.Visible)
     {
         other.Visible = dataRect;
     }
     return proposedDataRect;
 }
コード例 #8
0
		private void ChangeVisible(DataRect newVisible)
		{
			// Debug.WriteLine("ChangeVisible: old = " + plotter.Visible);
			// Debug.WriteLine("ChangeVisible: new = " + newVisible);
			if (!Object.Equals(plotter.Visible, newVisible))
				plotter.Visible = newVisible;
			if (!plotter.Visible.Equals(newVisible))
				Debug.WriteLine("ChangedVisible: Visible property is different!");
		}
コード例 #9
0
		public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
		{
			Point location = (Point)values[0];
			Vector direction = (Vector)values[1];

			DataRect bounds = new DataRect(location, location + direction);

			return bounds;
		}
        public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
        {
            DataRect borderRect = DataRect.Create(minSeconds, proposedDataRect.YMin, maxSeconds, proposedDataRect.YMax);
            if (proposedDataRect.IntersectsWith(borderRect))
            {
                DataRect croppedRect = DataRect.Intersect(proposedDataRect, borderRect);
                return croppedRect;
            }

            return previousDataRect;
        }
コード例 #11
0
		public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
		{
			DataRect parentVisible = parentViewport.Visible;

			double xmin = parentVisible.XMin * xScale + xShift;
			double xmax = parentVisible.XMax * xScale + xShift;
			double ymin = parentVisible.YMin * yScale + yShift;
			double ymax = parentVisible.YMax * yScale + yShift;

			return DataRect.Create(xmin, ymin, xmax, ymax);
		}
コード例 #12
0
        public override DataRect Apply(DataRect oldDataRect, DataRect newDataRect, Viewport2D viewport)
        {
            double ratio = newDataRect.Width / newDataRect.Height;
            double coeff = Math.Sqrt(ratio);

            double newWidth = newDataRect.Width / coeff;
            double newHeight = newDataRect.Height * coeff;

            Point center = newDataRect.GetCenter();
            DataRect res = DataRect.FromCenterSize(center, newWidth, newHeight);
            return res;
        }
コード例 #13
0
        private void CreateTask(TileIndex id, DataRect bounds)
        {
            var task = factory.StartNew(() =>
            {
                var set = new MandelbrotSet(size, bounds);
                set.Palette = new HSBPalette();
                var bmp = set.Draw();
                bmp.Freeze();
                ReportSuccessAsync(null, bmp, id);

                LookForNexttask();
            });
        }
コード例 #14
0
		/// <summary>
		/// Creates the environment.
		/// </summary>
		/// <returns></returns>
		protected DataSourceEnvironment CreateEnvironment()
		{
			if (plotter == null)
				throw new InvalidOperationException();

			Viewport2D viewport = plotter.Viewport;
			DataSourceEnvironment result = environmentPlugin.CreateEnvironment(viewport);

			visibleWhileCreation = result.Visible;
			outputWhileCreation = result.Output;

			return result;
		}
コード例 #15
0
        private void CreateTask(TileIndex id, DataRect bounds)
        {
            Task task = Task.Create(o =>
            {
                var set = new MandelbrotSet(size, bounds);
                set.Palette = new HSBPalette();
                var bmp = set.Draw();
                bmp.Freeze();
                ReportSuccessAsync(null, bmp, id);

                LookForNexttask();
            }, manager);
        }
コード例 #16
0
		public void TestIsClose()
		{
			DataRect rect1 = new DataRect(0, 0, 1, 1);
			DataRect rect2 = new DataRect(0, 0, 1, 1);

			const double diff = 0.01;

			Assert.IsTrue(rect1.IsCloseTo(rect2, diff));
			Assert.IsTrue(rect1.IsCloseTo(new DataRect(0, 0, 1, 1.005), diff));

			Assert.IsFalse(new DataRect(0, 0, 0.0001, 0.0001).IsCloseTo(DataRect.Empty, 0.1));
			Assert.IsFalse(rect1.IsCloseTo(new DataRect(-0.1, 0, 1, 0.99), 0.1));
		}
コード例 #17
0
		private void CreateTask(TileIndex id, DataRect bounds)
		{
			Task task = factory.StartNew(() =>
			{
				Thread.CurrentThread.Priority = ThreadPriority.Lowest;

				var set = new MandelbrotSet(size, bounds);
				set.Palette = new HsbPalette();
				var bmp = set.Draw();
				bmp.Freeze();
				ReportSuccessAsync(null, bmp, id);

				LookForNextTask();
			});
		}
コード例 #18
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value == null)
            {
                throw base.GetConvertFromException(value);
            }

            string source = value as string;

            if (source != null)
            {
                return(DataRect.Parse(source));
            }

            return(base.ConvertFrom(context, culture, value));
        }
コード例 #19
0
        public override DataRect GetTileBounds(TileIndex tile)
        {
            if (tile.Level == 0)
            {
                return(rect);
            }

            double width  = GetTileWidth(tile.Level);
            double height = GetTileHeight(tile.Level);
            double x      = 0 + tile.X * width;
            double y      = /*minY*/ 0 + tile.Y * height;

            DataRect bounds = new DataRect(x, y, width, height);

            return(bounds);
        }
コード例 #20
0
        private Effect CreateEffect(DataRect bounds)
        {
            MercatorShader effect = new MercatorShader();

            effect.YMax  = Math.Max(bounds.YMin, bounds.YMax);
            effect.YDiff = bounds.Height;

            double latMax = mercatorTransform.DataToViewport(new Point(0, Math.Max(bounds.YMin, bounds.YMax))).Y;
            double latMin = mercatorTransform.DataToViewport(new Point(0, Math.Min(bounds.YMin, bounds.YMax))).Y;

            effect.YLatMax  = latMax;
            effect.YLatDiff = 1.0 / Math.Abs(latMax - latMin);
            effect.Scale    = mercatorTransform.Scale;

            return(effect);
        }
コード例 #21
0
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (!isPanning && !isZooming)
            {
                return;
            }

            // dragging
            if (isPanning && e.LeftButton == MouseButtonState.Pressed)
            {
                if (!IsMouseCaptured)
                {
                    CaptureMouse();
                }

                Point endPoint = e.GetPosition(this).ScreenToViewport(Viewport.Transform);

                Point  loc   = Viewport.Visible.Location;
                Vector shift = panningStartPointInViewport - endPoint;
                loc += shift;

                // preventing unnecessary changes, if actually visible hasn't change.
                if (shift.X != 0 || shift.Y != 0)
                {
                    Cursor = Cursors.ScrollAll;

                    DataRect visible = Viewport.Visible;

                    visible.Location = loc;

                    Viewport.SetChangeType(ChangeType.Pan);
                    Viewport.Visible = visible;
                    Viewport.SetChangeType();
                }

                e.Handled = true;
            }
            // zooming
            else if (isZooming && e.LeftButton == MouseButtonState.Pressed)
            {
                Point zoomEndPoint = e.GetPosition(this);
                UpdateZoomRect(zoomEndPoint);

                e.Handled = true;
            }
        }
コード例 #22
0
        /// <summary>
        /// Applies the restriction.
        /// </summary>
        /// <param name="previousDataRect">Previous data rectangle.</param>
        /// <param name="proposedDataRect">Proposed data rectangle.</param>
        /// <param name="viewport">The viewport, to which current restriction is being applied.</param>
        /// <returns>New changed visible rectangle.</returns>
        public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
        {
            if (proposedDataRect.IsEmpty)
                return proposedDataRect;

            double followWidth = proposedDataRect.Width;
            if (!viewport.UnitedContentBounds.IsEmpty)
            {
                followWidth = Math.Min(width, viewport.UnitedContentBounds.Width);
            }
            if (followWidth.IsInfinite())
                followWidth = width;

            Rect visible = new Rect(proposedDataRect.XMin + proposedDataRect.Width - followWidth, proposedDataRect.YMin, followWidth, proposedDataRect.Height);

            return visible;
        }
コード例 #23
0
		protected virtual Size GetElementSize(FrameworkElement child, Size availableSize, CoordinateTransform transform)
		{
			Size result = availableSize;

			DataRect ownViewportBounds = GetViewportBounds(child);
			if (!ownViewportBounds.IsEmpty)
			{
				result = ownViewportBounds.ViewportToScreen(transform).Size;
			}
			else
			{
				double viewportWidth = GetViewportWidth(child);
				double viewportHeight = GetViewportHeight(child);

				bool hasViewportWidth = viewportWidth.IsNotNaN();
				bool hasViewportHeight = viewportHeight.IsNotNaN();

				double minScreenWidth = GetMinScreenWidth(child);
				bool hasMinScreenWidth = minScreenWidth.IsNotNaN();

				double selfWidth = child.Width.IsNotNaN() ? child.Width : availableSize.Width;
				double width = hasViewportWidth ? viewportWidth : selfWidth;

				double selfHeight = child.Height.IsNotNaN() ? child.Height : availableSize.Height;
				double height = hasViewportHeight ? viewportHeight : selfHeight;

				if (width < 0) width = 0;
				if (height < 0) height = 0;

				DataRect bounds = new DataRect(new Size(width, height));
				Rect screenBounds = bounds.ViewportToScreen(transform);

				result = new Size(hasViewportWidth ? screenBounds.Width : selfWidth,
					hasViewportHeight ? screenBounds.Height : selfHeight);

				if (hasMinScreenWidth && result.Width < minScreenWidth)
				{
					result.Width = minScreenWidth;
				}
			}

			if (result.Width.IsNaN()) result.Width = 0;
			if (result.Height.IsNaN()) result.Height = 0;

			return result;
		}
コード例 #24
0
        /// <summary>
        /// Applies the restriction.
        /// </summary>
        /// <param name="previousDataRect">Previous data rectangle.</param>
        /// <param name="proposedDataRect">Proposed data rectangle.</param>
        /// <param name="viewport">The viewport, to which current restriction is being applied.</param>
        /// <returns>New changed visible rectangle.</returns>
        public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
        {
            Rect output = viewport.Output;

            if (output.Height == 0 || output.Width == 0)
            {
                return(proposedDataRect);
            }

            double newRatio = proposedDataRect.Width * output.Height /
                              (proposedDataRect.Height * output.Width);

            // Don't modify rect if new ratio differs only slightly
            if (Math.Abs(newRatio - proportionRatio) < 1e-3)
            {
                return(proposedDataRect);
            }

            // Try to keep visible rect's square constant
            double width = proposedDataRect.Width, height = proposedDataRect.Height;
            double square = proposedDataRect.Width * proposedDataRect.Height;

            if (square > 0)
            {
                width  = Math.Sqrt(proportionRatio * output.Width * square / output.Height);
                height = Math.Sqrt(output.Height * square / (proportionRatio * output.Width));
            }

            // Finally ensure we have correct aspect ratio
            double delta = (proportionRatio * height * output.Width - width * output.Height) /
                           (output.Height + proportionRatio * output.Width);

            width  += delta;
            height -= delta;

            double x0 = (proposedDataRect.XMax + proposedDataRect.XMin) / 2;
            double y0 = (proposedDataRect.YMax + proposedDataRect.YMin) / 2;

            return(new DataRect
            {
                XMin = x0 - width / 2,
                Width = width,
                YMin = y0 - height / 2,
                Height = height
            });
        }
コード例 #25
0
        protected override BitmapSource RenderFrame(DataRect dataRect, Rect output)
        {
            Grid grid = new Grid();

            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            TextBlock lt = new TextBlock
            {
                VerticalAlignment   = VerticalAlignment.Top,
                HorizontalAlignment = HorizontalAlignment.Left,
                Text = String.Format("({0},{1})", dataRect.XMin, dataRect.YMax)
            };

            grid.Children.Add(lt);
            Grid.SetRow(lt, 0);
            TextBlock rb = new TextBlock
            {
                VerticalAlignment   = VerticalAlignment.Bottom,
                HorizontalAlignment = HorizontalAlignment.Right,
                Text = String.Format("({0},{1})", dataRect.XMax, dataRect.YMin)
            };

            grid.Children.Add(rb);
            Grid.SetRow(rb, 1);
            Border border = new Border();

            border.BorderThickness = new Thickness(3);
            border.BorderBrush     = Brushes.Blue;
            border.Child           = grid;

            RenderTargetBitmap rtb = new RenderTargetBitmap((int)output.Width, (int)output.Height, 96, 96, PixelFormats.Default);

            border.Measure(new Size(output.Width, output.Height));
            border.Arrange(output);
            rtb.Render(border);

            Thread.Sleep(1000);

            return(rtb);
        }
コード例 #26
0
        protected virtual void StopZooming()
        {
            if (zoomRect.HasValue)
            {
                Rect output = Viewport.Output;

                Point    p1         = zoomRect.Value.TopLeft.ScreenToViewport(Viewport.Transform);
                Point    p2         = zoomRect.Value.BottomRight.ScreenToViewport(Viewport.Transform);
                DataRect newVisible = new DataRect(p1, p2);

                Viewport.SetChangeType(ChangeType.Zoom);
                Viewport.Visible = newVisible;
                Viewport.SetChangeType();

                zoomRect = null;
                ReleaseMouseCapture();
                RemoveSelectionAdorner();
            }
        }
コード例 #27
0
        public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
        {
            if (!proposedDataRect.IsEmpty)
            {
                if (XRange != null)
                {
                    proposedDataRect.XMin = Math.Max(XRange.Start, proposedDataRect.XMin);
                    proposedDataRect.Width = XRange.End - XRange.Start;
                }

                if (YRange != null)
                {
                    proposedDataRect.YMin = YRange.Start;
                    proposedDataRect.Height = YRange.End - YRange.Start;
                }
                return proposedDataRect;
            }
            return previousDataRect;
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: XiBeichuan/hydronumerics
		static void window_VisibleChanged(object sender, EventArgs e)
		{
			if (inChange) return;

			inChange = true;

			PlotterWindow window = (PlotterWindow)sender;

			DataRect vis = window.Plotter.Viewport.Visible;
			visible = ComputeVisibleNewVisible(vis, window.X, window.Y);

			var otherWindows = windows.Where(w => w != window);
			foreach (var win in otherWindows)
			{
				win.Plotter.Viewport.Visible = ComputeVisible(win.X, win.Y);
			}

			inChange = false;
		}
コード例 #29
0
		protected internal override IEnumerable<Point> Filter(IEnumerable<Point> series)
		{
			prevOutput = Output;
			var visible = Visible;

			prevVisible = visible;
			bounds = DataRect.FromCenterSize(visible.GetCenter(), new Size(visible.Width * visibleIncreaseRatio, visible.Height * visibleIncreaseRatio));

			//IParallelEnumerable<Point> parallel = (IParallelEnumerable<Point>)series;

			//Trace.WriteLine("In BoundsFilter: " + Environment.TickCount);

			IEnumerable<Point> result;
			if (Environment.FirstDraw)
				result = series;
			else
				result = series.Where(p => bounds.Contains(p));
			return result;
		}
コード例 #30
0
		public override void BeginLoadImage(TileIndex id)
		{
			DataRect firstLevel = DataRect.Create(-1.7, -1.3, 0.8, 1.2);

			double width = firstLevel.Width / MapTileProvider.GetSideTilesCount(id.Level);
			double xmin = firstLevel.XMin + (id.X + MapTileProvider.GetSideTilesCount(id.Level) / 2) * width;

			double height = firstLevel.Height / MapTileProvider.GetSideTilesCount(id.Level);
			double ymin = firstLevel.YMin + (MapTileProvider.GetSideTilesCount(id.Level) / 2 - id.Y - 1) * height;

			DataRect tileBounds = new DataRect(xmin, ymin, width, height);

			if (tasks. Count == 0)
			{
				CreateTask(id, tileBounds);
			}
			else
			{
				tasks.Push(new TaskInfo { ID = id, TileBounds = tileBounds });
			}
		}
コード例 #31
0
		public override IEnumerable<TileIndex> GetTilesForRegion(DataRect region, double level)
		{
			if (region.IsEmpty)
				yield break;

			double tileSide = GetTileSide(level);

			int minIx = (int)Math.Floor(region.XMin / tileSide);
			int maxIx = (int)Math.Ceiling(region.XMax / tileSide);

			int minIy = (int)Math.Floor(region.YMin / tileSide);
			int maxIy = (int)Math.Ceiling(region.YMax / tileSide);

			for (int ix = minIx; ix < maxIx; ix++)
			{
				for (int iy = minIy; iy < maxIy; iy++)
				{
					yield return new TileIndex(ix, iy, level);
				}
			}
		}
コード例 #32
0
		/// <summary>
		/// Applies the restriction.
		/// </summary>
		/// <param name="previousDataRect">Previous data rectangle.</param>
		/// <param name="proposedDataRect">Proposed data rectangle.</param>
		/// <param name="viewport">The viewport, to which current restriction is being applied.</param>
		/// <returns>New changed visible rectangle.</returns>
		public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
		{
			Rect output = viewport.Output;
			if (output.Height == 0 || output.Width == 0)
				return proposedDataRect;

            double newRatio = proposedDataRect.Width * output.Height / 
                (proposedDataRect.Height * output.Width);

            // Don't modify rect if new ratio differs only slightly 
            if (Math.Abs(newRatio - proportionRatio) < 1e-3)
                return proposedDataRect;

            // Try to keep visible rect's square constant
            double width = proposedDataRect.Width, height = proposedDataRect.Height;
            double square = proposedDataRect.Width * proposedDataRect.Height;
            if (square > 0)
            {
                width = Math.Sqrt(proportionRatio * output.Width * square / output.Height);
                height = Math.Sqrt(output.Height * square / (proportionRatio * output.Width));
            }

            // Finally ensure we have correct aspect ratio
            double delta = (proportionRatio * height * output.Width - width * output.Height) /
                (output.Height + proportionRatio * output.Width);
            width += delta;
            height -= delta;

            double x0 = (proposedDataRect.XMax + proposedDataRect.XMin) / 2;
            double y0 = (proposedDataRect.YMax + proposedDataRect.YMin) / 2;

            return new DataRect
            {
                XMin = x0 - width / 2,
                Width = width,
                YMin = y0 - height / 2,
                Height = height
            };
		}
コード例 #33
0
        /// <summary>
        /// Applies the restriction.
        /// </summary>
        /// <param name="previousDataRect">Previous data rectangle.</param>
        /// <param name="proposedDataRect">Proposed data rectangle.</param>
        /// <param name="viewport">The viewport, to which current restriction is being applied.</param>
        /// <returns>New changed visible rectangle.</returns>
        public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
        {
            Rect output = viewport.Output;
            if (output.Width == 0 || output.Height == 0)
                return proposedDataRect;

            double screenRatio = output.Width / output.Height;
            double viewportRatio = proposedDataRect.Width / proposedDataRect.Height;
            double ratio = screenRatio / viewportRatio;
            double width = proportionRatio * proposedDataRect.Width * ratio;
            double height = proposedDataRect.Height;

            if (width < proposedDataRect.Width)
            {
                height = proposedDataRect.Height / proportionRatio / ratio;
                width = proposedDataRect.Width;
            }

            Point center = proposedDataRect.GetCenter();
            Rect res = RectExtensions.FromCenterSize(center, width, height);

            return res;
        }
コード例 #34
0
		public static void SetVisibleRect(DependencyObject obj, DataRect value)
		{
			obj.SetValue(VisibleRectProperty, value);
		}
コード例 #35
0
		public override DataRect Apply(DataRect previousDataRect, DataRect proposedDataRect, Viewport2D viewport)
		{
			return DataRect.Create(proposedDataRect.XMin, 0, proposedDataRect.XMax, 1);
		}
コード例 #36
0
 private DataRect GetTileBounds(TileIndex id)
 {
     double tileSide = GetTileSide(id.Level);
     DataRect result = new DataRect(id.X * tileSide, id.Y * tileSide, tileSide, tileSide);
     return result;
 }
コード例 #37
0
		protected override void RebuildUI()
		{
			if (Plotter == null)
				return;
			if (DataSource == null)
				return;

			width = DataSource.Width;
			height = DataSource.Height;
			fieldWrapper = new UniformField2DWrapper(DataSource.Data);

			bounds = DataSource.Grid.GetGridBounds();
			particleVelocity = (width + height) * 0.0001;
			Viewport2D.SetContentBounds(this, bounds);

			UpdateParticles(width, height);
		}
コード例 #38
0
ファイル: LineGraph.cs プロジェクト: XiBeichuan/hydronumerics
		protected override void OnVisibleChanged(DataRect newRect, DataRect oldRect)
		{
			if (newRect.Size != oldRect.Size)
			{
				filteredPoints = null;
			}

			base.OnVisibleChanged(newRect, oldRect);
		}