private static void OnMaxItemSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { // Create a weak reference to the var weakItemsWrapGrid = new WeakReference(d); UpdateItemSize(weakItemsWrapGrid.Target as ItemsWrapGrid); WindowSizeChangedEventHandler handler = null; handler = (_, __) => { if (weakItemsWrapGrid.Target is ItemsWrapGrid itemsWrapGrid) { UpdateItemSize(itemsWrapGrid); } else { // Unregister the delegate if the target instance is not available anymore. Window.Current.SizeChanged -= handler; } }; // The Uno ItemsWrapGrid is "virtual" and does not yet provide a parent for // which we can get the size. // This behavior assumes that the GridView will fill up the screen's width. Window.Current.SizeChanged += handler; }
public MainPage() { this.InitializeComponent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; #if !UNITY_WP_8_1 appCallbacks.SetKeyboardTriggerControl(this); #endif appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; #if UNITY_WP_8_1 SetupLocationService(); #endif Interop.LoadInterstitialEvent += Interop_LoadInterstitialEvent; Interop.ShowInterstitialEvent += Interop_ShowInterstitialEvent; }
public void Page_Loaded(object sender, RoutedEventArgs e) { object apiKey = null; if (Windows.Storage.ApplicationData.Current.RoamingSettings.Values.TryGetValue("FlickrApiKey", out apiKey)) { FlickrApiKey.Text = (string)apiKey; } object username = null; if (Windows.Storage.ApplicationData.Current.RoamingSettings.Values.TryGetValue("FlickrUsername", out username)) { FlickrUsername.Text = (string)username; } if (_displayHandler == null) { _displayHandler = Page_OrientationChanged; _layoutHandler = Page_LayoutChanged; } DisplayProperties.OrientationChanged += _displayHandler; Window.Current.SizeChanged += _layoutHandler; SetCurrentOrientation(this); }
public MainPage(SplashScreen splashScreen) { this.InitializeComponent(); // initialize extended splash splash = splashScreen; SetExtendedSplashBackgroundColor(); // ensure we are aware of app window being resized OnResize(); Window.Current.SizeChanged += onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize(e)); Window.Current.VisibilityChanged += OnWindowVisibilityChanged; // ensure we listen to when unity tells us game is ready WindowsGateway.UnityLoaded = OnUnityLoaded; // create extended splash timer extendedSplashTimer = new DispatcherTimer(); extendedSplashTimer.Interval = TimeSpan.FromMilliseconds(100); extendedSplashTimer.Tick += ExtendedSplashTimer_Tick; extendedSplashTimer.Start(); // configure settings charm settingsPane = SettingsPane.GetForCurrentView(); settingsPane.CommandsRequested += OnSettingsCommandsRequested; // configure share charm var dataTransferManager = DataTransferManager.GetForCurrentView(); dataTransferManager.DataRequested += DataTransferManager_DataRequested; }
public MainPage() { this.InitializeComponent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); bool isWindowsHolographic = false; #if UNITY_HOLOGRAPHIC // If application was exported as Holographic check if the deviceFamily actually supports it, // otherwise we treat this as a normal XAML application string deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily; isWindowsHolographic = String.Compare("Windows.Holographic", deviceFamily) == 0; #endif if (isWindowsHolographic) { appCallbacks.InitializeViewManager(Window.Current.CoreWindow); } else { appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; #if UNITY_UWP if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1)) { isPhone = true; } #endif #if !UNITY_WP_8_1 appCallbacks.SetKeyboardTriggerControl(this); #else isPhone = true; #endif appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; #if UNITY_WP_8_1 onRotationChangedHandler = new TypedEventHandler <DisplayInformation, object>((di, o) => { OnRotate(di); }); ExtendedSplashImage.RenderTransformOrigin = new Point(0.5, 0.5); var displayInfo = DisplayInformation.GetForCurrentView(); displayInfo.OrientationChanged += onRotationChangedHandler; OnRotate(displayInfo); SetupLocationService(); #endif } }
public MainPage() { this.InitializeComponent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; #if !UNITY_WP_8_1 appCallbacks.SetKeyboardTriggerControl(this); #endif appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; #if UNITY_WP_8_1 SetupLocationService(); #endif }
public MainPage() { this.InitializeComponent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); bool isWindowsHolographic = false; #if UNITY_HOLOGRAPHIC // If application was exported as Holographic check if the deviceFamily actually supports it, // otherwise we treat this as a normal XAML application string deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily; isWindowsHolographic = String.Compare("Windows.Holographic", deviceFamily) == 0; if (!isWindowsHolographic) { isWindowsHolographic = Windows.Graphics.Holographic.HolographicSpace.IsAvailable; } MyAppPlatformManager.DeviceFamilyString = deviceFamily; #endif if (isWindowsHolographic) { appCallbacks.InitializeViewManager(Window.Current.CoreWindow); } else { appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; appCallbacks.SetKeyboardTriggerControl(this); appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; xamlInputHandler = new XamlInputHandling(); DXSwapChainPanel.ManipulationMode = ManipulationModes.Scale | ManipulationModes.Rotate | ManipulationModes.TranslateX | ManipulationModes.TranslateY; DXSwapChainPanel.ManipulationDelta += DXSwapChainPanel_ManipulationDelta; DXSwapChainPanel.ManipulationStarted += DXSwapChainPanel_ManipulationStarted; DXSwapChainPanel.ManipulationCompleted += DXSwapChainPanel_ManipulationCompleted; DXSwapChainPanel.PointerReleased += DXSwapChainPanel_PointerReleased; DXSwapChainPanel.PointerMoved += DXSwapChainPanel_PointerMoved; DXSwapChainPanel.PointerWheelChanged += DXSwapChainPanel_PointerWheelChanged; DXSwapChainPanel.Holding += DXSwapChainPanel_Holding; DXSwapChainPanel.RightTapped += DXSwapChainPanel_RightTapped; AppBarButton_About.Click += AppBarButton_About_Click; AppBarButton_Reset.Click += AppBarButton_Reset_Click; } }
public MainPage() { this.InitializeComponent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; #if !UNITY_WP_8_1 appCallbacks.SetKeyboardTriggerControl(this); #endif appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; #if UNITY_WP_8_1 onRotationChangedHandler = new TypedEventHandler<DisplayInformation, object>((di, o) => { OnRotate(di); }); ExtendedSplashImage.RenderTransformOrigin = new Point(0.5, 0.5); var displayInfo = DisplayInformation.GetForCurrentView(); displayInfo.OrientationChanged += onRotationChangedHandler; OnRotate(displayInfo); SetupLocationService(); #endif }
/// <summary> /// Provides a memory-friendly registration to the <see cref="SizeChanged" /> event. /// </summary> /// <returns>A disposable instance that will cancel the registration.</returns> internal IDisposable RegisterSizeChangedEvent(WindowSizeChangedEventHandler handler) { return(WeakEventHelper.RegisterEvent( _sizeChangedHandlers, handler, (h, s, e) => (h as WindowSizeChangedEventHandler)?.Invoke(s, (WindowSizeChangedEventArgs)e) )); }
public MainPage(SplashScreen splashScreen) { this.InitializeComponent(); splash = splashScreen; GetSplashBackgroundColor(); OnResize(); Window.Current.SizeChanged += onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); }
public MainPage() { this.InitializeComponent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); #if !UNITY_WP_8_1 appCallbacks.SetKeyboardTriggerControl(this); #endif appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = ((App)App.Current).SplashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; Window.Current.VisibilityChanged += OnWindowVisibilityChanged; #if UNITY_WP_8_1 SetupLocationService(); #endif #if UNITY_METRO_8_1 // Configure settings charm settingsPane = SettingsPane.GetForCurrentView(); settingsPane.CommandsRequested += SettingsPaneCommandsRequested; #endif // provide the game configuration MarkerMetro.Unity.WinShared.GameController.Instance.Init(AppConfig.Instance); AppCallbacks.Instance.RenderingStarted += () => { isUnityLoaded = true; AppCallbacks.Instance.InvokeOnAppThread(() => { MarkerMetro.Unity.WinShared.ExceptionManager.Instance.Init(Crash); }, false); }; // create extended splash timer extendedSplashTimer = new DispatcherTimer(); extendedSplashTimer.Interval = TimeSpan.FromMilliseconds(100); extendedSplashTimer.Tick += ExtendedSplashTimer_Tick; extendedSplashTimer.Start(); #if UNITY_METRO_8_1 // set the fb web interface (only for Win8.1). FB.SetPlatformInterface(web); #endif }
public MainPage() { this.InitializeComponent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); #if !UNITY_WP_8_1 appCallbacks.SetKeyboardTriggerControl(this); #endif appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = ((App)App.Current).SplashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; #if UNITY_WP_8_1 SetupLocationService(); #endif #if UNITY_METRO_8_1 // Configure settings charm settingsPane = SettingsPane.GetForCurrentView(); settingsPane.CommandsRequested += SettingsPaneCommandsRequested; #endif // provide the game configuration MarkerMetro.Unity.WinShared.GameController.Instance.Init(AppConfig.Instance); AppCallbacks.Instance.RenderingStarted += () => { isUnityLoaded = true; AppCallbacks.Instance.InvokeOnAppThread(() => { MarkerMetro.Unity.WinShared.ExceptionManager.Instance.Init(Crash); }, false); }; // create extended splash timer extendedSplashTimer = new DispatcherTimer(); extendedSplashTimer.Interval = TimeSpan.FromMilliseconds(100); extendedSplashTimer.Tick += ExtendedSplashTimer_Tick; extendedSplashTimer.Start(); #if UNITY_METRO_8_1 // set the fb web interface (only for Win8.1). FB.SetPlatformInterface(web); #endif }
public void RemoveSplashScreen() { DXSwapChainPanel.Children.Remove(ExtendedSplashGrid); if (onResizeHandler != null) { Window.Current.SizeChanged -= onResizeHandler; onResizeHandler = null; } }
public MainPage(SplashScreen splashScreen) { this.InitializeComponent(); splash = splashScreen; GetSplashBackgroundColor(); OnResize(); Window.Current.SizeChanged += onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); UnityPlayer.AppCallbacks.Instance.Initialized += OnInitialized; }
public MainPage(SplashScreen splashScreen) { this.InitializeComponent(); splash = splashScreen; GetSplashBackgroundColor(); OnResize(); Window.Current.SizeChanged += onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Windows_Ad_Plugin.Helper.Instance.SetGrid(DXSwapChainBackgroundPanel); }
public void Page_Loaded(object sender, RoutedEventArgs e) { if (_displayHandler == null) { _displayHandler = Page_OrientationChanged; _layoutHandler = Page_LayoutChanged; } DisplayProperties.OrientationChanged += _displayHandler; Window.Current.SizeChanged += _layoutHandler; SetCurrentOrientation(this); }
/// <summary> /// Constructor. /// </summary> public MainPage() { this.InitializeComponent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; #if UNITY AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); bool isWindowsHolographic = false; #if UNITY_HOLOGRAPHIC // If application was exported as Holographic check if the deviceFamily actually supports it, // otherwise we treat this as a normal XAML application string deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily; isWindowsHolographic = String.Compare("Windows.Holographic", deviceFamily) == 0; #endif if (isWindowsHolographic) { appCallbacks.InitializeViewManager(Window.Current.CoreWindow); } else { appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; #if UNITY_UWP if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1)) { isPhone = true; } #endif appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); //splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; } PeerVideo.Visibility = Visibility.Collapsed; PeerVideo2.Visibility = Visibility.Collapsed; SelfVideo.Visibility = Visibility.Collapsed; #else DXSwapChainPanel.Visibility = Visibility.Collapsed; #endif // UNITY }
public void RemoveSplashScreen() { DXSwapChainPanel.Children.Remove(ExtendedSplashGrid); if (onResizeHandler != null) { Window.Current.SizeChanged -= onResizeHandler; onResizeHandler = null; #if UNITY_WP_8_1 DisplayInformation.GetForCurrentView().OrientationChanged -= onRotationChangedHandler; onRotationChangedHandler = null; #endif } }
public MainPage() { this.InitializeComponent(); _catalog = AppExtensionCatalog.Open("Atmosphere"); _catalog.PackageInstalled += _catalog_PackageInstalled; InstallPackageContent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; this.Loaded += MainPage_Loaded; this.KeyDown += MainPage_KeyDown; _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromSeconds(2); _timer.Tick += _timer_Tick; _timer.Start(); #if !UNITY_WP_8_1 appCallbacks.SetKeyboardTriggerControl(this); #endif appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; #if UNITY_WP_8_1 onRotationChangedHandler = new TypedEventHandler <DisplayInformation, object>((di, o) => { OnRotate(di); }); ExtendedSplashImage.RenderTransformOrigin = new Point(0.5, 0.5); var displayInfo = DisplayInformation.GetForCurrentView(); displayInfo.OrientationChanged += onRotationChangedHandler; OnRotate(displayInfo); SetupLocationService(); #endif }
public void Page_Loaded(object sender, RoutedEventArgs e) { BackButton.Visibility = (this.DataContext is FlickrDataSource) ? Visibility.Collapsed : Visibility.Visible; if (_displayHandler == null) { _displayHandler = Page_OrientationChanged; _layoutHandler = Page_LayoutChanged; } //get a nasty COM exception when attempting to register these event handlers under the file picker view or calling SetCurrentViewState below DisplayProperties.OrientationChanged += _displayHandler; Window.Current.SizeChanged += _layoutHandler; SetCurrentOrientation(this); }
public Popup Create(PopupSize size, UIElement content = null) { var container = new ContentControl { HorizontalContentAlignment = HorizontalAlignment.Stretch, VerticalContentAlignment = VerticalAlignment.Stretch, Height = Window.Current.Bounds.Height, Width = Window.Current.Bounds.Width, Content = content, }; var popup = new Popup { Child = container, HorizontalOffset = 0, VerticalOffset = 0, }; WindowSizeChangedEventHandler handler = (s, e) => { if (popup.IsOpen) { if (size == PopupSize.FullScreen) { container.Height = Window.Current.Bounds.Height; container.Width = Window.Current.Bounds.Width; } else if (size == PopupSize.ContentBased) { popup.HorizontalOffset = (Window.Current.Bounds.Width - popup.ActualWidth) / 2; popup.VerticalOffset = (Window.Current.Bounds.Height - popup.ActualHeight) / 2; } } }; popup.RegisterPropertyChangedCallback(Popup.IsOpenProperty, (d, e) => { if (popup.IsOpen) { Window.Current.SizeChanged += handler; } else { Window.Current.SizeChanged -= handler; } }); popup.Loaded += (s, e) => handler.Invoke(null, null); return(popup); }
public UnityView() { this.InitializeComponent(); if (!UnityUtils.IsInitialized) { UnityUtils.CreatePlayer(); } AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); bool isWindowsHolographic = false; #if UNITY_HOLOGRAPHIC // If application was exported as Holographic check if the device actually supports it, // otherwise we treat this as a normal XAML application isWindowsHolographic = AppCallbacks.IsMixedRealitySupported(); #endif if (isWindowsHolographic) { appCallbacks.InitializeViewManager(Window.Current.CoreWindow); } else { appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1)) { isPhone = true; } appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = UnityUtils.splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; } }
public void RemoveSplashScreen() { DXSwapChainPanel.Children.Remove(ExtendedSplashGrid); if (onResizeHandler != null) { Window.Current.SizeChanged -= onResizeHandler; onResizeHandler = null; } m_DisplayRequest = new Windows.System.Display.DisplayRequest(); m_DisplayRequest.RequestActive(); Application.Current.Suspending -= OnApplicationSuspending; Application.Current.Suspending += OnApplicationSuspending; ConnectBand(); }
public void RemoveSplashScreen() { DXSwapChainPanel.Children.Remove(ExtendedSplashGrid); if (onResizeHandler != null) { Window.Current.SizeChanged -= onResizeHandler; onResizeHandler = null; } if (AppConfig.Instance.IapDisclaimerEnabled) { CheckForOFT(); } if (AppConfig.Instance.DisplayMemoryUsageAllowed) { BeginRecording(); } }
public MainPage() { this.InitializeComponent(); this.speed.ManipulationMode = ManipulationModes.Rotate; this.volume.ManipulationMode = ManipulationModes.TranslateX; this.mediaPlayerElement.ManipulationMode = ManipulationModes.Scale | ManipulationModes.TranslateInertia | ManipulationModes.TranslateX | ManipulationModes.TranslateY; mediaPlayer = new MediaPlayer(); mediaTimelineController = new MediaTimelineController(); mediaPlayerElement.Source = MediaSource.CreateFromUri(new Uri("ms-appx:///Assets/sample.mp4")); mediaPlayer = mediaPlayerElement.MediaPlayer; mediaPlayer.CommandManager.IsEnabled = false; mediaPlayer.TimelineController = mediaTimelineController; mediaTimelineController.IsLoopingEnabled = true; mediaPlayer.Volume = 0.5; InitializePropertiesAsync(); OnResize(); SizeChanged = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += SizeChanged; }
public Popup Create(Sizes size, UIElement content = null) { var container = new ContentControl { HorizontalContentAlignment = HorizontalAlignment.Stretch, VerticalContentAlignment = VerticalAlignment.Stretch, Height = Window.Current.Bounds.Height, Width = Window.Current.Bounds.Width, Content = content, }; var popup = new Popup { Child = container, HorizontalOffset = 0, VerticalOffset = 0, }; WindowSizeChangedEventHandler handler = (s, e) => { if (popup.IsOpen) { container.Height = e.Size.Height; container.Width = e.Size.Width; } }; if (size == Sizes.FullScreen) { popup.RegisterPropertyChangedCallback(Popup.IsOpenProperty, (d, e) => { if (popup.IsOpen) { Window.Current.SizeChanged += handler; } else { Window.Current.SizeChanged -= handler; } }); } return(popup); }
public MainPage() { this.InitializeComponent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); bool isWindowsHolographic = false; #if UNITY_HOLOGRAPHIC // If application was exported as Holographic check if the deviceFamily actually supports it, // otherwise we treat this as a normal XAML application string deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily; isWindowsHolographic = String.Compare("Windows.Holographic", deviceFamily) == 0; #endif if (isWindowsHolographic) { appCallbacks.InitializeViewManager(); } else { appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; appCallbacks.SetKeyboardTriggerControl(this); appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; } }
public MainPage() { this.InitializeComponent(); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; AppCallbacks appCallbacks = AppCallbacks.Instance; bool isWindowsHolographic = false; #if UNITY_HOLOGRAPHIC // If application was exported as Holographic check if the device actually supports it, // otherwise we treat this as a normal XAML application isWindowsHolographic = AppCallbacks.IsMixedRealitySupported(); #endif if (isWindowsHolographic) { appCallbacks.InitializeViewManager(Window.Current.CoreWindow); } else { appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1)) { isPhone = true; } appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; } }
public void Dispose() { if (_popup != null) { _popup.Closed -= PopupOnClosed; } if (_weakSizeListener != null) { Window.Current.SizeChanged -= _weakSizeListener; } if (_weakInputPaneListener != null) { InputPane pane = InputPane.GetForCurrentView(); if (pane != null) { pane.Hiding -= _weakInputPaneListener; pane.Showing -= _weakInputPaneListener; } } _popup = null; _weakSizeListener = null; _weakInputPaneListener = null; _settings = null; }
public bool StartGameEngine(bool fullScreen, int framesPerSecond) { frameRate = 1.0 / framesPerSecond; frameTimeSpan = TimeSpan.FromSeconds(frameRate); AutoResetEvent startComplete = new AutoResetEvent(false); bool failed = false; var tcs = new TaskCompletionSource <object>(); WindowSizeChangedEventHandler endedLambda = (s, e) => { GameViewportWidthValue = e.Size.Width; GameViewportHeightValue = e.Size.Height; tcs.TrySetResult(null); }; InvokeOnUIThread( async() => { if (fullScreen) { //Try to enter full screen ApplicationView view = ApplicationView.GetForCurrentView(); Window.Current.SizeChanged += endedLambda; if (!view.IsFullScreenMode) { view.TryEnterFullScreenMode(); } await tcs.Task; } else { SetGameViewPortSizeFromWindow(); } if (move == null) { move = new Storyboard(); graphicsCanvas.Resources.Add("Move", move); move.Completed += Move_Completed; } if (viewportTransformGroup == null) { viewportTransformGroup = new TransformGroup(); viewportTranslate = new TranslateTransform(); viewportTransformGroup.Children.Add(viewportTranslate); viewportRotate = new RotateTransform(); viewportTransformGroup.Children.Add(viewportRotate); viewportScale = new ScaleTransform(); viewportTransformGroup.Children.Add(viewportScale); graphicsCanvas.RenderTransform = viewportTransformGroup; } startComplete.Set(); }); startComplete.WaitOne(); engineStarted = true; return(!failed); }
public void RemoveSplashScreen() { DXSwapChainPanel.Children.Remove(ExtendedSplashGrid); if (onResizeHandler != null) { Window.Current.SizeChanged -= onResizeHandler; onResizeHandler = null; } UnityEngine //UnityEngine.Object.FindObjectOfType<TestScript>(); //var b = CoreApplication.MainView.IsMain; //b = b; //CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => //{ // //var obj = UnityEngine.Object.FindObjectOfType<TestScript>(); //} ) ; }
public void Dispose() { if (_popup != null) _popup.Closed -= PopupOnClosed; if (_weakSizeListener != null) Window.Current.SizeChanged -= _weakSizeListener; if (_weakInputPaneListener != null) { InputPane pane = InputPane.GetForCurrentView(); if (pane != null) { pane.Hiding -= _weakInputPaneListener; pane.Showing -= _weakInputPaneListener; } } _popup = null; _weakSizeListener = null; _weakInputPaneListener = null; _settings = null; }
public void Show() { Rect bounds = Window.Current.Bounds; var child = (FrameworkElement)_popupView; _popup = new Popup { Width = bounds.Width, Height = bounds.Height, Child = child, IsLightDismissEnabled = false, ChildTransitions = new TransitionCollection { new PopupThemeTransition {FromHorizontalOffset = 0, FromVerticalOffset = 100} } }; InputPane inputPane = InputPane.GetForCurrentView(); if (inputPane != null) _flyoutOffset = inputPane.OccludedRect.Height; _settings = new PopupSettings { UpdatePositionAction = UpdatePositionDelegate, UpdateSizeAction = UpdateSizeDelegate }; _popupView.InitializePopup(_popup, _settings); UpdatePopup(bounds.Width, bounds.Height); _popup.Closed += PopupOnClosed; if (_settings.ShowAction == null) _popup.IsOpen = true; else _settings.ShowAction(_popup); _weakSizeListener = ReflectionExtensions .CreateWeakDelegate<PopupWrapper, WindowSizeChangedEventArgs, WindowSizeChangedEventHandler>( this, (wrapper, o, arg3) => wrapper.OnWindowSizeChanged(arg3), (o, handler) => ((Window)o).SizeChanged -= handler, handler => handler.Handle); Window.Current.SizeChanged += _weakSizeListener; if (inputPane != null) { _weakInputPaneListener = ReflectionExtensions .CreateWeakDelegate<PopupWrapper, InputPaneVisibilityEventArgs, TypedEventHandler<InputPane, InputPaneVisibilityEventArgs>>(this, (wrapper, o, arg3) => wrapper.OnInputPaneChanged(arg3), (o, handler) => { var pane = (InputPane)o; pane.Hiding -= handler; pane.Showing -= handler; }, handler => handler.Handle); inputPane.Showing += _weakInputPaneListener; inputPane.Hiding += _weakInputPaneListener; } }
public void Page_Loaded(object sender, RoutedEventArgs e) { //Workaround: the initial selection for a FlipView isn't respected when it's made before the page is loaded, // so it's necessary to clear its state and try again once the page is loaded. Clearly this is not intended // to be necessary. if (sender == this) { var originallySelectedItem = Item; Item = null; UpdateLayout(); Item = originallySelectedItem; } var control = sender as Control; if (viewStateAwareControls.Count == 0) { if (_displayHandler == null) { _displayHandler = Page_OrientationChanged; _layoutHandler = Page_LayoutChanged; } DisplayProperties.OrientationChanged += _displayHandler; Window.Current.SizeChanged += _layoutHandler; } viewStateAwareControls.Add(control); SetCurrentViewState(control); }
public MainPage() { this.InitializeComponent(); //Call the pointers of the screen. We use the pointers for draw and send position pointers = new Dictionary <uint, Windows.UI.Xaml.Input.Pointer>(); VideoBorder.PointerMoved += new PointerEventHandler(VideoBorder_PointerMoved); NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; try { // connect to socket.io via other server when App start socketWrapper = new SocketWrapper(); socketWrapper.OnReceiveMessenger += OnReceivedMessage_handler; socketWrapper.onDisconnect += OnDisconnection_handler; socketWrapper.Connect("ws://172.16.6.10:3001/socket.io/?EIO=4&transport=websocket"); } catch (Exception ex) { Debug.WriteLine(ex.Message); } #if UNITY AppCallbacks appCallbacks = AppCallbacks.Instance; // Setup scripting bridge _bridge = new WinRTBridge.WinRTBridge(); appCallbacks.SetBridge(_bridge); bool isWindowsHolographic = false; #if UNITY_HOLOGRAPHIC // If application was exported as Holographic check if the deviceFamily actually supports it, // otherwise we treat this as a normal XAML application string deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily; isWindowsHolographic = String.Compare("Windows.Holographic", deviceFamily) == 0; #endif if (isWindowsHolographic) { appCallbacks.InitializeViewManager(Window.Current.CoreWindow); } else { appCallbacks.RenderingStarted += () => { RemoveSplashScreen(); }; #if UNITY_UWP if (Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1)) { isPhone = true; } #endif appCallbacks.SetSwapChainPanel(GetSwapChainPanel()); appCallbacks.SetCoreWindowEvents(Window.Current.CoreWindow); appCallbacks.InitializeD3DXAML(); //splash = ((App)App.Current).splashScreen; GetSplashBackgroundColor(); OnResize(); onResizeHandler = new WindowSizeChangedEventHandler((o, e) => OnResize()); Window.Current.SizeChanged += onResizeHandler; } PeerVideo.Visibility = Visibility.Collapsed; SelfVideo.Visibility = Visibility.Collapsed; #else DXSwapChainPanel.Visibility = Visibility.Collapsed; #endif // UNITY }
public void Show() { Rect bounds = Window.Current.Bounds; var child = (FrameworkElement)_popupView; _popup = new Popup { Width = bounds.Width, Height = bounds.Height, Child = child, IsLightDismissEnabled = false, ChildTransitions = new TransitionCollection { new PopupThemeTransition { FromHorizontalOffset = 0, FromVerticalOffset = 100 } } }; InputPane inputPane = InputPane.GetForCurrentView(); if (inputPane != null) { _flyoutOffset = inputPane.OccludedRect.Height; } _settings = new PopupSettings { UpdatePositionAction = UpdatePositionDelegate, UpdateSizeAction = UpdateSizeDelegate }; _popupView.InitializePopup(_popup, _settings); UpdatePopup(bounds.Width, bounds.Height); _popup.Closed += PopupOnClosed; if (_settings.ShowAction == null) { _popup.IsOpen = true; } else { _settings.ShowAction(_popup); } _weakSizeListener = ReflectionExtensions .CreateWeakDelegate <PopupWrapper, WindowSizeChangedEventArgs, WindowSizeChangedEventHandler>( this, (wrapper, o, arg3) => wrapper.OnWindowSizeChanged(arg3), (o, handler) => ((Window)o).SizeChanged -= handler, handler => handler.Handle); Window.Current.SizeChanged += _weakSizeListener; if (inputPane != null) { _weakInputPaneListener = ReflectionExtensions .CreateWeakDelegate <PopupWrapper, InputPaneVisibilityEventArgs, TypedEventHandler <InputPane, InputPaneVisibilityEventArgs> >(this, (wrapper, o, arg3) => wrapper.OnInputPaneChanged(arg3), (o, handler) => { var pane = (InputPane)o; pane.Hiding -= handler; pane.Showing -= handler; }, handler => handler.Handle); inputPane.Showing += _weakInputPaneListener; inputPane.Hiding += _weakInputPaneListener; } }