示例#1
0
        /// <summary>
        /// Constructs a new MapView object.
        /// </summary>
        public MapView()
        {
            _baseMapView = new BaseMapView();

            InitializeComponent();

            this.Loaded += new Windows.UI.Xaml.RoutedEventHandler(OnPageLoaded);

            Windows.UI.Core.CoreWindow window = Windows.UI.Xaml.Window.Current.CoreWindow;
            window.VisibilityChanged += new Windows.Foundation.TypedEventHandler <Windows.UI.Core.CoreWindow, Windows.UI.Core.VisibilityChangedEventArgs> (OnVisibilityChanged);

            _swapChainPanel.SizeChanged += new Windows.UI.Xaml.SizeChangedEventHandler(OnSwapChainPanelSizeChanged);
            _swapChainPanelSize          = new Windows.Foundation.Size(_swapChainPanel.RenderSize.Width, _swapChainPanel.RenderSize.Height);

            Windows.Graphics.Display.DisplayInformation dispInfo = Windows.Graphics.Display.DisplayInformation.GetForCurrentView();
            _resolutionScale = (float)dispInfo.RawPixelsPerViewPixel;
            _baseMapView.GetOptions().DPI = (float)dispInfo.RawDpiX;

            _baseMapView.SetRedrawRequestListener(new MapViewRedrawRequestListener(this));
        }
示例#2
0
        private void InitBase()
        {
            this.Delegate = new MapViewGLKViewDelegate();

            _didEnterBackgroundNotificationObserver  = NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.DidEnterBackgroundNotification, OnAppDidEnterBackground, null);
            _willEnterForegroundNotificationObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.WillEnterForegroundNotification, OnAppWillEnterForeground, null);

            _active = true;

            _scale = (float)UIScreen.MainScreen.NativeScale;

            _baseMapView = new BaseMapView();
            _baseMapView.GetOptions().DPI = 160 * _scale;

            _redrawRequestListener = new MapRedrawRequestListener(this);
            _baseMapView.SetRedrawRequestListener(_redrawRequestListener);

            _viewContext = new EAGLContext(EAGLRenderingAPI.OpenGLES2);
            if (_viewContext == null)
            {
                Log.Fatal("MapView.InitGL: Failed to create OpenGLES 2.0 context");
            }
            this.Context            = _viewContext;
            this.ContentScaleFactor = _scale;

            DrawableColorFormat   = GLKViewDrawableColorFormat.RGBA8888;
            DrawableDepthFormat   = GLKViewDrawableDepthFormat.Format24;
            DrawableMultisample   = GLKViewDrawableMultisample.None;
            DrawableStencilFormat = GLKViewDrawableStencilFormat.Format8;
            MultipleTouchEnabled  = true;

            if (_viewContext != null)
            {
                EAGLContext.SetCurrentContext(_viewContext);
                _baseMapView.OnSurfaceCreated();
                _baseMapView.OnSurfaceChanged((int)(Bounds.Size.Width * _scale), (int)(Bounds.Size.Height * _scale));
            }

            SetNeedsDisplay();
        }