예제 #1
0
        private void OnRender()
        {
            if (Plotter == null)
            {
                return;
            }

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            if (rendering && !renderingPending)
            {
                Dispatcher.BeginInvoke(OnRender);
                return;
            }
            else if (rendering)
            {
                return;
            }

            rendering        = true;
            renderingPending = false;

            ContentPanel.Children.Clear();

            var  transform = Plotter.Viewport.Transform;
            Rect output    = Plotter.Viewport.Output;

            DataRect visible   = Plotter.Viewport.Visible;
            var      tileInfos = GetVisibleTiles();

            var lowerTiles = GetLoadedLowerTiles(tileInfos);

            foreach (var tile in lowerTiles)
            {
                var id = tile.Id;
                if (TileSystem.IsLoaded(id))
                {
                    var      bmp         = TileSystem[id];
                    DataRect visibleRect = Transform(TileProvider.GetTileBounds(id));
                    Rect     screenRect  = visibleRect.DataToScreen(transform);

                    DrawTile(bmp, screenRect, visibleRect, tile.Clip);
                }
                else
                {
                    TileSystem.BeginLoadImage(id);
                }
            }

            foreach (var tileInfo in tileInfos)
            {
                if (TileSystem.IsLoaded(tileInfo.Tile))
                {
                    var bmp = TileSystem[tileInfo.Tile];
                    DrawTile(bmp, tileInfo.ScreenBounds, tileInfo.VisibleBounds, null);
                }
                else
                {
                    TileSystem.BeginLoadImage(tileInfo.Tile);
                }
            }

            rendering = false;
        }