Beispiel #1
0
        private void SetTitlebar()
        {
            // Make the buttons transparent
            ApplicationViewTitleBar titlebar = ApplicationView.GetForCurrentView().TitleBar;

            titlebar.ButtonBackgroundColor         = Colors.Transparent;
            titlebar.ButtonInactiveBackgroundColor = Colors.Transparent;

            if (App.Current.RequestedTheme == ApplicationTheme.Dark)
            {
                titlebar.ButtonForegroundColor = Colors.White;
            }
            else if (App.Current.RequestedTheme == ApplicationTheme.Light)
            {
                titlebar.ButtonForegroundColor = Colors.Black;
            }

            // Extend the normal window to the Titlebar for the blur to reach there too
            CoreApplicationViewTitleBar coreTitlebar = CoreApplication.GetCurrentView().TitleBar;

            coreTitlebar.ExtendViewIntoTitleBar = true;
        }
        public MainPage()
        {
            InitializeComponent();

            // Hide default title bar.
            // https://docs.microsoft.com/en-us/windows/uwp/design/shell/title-bar
            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;

            // Register for changes
            coreTitleBar.LayoutMetricsChanged += this.CoreTitleBar_LayoutMetricsChanged;
            CoreTitleBar_LayoutMetricsChanged(coreTitleBar, null);

            coreTitleBar.IsVisibleChanged += this.CoreTitleBar_IsVisibleChanged;

            // Set XAML element as draggable region.
            Window.Current.SetTitleBar(AppTitleBar);

            // Listen for Fullscreen Changes from Shift+Win+Enter or our F11 shortcut
            ApplicationView.GetForCurrentView().VisibleBoundsChanged += this.MainPage_VisibleBoundsChanged;
        }
Beispiel #3
0
        /// <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)
        {
            // draw into the title bar
            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

            // remove the solid-colored backgrounds behind the caption controls and system back button
            var titleBar = ApplicationView.GetForCurrentView().TitleBar;

            titleBar.ButtonBackgroundColor         = Colors.Transparent;
            titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
            titleBar.ButtonForegroundColor         = (Color)this.Resources["SystemBaseHighColor"];

            if (string.IsNullOrEmpty(Settings.Instance.ExmoApiKey) ||
                string.IsNullOrEmpty(Settings.Instance.ExmoApiSecret))
            {
                Window.Current.Content = new LoginPage();
                Window.Current.Activate();
                return;
            }

            this.InitShell(e);
        }
		public static Visibility CalculateBackVisibility(Frame frame)
		{
			if (frame == null)
				return Visibility.Collapsed;

			var canGoBack = frame.CanGoBack;
			if (!canGoBack)
				return Visibility.Collapsed;

			var touchMode = UIViewSettings.GetForCurrentView().UserInteractionMode == UserInteractionMode.Touch;
			var mobilefam = ResourceContext.GetForCurrentView().QualifierValues["DeviceFamily"].Equals("Mobile");
			if (mobilefam && touchMode)
				return Visibility.Collapsed;

			var iotfam = ResourceContext.GetForCurrentView().QualifierValues["DeviceFamily"].Equals("IoT");
			if(!iotfam)
			{
				var desktopfam = ResourceContext.GetForCurrentView().QualifierValues["DeviceFamily"].Equals("Desktop");
				if (!desktopfam)
					return Visibility.Collapsed;
			}

			if (!iotfam && touchMode)
				return Visibility.Collapsed;

			var fullscreen = ApplicationView.GetForCurrentView().IsFullScreenMode;
			if (fullscreen)
				return Visibility.Visible;

			var optinback = SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility.Equals(AppViewBackButtonVisibility.Visible);
			if(optinback)
			{
				var hastitle = !CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar;
				if (hastitle)
					return Visibility.Collapsed;
			}

			return Visibility.Visible;
		}
Beispiel #5
0
        private void InitializeTitleBar()
        {
            App.DeviceType = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;

            if (App.DeviceType == "Windows.Mobile")
            {
                var statusBar = StatusBar.GetForCurrentView();
                statusBar.HideAsync();
                return;
            }

            Window.Current.Activated += Current_Activated;
            CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;

            TitleBar.Height = coreTitleBar.Height;
            Window.Current.SetTitleBar(MainTitleBar);

            coreTitleBar.IsVisibleChanged     += CoreTitleBar_IsVisibleChanged;
            coreTitleBar.LayoutMetricsChanged += CoreTitleBar_LayoutMetricsChanged;
        }
