private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set window bounds in dips m_d3dInterop.WindowBounds = new Windows.Foundation.Size((float)DrawingSurface.ActualWidth, (float)DrawingSurface.ActualHeight); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size((float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; // Hook-up native component to DrawingSurface DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider(m_username, false)); DrawingSurface.SetManipulationHandler(m_d3dInterop); m_d3dInterop.setWinRtCallback(new WinRtCallback(ProcessCallback)); string preGameUpdate = "{\"" + EVENT_TYPE + "\":" + PRE_GAME + ",\"" + PHASE + "\":" + CONNECTING + "}"; Deployment.Current.Dispatcher.BeginInvoke(() => { m_d3dInterop.onChatReceived(preGameUpdate); WarpClient.GetInstance().AddConnectionRequestListener(m_connectionRequestListener); WarpClient.GetInstance().AddNotificationListener(m_notifyListener); WarpClient.GetInstance().Connect(m_username, AppWarpConstants.APPWARP_AUTH_DATA); }); } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set WindowBounds to size of DrawingSurface m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)Application.Current.Host.Content.ActualWidth, (float)Application.Current.Host.Content.ActualHeight ); // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); // Set the preferred device orientation m_d3dInterop.WindowOrientation = DisplayOrientations.Landscape; // Hook-up Cocos2d-x delegates m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent); m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox); } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { // Set window bounds in dips m_d3dBackground.WindowBounds = new Windows.Foundation.Size( (float)Application.Current.Host.Content.ActualWidth, (float)Application.Current.Host.Content.ActualHeight ); // Set native resolution in pixels m_d3dBackground.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); // Set render resolution to the full native resolution m_d3dBackground.RenderResolution = m_d3dBackground.NativeResolution; // Hook-up native component to DrawingSurface if (m_d3dContentProvider == null) { m_d3dContentProvider = m_d3dBackground.CreateContentProvider(); } // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dContentProvider); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dBackground); }
private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) { // Set window bounds in dips m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)DrawingSurface.ActualWidth, (float)DrawingSurface.ActualHeight ); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; // Hook-up native component to DrawingSurface DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurface.SetManipulationHandler(m_d3dInterop); Deployment.Current.Dispatcher.BeginInvoke(() => { StreamResourceInfo resourceInfo = Application.GetResourceStream(new Uri("Assets/Lena.png", UriKind.Relative)); BitmapImage bitmap = new BitmapImage(); bitmap.SetSource(resourceInfo.Stream); m_bmp = new WriteableBitmap(bitmap); m_d3dInterop.CreateTexture(m_bmp.Pixels, m_bmp.PixelWidth, m_bmp.PixelHeight, OCVFilterType.ePreview); m_bInitialized = true; }); }
private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set window bounds in dips m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)DrawingSurface.ActualWidth, (float)DrawingSurface.ActualHeight ); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; // Hook-up native component to DrawingSurface DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurface.SetManipulationHandler(m_d3dInterop); } }
private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set window bounds in dips m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)DrawingSurface.ActualWidth, (float)DrawingSurface.ActualHeight ); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurface.SetManipulationHandler(m_d3dInterop); m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); EditBoxDelegate editBoxDelegate = new EditBoxDelegate(); EditBoxImpl editBoxImpl = new EditBoxImpl(); editBoxImpl.setMainPage(this); editBoxImpl.setD3dInterop(m_d3dInterop); editBoxDelegate.SetCallback(editBoxImpl); } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { PageOrientation pageOrientation = (PageOrientation)GetValue(OrientationProperty); DisplayOrientations displayOrientation = ConvertToNativeOrientation(pageOrientation); m_d3dInterop = new Direct3DInterop(displayOrientation); // Set WindowBounds to size of DrawingSurface m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)Application.Current.Host.Content.ActualWidth, (float)Application.Current.Host.Content.ActualHeight ); // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); // Hook-up Cocos2d-x delegates m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent); m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox); m_d3dInterop.SetCocos2dOpenURLDelegate(OpenURL); } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { PageOrientation pageOrientation = (PageOrientation)GetValue(OrientationProperty); DisplayOrientations displayOrientation; switch (pageOrientation) { case PageOrientation.Portrait: case PageOrientation.PortraitUp: displayOrientation = DisplayOrientations.Portrait; break; case PageOrientation.PortraitDown: displayOrientation = DisplayOrientations.PortraitFlipped; break; case PageOrientation.Landscape: case PageOrientation.LandscapeLeft: displayOrientation = DisplayOrientations.Landscape; break; case PageOrientation.LandscapeRight: displayOrientation = DisplayOrientations.LandscapeFlipped; break; default: displayOrientation = DisplayOrientations.Landscape; break; } m_d3dInterop = new Direct3DInterop(displayOrientation); // Set WindowBounds to size of DrawingSurface m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)Application.Current.Host.Content.ActualWidth, (float)Application.Current.Host.Content.ActualHeight ); // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); // Hook-up Cocos2d-x delegates m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent); m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox); m_d3dInterop.SetCocos2dOpenURLDelegate(OpenURL); } }
private void drawingSurfacebg_Loaded(object sender, RoutedEventArgs e) { cb = new ONSCL_Callback(this); if (m_d3dBackground == null) { m_d3dBackground = new Direct3DInterop(gamefolder); //横屏 double deviceh = Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0); double devicew = Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0); double xamlh = Application.Current.Host.Content.ActualWidth; double xamlw = Application.Current.Host.Content.ActualHeight; switch (ONSCL_GameInfoPage.nsg.screentype) { case 1: m_d3dBackground.SetONSResolutionAndDisplayMode((int)deviceh * 4 / 3, (int)deviceh, 640, 480, 0xF); drawingSurfacebg.Width = 640; break; case 2: m_d3dBackground.SetONSResolutionAndDisplayMode((int)devicew, (int)devicew * 3 / 4, 800, 600, 0xFF); RenderArea.Margin = new Thickness(0, 0, 0, -200); drawingSurfacebg.Height = 600; drawingSurfacebg.VerticalAlignment = VerticalAlignment.Top; break; } m_d3dBackground.InitGlobalCallback(cb); // 设置窗口边界(以 dip 为单位) m_d3dBackground.WindowBounds = new Windows.Foundation.Size(xamlw, xamlh); // 设置本机分辨率(以像素为单位) m_d3dBackground.NativeResolution = new Windows.Foundation.Size(devicew, deviceh); // 将呈现分辨率设置为本机的最大分辨率 m_d3dBackground.RenderResolution = m_d3dBackground.NativeResolution; // 将本机组件挂钩到 DrawingSurfaceBackgroundGrid drawingSurfacebg.SetContentProvider(m_d3dBackground.CreateContentProvider()); drawingSurfacebg.SetManipulationHandler(m_d3dBackground); } }
private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) { // Set window bounds in dips m_d3dInterop.WindowBounds = new Windows.Foundation.Size((float)DrawingSurface.ActualWidth, (float)DrawingSurface.ActualHeight); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size((float)Math.Floor(DrawingSurface.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(DrawingSurface.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f)); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; if (m_d3dContentProvider == null) { m_d3dContentProvider = m_d3dInterop.CreateContentProvider(levelIndex, difficulty, SaveData.getHighWaveForDifficultyLevelAndLevelIndex(difficulty, levelIndex) >= LevelWaveRequirementMapper.getWaveRequirementForLevelIndex(levelIndex)); } // Hook-up native component to DrawingSurface DrawingSurface.SetContentProvider(m_d3dContentProvider); DrawingSurface.SetManipulationHandler(m_d3dInterop); m_d3dInterop.setWinRtCallback(new WinRtCallback(ProcessCallback)); }
private void DrawingSurface_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set WindowBounds to size of DrawingSurface m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)DrawingSurface.ActualWidth, (float)DrawingSurface.ActualHeight ); // Hook-up native component to DrawingSurface DrawingSurface.SetContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurface.SetManipulationHandler(m_d3dInterop); // Hook-up Cocos2d-x delegates m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent); m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox); } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { m_d3dInterop = new Direct3DInterop(); // Set native resolution in pixels m_d3dInterop.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(Application.Current.Host.Content.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(Application.Current.Host.Content.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); // Set render resolution to the full native resolution m_d3dInterop.RenderResolution = m_d3dInterop.NativeResolution; // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); m_d3dInterop.WindowOrientation = DisplayOrientations.Portrait; } }
private void DrawingSurfaceBackground_Loaded(object sender, RoutedEventArgs e) { if (m_d3dInterop == null) { PageOrientation pageOrientation = (PageOrientation)GetValue(OrientationProperty); DisplayOrientations displayOrientation; switch(pageOrientation) { case PageOrientation.Portrait: case PageOrientation.PortraitUp: displayOrientation = DisplayOrientations.Portrait; break; case PageOrientation.PortraitDown: displayOrientation = DisplayOrientations.PortraitFlipped; break; case PageOrientation.Landscape: case PageOrientation.LandscapeLeft: displayOrientation = DisplayOrientations.Landscape; break; case PageOrientation.LandscapeRight: displayOrientation = DisplayOrientations.LandscapeFlipped; break; default: displayOrientation = DisplayOrientations.Landscape; break; } m_d3dInterop = new Direct3DInterop(displayOrientation); // Set WindowBounds to size of DrawingSurface m_d3dInterop.WindowBounds = new Windows.Foundation.Size( (float)Application.Current.Host.Content.ActualWidth, (float)Application.Current.Host.Content.ActualHeight ); // Hook-up native component to DrawingSurfaceBackgroundGrid DrawingSurfaceBackground.SetBackgroundContentProvider(m_d3dInterop.CreateContentProvider()); DrawingSurfaceBackground.SetBackgroundManipulationHandler(m_d3dInterop); // Hook-up Cocos2d-x delegates m_d3dInterop.SetCocos2dEventDelegate(OnCocos2dEvent); m_d3dInterop.SetCocos2dMessageBoxDelegate(OnCocos2dMessageBoxEvent); m_d3dInterop.SetCocos2dEditBoxDelegate(OpenEditBox); m_d3dInterop.SetCocos2dOpenURLDelegate(OpenURL); } }
private void SetContentProvider(byte[] asset) { try { _interop = new Direct3DInterop(asset); // Set native resolution in pixels _interop.WindowBounds = _interop.RenderResolution = _interop.NativeResolution = new Windows.Foundation.Size(_interop.Width, _interop.Height); image.Height = _interop.Height; image.Width = _interop.Width; // Hook-up native component to DrawingSurface if (_loaded) { image.SetContentProvider(_interop.CreateContentProvider()); CoerceScale(true); ResizeImage(true); } } catch { ServiceLocator.Current.GetInstance<INotificationService>().CreateNotification("Invalid Gif detected"); } }
private async void SetContentProvider(string sourceUrl) { Monitor.Enter(this); try { if (_interop != null) return; Messenger.Default.Send<LoadingMessage>(new LoadingMessage { Loading = true }); var asset = await SimpleHttpService.GetBytes(sourceUrl); if (asset == null) return; _interop = new Direct3DInterop(asset); // Set native resolution in pixels _interop.RenderResolution = _interop.NativeResolution = _interop.WindowBounds = new Windows.Foundation.Size(_interop.Width, _interop.Height); image.Height = _interop.Height; image.Width = _interop.Width; // Hook-up native component to DrawingSurface image.SetContentProvider(_interop.CreateContentProvider()); _scale = 0; CoerceScale(true); _scale = _coercedScale; ResizeImage(true); } catch { } finally { Messenger.Default.Send<LoadingMessage>(new LoadingMessage { Loading = false }); Monitor.Exit(this); } }