private void viewport_PanningStateChanged(object sender, ValueChangedEventArgs <Viewport2DPanningState> e)
 {
     if (e.CurrentValue == Viewport2DPanningState.Panning && e.PreviousValue == Viewport2DPanningState.NotPanning)
     {
         prevVisible = Visible;
     }
     else if (e.CurrentValue == Viewport2DPanningState.NotPanning && e.PreviousValue == Viewport2DPanningState.Panning)
     {
         notMineEvent = true;
         try
         {
             Visible = viewport.Visible;
         }
         finally { notMineEvent = false; }
     }
 }
Beispiel #2
0
        private static object OnCoerceVisible(DependencyObject d, object newValue)
        {
            Viewport2D viewport = (Viewport2D)d;

            DataRect newRect = viewport.CoerceVisible((DataRect)newValue);

            if (newRect.Width == 0 || newRect.Height == 0)
            {
                // doesn't apply rects with zero square
                return(DependencyProperty.UnsetValue);
            }
            else
            {
                return(newRect);
            }
        }
        //bool SizeEqual(Size s1, Size s2, double eps)
        //{
        //    double width = Math.Min(s1.Width, s2.Width);
        //    double height = Math.Min(s1.Height, s2.Height);
        //    return Math.Abs(s1.Width - s2.Width) < width * eps &&
        //           Math.Abs(s1.Height - s2.Height) < height * eps;
        //}

        protected virtual void OnVisibleChanged(DataRect newRect, DataRect oldRect)
        {
            if (newRect.Size == oldRect.Size)
            {
                var transform = viewport.Transform;
                offset += oldRect.Location.DataToScreen(transform) - newRect.Location.DataToScreen(transform);
                if (ManualTranslate)
                {
                    Update();
                }
            }
            else
            {
                offset = new Vector();
                Update();
            }
        }
        private static object CoerceContentBounds(DependencyObject d, object value)
        {
            DataRect prevBounds = GetContentBounds(d);
            DataRect currBounds = (DataRect)value;

            bool approximateComparanceAllowed = GetUsesApproximateContentBoundsComparison(d);

            bool areClose = approximateComparanceAllowed && currBounds.IsCloseTo(prevBounds, 0.005);

            if (areClose)
            {
                return(DependencyProperty.UnsetValue);
            }
            else
            {
                return(value);
            }
        }
        protected override DataRect CoerceVisible(DataRect newVisible, DataRect baseVisible)
        {
            DataRect result = newVisible;

            if (Plotter == null)
            {
                return(baseVisible);
            }

            DataRect outerVisible = Plotter.Viewport.Visible;

            double xMin = outerVisible.XMin * xScale + xShift;
            double xMax = outerVisible.XMax * xScale + xShift;
            double yMin = outerVisible.YMin * yScale + yShift;
            double yMax = outerVisible.YMax * yScale + yShift;

            outerVisible = DataRect.Create(xMin, yMin, xMax, yMax);

            switch (ConjunctionMode)
            {
            case ViewportConjunctionMode.None:
                result = baseVisible;
                break;

            case ViewportConjunctionMode.X:
                result = new DataRect(outerVisible.XMin, baseVisible.YMin, outerVisible.Width, baseVisible.Height);
                break;

            case ViewportConjunctionMode.Y:
                result = new DataRect(baseVisible.XMin, outerVisible.YMin, baseVisible.Width, outerVisible.Height);
                break;

            case ViewportConjunctionMode.XY:
                result = outerVisible;
                break;

            default:
                break;
            }

            return(result);
        }