Beispiel #6
0
        public Home()
        {
            this.InitializeComponent();
            ((HomeViewModel)DataContext).Reload();

            var titleBar = ApplicationView.GetForCurrentView().TitleBar;

            titleBar.ButtonBackgroundColor         = Colors.Transparent;
            titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;
            UpdateTitleBarLayout(coreTitleBar);

            Window.Current.SetTitleBar(AppTitleBar);

            coreTitleBar.LayoutMetricsChanged += CoreTitleBar_LayoutMetricsChanged;
            coreTitleBar.IsVisibleChanged     += CoreTitleBar_IsVisibleChanged;

            Window.Current.Activated += Current_Activated;
        }
Beispiel #7
0
        private void OnLoading(FrameworkElement sender, object e)
        {
            Color accent      = (Color)Application.Current.Resources["Theme.Color.Accent"];
            Color accentLight = (Color)Application.Current.Resources["Theme.Color.AccentLight"];
            Color accentDark  = (Color)Application.Current.Resources["Theme.Color.AccentDark"];
            Color foreground  = (Color)Application.Current.Resources["Theme.Color.AccentForeground"];

            ApplicationView view = ApplicationView.GetForCurrentView();

            view.TitleBar.BackgroundColor              = view.TitleBar.InactiveBackgroundColor = accent;
            view.TitleBar.ButtonBackgroundColor        = view.TitleBar.ButtonInactiveBackgroundColor = accent;
            view.TitleBar.ForegroundColor              = view.TitleBar.ButtonForegroundColor = foreground;
            view.TitleBar.InactiveForegroundColor      = view.TitleBar.ButtonInactiveForegroundColor = foreground;
            view.TitleBar.ButtonHoverBackgroundColor   = accentLight;
            view.TitleBar.ButtonPressedBackgroundColor = accentDark;
            view.TitleBar.ButtonHoverForegroundColor   = view.TitleBar.ButtonPressedForegroundColor = foreground;

            CoreApplicationView coreView = CoreApplication.GetCurrentView();

            coreView.TitleBar.ExtendViewIntoTitleBar = true;
            Window.Current.SetTitleBar(TitleBarPanel);
        }
Beispiel #8
0
        /// <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)
        {
            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
            ApplicationView.GetForCurrentView().TitleBar.ButtonBackgroundColor = Colors.Transparent;
            ApplicationView.GetForCurrentView().TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

            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();
            }
        }
        /// <summary>
        /// Displays a save file dialog to the user.
        /// </summary>
        /// <param name="commitButtonText">The text, that is displayed on the commit button, that the user has to press to select a file.</param>
        /// <param name="fileTypeChoices">The file type filter, which determines which kinds of files are available to the user.</param>
        /// <param name="suggestedSaveFile">The file which is suggested to the user as the file to which he is saving.</param>
        /// <param name="suggestedStartLocation">The suggested start location, which is initally displayed by the save file dialog.</param>
        /// <returns>Returns the dialog result with the file that was selected by the user.</returns>
        public virtual async Task <DialogResult <StorageFile> > ShowSaveFileDialogAsync(string commitButtonText, IEnumerable <FileTypeRestriction> fileTypeChoices, StorageFile suggestedSaveFile, PickerLocationId suggestedStartLocation)
        {
            // Creates a new task completion source for the result of the save file dialog
            TaskCompletionSource <StorageFile> taskCompletionSource = new TaskCompletionSource <StorageFile>();

            // Executes the save file dialog on the dispatcher thread of the current core application view, this is needed so that the code is always executed on the UI thread
            await CoreApplication.GetCurrentView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                // Creates a new save file dialog
                FileSavePicker fileSavePicker = new FileSavePicker
                {
                    CommitButtonText       = commitButtonText,
                    SuggestedStartLocation = suggestedStartLocation
                };
                if (suggestedSaveFile != null)
                {
                    fileSavePicker.SuggestedSaveFile = suggestedSaveFile;
                }
                foreach (FileTypeRestriction fileTypeRestriction in fileTypeChoices)
                {
                    fileSavePicker.FileTypeChoices.Add(fileTypeRestriction.FileTypesDescription, fileTypeRestriction.FileTypes.Select(fileType => fileType == "*" ? fileType : $".{fileType}").ToList());
                }

                // Shows the save file dialog and stores the result
                taskCompletionSource.TrySetResult(await fileSavePicker.PickSaveFileAsync());
            });

            // Checks if the user cancelled the save file dialog, if so then cancel is returned, otherwise okay is returned with the file that was picked by the user
            StorageFile storageFile = await taskCompletionSource.Task;

            if (storageFile == null)
            {
                return(new DialogResult <StorageFile>(DialogResult.Cancel, null));
            }
            else
            {
                return(new DialogResult <StorageFile>(DialogResult.Okay, storageFile));
            }
        }
