예제 #1
0
		private void Viewport_PropertyChanged(object sender, ExtendedPropertyChangedEventArgs e)
		{
			var transform = plotter.Viewport.Transform;

			bool ok = false;
			do
			{
				double width = tileProvider.GetTileWidth(tileProvider.Level);
				double height = tileProvider.GetTileHeight(tileProvider.Level);

				Rect size = new Rect(new Size(width, height));
				Rect onScreen = size.ViewportToScreen(transform);

				// todo написать нормально
				if (onScreen.Width > tileWidth * 1.45)
				{
					if (tileProvider.IncreaseLevel())
					{
						continue;
					}
				}
				else if (onScreen.Width < tileWidth / 1.45)
				{
					if (tileProvider.DecreaseLevel())
					{
						continue;
					}
				}
				ok = true;
			} while (!ok);

			BeginInvalidateVisual();
		}