private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { try { if (e.NavigationParameter != null) { this.LockScreenPreviewViewModel.Post = Post.FromXml(e.NavigationParameter as string); } } catch (Exception ex) { } ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); IsFullScreenEnabled = ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); ApplicationView.GetForCurrentView().SuppressSystemOverlays = true; ApplicationView.GetForCurrentView().FullScreenSystemOverlayMode = FullScreenSystemOverlayMode.Minimal; if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") && StatusBar.GetForCurrentView() != null) { DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait; await StatusBar.GetForCurrentView().ShowAsync(); } else { ApplicationView.GetForCurrentView().VisibleBoundsChanged += LockScreenPreviewPage_VisibleBoundsChanged; } PreviewTextBlock.Text = DateTimeOffset.Now.ToString("%H"); PreviewTextBlock2.Text = DateTimeOffset.Now.ToString("mm"); try { var f = DateTimeFormatter.LongDate; var formateWithoutYear = new DateTimeFormatter(YearFormat.None, MonthFormat.Full, DayFormat.Default, DayOfWeekFormat.Full, f.IncludeHour, f.IncludeMinute, f.IncludeSecond, Windows.System.UserProfile.GlobalizationPreferences.Languages); PreviewTextBlock3.Text = formateWithoutYear.Format(DateTimeOffset.Now); } catch (Exception ex) { } }
public DeviceInputRelatedTrigger() { if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { if (ApiInformation.IsTypePresent("Windows.Gaming.Input.UINavigationController")) { isControllerActive = Windows.Gaming.Input.UINavigationController.UINavigationControllers.Any(); if (AppInformation.DeviceType != DeviceType.Xbox) { Windows.Gaming.Input.UINavigationController.UINavigationControllerAdded += UINavigationController_UINavigationControllerManipulated; Windows.Gaming.Input.UINavigationController.UINavigationControllerRemoved += UINavigationController_UINavigationControllerManipulated; } if (AppInformation.DeviceType == DeviceType.Mobile) { CoreWindow.GetForCurrentThread().SizeChanged += ScreenSizeChanged; } } } }
public static void CheckTheme() { InitializeSettings(); //if (Window.Current?.Content is FrameworkElement frameworkElement) var frameworkElement = Tools.rootPage; if (!GetBoolen("IsDarkMode")) { frameworkElement.RequestedTheme = ElementTheme.Light; ChangeTitleBarColor(true); } else { frameworkElement.RequestedTheme = ElementTheme.Dark; ChangeTitleBarColor(false); } void ChangeTitleBarColor(bool value)//标题栏颜色 { Color BackColor = value ? Color.FromArgb(255, 242, 242, 242) : Color.FromArgb(255, 23, 23, 23), ForeColor = value ? Colors.Black : Colors.White, ButtonForeInactiveColor = value ? Color.FromArgb(255, 50, 50, 50) : Color.FromArgb(255, 200, 200, 200), ButtonBackPressedColor = value ? Color.FromArgb(255, 200, 200, 200) : Color.FromArgb(255, 50, 50, 50); Tools.mainPage?.ChangeButtonForeground(); if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { StatusBar statusBar = StatusBar.GetForCurrentView(); statusBar.BackgroundOpacity = 1; // 透明度 statusBar.BackgroundColor = BackColor; statusBar.ForegroundColor = ForeColor; } else { var view = ApplicationView.GetForCurrentView().TitleBar; view.ButtonBackgroundColor = view.InactiveBackgroundColor = view.ButtonInactiveBackgroundColor = Colors.Transparent; view.ForegroundColor = view.ButtonForegroundColor = view.ButtonHoverForegroundColor = view.ButtonPressedForegroundColor = ForeColor; view.InactiveForegroundColor = view.ButtonInactiveForegroundColor = ButtonForeInactiveColor; view.ButtonHoverBackgroundColor = BackColor; view.ButtonPressedBackgroundColor = ButtonBackPressedColor; } } }
private async Task logoAnimation() { //Perform the animations BindableMargin margin = new Views.BindableMargin(logoimage_animated); margin.Top = -315; DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames(); animation.EnableDependentAnimation = true; EasingDoubleKeyFrame f1 = new EasingDoubleKeyFrame(); f1.Value = -315; f1.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.2)); animation.KeyFrames.Add(f1); EasingDoubleKeyFrame f2 = new EasingDoubleKeyFrame(); f2.EasingFunction = new PowerEase() { EasingMode = EasingMode.EaseInOut, Power = 4 }; f2.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.8)); f2.Value = 0; animation.KeyFrames.Add(f2); Storyboard.SetTarget(animation, margin); Storyboard.SetTargetProperty(animation, "Top"); //Windows Phones do not need the animation //if (DeviceTypeHelper.GetDeviceFormFactorType() != DeviceFormFactorType.Phone) { storyboard.Children.Add(animation); } //Only phones should have this step if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { //var appview = ApplicationView.GetForCurrentView(); //appview.SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);//不能这样做,这样做可能会导致无法适应虚拟导航栏 var statusbar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView(); statusbar.ForegroundColor = Colors.White; statusbar.BackgroundOpacity = 0; await statusbar.HideAsync(); } storyboard.Completed += Storyboard_Completed; storyboard.Begin(); }
private static void SetStatusBarColor() { var orangeColor = (Color)Application.Current.Resources["orangeColor"]; var whiteColor = (Color)Application.Current.Resources["whiteColor"]; whiteColor = Colors.Black; //PC customization if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) { var titleBar = ApplicationView.GetForCurrentView().TitleBar; if (titleBar != null) { titleBar.ButtonBackgroundColor = orangeColor; titleBar.ButtonForegroundColor = whiteColor; titleBar.BackgroundColor = orangeColor; titleBar.ForegroundColor = whiteColor; } } }
public MainPage() { InitializeComponent(); if (Device.Idiom == TargetIdiom.Desktop) { MinWidth = 600; MinHeight = 800; } LoadApplication(new XF.App()); if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView(); statusBar.BackgroundColor = Windows.UI.Color.FromArgb(0, 0, 0, 0); statusBar.ForegroundColor = Windows.UI.Color.FromArgb(255, 255, 255, 255); statusBar.ShowAsync().AsTask().Wait(); //statusBar.BackgroundColor = Windows.UI.Colors.Transparent; //statusBar.ForegroundColor = Windows.UI.Colors.Red; } }
public void Update(ThemeCustomInfo custom) { if (custom == null) { Update(SettingsService.Current.Appearance.RequestedTheme); return; } try { // Because of Compact, UpdateSource may be executed twice, but there is a bug in XAML and manually clear theme dictionaries here: // Prior to RS5, when ResourceDictionary.Source property is changed, XAML forgot to clear ThemeDictionaries. ThemeDictionaries.Clear(); MergedDictionaries.Clear(); MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("ms-appx:///Themes/ThemeGreen.xaml") }); var dict = new ResourceDictionary(); foreach (var item in custom.Values) { if (item.Key.EndsWith("Brush")) { dict[item.Key] = new SolidColorBrush((Color)item.Value); } else if (item.Key.EndsWith("Color")) { dict[item.Key] = (Color)item.Value; } } MergedDictionaries[0].MergedDictionaries.Clear(); MergedDictionaries[0].MergedDictionaries.Add(dict); if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { TLWindowContext.GetForCurrentView().UpdateTitleBar(); } } catch { } }
private void Activate() { if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) { var view = ApplicationView.GetForCurrentView(); view.SetPreferredMinSize(new Size(width: 800, height: 600)); var titleBar = ApplicationView.GetForCurrentView().TitleBar; if (titleBar != null) { titleBar.ButtonBackgroundColor = titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; titleBar.ForegroundColor = titleBar.ButtonInactiveForegroundColor = titleBar.ButtonForegroundColor = Colors.White; } } }
private async void NavigationHelper_SaveState(object sender, SaveStateEventArgs e) { if (this.ImagesViewModel.SelectedImageViewModel != null) { e.PageState["PostId"] = ImagesViewModel.SelectedImageViewModel.Post.Id; e.PageState["Index"] = ImagesViewModel.SelectedIndex; } if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { var statusBar = StatusBar.GetForCurrentView(); if (statusBar != null) { await statusBar.ShowAsync(); } } }
/// <summary> /// Registers event handlers for hardware buttons and orientation sensors, and performs an initial update of the UI rotation /// </summary> private void RegisterEventHandlers() { if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { HardwareButtons.CameraPressed += HardwareButtons_CameraPressed; } // If there is an orientation sensor present on the device, register for notifications if (_orientationSensor != null) { _orientationSensor.OrientationChanged += OrientationSensor_OrientationChanged; // Update orientation of buttons with the current orientation UpdateButtonOrientation(); } _displayInformation.OrientationChanged += DisplayInformation_OrientationChanged; _systemMediaControls.PropertyChanged += SystemMediaControls_PropertyChanged; }
private void SetupTitleBar() { ApplicationView view = ApplicationView.GetForCurrentView(); CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; ApplicationViewTitleBar titleBar = view.TitleBar; titleBar.ButtonBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { StatusBar statusBar = StatusBar.GetForCurrentView(); if (statusBar != null) { try { statusBar.BackgroundOpacity = 1; statusBar.BackgroundColor = ((AcrylicBrush)Current.Resources["AcrylicCommandBarBackground"]).TintColor; statusBar.ForegroundColor = ((SolidColorBrush)Current.Resources["Foreground"]).Color; } catch (Exception ex) { Logger.LogError(default(EventId), ex, "Error caught accessing resources. (Group 1)"); } } } try { view.TitleBar.ButtonForegroundColor = ((SolidColorBrush)Current.Resources["Foreground"]).Color; view.TitleBar.ButtonHoverBackgroundColor = ((SolidColorBrush)Current.Resources["MidBG"]).Color; view.TitleBar.ButtonHoverForegroundColor = ((SolidColorBrush)Current.Resources["Foreground"]).Color; view.TitleBar.ButtonPressedBackgroundColor = ((SolidColorBrush)Current.Resources["LightBG"]).Color; view.TitleBar.ButtonPressedForegroundColor = ((SolidColorBrush)Current.Resources["Foreground"]).Color; view.TitleBar.ButtonInactiveForegroundColor = ((SolidColorBrush)Current.Resources["MidBG_hover"]).Color; view.TitleBar.InactiveForegroundColor = ((SolidColorBrush)Current.Resources["MidBG_hover"]).Color; } catch (Exception ex) { Logger.LogError(default(EventId), ex, "Error caught accessing resources (Group 2)."); } }
public static string GetFolderPath(SpecialFolder folder, SpecialFolderOption option) { // For testing we'll fall back if the needed APIs aren't present. // // We're not honoring the special folder options (noverify/create) for a few reasons. One, most of the // folders always exist (e.g. it is moot). Two, most locations are inaccessible from an appcontainer // currently - making it impossible to answer the question of existence or create if necessary. Thirdly, // the Win32 API would create these folders with very specific ACLs, which even in the cases we can create // are a significant compat risk (trying to replicate internal Windows behavior- it is documented that they // set specific ACLs, but not which ones). if (ApiInformation.IsTypePresent("Windows.Storage.UserDataPaths")) { return(GetFolderPathCoreCurrent(folder)); } else { return(GetFolderPathCoreFallBack(folder)); } }
// Methods private void ShowStatusBar() { // Show StatusBar on Win10 Mobile, in theme of the pass if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { var statusBar = StatusBar.GetForCurrentView(); var bgcolor = Application.Current.Resources["TelegramBackgroundTitlebarBrush"] as SolidColorBrush; // Background statusBar.BackgroundColor = bgcolor.Color; statusBar.BackgroundOpacity = 1; // Branding colour //statusBar.BackgroundColor = Color.FromArgb(255, 54, 173, 225); //statusBar.ForegroundColor = Colors.White; //statusBar.BackgroundOpacity = 1; } }
async Task SetupUIAsync() { // Lock page to landscape to prevent the capture element from rotating DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape; // Hide status bar if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync(); } displayOrientation = displayInformation.CurrentOrientation; if (orientationSensor != null) { deviceOrientation = orientationSensor.GetCurrentOrientation(); } RegisterEventHandlers(); }
/// <summary> /// Initializes a new instance of the AppShell, sets the static 'Current' reference, /// adds callbacks for Back requests and changes in the SplitView's DisplayMode, and /// provide the nav menu list with the data to display. /// </summary> public AppShell() { this.InitializeComponent(); // Status bar color if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { StatusBar.GetForCurrentView().BackgroundOpacity = 0; StatusBar.GetForCurrentView().BackgroundColor = null; StatusBar.GetForCurrentView().ForegroundColor = Colors.WhiteSmoke; } // Setting the minimum size of the app :P ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size { Height = 340, Width = 340 }); this.Loaded += (sender, args) => { Current = this; }; // Register a handler for BackRequested events and set the // visibility of the Back button SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; this.CustomTitleBar.BackButtonVisibility = AppFrame.CanGoBack ? Visibility.Visible : Visibility.Collapsed; SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppFrame.CanGoBack ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; ApplicationView.GetForCurrentView().VisibleBoundsChanged += AppShell_VisibleBoundsChanged; }
public MainPage() { this.InitializeComponent(); this.DataContext = (Application.Current as App).PVM; //Value="{Binding ElementName=BackgroundMediaPlayer.Current, Path=Volume,Mode=TwoWay,Converter={StaticResource DoubleConverter}}" if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { Windows.UI.ViewManagement.StatusBar.GetForCurrentView().BackgroundColor = Color.FromArgb(100, 56, 79, 161); Windows.UI.ViewManagement.StatusBar.GetForCurrentView().BackgroundOpacity = 1; Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ForegroundColor = Colors.White; } else { Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar.BackgroundColor = Color.FromArgb(100, 56, 79, 161); Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar.ForegroundColor = Colors.White; Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar.ButtonBackgroundColor = Color.FromArgb(100, 56, 79, 161); Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar.ButtonForegroundColor = Colors.White; } Binding volumeB = new Binding { Source = BackgroundMediaPlayer.Current, Path = new PropertyPath("Volume"), Mode = BindingMode.TwoWay, Converter = new IntToDoubleConverter() }; volumeslider.SetBinding(Slider.ValueProperty, volumeB); BackgroundMediaPlayer.MessageReceivedFromBackground += BackgroundMediaPlayer_MessageReceivedFromBackground; BackgroundMediaPlayer.Current.MediaFailed += Current_MediaFailed; // Hook up app to system transport controls. systemControls = SystemMediaTransportControls.GetForCurrentView(); systemControls.ButtonPressed += SystemControls_ButtonPressed; // Register to handle the following system transpot control buttons. systemControls.IsPlayEnabled = true; systemControls.IsPauseEnabled = true; }
// Call this in App OnLaunched. // Requires reference to Windows Mobile Extensions for the UWP. /// <summary> /// Applies to the theme to the Application View. /// </summary> public static void ApplyToContainer() { // Custom accent color. ApplyAccentColor(DefaultAccentColor); // Title bar - if present. if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) { var titleBar = ApplicationView.GetForCurrentView().TitleBar; if (titleBar != null) { titleBar.ButtonBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; titleBar.ButtonForegroundColor = TitleBarButtonForegroundColor; titleBar.ButtonHoverBackgroundColor = TitleBarButtonForegroundColor; titleBar.ButtonPressedBackgroundColor = TitleBarButtonForegroundColor; } } }
private async void GenerateRenderTargetBitmapButton_Click(object sender, RoutedEventArgs e) { var rtb = new RenderTargetBitmap(); await rtb.RenderAsync(GradientRectangle); RenderTargetBitmapResultRectangle.Fill = new ImageBrush() { ImageSource = rtb }; var pixelBuffer = await rtb.GetPixelsAsync(); byte[] pixelArray = pixelBuffer.ToArray(); // Sample top left and center pixels to verify rendering is correct. var centerColor = GetPixelAtPoint(new Point(rtb.PixelWidth / 2, rtb.PixelHeight / 2), rtb, pixelArray); var outerColor = GetPixelAtPoint(new Point(0, 0), rtb, pixelArray); if (ApiInformation.IsTypePresent("Windows.UI.Composition.CompositionRadialGradientBrush")) { // If CompositionRadialGradientBrush is available then should be rendering a gradient. if (centerColor == Windows.UI.Colors.Orange && outerColor == Windows.UI.Colors.Green) { ColorMatchTestResult.Text = "Passed"; } else { ColorMatchTestResult.Text = "Failed"; } } else { if (centerColor == Windows.UI.Colors.Red && outerColor == Windows.UI.Colors.Red) { ColorMatchTestResult.Text = "Passed"; } else { ColorMatchTestResult.Text = "Failed"; } } }
private void LoadScenarios() { if (ApiInformation.IsTypePresent("Windows.Devices.Enumeration.DevicePicker")) { scenarios = new List <Scenario> { new Scenario() { Title = "1 - Media Element Casting 101", ClassType = Type.GetType("ScreenCasting.Scenario01", false) }, new Scenario() { Title = "2 - Casting APIs and a Custom Cast Button", ClassType = Type.GetType("ScreenCasting.Scenario02", false) }, new Scenario() { Title = "3 - DIAL Sender Windows Universal Application", ClassType = Type.GetType("ScreenCasting.Scenario03", false) }, new Scenario() { Title = "4 - DIAL Receiver Windows Universal Application", ClassType = Type.GetType("ScreenCasting.Scenario04") }, new Scenario() { Title = "5 - Multi-View Media Application", ClassType = Type.GetType("ScreenCasting.Scenario05") }, new Scenario() { Title = "6 - Combine Casting Methods", ClassType = Type.GetType("ScreenCasting.Scenario06") } }; } else { scenarios = new List <Scenario> { new Scenario() { Title = "DIAL Receiver Windows Universal Application", ClassType = typeof(Scenario04) } }; } }
/// <summary> /// This runs everytime the app is launched, even after suspension, so we use this to initialize stuff /// </summary> /// <param name="args"></param> /// <returns></returns> public override async Task OnInitializeAsync(IActivatedEventArgs args) { #if DEBUG // Init logger Logger.SetLogger(new ConsoleLogger(LogLevel.Info)); #endif // If we have a phone contract, hide the status bar if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { var statusBar = StatusBar.GetForCurrentView(); await statusBar.HideAsync(); } // Enter into full screen mode ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); ApplicationView.GetForCurrentView().FullScreenSystemOverlayMode = FullScreenSystemOverlayMode.Standard; // Forces the display to stay on while we play //_displayRequest.RequestActive(); WindowWrapper.Current().Window.VisibilityChanged += WindowOnVisibilityChanged; // Init vibration device if (ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice")) { _vibrationDevice = VibrationDevice.GetDefault(); } if (SettingsService.Instance.LiveTileMode == LiveTileModes.Peek) { LiveTileUpdater.EnableNotificationQueue(true); } // Check for network status NetworkInformation.NetworkStatusChanged += NetworkInformationOnNetworkStatusChanged; // Respond to changes in inventory and Pokemon in the immediate viscinity. GameClient.PokemonsInventory.CollectionChanged += PokemonsInventory_CollectionChanged; GameClient.CatchablePokemons.CollectionChanged += CatchablePokemons_CollectionChanged; await Task.CompletedTask; }
private void InitCompositionWithRotate(FrameworkElement element) { if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Hosting.ElementCompositionPreview")) { _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; var easing = _compositor.CreateCubicBezierEasingFunction( new Vector2(0.3f, 0.3f), new Vector2(0.0f, 1.0f) ); _visual = ElementCompositionPreview.GetElementVisual(element); // Set CenterPoint to the center, also when resized SizeChangedEventHandler fp = (sender, e) => _visual.CenterPoint = new Vector3((float)element.ActualWidth / 2f, (float)element.ActualHeight / 2f, 0.0f); element.SizeChanged += fp; fp.Invoke(null, null); // Create animation _offsetAnimation = _compositor.CreateVector3KeyFrameAnimation(); _offsetAnimation.Target = nameof(Visual.Offset); _offsetAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue", easing); _offsetAnimation.Duration = TimeSpan.FromMilliseconds(SelectedDuration); _rotationAnimation = _compositor.CreateScalarKeyFrameAnimation(); _rotationAnimation.Target = nameof(Visual.RotationAngleInDegrees); _rotationAnimation.InsertKeyFrame(0.0f, 0.0f); _rotationAnimation.InsertKeyFrame(1.0f, 360.0f); _rotationAnimation.Duration = _offsetAnimation.Duration; var animationGroup = _compositor.CreateAnimationGroup(); animationGroup.Add(_offsetAnimation); animationGroup.Add(_rotationAnimation); // Set trigger + assign animation var implicitAnimations = _compositor.CreateImplicitAnimationCollection(); implicitAnimations[nameof(Visual.Offset)] = animationGroup; _visual.ImplicitAnimations = implicitAnimations; } }
/// <summary> /// This runs everytime the app is launched, even after suspension, so we use this to initialize stuff /// </summary> /// <param name="args"></param> /// <returns></returns> public override async Task OnInitializeAsync(IActivatedEventArgs args) { // If we have a phone contract, hide the status bar if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { var statusBar = StatusBar.GetForCurrentView(); await statusBar.HideAsync(); } // Enter into full screen mode ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); ApplicationView.GetForCurrentView().FullScreenSystemOverlayMode = FullScreenSystemOverlayMode.Standard; // Forces the display to stay on while we play //_displayRequest.RequestActive(); WindowWrapper.Current().Window.VisibilityChanged += WindowOnVisibilityChanged; // Initialize Map styles await MapStyleHelpers.Initialize(); // Turn the display off when the proximity stuff detects the display is covered (battery saver) if (SettingsService.Instance.IsBatterySaverEnabled) { _proximityHelper.EnableDisplayAutoOff(true); } // Init vibration device if (ApiInformation.IsTypePresent("Windows.Phone.Devices.Notification.VibrationDevice")) { _vibrationDevice = VibrationDevice.GetDefault(); } // Check for network status NetworkInformation.NetworkStatusChanged += NetworkInformationOnNetworkStatusChanged; // Respond to changes in inventory and Pokemon in the immediate viscinity. GameClient.PokemonsInventory.CollectionChanged += PokemonsInventory_CollectionChanged; GameClient.CatchablePokemons.CollectionChanged += CatchablePokemons_CollectionChanged; await Task.CompletedTask; }
public static void ApplyOnWindowsContainer() { //Device check if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) { var windowsbar = ApplicationView.GetForCurrentView().TitleBar; windowsbar.BackgroundColor = (Application.Current.Resources["WindowsbarBackgroundBrush"] as SolidColorBrush)?.Color; windowsbar.ButtonBackgroundColor = (Application.Current.Resources["WindowsbarButtonBackgroundBrush"] as SolidColorBrush)?.Color; windowsbar.ButtonForegroundColor = (Application.Current.Resources["WindowsbarForegroundBrush"] as SolidColorBrush)?.Color; windowsbar.ForegroundColor = (Application.Current.Resources["WindowsbarForegroundBrush"] as SolidColorBrush)?.Color; windowsbar.ButtonBackgroundColor = (Application.Current.Resources["WindowsbarButtonBackgroundBrush"] as SolidColorBrush)?.Color; windowsbar.ButtonHoverBackgroundColor = (Application.Current.Resources["WindowsbarButtonHoverBrush"] as SolidColorBrush)?.Color; windowsbar.ButtonPressedBackgroundColor = (Application.Current.Resources["WindowsbarButtonPressedBrush"] as SolidColorBrush)?.Color; windowsbar.ButtonPressedForegroundColor = (Application.Current.Resources["WindowsbarForegroundBrush"] as SolidColorBrush)?.Color; windowsbar.ButtonInactiveBackgroundColor = (Application.Current.Resources["WindowsbarBackgroundBrush"] as SolidColorBrush)?.Color; windowsbar.ButtonInactiveForegroundColor = (Application.Current.Resources["WindowsbarForegroundBrush"] as SolidColorBrush)?.Color; windowsbar.ButtonHoverForegroundColor = (Application.Current.Resources["WindowsbarForegroundBrush"] as SolidColorBrush)?.Color; } }
public NavigationHelper(Page page) { this.Page = page; this.Page.Loaded += (sender, e) => { //if (this.Page.ActualHeight == Window.Current.Bounds.Height && // this.Page.ActualWidth == Window.Current.Bounds.Width) //{ if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed; } else { Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated += CoreDispatcher_AcceleratorKeyActivated; Window.Current.CoreWindow.PointerPressed += this.CoreWindow_PointerPressed; ViewModelLocator.Instance.NavigateBackHandler += NavigateBackHandler; } //} }; this.Page.Unloaded += (sender, e) => { if (ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) { Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed; } else { Window.Current.CoreWindow.Dispatcher.AcceleratorKeyActivated -= CoreDispatcher_AcceleratorKeyActivated; Window.Current.CoreWindow.PointerPressed -= this.CoreWindow_PointerPressed; ViewModelLocator.Instance.NavigateBackHandler -= NavigateBackHandler; } }; }
/// <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) { #if !DEBUG MobileCenter.Start("1fba816a-eea6-42a8-bf46-0c0fcc1589db", typeof(Analytics), typeof(Crashes)); #endif if (e.PreviousExecutionState != ApplicationExecutionState.Running) { Window.Current.Content = new ShellPage { Language = ApplicationLanguages.Languages[0] }; ApplicationLanguages.PrimaryLanguageOverride = GlobalizationPreferences.Languages[0]; var shell = (ShellPage)Window.Current.Content; // When the navigation stack isn't restored, navigate to the first page // suppressing the initial entrance animation. var setup = new Setup(shell.Frame); setup.Initialize(); var start = Mvx.Resolve <IMvxAppStart>(); start.Start(); BackgroundTaskHelper.Register(typeof(ClearPaymentsTask), new TimeTrigger(60, false)); BackgroundTaskHelper.Register(typeof(RecurringPaymentTask), new TimeTrigger(60, false)); Mvx.Resolve <IBackgroundTaskManager>().StartBackupSyncTask(60); shell.ViewModel = Mvx.Resolve <ShellViewModel>(); //If Jump Lists are supported, add them if (ApiInformation.IsTypePresent("Windows.UI.StartScreen.JumpList")) { await SetJumplist(); } await CallRateReminder(); } OverrideTitleBarColor(); // Ensure the current window is active Window.Current.Activate(); }
public void HoveringBehaviorTest() { // Overlay pass through element is only available from IFlyoutBase3 forward // On OS versions below RS5 test is unreliable/not working. // Tracked by https://github.com/Microsoft/microsoft-ui-xaml/issues/115 if (PlatformConfiguration.IsDevice(DeviceType.Phone) || !ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.Primitives.IFlyoutBase3") || PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone4)) { Log.Comment("Skipping tests on phone, because menubar is not supported."); return; } using (var setup = new TestSetupHelper("MenuBar Tests")) { var menuBar = FindElement.ById("SizedMenuBar"); var addButton = FindElement.ByName("AddItemsToEmptyMenuBar"); addButton.Click(); addButton.Click(); addButton.Click(); var help0 = FindElement.ByName <Button>("Help0"); var help1 = FindElement.ByName <Button>("Help1"); // This behavior seems to a bit unreliable, so repeat InputHelper.LeftClick(help0); TestEnvironment.VerifyAreEqualWithRetry(20, () => FindCore.ByName("Add0", shouldWait: false) != null, // The item should be in the tree () => true); // Check if hovering over the next button actually will show the correct item VerifyElement.NotFound("Add1", FindBy.Name); InputHelper.MoveMouse(help1, 0, 0); InputHelper.MoveMouse(help1, 1, 1); InputHelper.MoveMouse(help1, 5, 5); UIObject add1Element = null; ElementCache.Clear(); var element = GetElement(ref add1Element, "Add1"); Verify.IsNotNull(add1Element); } }
/// <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 void OnLaunched(LaunchActivatedEventArgs e) { if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { Windows.UI.ViewManagement.StatusBar.GetForCurrentView().BackgroundColor = Color.FromArgb(100, 0, 0, 0); Windows.UI.ViewManagement.StatusBar.GetForCurrentView().BackgroundOpacity = 1; Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ForegroundColor = Colors.White; } 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) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } }
private async Task InitializeStatusBar() { var accentBrush = Application.Current.Resources["ApplicationAccentBrush"] as SolidColorBrush; var accentDarkBrush1 = Application.Current.Resources["ApplicationDarkAccentBrush1"] as SolidColorBrush; var accentDarkBrush2 = Application.Current.Resources["ApplicationDarkAccentBrush2"] as SolidColorBrush; var accentDarkBrush3 = Application.Current.Resources["ApplicationDarkAccentBrush3"] as SolidColorBrush; //PC customization if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) { var titleBar = ApplicationView.GetForCurrentView().TitleBar; if (titleBar != null) { titleBar.ButtonBackgroundColor = accentBrush.Color; titleBar.ButtonHoverBackgroundColor = accentDarkBrush1.Color; titleBar.ButtonPressedBackgroundColor = accentDarkBrush2.Color; titleBar.ButtonForegroundColor = Colors.White; titleBar.ButtonHoverForegroundColor = Colors.White; titleBar.ButtonPressedForegroundColor = Colors.White; titleBar.BackgroundColor = accentBrush.Color; titleBar.ForegroundColor = Colors.White; titleBar.InactiveBackgroundColor = accentBrush.Color; titleBar.InactiveForegroundColor = Colors.White; titleBar.ButtonInactiveForegroundColor = Colors.White; titleBar.ButtonInactiveBackgroundColor = accentBrush.Color; } } //Mobile customization if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { var statusBar = StatusBar.GetForCurrentView(); await statusBar.HideAsync(); if (statusBar != null) { statusBar.BackgroundOpacity = 1; statusBar.BackgroundColor = accentBrush.Color; statusBar.ForegroundColor = Colors.White; } } }
/// <summary> /// Initializes a new instance of the <see cref="NavigationService"/> class. /// </summary> /// <param name="frame"> /// The frame. /// </param> public NavigationService(Frame frame) { if (frame == null) { throw new ArgumentNullException(nameof(frame)); } this.Frame = frame; this.Frame.Navigated += this.OnFrameNavigated; this.Frame.NavigationFailed += Frame_OnNavigationFailed; if (ApiInformation.IsTypePresent("Windows.UI.Core.SystemNavigationManager")) { this.navigationManager = SystemNavigationManager.GetForCurrentView(); if (this.navigationManager != null) { this.navigationManager.BackRequested += this.SystemNavigationManager_OnBackRequested; } } }
/// <summary> /// Attempts to lock the page orientation, hide the StatusBar (on Phone) and registers event handlers for hardware buttons and orientation sensors /// </summary> /// <returns></returns> private async Task SetupUiAsync() { // Attempt to lock page to landscape orientation to prevent the CaptureElement from rotating, as this gives a better experience DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape; // Hide the status bar if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync(); } // Populate orientation variables with the current state _displayOrientation = _displayInformation.CurrentOrientation; if (_orientationSensor != null) { _deviceOrientation = _orientationSensor.GetCurrentOrientation(); } RegisterEventHandlers(); }