Beispiel #10
0
        public Settings()
        {
            this.InitializeComponent();

            var CoreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            CoreTitleBar.ExtendViewIntoTitleBar = true;
            Window.Current.SetTitleBar(DragArea);

            var currentView = SystemNavigationManager.GetForCurrentView();

            currentView.BackRequested += OnBackRequested;

            var flowDirectionSetting = ResourceContext.GetForCurrentView().QualifierValues["LayoutDirection"];

            if (flowDirectionSetting == "RTL")
            {
                FlowDirection = FlowDirection.RightToLeft;
            }

            SettingsPane.SelectedItem = SettingsPane.MenuItems[0];
        }
        public TalkPage()
        {
            this.InitializeComponent();
            synth = new SpeechSynthesizer();

            appVersion.Text = UpdateHelper.GetVersion();
            CheckUpdateStatus();
            GetVoices();
            CheckPurchaseStatus();

            _loopEnabled = false;

            _player.AutoPlay              = false;
            _player.AudioCategory         = MediaPlayerAudioCategory.Speech;
            _mediaControls                = _player.SystemMediaTransportControls;
            _mediaControls.AutoRepeatMode = MediaPlaybackAutoRepeatMode.None;
            txtTextToSay.Focus(FocusState.Programmatic);

            var titleBar = CoreApplication.GetCurrentView().TitleBar;

            titleBar.IsVisibleChanged += TitleBar_IsVisibleChanged;
        }
Beispiel #12
0
        /// <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();
            _appVersion = (TextBlock)this.FindName("appVersion");

            this.Loaded += (sender, args) =>
            {
                Current = this;

                this.CheckTogglePaneButtonSizeChanged();

                var titleBar = CoreApplication.GetCurrentView().TitleBar;

                ApplicationViewTitleBar formattableTitleBar = ApplicationView.GetForCurrentView().TitleBar;
                formattableTitleBar.ButtonBackgroundColor = Windows.UI.Colors.Transparent;
                CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;
                coreTitleBar.ExtendViewIntoTitleBar          = true;
                ApplicationView.PreferredLaunchViewSize      = new Size(1000, 750);
                ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

                titleBar.IsVisibleChanged += TitleBar_IsVisibleChanged;
            };

            this.RootSplitView.RegisterPropertyChangedCallback(
                SplitView.DisplayModeProperty,
                (s, a) =>
            {
                // Ensure that we update the reported size of the TogglePaneButton when the SplitView's
                // DisplayMode changes.
                this.CheckTogglePaneButtonSizeChanged();
            });

            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;


            NavMenuList.ItemsSource  = navlist;
            NavMenuList2.ItemsSource = navlist2;
            NavMenuList3.ItemsSource = navlist3;
        }
        /// <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 (e == null)
            {
                return;
            }
            // 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))
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e != null && 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(AppNavigation), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
            EnsureWindow();

            ThemeHelper.Initialize();

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
            Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;
            rootFrame.PointerPressed += On_PointerPressed;
        }
        public NavigationRootPage()
        {
            this.InitializeComponent();

            _navHelper = new RootFrameNavigationHelper(rootFrame, NavigationViewControl);

            SetDeviceFamily();
            AddNavigationMenuItems();
            Current   = this;
            RootFrame = rootFrame;

            this.GotFocus += (object sender, RoutedEventArgs e) =>
            {
                // helpful for debugging focus problems w/ keyboard & gamepad
                if (FocusManager.GetFocusedElement() is FrameworkElement focus)
                {
                    Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")");
                }
            };

            this.Loaded += (s, e) =>
            {
                // This is to work around a bug in the NavigationView header that hard-codes the header content to a 48 pixel height.
                var headerContentControl = NavigationViewControl.GetDescendantsOfType <ContentControl>().Where(c => c.Name == "HeaderContent").FirstOrDefault();

                if (headerContentControl != null)
                {
                    headerContentControl.Height = double.NaN;
                }
            };

            Gamepad.GamepadAdded   += OnGamepadAdded;
            Gamepad.GamepadRemoved += OnGamepadRemoved;

            Window.Current.CoreWindow.SizeChanged += (s, e) => UpdateAppTitle();
            CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle();

            _isKeyboardConnected = Convert.ToBoolean(new KeyboardCapabilities().KeyboardPresent);
        }
        /// <summary>
        /// Set the source URI of the image.
        /// </summary>
        /// <param name="view">The image view instance.</param>
        /// <param name="source">The source URI.</param>
        private async void SetUriFromSingleSource(Border view, string source)
        {
            var imageBrush = (ImageBrush)view.Background;

            OnImageStatusUpdate(view, ImageLoadStatus.OnLoadStart, default(ImageMetadata));
            try
            {
                var imagePipeline = ImagePipelineFactory.Instance.GetImagePipeline();
                var dispatcher    = CoreApplication.GetCurrentView().Dispatcher;
                var image         = await imagePipeline.FetchEncodedBitmapImageAsync(new Uri(source), default(CancellationToken), dispatcher);

                var metadata = new ImageMetadata(source, image.PixelWidth, image.PixelHeight);

                OnImageStatusUpdate(view, ImageLoadStatus.OnLoad, metadata);
                imageBrush.ImageSource = image;
                OnImageStatusUpdate(view, ImageLoadStatus.OnLoadEnd, metadata);
            }
            catch (Exception e)
            {
                OnImageFailed(view, e);
            }
        }