Beispiel #6
0
        public static void Zoom(this Viewport2D viewport, double factor)
        {
            if (factor > 1 && viewport.Visible.XMax - viewport.Visible.XMin > 2000)
            {
                return;
            }
            else if (factor < 1 && viewport.Visible.XMax - viewport.Visible.XMin < 1)
            {
                return;
            }
            DataRect visible    = viewport.Visible;
            DataRect oldVisible = visible;
            Point    center     = visible.GetCenter();
            Vector   halfSize   = new Vector(visible.Width * factor / 2, visible.Height * factor / 2);

            //Vector halfSize = new Vector(visible.Width * factor / 2, visible.Height / 2);//Y轴不能被缩放
            viewport.Visible = new DataRect(center - halfSize, center + halfSize);

            viewport.Plotter.UndoProvider.AddAction(new DependencyPropertyChangedUndoAction(viewport, Viewport2D.VisibleProperty, oldVisible, visible));
        }
        void Viewport_PropertyChanged(object sender, ExtendedPropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Visible")
            {
                DataRect prevVisible = (DataRect)e.OldValue;
                DataRect currVisible = (DataRect)e.NewValue;

                if (currVisible.Size != prevVisible.Size)
                {
                    Update();
                }
                else
                {
                    UpdateTransform();
                }
            }
            else
            {
                Update();
            }
        }
Beispiel #8
0
        private void CreateRenderTask(DataRect visible, Rect output)
        {
            lock (this)
            {
                bitmapInvalidated = true;

                if (activeRequest != null)
                {
                    activeRequest.Cancel();
                }
                pendingRequest = new RenderRequest(nextRequestId++, visible, output);
                renderRequested.Set();
            }
            if (renderThread == null)
            {
                renderThread = new Thread(RenderThreadFunc);
                renderThread.IsBackground = true;
                renderThread.SetApartmentState(ApartmentState.STA);
                renderThread.Start();
            }
        }
        private void MakePlots()
        {
            if (!PlotsMade) //Only do this once
            {
                Model  mShe         = new Model(SheFileName);
                DFS3   dfs          = new DFS3(Dfs3FileName);
                Item   dfsI         = dfs.Items[ItemNumber - 1];
                string BaseFileName = System.IO.Path.ChangeExtension(Dfs3FileName, "");

                int[] TimeSteps = Dfs3plotdfs0.MainWindow.ParseString(TimeStepsAsString, 0, dfs.NumberOfTimeSteps - 1);
                int[] Layers    = Dfs3plotdfs0.MainWindow.ParseString(LayersAsString, 0, dfs.NumberOfLayers - 1);

                //Set graph headers
                Header.Content = dfsI.Name;
                Unit.Content   = dfsI.EumQuantity.UnitAbbreviation;

                //Give plot the same scale as the dfs grid
                plotter.Width = plotter.Height * ((double)dfs.NumberOfColumns) / (double)dfs.NumberOfRows;

                //Plot the extraction wells
                EnumerableDataSource <MikeSheWell> ds = new EnumerableDataSource <MikeSheWell>(mShe.ExtractionWells);
                ds.SetXMapping(var => var.X);
                ds.SetYMapping(var => var.Y);
                var point = new Microsoft.Research.DynamicDataDisplay.PointMarkers.CirclePointMarker();
                point.Size = 10;
                point.Pen  = new Pen(Brushes.Black, 3);
                plotter.AddLineGraph(ds, null, point, null);

                //Now loop, first on time steps then on layers
                foreach (int T in TimeSteps)
                {
                    foreach (int L in Layers)
                    {
                        Header2.Content = "Time: " + dfs.TimeSteps[T].ToShortDateString() + ", Layer: " + L;
                        var           M  = dfs.GetData(T, ItemNumber)[L];
                        NaiveColorMap nc = new NaiveColorMap();
                        M.Transpose(); //Need to transpose
                        nc.Data = M.ToArray();
                        M.Transpose(); //Transpose back as this is a reference to data held in the buffer
                        nc.Palette = Microsoft.Research.DynamicDataDisplay.Common.Palettes.UniformLinearPalettes.RedGreenBluePalette;
                        var bmp = nc.BuildImage();
                        image.Source = bmp;

                        //Set the color scale
                        paletteControl.Palette = nc.Palette;
                        paletteControl.Range   = nc.Data.GetMinMax();

                        //Set the size
                        var visible = new Microsoft.Research.DynamicDataDisplay.DataRect(dfs.XOrigin, dfs.YOrigin, dfs.GridSize * dfs.NumberOfColumns, dfs.GridSize * dfs.NumberOfRows);
                        ViewportPanel.SetViewportBounds(image, visible);
                        plotter.Visible = visible;

                        //Write the bitmap
                        this.UpdateLayout();
                        string fname = BaseFileName + "TimeStep_" + T + "_Layer_" + L;
                        Dfs3plotdfs0.MainWindow.SaveScreen(this, fname + ".jpg", (int)ActualWidth, (int)ActualHeight);

                        //Now write the ascii grid
                        using (StreamWriter sw = new StreamWriter(fname + ".asc"))
                        {
                            sw.Write(dfs.GetASCIIGrid(T, ItemNumber, L));
                        }
                    }
                }
            }
        }
 public static DataRect WithY(this DataRect rect, double ymin, double ymax)
 {
     return(DataRect.Create(rect.XMin, ymin, rect.XMax, ymax));
 }
 public static void SetContentBounds(DependencyObject obj, DataRect value)
 {
     obj.SetValue(ContentBoundsProperty, value);
 }
