public LayerBackgroundMap(Canvas parent_canvas, ExplorerContentMap parent_map) { parentCanvas = parent_canvas; parentCanvas.Children.Add(this); parentMap = parent_map; Image mapImage = parentMap.getImage(); background = new Canvas(); background.Background = new ImageBrush(mapImage.Source); background.MinWidth = mapImage.Source.Width; background.MaxWidth = mapImage.Source.Width; background.MinHeight = mapImage.Source.Height; background.MaxHeight = mapImage.Source.Height; Child = background; IsRSTEnabled = true; IsRotateEnabled = false; //Prevent rotation since bounds algo doesnt take that into consideration IsScaleEnabled = true; IsFlickEnabled = false; //Prevent and twitchy behavior IsStayInboundsEnabled = false; //Prevent the shifting when zoomed in IsMoveToTopOnTouchEnabled = false; //Prevent the layer from coming above other layers BehaviorSingleClickHelper clickHelper = new BehaviorSingleClickHelper(parentCanvas); clickHelper.OnSingleClick += clickHelper_OnSingleClick; Attach(clickHelper); Attach(new BehaviorBoundMapToScreen(parent_canvas, mapImage.Source.Width, mapImage.Source.Height)); }
public DraggableBackgroundMap(ExplorerContentMap parent_map) { parentMap = parent_map; Image mapImage = parentMap.getImage(); parentCanvas = new Canvas(); parentCanvas.Background = new ImageBrush(mapImage.Source); parentCanvas.MinWidth = mapImage.Source.Width; parentCanvas.MaxWidth = mapImage.Source.Width; parentCanvas.MinHeight = mapImage.Source.Height; parentCanvas.MaxHeight = mapImage.Source.Height; Child = parentCanvas; IsRSTEnabled = false; IsRNTEnabled = true; IsRotateEnabled = false; IsFlickEnabled = false; BehaviorSingleClickHelper clickHelper = new BehaviorSingleClickHelper(); clickHelper.OnSingleClick += clickHelper_OnSingleClick; Attach(clickHelper); Attach( new BehaviorBoundMapToScreen(mapImage.Source.Width, mapImage.Source.Height)); foreach(ExplorerRegion region in parent_map.getRegions()) { Console.WriteLine("Adding " + region.getName()); Polygon regionPolygon = new Polygon(); foreach(ExplorerPoint point in region.getPoints()) { regionPolygon.Points.Add(new Point(point.getX() / 2 * ScaleTransform.ScaleX, point.getY() / 2 * ScaleTransform.ScaleY)); } regionPolygon.Fill = new SolidColorBrush(Color.FromArgb(128, 255, 0, 0)); parentCanvas.Children.Add(regionPolygon); } }