Beispiel #16
0
        public MainPage()
        {
            this.InitializeComponent();
            #region 标题栏设置 Title Bar Setting
            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; //扩展标题栏
            Window.Current.SetTitleBar(TitleBar);                                    //设置某个容器空间(我一般就用的Grid)为标题栏,即可拖拽来位移窗体
            //注意:该控件必须要有颜色,哪怕是Transparent透明也行。如果不设置background,它就是空的没法进行拖拽。
            var view = ApplicationView.GetForCurrentView();                          //来进行以下一系列设置标题栏组件颜色的操作

            view.TitleBar.ButtonBackgroundColor         = Color.FromArgb(0, 0, 0, 0);
            view.TitleBar.ButtonForegroundColor         = Colors.White;
            view.TitleBar.ButtonHoverBackgroundColor    = Color.FromArgb(38, 0, 0, 0);
            view.TitleBar.ButtonHoverForegroundColor    = Colors.White;
            view.TitleBar.ButtonPressedBackgroundColor  = Color.FromArgb(70, 0, 0, 0);
            view.TitleBar.ButtonPressedForegroundColor  = Colors.White;
            view.TitleBar.ButtonInactiveBackgroundColor = Color.FromArgb(0, 0, 0, 0);
            view.TitleBar.ButtonInactiveForegroundColor = Colors.White;
            #endregion
            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(350, 500));

            MainFrame.Navigate(typeof(FramePage));
        }
Beispiel #17
0
        public Settings()
        {
            this.InitializeComponent();

            var CoreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            CoreTitleBar.ExtendViewIntoTitleBar = true;
            var titleBar = ApplicationView.GetForCurrentView().TitleBar;

            titleBar.ButtonInactiveBackgroundColor = Color.FromArgb(0, 255, 255, 255);
            titleBar.ButtonHoverBackgroundColor    = Color.FromArgb(75, 10, 10, 10);
            if (App.Current.RequestedTheme == ApplicationTheme.Dark)
            {
                titleBar.ButtonBackgroundColor      = Color.FromArgb(0, 0, 0, 0);
                titleBar.ButtonForegroundColor      = Colors.White;
                titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 240, 240, 240);
                titleBar.BackgroundColor            = Color.FromArgb(255, 25, 25, 25);
            }
            else if (App.Current.RequestedTheme == ApplicationTheme.Light)
            {
                titleBar.ButtonBackgroundColor      = Color.FromArgb(0, 255, 255, 255);
                titleBar.ButtonForegroundColor      = Colors.Black;
                titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 155, 155, 155);
            }

            if (this.RequestedTheme == ElementTheme.Dark)
            {
                titleBar.ButtonForegroundColor      = Colors.White;
                titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 240, 240, 240);
                titleBar.BackgroundColor            = Color.FromArgb(255, 25, 25, 25);
            }
            else if (this.RequestedTheme == ElementTheme.Light)
            {
                titleBar.ButtonForegroundColor      = Colors.Black;
                titleBar.ButtonHoverBackgroundColor = Color.FromArgb(75, 155, 155, 155);
                titleBar.BackgroundColor            = Colors.Transparent;
            }
            SettingsContentFrame.Navigate(typeof(Appearance));
        }
