<commit_before>using Windows.UI;

using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.UI;
using Microsoft.Graphics.Canvas.UI.Xaml;

using UniversalMapControl.Interfaces;
using UniversalMapControl.Tiles.Default;

namespace UniversalMapControl.Tiles
{
	public class TileLayer : CanvasMapLayer
	{
		public TileLayer()
		{
			LayerConfiguration = new DefaultWebLayerConfig();
			ShowLoadingOverlay = false;
			LoadingOverlayColor = Color.FromArgb(100, 150, 150, 150);
		}

		public ILayerConfiguration LayerConfiguration { get; set; }

		public bool ShowLoadingOverlay { get; set; }

		public Color LoadingOverlayColor { get; set; }

		protected override void OnCreateResource(CanvasControl sender, CanvasCreateResourcesEventArgs args)
		{
			// Clear all Tiles and Reload (Display Device might have changed...)
			LayerConfiguration.TileProvider.ResetTiles(ParentMap, sender);
		}

		protected override void DrawInternal(CanvasDrawingSession drawingSession, Map parentMap)
		{
			LayerConfiguration.TileProvider.RefreshTiles(ParentMap);
			double zoomFactor = parentMap.ViewPortProjection.GetZoomFactor(parentMap.ZoomLevel);

			foreach (ICanvasBitmapTile tile in LayerConfiguration.TileProvider.GetTiles(zoomFactor))
			{
				if (tile.State == TileState.TileDoesNotExist)
				{
					continue;
				}
				CanvasBitmap canvasBitmap = tile.GetCanvasBitmap();
				if (canvasBitmap != null)
				{
					drawingSession.DrawImage(canvasBitmap, tile.Bounds);
				}
				else if (ShowLoadingOverlay)
				{
					drawingSession.FillRectangle(tile.Bounds, LoadingOverlayColor);
				}
			}
		}
	}<commit_msg>Extracted drawing of replacement Tiles into methods.<commit_after>using Windows.UI;

using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.UI;
using Microsoft.Graphics.Canvas.UI.Xaml;

using UniversalMapControl.Interfaces;
using UniversalMapControl.Tiles.Default;

namespace UniversalMapControl.Tiles
{
	public class TileLayer : CanvasMapLayer
	{
		public TileLayer()
		{
			LayerConfiguration = new DefaultWebLayerConfig();
			ShowLoadingOverlay = false;
			LoadingOverlayColor = Color.FromArgb(100, 150, 150, 150);
		}

		public ILayerConfiguration LayerConfiguration { get; set; }

		public bool ShowLoadingOverlay { get; set; }

		public Color LoadingOverlayColor { get; set; }

		protected override void OnCreateResource(CanvasControl sender, CanvasCreateResourcesEventArgs args)
		{
			// Clear all Tiles and Reload (Display Device might have changed...)
			LayerConfiguration.TileProvider.ResetTiles(ParentMap, sender);
		}

		protected override void DrawInternal(CanvasDrawingSession drawingSession, Map parentMap)
		{
			LayerConfiguration.TileProvider.RefreshTiles(ParentMap);
			double zoomFactor = parentMap.ViewPortProjection.GetZoomFactor(parentMap.ZoomLevel);

			foreach (ICanvasBitmapTile tile in LayerConfiguration.TileProvider.GetTiles(zoomFactor))
			{
				if (tile.State == TileState.TileDoesNotExist)
				{
					DrawInexistentTile(drawingSession, tile, parentMap);
					continue;
				}
				CanvasBitmap canvasBitmap = tile.GetCanvasBitmap();
				if (canvasBitmap != null)
				{
					drawingSession.DrawImage(canvasBitmap, tile.Bounds);
				}
				else if (ShowLoadingOverlay)
				{
					DrawLoadingTile(drawingSession, tile, parentMap);
				}
			}
		}

		protected virtual void DrawInexistentTile(CanvasDrawingSession drawingSession, ICanvasBitmapTile tile, Map parentMap)
		{}

		protected virtual void DrawLoadingTile(CanvasDrawingSession drawingSession, ICanvasBitmapTile tile, Map parentMap)
		{
			drawingSession.FillRectangle(tile.Bounds, LoadingOverlayColor);
		}
	}
{'fraction_non_alphanumeric': 0.08176274944567627, 'fraction_numerical': 0.0066518847006651885, 'mean_word_length': 4.7744, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6872609', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1002, 'n_words': 224}