Beispiel #12
0
 protected virtual UIElement GetTooltipForPoint(Point point, DataRect visible, Rect output)
 {
     return(null);
 }
Beispiel #13
0
 public RenderRequest(int requestId, DataRect visible, Rect output)
 {
     this.requestId = requestId;
     this.visible   = visible;
     this.output    = output;
 }
		protected abstract DataRect CoerceVisible(DataRect newVisible, DataRect baseVisible);
Beispiel #15
0
        protected override void OnRenderCore(DrawingContext dc, RenderState state)
        {
            if (DataSource == null)
            {
                return;
            }
            if (Marker == null)
            {
                return;
            }
            if (Marker.markers == null)
            {
                return;
            }

            var transform = Plotter2D.Viewport.Transform;

            DataRect            bounds = DataRect.Empty;
            IEnumerable <Point> ps     = GetPoints();//实际值
            List <Point>        buf    = new List <Point>(ps);

            if (buf.Count < 1)
            {
                return;
            }
            double xstart = buf[0].X;

            foreach (MarkersPoint mp in Marker.markers)
            {
                try
                {
                    int   idx         = (int)((mp.x - xstart) / Step.len);
                    Point screenPoint = buf[idx].DataToScreen(transform);
                    bounds = DataRect.Union(bounds, buf[idx]);
                    Marker.Render(dc, screenPoint, mp);//画标记
                }
                catch (Exception ex)
                {
                    return;
                }
            }
            Viewport2D.SetContentBounds(this, bounds);
            return;

            using (IPointEnumerator enumerator = DataSource.GetEnumerator(GetContext()))
            {
                Point point = new Point();
                int   i     = 0;

                while (enumerator.MoveNext())
                {
                    enumerator.GetCurrent(ref point);
                    if (!Marker.markers.Contains(new MarkersPoint {
                        x = (float)point.X
                    }))
                    {
                        continue;
                    }
                    enumerator.ApplyMappings(Marker);
                    i++;
                    MarkersPoint mp = Marker.markers[i - 1];
                    //Point screenPoint = point.Transform(state.Visible, state.Output);
                    Point screenPoint = point.DataToScreen(transform);

                    bounds = DataRect.Union(bounds, point);
                    Marker.Render(dc, screenPoint, mp);                   //画标记
                }
            }

            Viewport2D.SetContentBounds(this, bounds);
        }
Beispiel #16
0
 public static Point GetCenter(this DataRect rect)
 {
     return(new Point(rect.XMin + rect.Width * 0.5, rect.YMin + rect.Height * 0.5));
 }
 public static DataRect RectZoom(DataRect rect, double horizontalRatio, double verticalRatio)
 {
     return(RectZoom(rect, rect.GetCenter(), horizontalRatio, verticalRatio));
 }
Beispiel #18
0
 protected override void OnVisibleChanged(DataRect newRect, DataRect oldRect)
 {
     base.OnVisibleChanged(newRect, oldRect);
     InvalidateVisual();
 }