Beispiel #18
0
        private void lanunchCore(IActivatedEventArgs e, bool prelaunchActivated)
        {
#if !DEBUG
            if (!AppCenter.Configured)
            {
                var region = new Windows.Globalization.GeographicRegion();
                AppCenter.SetCountryCode(region.CodeTwoLetter);
                AppCenter.Start(Telemetry.AppCenterKey, typeof(Analytics), typeof(Crashes));
            }
#endif
            if (Opportunity.MvvmUniverse.Services.Notification.Notificator.GetForCurrentView().Handlers.Count == 0)
            {
                Opportunity.MvvmUniverse.Services.Notification.Notificator.GetForCurrentView().Handlers.Add(new Services.ContentDialogNotification());
                Opportunity.MvvmUniverse.Services.Notification.Notificator.GetForCurrentView().Handlers.Add(new Services.InAppToastNotification());
            }
            var jumplist       = JumplistManager.RefreshJumplistAsync();
            var currentWindow  = Window.Current;
            var currentContent = currentWindow.Content;
            if (currentContent is null)
            {
                var view = ApplicationView.GetForCurrentView();
                view.SetPreferredMinSize(new Size(320, 500));
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                currentContent        = new SplashControl(e.SplashScreen);
                currentWindow.Content = currentContent;
            }
            if (currentContent is SplashControl sc)
            {
                if (!prelaunchActivated)
                {
                    sc.EnableGoToContent();
                }
            }
            else
            {
                currentWindow.Activate();
            }
            ((Opportunity.UWP.Converters.Typed.StringToBooleanConverter) this.Resources["EmptyStringToFalseConverter"]).ValuesForFalse.Add("");
        }
Beispiel #19
0
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: 从之前挂起的应用程序加载状态
                }

                // 将框架放在当前窗口中
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // 当导航堆栈尚未还原时,导航到第一页,
                    // 并通过将所需信息作为导航参数传入来配置
                    // 参数
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // 确保当前窗口处于活动状态
                Window.Current.Activate();
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
                titleBar.ButtonBackgroundColor         = Colors.Transparent;
                titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
            }
        }
Beispiel #20
0
        public NavigationRootPage()
        {
            this.InitializeComponent();

            _navHelper = new RootFrameNavigationHelper(rootFrame, NavigationViewControl);

            SetDeviceFamily();
            AddNavigationMenuItems();
            Current   = this;
            RootFrame = rootFrame;

            this.GotFocus += (object sender, RoutedEventArgs e) =>
            {
                // helpful for debugging focus problems w/ keyboard & gamepad
                if (FocusManager.GetFocusedElement() is FrameworkElement focus)
                {
                    Debug.WriteLine("got focus: " + focus.Name + " (" + focus.GetType().ToString() + ")");
                }
            };

            Gamepad.GamepadAdded   += OnGamepadAdded;
            Gamepad.GamepadRemoved += OnGamepadRemoved;

            Window.Current.SetTitleBar(AppTitleBar);

            CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += (s, e) => UpdateAppTitle(s);

            _isKeyboardConnected = Convert.ToBoolean(new KeyboardCapabilities().KeyboardPresent);


            // remove the solid-colored backgrounds behind the caption controls and system back button
            // This is done when the app is loaded since before that the actual theme that is used is not "determined" yet
            Loaded += delegate(object sender, RoutedEventArgs e) {
                ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
                titleBar.ButtonBackgroundColor         = Colors.Transparent;
                titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
            };
        }
