/* #endregion Private Methods */
        /* #region Protected Methods */
        protected override Size ArrangeOverride(Size finalSize)
        {
            var baseVal = base.ArrangeOverride(finalSize);
            //foreach(FrameworkElement child in this.Children)
            //{
            //    var imageRect = new Rect(0,0, 200,200);
            //    child.Arrange(imageRect);
            //}
            var viewport = this.GetViewport();
            var uspan    = UVWavHelpers.GetUSpan(this.StartMs, this.EndMs);

            foreach (var kvp in this.TileControls)
            {
                QuadkeyHelpers.QuadKeyToTileXY(kvp.Key, out int tileX, out int tileY, out int ld);
                var tile        = new Tile(tileX, tileY, ld);
                var tileUV      = tile.Viewport();
                var imageLeft   = finalSize.Width * (tileUV.Left - uspan.Value) / uspan.Width;
                var imageRight  = finalSize.Width * ((tileUV.Left + tileUV.Width) - uspan.Value) / uspan.Width;
                var tileLeftMs  = tileUV.Left * UVWavHelpers.FullRangeProjection.Width;
                var tileWidthMs = tileUV.Width * UVWavHelpers.FullRangeProjection.Width;
                var imageTop    = 0.0;
                var imageHeight = finalSize.Height;
                //var imageLeft = 0.0;
                //var imageWidth = 100.0;
                //var imageTop = 0.0;
                //var imageHeight = 100.0;
                var imageRect = new Rect(imageLeft, imageTop, imageRight - imageLeft, imageHeight);
                //kvp.Value.SetValue(Canvas.LeftProperty, imageLeft);
                //kvp.Value.SetValue(Canvas.TopProperty, imageTop);
                //kvp.Value.Width = imageWidth;
                //kvp.Value.Height = imageHeight;
                kvp.Value.Arrange(imageRect);
            }

            return(finalSize);
        }
        private void InvalidateTiles()
        {
            if (this.FilePath == null)
            {
                return;
            }

            var viewport      = this.GetViewport();
            var tileProvider  = new DefaultTileProvider();
            var levelOfDetail = QuadkeyHelpers.GetLevelOfDetail(viewport);
            //levelOfDetail++;

            var tiles       = tileProvider.GetTiles(levelOfDetail, viewport);
            var tiles1d     = tiles.Where(p => p.TileY() == 0);
            var currentKeys = this.TileControls.Keys.ToArray();
            /* #region Get new, old and existing keys */
            var newTileKeys      = new List <string>();
            var oldTileKeys      = new List <string>();
            var existingTileKeys = new List <string>();

            foreach (var tile in tiles1d)
            {
                if (currentKeys.Contains(tile.Key))
                {
                    existingTileKeys.Add(tile.Key);
                }
                else
                {
                    newTileKeys.Add(tile.Key);
                }
            }

            foreach (var existingKey in currentKeys)
            {
                if (!tiles.Any(p => p.Key == existingKey))
                {
                    oldTileKeys.Add(existingKey);
                }
            }

            /* #endregion*/
            foreach (var newTileKey in newTileKeys)
            {
                var tileControl = new TileControl(this.ServiceProvider, newTileKey, this.FilePath);
                this.TileControls.Add(newTileKey, tileControl);
                this.Children.Add(tileControl);
                //this.AddVisualChild(tileControl);
            }

            foreach (var oldTileKey in oldTileKeys)
            {
                var tileControl = this.TileControls[oldTileKey];
                this.TileControls.Remove(oldTileKey);
                this.Children.Remove(tileControl);
                //this.RemoveVisualChild(tileControl);
            }

            foreach (var existingTile in existingTileKeys)
            {
            }

            this.InvalidateArrange();
        }