public MainPage() { this.InitializeComponent(); // Setup try { if ((bool)SettingsHelper.GetSetting("SetupComplete", false) == false) { setupView.Visibility = Visibility.Visible; } } catch { SettingsHelper.UpdateSetting("SetupComplete", false, false); setupView.Visibility = Visibility.Visible; } // Set window properties, adjust title bar and track theme changes ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(800, 500)); TitleBarHelper titleBarHelper = new TitleBarHelper(textBlockPalettes); titleBarHelper.SetToAutomaticTitleBar(); // Events Messenger.Default.Register <Tuple <String, ColorCollectionItem> >(this, (action) => ReceiveVersionsViewModel(action)); Window.Current.Activated += Current_Activated; Clipboard.ContentChanged += Clipboard_ContentChanged; }
#pragma warning restore private void CreateFrame() { Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.Background = App.Current.Resources["MyerSplashDarkColor"] as SolidColorBrush; Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), null); } Window.Current.Activate(); TitleBarHelper.SetUpLightTitleBar(); if (DeviceHelper.IsMobile) { StatusBarHelper.SetUpStatusBar(); } SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; SystemNavigationManager.GetForCurrentView().BackRequested -= App_BackRequested; SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; if (APIInfoHelper.HasHardwareButton) { HardwareButtons.BackPressed -= HardwareButtons_BackPressed; HardwareButtons.BackPressed += HardwareButtons_BackPressed; } }
private void MainVM_OnCategoryChanged() { if (Window.Current.Bounds.Width >= 720) { HamburgerBtn.ForegroundBrush = MainVM.CateColor; TitleTB.Foreground = MainVM.CateColor; ProgressRing.Foreground = MainVM.CateColor; TitleBarHelper.SetUpTitleBarColorForDarkText(); } else { var solidColor = HeaderContentRootGrid.Background as SolidColorBrush; if (solidColor == null) { return; } if (solidColor.Color != MainVM.CateColor.Color) { ChangeColorAnim.To = MainVM.CateColor.Color; ChangeColorAnim.From = Colors.White; ChangeColorStory.Begin(); } HamburgerBtn.ForegroundBrush = new SolidColorBrush(Colors.White); TitleTB.Foreground = new SolidColorBrush(Colors.White); ProgressRing.Foreground = new SolidColorBrush(Colors.White); TitleBarHelper.SetUpTitleBarColorForLightText(); } }
protected override void OnLaunched(LaunchActivatedEventArgs e) { // Ensure the UI is initialized if (!(Window.Current.Content is Frame rootFrame)) { rootFrame = new Frame(); rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; TitleBarHelper.StyleTitleBar(); TitleBarHelper.ExpandViewIntoTitleBar(); if (e.PreviousExecutionState != ApplicationExecutionState.Running) { bool loadState = (e.PreviousExecutionState == ApplicationExecutionState.Terminated); ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, loadState); rootFrame.Content = extendedSplash; Window.Current.Content = rootFrame; } } // Enable the prelaunch if needed, and activate the window if (e.PrelaunchActivated == false) { CoreApplication.EnablePrelaunch(true); Window.Current.Activate(); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { await TitleBarHelper.SetVisibilityAsync(Windows.UI.Xaml.Visibility.Collapsed); TitleBarHelper.SetButtonBackgroundColor(Colors.Transparent); TitleBarHelper.SetButtonForegroundColor(Colors.White); }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); if (AllowShadows) { FrameworkElement tb = (FrameworkElement)this.GetTemplateChild("TitleBackground"); FrameworkElement cr = (FrameworkElement)this.GetTemplateChild("ContentRoot"); CompositionFactory.SetThemeShadow(cr, 40, tb); } if (this.GetTemplateChild("BtnClose") is Button close) { close.Click -= Close_Click; close.Click += Close_Click; } if (this.GetTemplateChild("TitleBackground") is FrameworkElement f && IsWindowRoot) { TitleBarHelper.SetTitleBar(f); CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; } OnTitleContentChanged(); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); await TitleBarHelper.SetVisibilityAsync(Windows.UI.Xaml.Visibility.Collapsed); TitleBarHelper.SetButtonBackgroundColor(Colors.Transparent); TitleBarHelper.SetButtonForegroundColor(Colors.White); var snm = SystemNavigationManager.GetForCurrentView(); snm.BackRequested -= App.GlobalBackRequested; snm.BackRequested += LoginPage_BackRequested; Messenger.Default.Register <NotificationMessage>(this, message => { ShowAlertGridStoryboard.Begin(); AlertDescriptionTextBlock.Text = message.Notification; }); ViewModel.PropertyChanged += (s, args) => { if (args.PropertyName.Equals(nameof(ViewModel.CurrentStep))) { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = ViewModel.PreviousCommand.CanExecute(null) ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; } }; }
/// <inheritdoc/> protected override void OnLaunched(LaunchActivatedEventArgs e) { // Ensure the UI is initialized if (Window.Current.Content is null) { Window.Current.Content = new Shell(); TitleBarHelper.StyleTitleBar(); TitleBarHelper.ExpandViewIntoTitleBar(); // Register services Ioc.Default.ConfigureServices( new ServiceCollection() .AddSingleton <IFilesService, FilesService>() .AddSingleton <ISettingsService, SettingsService>() .AddSingleton(RestService.For <IRedditService>("https://www.reddit.com/")) .BuildServiceProvider()); } // Enable the prelaunch if needed, and activate the window if (e.PrelaunchActivated == false) { CoreApplication.EnablePrelaunch(true); Window.Current.Activate(); } }
private void UpdateColorWhenSizeChanged() { if (Window.Current.Bounds.Width >= WIDTH_THRESHOLD) { if (!_isToggleAnim1) { ChangeColorAnim.To = Colors.White; ChangeColorAnim.From = (HeaderContentRootGrid.Background as SolidColorBrush).Color; ChangeColorStory.Begin(); _isToggleAnim1 = true; _isToggleAnim2 = false; ToggleDrawerAnimation(true); } HamburgerBtn.ForegroundBrush = MainVM.CateColor; TitleTB.Foreground = MainVM.CateColor; ProgressRing.Foreground = MainVM.CateColor; TitleBarHelper.SetUpTitleBarColorForDarkText(); } else { if (!_isToggleAnim2) { ChangeColorAnim.To = MainVM.CateColor.Color; ChangeColorAnim.From = Colors.White; ChangeColorStory.Begin(); _isToggleAnim2 = true; _isToggleAnim1 = false; ToggleDrawerAnimation(false); } HamburgerBtn.ForegroundBrush = new SolidColorBrush(Colors.White); TitleTB.Foreground = new SolidColorBrush(Colors.White); ProgressRing.Foreground = new SolidColorBrush(Colors.White); TitleBarHelper.SetUpTitleBarColorForLightText(); } }
public void SetTitleBar() { this.ApplyTemplate(); if (this.GetTemplateChild("TitleBackground") is FrameworkElement e) { TitleBarHelper.SetTranisentTitleBar(e); } }
public void SetWindowTitleBar() { this.ApplyTemplate(); if (this.GetTemplateChild("TitleBackground") is FrameworkElement e) { e.Measure(new Windows.Foundation.Size(32, 32)); TitleBarHelper.SetTitleBar(e); } }
private void QuickCompareView_Loaded(object sender, RoutedEventArgs e) { VisualStateManager.GoToState(this, NormalState.Name, false); TitleBarHelper.SetTitle(Presenter.Title); _navHelper.Activate(); //await Task.Delay(150); //Presenter.SetWindowTitleBar(); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { await TitleBarHelper.ResetToDefaultsAsync(); var titleBarColor = (App.Current.Resources["SystemControlBackgroundChromeMediumBrush"] as SolidColorBrush).Color; TitleBarHelper.SetBackgroundColor(titleBarColor); TitleBarHelper.SetButtonBackgroundColor(titleBarColor); Messenger.Default.Register <CompleteMultipleSelectionMessage>(this, message => DisableMultipleSelection()); }
private void UpdateThemeAndNotify() { var isLight = _uiSettings.GetColorValue(UIColorType.Background) == Colors.Black; if (isLight != IsLight) { IsLight = isLight; AppSettings.NotifyThemeChanged(); TitleBarHelper.SetupTitleBarColor(IsLight ?? false); Messenger.Default.Send(new GenericMessage <bool>(IsLight ?? false), MessengerTokens.THEME_CHANGED); } }
/// <summary> /// 进入 MainPage 会调用 /// </summary> /// <param name="param"></param> public async void Activate(object param) { TitleBarHelper.SetUpCateTitleBar(Enum.GetName(typeof(CateColors), SelectedCate)); if (param is LoginMode) { if (LOAD_ONCE) { return; } LOAD_ONCE = true; var mode = (LoginMode)param; switch (mode) { //已经登陆过的了 case LoginMode.Login: { CurrentUser.Email = LocalSettingHelper.GetValue("email"); ShowLoginBtnVisibility = Visibility.Collapsed; ShowAccountInfoVisibility = Visibility.Visible; //没有网络 if (App.IsNoNetwork) { await RestoreData(true); await Task.Delay(500); Messenger.Default.Send(new GenericMessage <string>(ResourcesHelper.GetString("NoNetworkHint")), MessengerTokens.ToastToken); } //有网络 else { Messenger.Default.Send(new GenericMessage <string>(ResourcesHelper.GetString("WelcomeBackHint")), MessengerTokens.ToastToken); await SyncAllToDos(); CurrentDisplayToDos = MyToDos; var resotreTask = RestoreData(false); } }; break; //处于离线模式 case LoginMode.OfflineMode: { ShowLoginBtnVisibility = Visibility.Visible; ShowAccountInfoVisibility = Visibility.Collapsed; var restoreTask = RestoreData(true); }; break; } } }
public void Show() { StartShowAnimation(); this.Visibility = Visibility.Visible; // Focus the close button to ensure keyboard focus is retained inside the panel BtnClose.Focus(FocusState.Programmatic); ViewModel.PropertyChanged -= ViewModel_PropertyChanged; ViewModel.PropertyChanged += ViewModel_PropertyChanged; TitleBarHelper.SetTranisentTitleBar(TitleBackground); }
/// <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 DEBUG if (Debugger.IsAttached) { DebugSettings.EnableFrameRateCounter = true; } #endif var 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) { // Init 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 } // Display an extended splash screen if app was not previously running. if (e.PreviousExecutionState != ApplicationExecutionState.Running) { var extendedSplash = new SplashPage(e.SplashScreen); rootFrame.Content = extendedSplash; Window.Current.Content = rootFrame; } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated) { return; } if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); // 设置透明TitleBar TitleBarHelper.SetTransparentTitleBar(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (DeviceHelper.IsDesktop) { TitleBarUc = TitleBarHelper.CustomTitleBar(this.Content); TitleBarUc.OnClickBackBtn += (s, ex) => { if (Frame.CanGoBack) { Frame.GoBack(); } }; } }
/// <summary> /// 改变要显示的列表 /// </summary> /// <param name="id"></param> private void ChangeDisplayCateList(int id) { Messenger.Default.Send(new GenericMessage <string>(""), MessengerTokens.CloseHam); var cateid = id; CateColor = App.Current.Resources[Enum.GetName(typeof(CateColors), cateid)] as SolidColorBrush; CateColorLight = App.Current.Resources[Enum.GetName(typeof(CateColors), cateid) + "Light"] as SolidColorBrush; CateColorDark = App.Current.Resources[Enum.GetName(typeof(CateColors), cateid) + "Dark"] as SolidColorBrush; TitleBarHelper.SetUpCateTitleBar(Enum.GetName(typeof(CateColors), cateid)); UpdateDisplayList(id); IsInSortMode = false; switch (cateid) { case 0: { Title = ResourcesHelper.GetString("CateDefault"); }; break; case 1: { Title = ResourcesHelper.GetString("CateWork"); }; break; case 2: { Title = ResourcesHelper.GetString("CateLife"); }; break; case 3: { Title = ResourcesHelper.GetString("CateFamily"); }; break; case 4: { Title = ResourcesHelper.GetString("CateEnter"); }; break; } }
/// <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 async override void OnLaunched(LaunchActivatedEventArgs e) { 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(MainView), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); TitleBarHelper.ExpandViewIntoTitleBar(); TitleBarHelper.SetupTitleBar(); await SetupStoreServices(); await GetCurrentUserIfSignedIn(); await CheckForUpdateOrFirstRun(); } }
private void UpdateBrushesAndTheme() { if (ViewModel.ColorScheme.Equals("light")) { ForegroundBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x44, 0x44, 0x44)); BackgroundBrush = new SolidColorBrush(Colors.White); ColorApplicationTheme = ElementTheme.Light; } else if (ViewModel.ColorScheme.Equals("sepia")) { ForegroundBrush = new SolidColorBrush(Colors.Maroon); BackgroundBrush = new SolidColorBrush(Colors.Beige); ColorApplicationTheme = ElementTheme.Light; } else if (ViewModel.ColorScheme.Equals("dark")) { ForegroundBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xCC, 0xCC, 0xCC)); BackgroundBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x33, 0x33, 0x33)); ColorApplicationTheme = ElementTheme.Dark; } else if (ViewModel.ColorScheme.Equals("black")) { ForegroundBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xB3, 0xB3, 0xB3)); BackgroundBrush = new SolidColorBrush(Colors.Black); ColorApplicationTheme = ElementTheme.Dark; } (FindName(nameof(commandsGrid)) as Grid).RequestedTheme = ColorApplicationTheme; TitleBarHelper.SetButtonForegroundColor(ForegroundBrush.Color); var gradientStops = (TitleBarBackgroundRectangle.Fill as LinearGradientBrush).GradientStops; gradientStops[0].Color = BackgroundBrush.Color; if (ColorApplicationTheme == ElementTheme.Dark) { gradientStops[1].Color = Color.FromArgb(1, 0, 0, 0); } else { gradientStops[1].Color = Colors.Transparent; } }
#pragma warning disable 1998 protected async override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { DebugSettings.EnableFrameRateCounter = true; } #endif if (e.PrelaunchActivated) { return; } CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; var task = JumpListHelper.SetupJumpList(); CreateFrameAndNavigate(e.Arguments); TitleBarHelper.SetupTitleBarColor(true); }
#pragma warning disable 1998 protected async override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif if (e.PrelaunchActivated) { return; } Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.Background = App.Current.Resources["MyerSplashDarkColor"] as SolidColorBrush; Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), e.Arguments); } Window.Current.Activate(); TitleBarHelper.SetUpLightTitleBar(); if (DeviceHelper.IsMobile) { StatusBarHelper.SetUpStatusBar(); } SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; if (APIInfoHelper.HasHardwareButton) { HardwareButtons.BackPressed += HardwareButtons_BackPressed; } }
public virtual void OnShow() { OnShownChanged?.Invoke(this, new ShownArgs() { Shown = true }); _titleBarControl = TitleBarHelper.CustomTitleBar(this.Content); _titleBarControl.OnClickBackBtn += (x, e) => { Shown = false; }; //Window.Current.SetTitleBar(this); if (DeviceHelper.IsMobile) { StatusBarHelper.SetUpBlackStatusBar(); } else { TitleBarHelper.SetUpTitleBarColorForDarkText(); } }
/// <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) { // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (!(Window.Current.Content is Frame rootFrame)) { await InitializeServices(); // Initial UI styling TitleBarHelper.ExpandViewIntoTitleBar(); TitleBarHelper.StyleTitleBar(); // 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(); await Services.GetService <IWhatsNewDisplayService>().ShowIfAppropriateAsync(); } }
#pragma warning restore private Frame CreateFrameAndNavigate(string arg) { Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.Background = App.Current.Resources["MyerSplashDarkColorBrush"] as SolidColorBrush; Window.Current.Content = rootFrame; } rootFrame.Navigate(typeof(MainPage), arg); Window.Current.Activate(); TitleBarHelper.SetUpLightTitleBar(); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; SystemNavigationManager.GetForCurrentView().BackRequested -= App_BackRequested; SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; return(rootFrame); }
#pragma warning restore private Frame CreateFrameAndNavigate(string arg) { if (!(Window.Current.Content is Frame rootFrame)) { rootFrame = new Frame { Background = App.Current.Resources["MyerSplashDarkColorBrush"] as SolidColorBrush }; Window.Current.Content = rootFrame; } rootFrame.Navigate(typeof(MainPage), arg); Window.Current.Activate(); var view = ApplicationView.GetForCurrentView(); if (DeviceUtil.IsXbox) { ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); if (view.TryEnterFullScreenMode()) { ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen; } } else { view.ExitFullScreenMode(); ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto; } TitleBarHelper.SetUpDarkTitleBar(); SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; SystemNavigationManager.GetForCurrentView().BackRequested -= App_BackRequested; SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; return(rootFrame); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { await TitleBarHelper.SetVisibilityAsync(Visibility.Collapsed); TitleBarHelper.SetButtonBackgroundColor(Colors.Transparent); TitleBarHelper.SetButtonForegroundColor(ForegroundBrush.Color); Messenger.Default.Register <LoadContentMessage>(this, message => { HtmlViewer.NavigateToString(ViewModel.FormattedHtml); }); Messenger.Default.Register <TagsEditedMessage>(this, async message => { if (message.Item.Id == ViewModel.Item.Model.Id) { await HtmlViewer.InvokeScriptAsync("updateTagsElement", new List <string>() { ViewModel.BuildTagsHtml(message.Item) }); } }); }
/// <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) { // Ensure the UI is initialized if (Window.Current.Content is null) { // Register services. Ioc.Default.ConfigureServices(ConfigureServices()); InitializeSettings(); Window.Current.Content = new MainPage(); TitleBarHelper.StyleTitleBar(); TitleBarHelper.ExpandViewIntoTitleBar(); } // Enable the prelaunch if needed, and activate the window if (e.PrelaunchActivated == false) { CoreApplication.EnablePrelaunch(true); Window.Current.Activate(); } }
protected override void SetUpTitleBar() { TitleBarHelper.SetUpLightTitleBar(); }