Beispiel #21
0
        public Link()
        {
            currentObject = this;
            this.InitializeComponent();
            //设置标题栏
            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            if (!coreTitleBar.IsVisible)
            {
                AppTitleBar.Visibility = Visibility.Collapsed;
            }
            Thickness thickness = new Thickness()
            {
                Top = coreTitleBar.IsVisible ? 32 : 0
            };

            PaneGrid.Padding = thickness;
            TopBar.Padding   = thickness;
            coreTitleBar.IsVisibleChanged += CoreTitleBar_IsVisibleChanged;
            Window.Current.SetTitleBar(DraggableArea);
            //设置导航
            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackrequested;
            Rua.Navigated        += Content_Navigated;
            Rua.NavigationFailed += App.OnNavigationFailed;
            Rua.Navigate(typeof(Index), null, new DrillInNavigationTransitionInfo());
            App.Link   = Rua;
            frameTitle = PageName;
            toastArea  = ToastArea;
            //如果第一次打开这个版本则弹出提示
            string appVersion = Methods.GetAppVersion();

            if (SettingHelper.Values.Version != appVersion)
            {
                var dialog = new UpdateLog();
                var task   = dialog.ShowAsync();
                SettingHelper.Values.Version = appVersion;
            }
        }
Beispiel #22
0
        private void SetupTitleBar(CoreApplicationViewTitleBar coreAppTitleBar = null)
        {
            var coreTitleBar = coreAppTitleBar ?? CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;

            // Get the size of the caption controls area and back button
            // (returned in logical pixels), and move your content around as necessary.
            LeftPaddingColumn.Width  = new GridLength(coreTitleBar.SystemOverlayLeftInset);
            RightPaddingColumn.Width = new GridLength(coreTitleBar.SystemOverlayRightInset);

            // Set XAML element as a draggable region.
            Window.Current.SetTitleBar(UserLayout);

            // Register a handler for when the size of the overlaid caption control changes.
            // For example, when the app moves to a screen with a different DPI.
            coreTitleBar.LayoutMetricsChanged += OnTitleBarLayoutMetricsChanged;

            //Display the right icon for exiting/entering Overlay Mode
            if (ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.Default)
            {
                ExitOverlayIcon.Visibility = Visibility.Collapsed;
                GoToOverlayIcon.Visibility = Visibility.Visible;
                ToolTip toolTip = new ToolTip();
                toolTip.Content = Strings.Resources.GoToOverlay;
                ToolTipService.SetToolTip(OverlayButton, toolTip);
                AutomationProperties.SetName(OverlayButton, Strings.Resources.GoToOverlay);
            }
            else
            {
                ExitOverlayIcon.Visibility = Visibility.Visible;
                GoToOverlayIcon.Visibility = Visibility.Collapsed;
                ToolTip toolTip = new ToolTip();
                toolTip.Content = Strings.Resources.ExitOverlay;
                ToolTipService.SetToolTip(OverlayButton, toolTip);
                AutomationProperties.SetName(OverlayButton, Strings.Resources.ExitOverlay);
            }
        }
Beispiel #23
0
        /// <summary>
        /// Wird aufgerufen, wenn die Anwendung durch den Endbenutzer normal gestartet wird. Weitere Einstiegspunkte
        /// werden z. B. verwendet, wenn die Anwendung gestartet wird, um eine bestimmte Datei zu öffnen.
        /// </summary>
        /// <param name="e">Details über Startanforderung und -prozess.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // App-Initialisierung nicht wiederholen, wenn das Fenster bereits Inhalte enthält.
            // Nur sicherstellen, dass das Fenster aktiv ist.
            if (rootFrame == null)
            {
                // Frame erstellen, der als Navigationskontext fungiert und zum Parameter der ersten Seite navigieren
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Zustand von zuvor angehaltener Anwendung laden
                }

                // Den Frame im aktuellen Fenster platzieren
                Window.Current.Content = rootFrame;
                App.RootTheme          = AppSettings.Theme;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // Wenn der Navigationsstapel nicht wiederhergestellt wird, zur ersten Seite navigieren
                    // und die neue Seite konfigurieren, indem die erforderlichen Informationen als Navigationsparameter
                    // übergeben werden
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Sicherstellen, dass das aktuelle Fenster aktiv ist
                Window.Current.Activate();
            }

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
        }