Beispiel #19
0
 protected abstract DataRect CreateVisibleRect(DataRect rect, double value);
Beispiel #20
0
        protected virtual DataRect CoerceVisible(DataRect newVisible)
        {
            if (Plotter == null)
            {
                return(newVisible);
            }

            bool isDefaultValue = newVisible == (DataRect)VisibleProperty.DefaultMetadata.DefaultValue;

            if (isDefaultValue)
            {
                newVisible = DataRect.Empty;
            }

            if (isDefaultValue && IsFittedToView)
            {
                // determining content bounds
                DataRect bounds = DataRect.Empty;

                foreach (var item in contentBoundsHosts)
                {
                    IPlotterElement plotterElement = item as IPlotterElement;
                    if (plotterElement == null)
                    {
                        continue;
                    }
                    if (plotterElement.Plotter == null)
                    {
                        continue;
                    }

                    var plotter = (Plotter2D)plotterElement.Plotter;
                    var visual  = plotter.VisualBindings[plotterElement];
                    if (visual.Visibility == Visibility.Visible)
                    {
                        DataRect contentBounds = Viewport2D.GetContentBounds(item);
                        if (contentBounds.Width.IsNaN() || contentBounds.Height.IsNaN())
                        {
                            continue;
                        }

                        bounds.UnionFinite(contentBounds);
                    }
                }

                if (useApproximateContentBoundsComparison)
                {
                    var intersection = prevContentBounds;
                    intersection.Intersect(bounds);

                    double currSquare         = bounds.GetSquare();
                    double prevSquare         = prevContentBounds.GetSquare();
                    double intersectionSquare = intersection.GetSquare();

                    double squareTopLimit    = 1 + maxContentBoundsComparisonMistake;
                    double squareBottomLimit = 1 - maxContentBoundsComparisonMistake;

                    if (intersectionSquare != 0)
                    {
                        double currRatio = currSquare / intersectionSquare;
                        double prevRatio = prevSquare / intersectionSquare;

                        if (squareBottomLimit < currRatio &&
                            currRatio < squareTopLimit &&
                            squareBottomLimit < prevRatio &&
                            prevRatio < squareTopLimit)
                        {
                            bounds = prevContentBounds;
                        }
                    }
                }

                prevContentBounds   = bounds;
                UnitedContentBounds = bounds;

                // applying fit-to-view restrictions
                bounds = fitToViewRestrictions.Apply(Visible, bounds, this);

                // enlarging 放大
                if (!bounds.IsEmpty)
                {
                    if ((MaxWidth > 0 && bounds.Width > MaxWidth))//设置了最大宽度
                    {
                        //bounds.XMin = 0 ;
                        bounds.Width  = MaxWidth;
                        bounds.Height = (MaxHeight >= 0 && bounds.Height > MaxHeight) ? MaxHeight : bounds.Height;
                        bounds        = bounds.DataToViewport(transform);
                    }
                    //else bounds = CoordinateUtilities.RectZoom(bounds, bounds.GetCenter(), clipToBoundsEnlargeFactor);
                }
                else
                {
                    bounds = (DataRect)VisibleProperty.DefaultMetadata.DefaultValue;
                }
                newVisible.Union(bounds);
            }

            if (newVisible.IsEmpty)
            {
                newVisible = (DataRect)VisibleProperty.DefaultMetadata.DefaultValue;
            }
            else if (newVisible.Width == 0 || newVisible.Height == 0)
            {
                DataRect defRect = (DataRect)VisibleProperty.DefaultMetadata.DefaultValue;
                Size     size    = newVisible.Size;
                Point    loc     = newVisible.Location;

                if (newVisible.Width == 0)
                {
                    size.Width = defRect.Width;
                    loc.X     -= size.Width / 2;
                }
                if (newVisible.Height == 0)
                {
                    size.Height = defRect.Height;
                    loc.Y      -= size.Height / 2;
                }

                newVisible = new DataRect(loc, size);
            }

            // apply domain restriction
            newVisible = domainRestriction.Apply(Visible, newVisible, this);

            // apply other restrictions
            newVisible = restrictions.Apply(Visible, newVisible, this);

            // applying transform's data domain restriction
            if (!transform.DataTransform.DataDomain.IsEmpty)
            {
                var newDataRect = newVisible.ViewportToData(transform);
                newDataRect = DataRect.Intersect(newDataRect, transform.DataTransform.DataDomain);
                newVisible  = newDataRect.DataToViewport(transform);
            }

            if (newVisible.IsEmpty)
            {
                newVisible = new Rect(0, 0, 1, 1);
            }

            return(newVisible);
        }
    private void MakePlots()
    {
      if (!PlotsMade) //Only do this once
      {
        Model mShe = new Model(SheFileName);
        DFS3 dfs = new DFS3(Dfs3FileName);
        Item dfsI = dfs.Items[ItemNumber - 1];
        string BaseFileName = System.IO.Path.ChangeExtension(Dfs3FileName, "");

        int[] TimeSteps = Dfs3plotdfs0.MainWindow.ParseString(TimeStepsAsString, 0, dfs.NumberOfTimeSteps - 1);
        int[] Layers = Dfs3plotdfs0.MainWindow.ParseString(LayersAsString, 0, dfs.NumberOfLayers - 1);

        //Set graph headers
        Header.Content = dfsI.Name;
        Unit.Content = dfsI.EumQuantity.UnitAbbreviation;

        //Give plot the same scale as the dfs grid
        plotter.Width = plotter.Height * ((double)dfs.NumberOfColumns) / (double)dfs.NumberOfRows;

        //Plot the extraction wells
        EnumerableDataSource<MikeSheWell> ds = new EnumerableDataSource<MikeSheWell>(mShe.ExtractionWells);
        ds.SetXMapping(var => var.X);
        ds.SetYMapping(var => var.Y);
        var point = new Microsoft.Research.DynamicDataDisplay.PointMarkers.CirclePointMarker();
        point.Size = 10;
        point.Pen = new Pen(Brushes.Black, 3);
        plotter.AddLineGraph(ds, null, point, null);

        //Now loop, first on time steps then on layers
        foreach (int T in TimeSteps)
        {
          foreach (int L in Layers)
          {
            Header2.Content = "Time: " + dfs.TimeSteps[T].ToShortDateString() + ", Layer: " + L; 
            var M = dfs.GetData(T, ItemNumber)[L];
            NaiveColorMap nc = new NaiveColorMap();
            M.Transpose(); //Need to transpose
            nc.Data = M.ToArray();
            M.Transpose(); //Transpose back as this is a reference to data held in the buffer
            nc.Palette = Microsoft.Research.DynamicDataDisplay.Common.Palettes.UniformLinearPalettes.RedGreenBluePalette;
            var bmp = nc.BuildImage();
            image.Source = bmp;

            //Set the color scale
            paletteControl.Palette = nc.Palette;
            paletteControl.Range = nc.Data.GetMinMax();
            
            //Set the size
            var visible = new Microsoft.Research.DynamicDataDisplay.DataRect(dfs.XOrigin, dfs.YOrigin, dfs.GridSize*dfs.NumberOfColumns, dfs.GridSize * dfs.NumberOfRows);            
            ViewportPanel.SetViewportBounds(image, visible);
            plotter.Visible = visible;

            //Write the bitmap
            this.UpdateLayout();
            string fname = BaseFileName + "TimeStep_" +T + "_Layer_" + L;
            Dfs3plotdfs0.MainWindow.SaveScreen(this, fname + ".jpg", (int)ActualWidth, (int)ActualHeight);

            //Now write the ascii grid
            using (StreamWriter sw = new StreamWriter(fname + ".asc"))
            {
              sw.Write(dfs.GetASCIIGrid(T, ItemNumber, L)); 
            }
          }
        }
      }
    }
