public App() { this.InitializeComponent(); try { if (DeviceTypeHelper.GetDeviceFormFactorType().ToString() == "Xbox") { this.RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested; //Test if xbox support reveal effect if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.FocusVisualKind")) { try { this.FocusVisualKind = FocusVisualKind.Reveal; } catch { //Earlier version on Xbox than RS4 which does not support reveal effect } } } } catch { } this.Suspending += OnSuspending; }
private void Call(object obj) { if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Phone) { Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI(Phone, Title); } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { Xamarin.Forms.Forms.Init(e); await InitNotificationsAsync(); #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { AppStatus.UserLogged = UserApiService.GetUserLogged(); if (AppStatus.UserLogged == null) { rootFrame.Navigate(typeof(MainPage), e.Arguments); } else { AppShell appShell = new AppShell(); appShell.AppFrame.Navigate(typeof(HomePage), e.Arguments, new Windows.UI.Xaml.Media.Animation.SuppressNavigationTransitionInfo()); Window.Current.Content = appShell; } } // Ensure the current window is active Window.Current.Activate(); } if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Phone) { await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync(); } }
private void loadState() { this.tgSound.IsOn = App.Config.Sound; this.tgVibrate.IsOn = App.Config.Vibrate; this.deviceType = DeviceTypeHelper.GetDeviceFormFactorType(); }
public NavigationPage() { InitializeComponent(); var device = DeviceTypeHelper.GetDeviceFormFactorType(); if (device == DeviceFormFactorType.Phone || device == DeviceFormFactorType.IoT || device == DeviceFormFactorType.Other) { splitView.CompactPaneLength = 0; } }
private async Task TrySetMapViewWithMargin(BasicGeoposition pos, double boundingBoxZoomAdjustment, MapAnimationKind mapAnimation = MapAnimationKind.None) { double narrowZoomAdjustment = boundingBoxZoomAdjustment / 2; // Creators update changed maps a bit, so we need to zoom in closer on any device running it. // MapStyle is a decent proxy for "are we on Creators or not" if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Phone && !ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.Maps.MapStyle")) { narrowZoomAdjustment = boundingBoxZoomAdjustment / 1.35; } // Create a box surrounding the specified point to emulate a zoom level on the map. // We're using a simulated bounding box, because we need to be able to specify a margin, // to accommodate either of the the floating content panels. BasicGeoposition northwest = BasicGeopositionExtensions.Create ( 0.0, pos.Longitude - boundingBoxZoomAdjustment, pos.Latitude + boundingBoxZoomAdjustment ); BasicGeoposition southeast = BasicGeopositionExtensions.Create ( 0.0, pos.Longitude + boundingBoxZoomAdjustment, pos.Latitude - boundingBoxZoomAdjustment ); if (AdaptiveVisualStateGroup.CurrentState == _narrowVisualState) { // Zoom in a little further when in the narrow view, otherwise we're a little // too far out for the narrow field of view northwest.Longitude += narrowZoomAdjustment; northwest.Latitude -= narrowZoomAdjustment; southeast.Longitude -= narrowZoomAdjustment; southeast.Latitude += narrowZoomAdjustment; GeoboundingBox box = new GeoboundingBox(northwest, southeast); if (NarrowSearchPanel.IsOpen) { double bottomMargin = NarrowSearchPanel.ExpandedHeight; await PageMap.TrySetViewBoundsAsync(box, new Thickness(0, 0, 0, bottomMargin), mapAnimation); } else { await PageMap.TrySetViewBoundsAsync(box, new Thickness(0, 0, 0, 0), mapAnimation); } } else { GeoboundingBox box = new GeoboundingBox(northwest, southeast); await PageMap.TrySetViewBoundsAsync(box, new Thickness(410, 0, 0, 0), mapAnimation); } }
private async void BtnFaceBookLogin_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { StartLoading(); await ObjFBHelper.LoginAndContinue(); if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Desktop) { ContinueWithWebAuthenticationBroker(null); } }
protected override async void OnLaunched(LaunchActivatedEventArgs args) { if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Xbox) { SettingsForXbox(); } if (!args.PrelaunchActivated) { await ActivationService.ActivateAsync(args); } }
public MapDetailsControl() { this.InitializeComponent(); if (DeviceTypeHelper.GetDeviceFormFactorType() != DeviceFormFactorType.Phone && DeviceTypeHelper.GetDeviceFormFactorType() != DeviceFormFactorType.Tablet) { CurrentLocation.Visibility = Visibility.Collapsed; } _mapCurrentLocationIcon = new MapIcon(); _mapCurrentLocationIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/Icons/curlocation-marker.png")); }
public async Task LoginAndContinue() { if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Desktop) { WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, _loginUrl); ValidateAndProccessResult(result); } else { WebAuthenticationBroker.AuthenticateAndContinue(_loginUrl); } }
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // TODO: add your long-running task here // DB init - to fix if (firstInit) { firstInit = false; using (var db = new LocalContext()) { try { db.Database.Migrate(); } catch (Exception) { // first time exception } await db.InitMigrateAsync(); } Init(); } // Get Device Type SettingsService.Instance.DeviceType = DeviceTypeHelper.GetDeviceFormFactorType(); // Check for connection SettingsService.Instance.CheckConnections(); Views.Shell.HamburgerMenu.IsFullScreen = true; if (args.Kind == ActivationKind.Protocol) { var protocolUri = (args as ProtocolActivatedEventArgs).Uri; var token = await DataUtils.TryGetToken(protocolUri); if (!string.IsNullOrWhiteSpace(token)) { await PassportService.Instance.GetProfileData(token); } } if (SettingsService.Instance.CurrentUserData?.CanUse() ?? false) { Views.Shell.HamburgerMenu.IsFullScreen = false; await NavigationService.NavigateAsync(typeof(Views.MainPage)); } else { await NavigationService.NavigateAsync(typeof(Views.LoginPage)); } }
private void NavCommandBar_Unloaded(object sender, RoutedEventArgs e) { Views.Busy.BusyChanged -= BusyView_BusyChanged; _navigationService.Frame.Navigated -= Frame_Navigated; this.UnregisterPropertyChangedCallback(IsOpenProperty, _isOpenCallbackToken); this.SizeChanged -= NavCommandBar_SizeChanged; this.PrimaryCommands.VectorChanged -= PrimaryCommands_VectorChanged; this.SecondaryCommands.VectorChanged -= SecondaryCommands_VectorChanged; if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Phone) { InputPane.GetForCurrentView().Showing -= InputPane_Showing; InputPane.GetForCurrentView().Hiding -= InputPane_Hiding; } }
public StepThroughListView() { InitializeComponent(); if (DeviceTypeHelper.GetDeviceFormFactorType() == Core.Enums.DeviceFormFactorType.Xbox) { ButtonLeft.Visibility = Visibility.Collapsed; ButtonRight.Visibility = Visibility.Collapsed; } else { if (AlwaysShowButton == Visibility.Visible) { ButtonLeft.Visibility = Visibility.Visible; ButtonRight.Visibility = Visibility.Visible; } } SizeChanged += StepThroughListView_SizeChanged; }
private void NavCommandBar_Loaded(object sender, RoutedEventArgs e) { Views.Busy.BusyChanged += BusyView_BusyChanged; _navigationService.Frame.Navigated += Frame_Navigated; /* AppBarButtons displayed in the NavigationButtons StackPanel won't have their Label * Visibility updated automatically when the AppBar opens. So instead, we listen directly * to the IsOpen property, and when it changes, we update each button's IsCompact property * accordingly. */ _isOpenCallbackToken = this.RegisterPropertyChangedCallback(IsOpenProperty, new DependencyPropertyChangedCallback(IsOpenChanged)); this.SizeChanged += NavCommandBar_SizeChanged; this.PrimaryCommands.VectorChanged += PrimaryCommands_VectorChanged; this.SecondaryCommands.VectorChanged += SecondaryCommands_VectorChanged; /*Arbitary value. I figure with a target of 60FPS, it's not unreasonabe to expect * simultaneous visibility changes to propagate within ~20 frames of each other. */ _visibilityChangedThrottle.Interval = TimeSpan.FromMilliseconds(5.34); _visibilityChangedThrottle.Tick += (s, args) => { ReflowCommands(RenderSize, RenderSize); _visibilityChangedThrottle.Stop(); }; UpdateNavSeparatorVisibility(); this.UpdateLayout(); UpdateSelectionVisual(); // Call this once first, to make sure that _currentlySelected gets populated before we start Reflow()ing. ReflowCommands(this.RenderSize, this.RenderSize); UpdateSelectionVisual(); UpdateButtonLabels(IsOpen); UpdateCommandsVisibilityTracking(this.PrimaryCommands); UpdateCommandsVisibilityTracking(this.SecondaryCommands); if (DeviceTypeHelper.GetDeviceFormFactorType() == DeviceFormFactorType.Phone) { InputPane.GetForCurrentView().Showing += InputPane_Showing; InputPane.GetForCurrentView().Hiding += InputPane_Hiding; } }
public async Task TrySetViewBoundsAsync(GeoboundingBox bounds, Thickness?margin, MapAnimationKind animation, bool retryOnFailure = false) { if (DigiTransitMapControl == null) { return; } // We're checking for the MapStyle type as a proxy for "are we running on Creators or higher?". // We don't need to run the following code if we are. if (margin != null && !ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.Maps.MapStyle") && DeviceTypeHelper.GetDeviceFormFactorType() != DeviceFormFactorType.Phone) { //Margins are a little smaller on desktop for some reason. investigate this a little further, may just be a DPI thing? const int desktopPlusCoeff = 40; margin = new Thickness(margin.Value.Left + desktopPlusCoeff, margin.Value.Top + desktopPlusCoeff, margin.Value.Right + desktopPlusCoeff, margin.Value.Bottom + desktopPlusCoeff); } //If map movement fails, keep retrying until we get it right bool moved = false; do { moved = await DigiTransitMapControl.TrySetViewBoundsAsync(bounds, margin, animation); if (moved) { break; } else { await Task.Delay(2000); //looong delay to acommodate slow mobile rendering } } while (!moved && retryOnFailure); }