Beispiel #24
0
        private async Task LaunchApplicationAsync(string page, object launchParam)
        {
            CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;
            await DataService.CreateTheDatabaseAsync();

            await DataService.RemoveFuturePeriodsAsync();

            await ThemeSelectorService.SetRequestedThemeAsync();

            NavigationService.Navigate(page, launchParam);
            Window.Current.Activate();

            SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += async(s, e) =>
            {
                HasExited = true;
                var deferral = e.GetDeferral();
                await DataService.RemoveFuturePeriodsAsync();

                NotificationManager.Current.IsEnabled = false;
                NotificationManager.Current.RemoveBreakFinishedToastNotificationSchedule();
                NotificationManager.Current.RemovePomodoroFinishedToastNotificationSchedule();

                deferral.Complete();
            };
            NotificationManager.Current.RemoveBreakFinishedToastNotificationSchedule();
            NotificationManager.Current.RemovePomodoroFinishedToastNotificationSchedule();


            //var dialog = new Views.FirstRunDialog();
            //await dialog.ShowAsync();
            //await Container.Resolve<IWhatsNewDisplayService>().ShowIfAppropriateAsync();
            await Container.Resolve <IFirstRunDisplayService>().ShowIfAppropriateAsync();

            //Container.Resolve<ILiveTileService>().SampleUpdate();
            //Container.Resolve<IToastNotificationsService>().ShowToastNotificationSample();
        }
Beispiel #25
0
        public MainPage()
        {
            this.InitializeComponent();

            //回退功能
            SystemNavigationManager navmgr = SystemNavigationManager.GetForCurrentView();

            navmgr.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            navmgr.BackRequested += navmgr_BackRequested;

            this.RegisterPropertyChangedCallback(ViewModelProperty, (_, __) =>
            {
                StrongTypeViewModel = this.ViewModel as MainPage_Model;
            });
            StrongTypeViewModel = this.ViewModel as MainPage_Model;


            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;
            initializeFrostedGlass(GlassHost);
            initializeFrostedGlass(GlassHost1);
            ApplicationView view = ApplicationView.GetForCurrentView();

            //将标题栏的三个键背景设为透明
            view.TitleBar.ButtonBackgroundColor = Colors.Transparent;
            //失去焦点时,将三个键背景设为透明
            view.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
            //失去焦点时,将三个键前景色设为白色
            view.TitleBar.ButtonInactiveForegroundColor = Colors.White;

            //X方向滑动打开汉堡菜单服务
            this.ManipulationMode       = ManipulationModes.TranslateX;
            this.ManipulationCompleted += The_ManipulationCompleted;
            this.ManipulationDelta     += The_ManipulationDelta;

            Page_Loaded();
        }
Beispiel #26
0
        public MainPage(IActivatedEventArgs args)
        {
            this.InitializeComponent();

            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;

            coreTitleBar.LayoutMetricsChanged += delegate
            {
                AppTitleBar.Height = coreTitleBar.Height;
            };

            // Set a XAML element as title bar
            Window.Current.SetTitleBar(AppTitleBar);

            ViewModel        = new MainViewmodel(args);
            this.DataContext = ViewModel;

            #region registering for messages
            Messenger.Default.Register <LocalNotificationMessageType>(this, RecieveLocalNotificationMessage);
            Messenger.Default.Register(this, delegate(SetHeaderTextMessageType m) { SetHeadertext(m.PageName); });
            Messenger.Default.Register(this, delegate(AdsEnabledMessageType m) { ViewModel.ToggleAdsVisiblity(); });
            Messenger.Default.Register(this, delegate(UpdateUnreadNotificationMessageType m) { ViewModel.UpdateUnreadNotificationIndicator(m.IsUnread); });
            Messenger.Default.Register(this, async delegate(ShowWhatsNewPopupMessageType m) { await ShowWhatsNewPopupVisiblity(); });
            Messenger.Default.Register <User>(this, ViewModel.RecieveSignInMessage);
            #endregion

            notifManager = new LocalNotificationManager(NotificationGrid);

            Loaded      += MainPage_Loaded;
            SizeChanged += MainPage_SizeChanged;

            SimpleIoc.Default.Register <IAsyncNavigationService>(() => { return(new NavigationService(AppFrame)); });
            SystemNavigationManager.GetForCurrentView().BackRequested += SystemNavigationManager_BackRequested;

            NavigationCacheMode = NavigationCacheMode.Enabled;
        }