Beispiel #22
0
 public static DataRect ZoomInToCenter(this DataRect rect, double ratio)
 {
     return(CoordinateUtilities.RectZoom(rect, rect.GetCenter(), 1 / ratio));
 }
Beispiel #23
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);
                    }
                }
            }
        }
        internal static CoordinateTransform FromRects(DataRect visibleRect, Rect screenRect)
        {
            CoordinateTransform result = new CoordinateTransform(visibleRect, screenRect);

            return(result);
        }
Beispiel #25
0
 protected abstract BitmapSource RenderFrame(DataRect visible, Rect output);
Beispiel #26
0
		private static bool ValidateVisibleCallback(object value)
		{
			DataRect rect = (DataRect)value;

			return !rect.IsNaN();
		}
Beispiel #27
0
 public static DataRect ZoomY(this DataRect rect, Point to, double ratio)
 {
     return(CoordinateUtilities.RectZoomY(rect, to, ratio));
 }
 public static DataRect RectZoom(DataRect rect, double ratio)
 {
     return(RectZoom(rect, rect.GetCenter(), ratio));
 }
Beispiel #29
0
		private DataRect CoerceVisible(DataRect newVisible)
		{
			if (Plotter == null)
			{
				return newVisible;
			}

			bool isDefaultValue = newVisible == (DataRect)VisibleProperty.DefaultMetadata.DefaultValue;
			if (isDefaultValue)
			{
				newVisible = DataRect.Empty;
			}

			if (isDefaultValue && IsFittedToView)
			{
				// determining content bounds
				DataRect bounds = DataRect.Empty;

				foreach (var item in contentBoundsHosts)
				{
					var visual = plotter.VisualBindings[item];
					if (visual.Visibility == Visibility.Visible)
					{
						DataRect contentBounds = (DataRect)visual.GetValue(Viewport2D.ContentBoundsProperty);
						bounds.UnionFinite(contentBounds);
					}
				}

				DataRect viewportBounds = bounds;
				ContentBounds = bounds;

				// applying fit-to-view restrictions
				bounds = fitToViewRestrictions.Apply(Visible, bounds, this);

				// enlarging
				if (!bounds.IsEmpty)
				{
					bounds = CoordinateUtilities.RectZoom(bounds, bounds.GetCenter(), clipToBoundsEnlargeFactor);
				}
				else
				{
					bounds = (DataRect)VisibleProperty.DefaultMetadata.DefaultValue;
				}
				newVisible.Union(bounds);
			}

			if (newVisible.IsEmpty)
			{
				newVisible = (DataRect)VisibleProperty.DefaultMetadata.DefaultValue;
			}
			else if (newVisible.Width == 0 || newVisible.Height == 0)
			{
				DataRect defRect = (DataRect)VisibleProperty.DefaultMetadata.DefaultValue;
				Size size = newVisible.Size;
				Point loc = newVisible.Location;

				if (newVisible.Width == 0)
				{
					size.Width = defRect.Width;
					loc.X -= size.Width / 2;
				}
				if (newVisible.Height == 0)
				{
					size.Height = defRect.Height;
					loc.Y -= size.Height / 2;
				}

				newVisible = new DataRect(loc, size);
			}

			// apply domain restriction
			newVisible = domainRestriction.Apply(Visible, newVisible, this);

			// apply other restrictions
			newVisible = restrictions.Apply(Visible, newVisible, this);

			// applying transform's data domain restriction
			if (!transform.DataTransform.DataDomain.IsEmpty)
			{
				var newDataRect = newVisible.ViewportToData(transform);
				newDataRect = DataRect.Intersect(newDataRect, transform.DataTransform.DataDomain);
				newVisible = newDataRect.DataToViewport(transform);
			}

			if (newVisible.IsEmpty) newVisible = new Rect(0, 0, 1, 1);

			return newVisible;
		}
 public static DataRect RectZoom(DataRect rect, Point zoomCenter, double ratio)
 {
     return(RectZoom(rect, zoomCenter, ratio, ratio));
 }
Beispiel #31
0
 protected override void OnVisibleChanged(DataRect newRect, DataRect oldRect)
 {
     base.OnVisibleChanged(newRect, oldRect);
     CreateRenderTask(newRect, Viewport.Output);
     InvalidateVisual();
 }