Beispiel #27
0
        public MainPage()
        {
            InitializeComponent();
            TheMainPage = this;
            Settings    = AppData.Settings;
            AppMenu     = new AppMenu(MenuItem_Click);

            AppData.Settings.PropertyChanged += Settings_PropertyChanged;
            ApplyUiColors();
            // Set XAML element as draggable region.
            Window.Current.SetTitleBar(AppTitleBar);

            // Hide default title bar.
            // https://docs.microsoft.com/en-us/windows/uwp/design/shell/title-bar
            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;

            // Register for changes
            coreTitleBar.LayoutMetricsChanged += this.CoreTitleBar_LayoutMetricsChanged;
            CoreTitleBar_LayoutMetricsChanged(coreTitleBar, null);

            coreTitleBar.IsVisibleChanged += this.CoreTitleBar_IsVisibleChanged;

            // Listen for Fullscreen Changes from Shift+Win+Enter or our F11 shortcut
            ApplicationView.GetForCurrentView().VisibleBoundsChanged += this.MainPage_VisibleBoundsChanged;

            if (AppData.SavedChapter == null)
            {
                WelcomeBubble.Visibility = Visibility.Visible;
                AddTabButton.Visibility  = Visibility.Collapsed;
            }
            else
            {
                SetTabItem(AppData.SavedChapter.BookNumber, AppData.SavedChapter.ChapterNumber, AppData.SavedChapter.Paragraph, true);
                AppData.SavedChapter = null;
            }
        }
Beispiel #28
0
        /// <summary>
        ///     Setup the view model, passing in the navigation events.
        /// </summary>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Setup view model
            ViewModel.SetupModel();

            // Track Event
            App.Telemetry.TrackPage("Now Playing View");

            if (DeviceHelper.IsDesktop)
            {
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                // Update Title bar colors
                ApplicationView.GetForCurrentView().TitleBar.ButtonBackgroundColor = Colors.Transparent;
                ApplicationView.GetForCurrentView().TitleBar.ButtonHoverBackgroundColor =
                    new Color {
                    R = 0, G = 0, B = 0, A = 20
                };
                ApplicationView.GetForCurrentView().TitleBar.ButtonPressedBackgroundColor =
                    new Color {
                    R = 0, G = 0, B = 0, A = 60
                };
                ApplicationView.GetForCurrentView().TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
                ApplicationView.GetForCurrentView().TitleBar.ForegroundColor = Colors.White;
                ApplicationView.GetForCurrentView().TitleBar.ButtonForegroundColor = Colors.White;
                ApplicationView.GetForCurrentView().TitleBar.ButtonHoverForegroundColor = Colors.White;
                ApplicationView.GetForCurrentView().TitleBar.ButtonPressedForegroundColor = Colors.White;
            }

            // Hide the overlay for a new session
            HideOverlay();

            if (!DeviceHelper.IsDesktop)
            {
                CompactViewButton.Visibility = Visibility.Collapsed;
                FullScreenButton.Visibility  = Visibility.Collapsed;
                EnhanceButton.Visibility     = Visibility.Collapsed;
            }
        }
Beispiel #29
0
        private void OnLaunchedOrActivated(IActivatedEventArgs e)
        {
            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(380, 300));
            Frame rootFrame = Window.Current.Content as Frame;
            var   titleBar  = ApplicationView.GetForCurrentView().TitleBar;

            titleBar.ButtonBackgroundColor         = Windows.UI.Colors.Transparent;
            titleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.Transparent;

            var coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = true;

            // 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)
                {
                    // Handle different ExecutionStates
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(Instagram.IsUserAuthenticatedPersistent ? typeof(MainPage) : typeof(Login));
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
Beispiel #30
0
        protected async override void OnActivated(IActivatedEventArgs e)
        {
            Frame frame = Window.Current.Content as Frame;

            if (e is ToastNotificationActivatedEventArgs)
            {
                var         toastActivationArgs = e as ToastNotificationActivatedEventArgs;
                QueryString args = QueryString.Parse(toastActivationArgs.Argument);
                switch (args.ToString())
                {
                case "action&NextIllust":
                    MainPage.mp.SetWallpaper(await MainPage.mp.update());
                    if (frame.Content is MainPage)
                    {
                        break;
                    }
                    frame.Navigate(typeof(MainPage));
                    break;

                case "action&BatterySetting":
                    //唤起Windows电源设置
                    await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:batterysaver"));

                    if (frame.Content is MainPage)
                    {
                        break;
                    }
                    frame.Navigate(typeof(MainPage));
                    break;
                }
            }
            Window.Current.Activate();
            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
            ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;

            titleBar.ButtonBackgroundColor         = Colors.Transparent;
            titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
        }