コード例 #1
0
        internal async Task ShowLyricWindow()
        {
            await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var frame   = new Frame();
                lyricViewID = ApplicationView.GetForCurrentView().Id;
                frame.Navigate(typeof(LyricView), Context.NowPlayingList[Context.CurrentIndex]);
                Window.Current.Content = frame;
                Window.Current.Activate();
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                ApplicationViewTitleBar titleBar       = ApplicationView.GetForCurrentView().TitleBar;
                titleBar.ButtonBackgroundColor         = Colors.Transparent;
                titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
                titleBar.ButtonHoverBackgroundColor    = Color.FromArgb(0x33, 0x00, 0x00, 0x00);
                titleBar.ButtonForegroundColor         = Colors.Black;
                titleBar.ButtonHoverForegroundColor    = Colors.White;
                titleBar.ButtonInactiveForegroundColor = Colors.Gray;
            });

            ViewModePreferences compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            compactOptions.CustomSize         = new Size(1000, 100);
            compactOptions.ViewSizePreference = ViewSizePreference.Custom;
            bool viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(lyricViewID, ApplicationViewMode.CompactOverlay, compactOptions);
        }
コード例 #2
0
        public async void Unpip()
        {
            localSettings.Values["Pip"] = "0";
            var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.Default);

            preferences.CustomSize = new Size(330, viewHeight - 20);
            await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default, preferences);

            //ApplicationView.PreferredLaunchViewSize = new Size(330, viewHeight - 20);
            //ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;

            Frame.Navigate(typeof(DesktopTool), null, new SuppressNavigationTransitionInfo());
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

            //timer = new DispatcherTimer();
            //timer.Interval = new TimeSpan(0, 0, 1);
            //timer.Tick += Timer_Tick;//每秒触发这个事件,以刷新指针
            if (ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.Default)
            {
                SetTopBtn.Visibility   = Visibility.Visible;
                DeSetTopBtn.Visibility = Visibility.Collapsed;
            }
            else
            {
                SetTopBtn.Visibility   = Visibility.Collapsed;
                DeSetTopBtn.Visibility = Visibility.Visible;
            }
        }
コード例 #3
0
        private static async void EnterExitCompactOverlayMode()
        {
            if (App.IsGameBarWidget)
            {
                return;
            }

            if (ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.Default)
            {
                var compactOverlayViewModePreferences = ViewModePreferences.CreateDefault(ApplicationViewMode.Default);
                compactOverlayViewModePreferences.CustomSize = new Size(1000, 1000);
                var modeSwitched = await ApplicationView.GetForCurrentView()
                                   .TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, compactOverlayViewModePreferences);

                if (!modeSwitched)
                {
                    LoggingService.LogError($"[{nameof(NotepadsMainPage)}] Failed to enter CompactOverlay view mode.");
                    Analytics.TrackEvent("FailedToEnterCompactOverlayViewMode");
                }
            }
            else if (ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.CompactOverlay)
            {
                var modeSwitched = await ApplicationView.GetForCurrentView()
                                   .TryEnterViewModeAsync(ApplicationViewMode.Default);

                if (!modeSwitched)
                {
                    LoggingService.LogError($"[{nameof(NotepadsMainPage)}] Failed to enter Default view mode.");
                    Analytics.TrackEvent("FailedToEnterDefaultViewMode");
                }
            }
        }
コード例 #4
0
        private async void CloseCompactClicked()
        {
            var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.Default);
            await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default, preferences);

            App.AppFrame.GoBack();
        }
コード例 #5
0
        private async void SymbolIcon_Tapped_1(object sender, TappedRoutedEventArgs e)
        {
            Employee        employee = employeeView.DataContext as Employee;
            ApplicationView newView = null;
            await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var frame = new Frame();
                frame.Navigate(typeof(EmployeePage), employee);
                Window.Current.Content = frame;
                Window.Current.Activate();
                newView = ApplicationView.GetForCurrentView();
                newView.SetPreferredMinSize(new Size(200, 200));
                newView.Title = employee.Name;
                newView.SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
                newView.TitleBar.BackgroundColor = Windows.UI.Colors.Transparent;
            });

            var compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            compactOptions.CustomSize         = new Size(300, 200);
            compactOptions.ViewSizePreference = ViewSizePreference.Custom;
            await ApplicationViewSwitcher.TryShowAsViewModeAsync(newView.Id, ApplicationViewMode.CompactOverlay, compactOptions);

            employeeView.Visibility = Visibility.Collapsed;
        }
コード例 #6
0
        public static async Task <bool> OpenCompactOverlayView()
        {
            bool _modeswitchstatus = false; // 切换模式成功指示器

            if (CompactOverlayView == null)
            {
                CompactOverlayCoreApplicationView = CoreApplication.CreateNewView();
                int newViewId = 0;
                await CompactOverlayCoreApplicationView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
                {
                    Frame frame = new Frame();
                    frame.Navigate(typeof(CompactOverlay_HomePage), null);
                    Window.Current.Content = frame;
                    // You have to activate the window in order to show it later.
                    Window.Current.Activate();
                    CompactOverlayView = ApplicationView.GetForCurrentView();
                    bool a             = CompactOverlayView.IsViewModeSupported(ApplicationViewMode.CompactOverlay);
                    newViewId          = CompactOverlayView.Id;
                });

                bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);

                ViewModePreferences compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
                compactOptions.CustomSize = new Windows.Foundation.Size(350, 50); //调整画中画模式的窗口初始大小
                await CompactOverlayView.TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, compactOptions);

                //进入默认视图模式
            }
            else
            {
                ShowCompactOverlayView();
            }
            return(IsInCompactOverlayMode = _modeswitchstatus ? !IsInCompactOverlayMode : IsInCompactOverlayMode); //如果切换模式成功,则逆转这个值
        }
コード例 #7
0
        public async Task <bool> EnterCompactOverlayAsync(double widthRequest = default(double), double heightRequest = default(double))
        {
            if (!IsCompactOverlaySupported)
            {
                return(false);
            }

            Size desiredSize = new Size(widthRequest, heightRequest);

            ViewModePreferences compactOptions
                = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            if (desiredSize != default(Size))
            {
                compactOptions.CustomSize = desiredSize;
            }

            bool modeSwitched
                = await ApplicationView.GetForCurrentView()
                  .TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, compactOptions);

            if (modeSwitched)
            {
                ViewModeChanged?.Invoke(ApplicationView.GetForCurrentView(), EventArgs.Empty);
            }

            return(modeSwitched);
        }
コード例 #8
0
        private async void OverlayButton_Click(object sender, RoutedEventArgs e)
        {
            if (ApplicationView.GetForCurrentView().ViewMode == ApplicationViewMode.Default)
            {
                var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
                preferences.CustomSize = new Size(400, 260);
                bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, preferences);

                if (modeSwitched)
                {
                    GoToOverlayIcon.Visibility = Visibility.Collapsed;
                    ExitOverlayIcon.Visibility = Visibility.Visible;
                    ToolTip toolTip = new ToolTip();
                    toolTip.Content = Strings.Resources.ExitOverlay;
                    ToolTipService.SetToolTip(OverlayButton, toolTip);
                    AutomationProperties.SetName(OverlayButton, Strings.Resources.ExitOverlay);
                }
            }
            else
            {
                bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);

                if (modeSwitched)
                {
                    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);
                }
            }
        }
コード例 #9
0
        private async Task GoToCompactOverlayMode()
        {
            if (!ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay))
            {
                return;
            }

            VisualStateManager.GoToState(this, nameof(CompactOverlayVisualState), false);

            var viewMode = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            viewMode.ViewSizePreference = ViewSizePreference.Custom;
            viewMode.CustomSize         = LocalConfiguration.CompactOverlaySize;

            var modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, viewMode);

            if (modeSwitched)
            {
                nowPlaying.ActionRequested += NowPlaying_ActionRequested;
                topBar.UpdateTitleBarColors(Theme.Dark);

                AnalyticsHelper.PageView("CompactOverlay");
            }
            else
            {
                VisualStateManager.GoToState(this, nameof(MainScreenVisualState), false);
            }
        }
コード例 #10
0
        /// <summary>
        ///     Open the compact overlay view
        /// </summary>
        /// <returns></returns>
        public static async Task SwitchToCompactView()
        {
            var compactView   = CoreApplication.CreateNewView();
            var compactViewId = -1;

            // Create a new window within the view
            await compactView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                // Create a new frame and navigate it to the overlay view
                var overlayFrame = new Frame();
                overlayFrame.Navigate(typeof(OverlayView));

                // Set the window content and activate it
                Window.Current.Content = overlayFrame;
                Window.Current.Activate();

                // Get the Id back
                compactViewId = ApplicationView.GetForCurrentView().Id;
            });

            // Make the overlay small
            var compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            compactOptions.CustomSize = new Size(350, 150);

            // Display as compact overlay
            await ApplicationViewSwitcher.TryShowAsViewModeAsync(compactViewId, ApplicationViewMode.CompactOverlay,
                                                                 compactOptions);
        }
コード例 #11
0
        public async Task ToggleCompactOverlayAsync()
        {
            if (!IsShowSecondaryView)
            {
                return;
            }

            if (!SecondaryAppView.IsViewModeSupported(ApplicationViewMode.CompactOverlay))
            {
                return;
            }

            await SecondaryCoreAppView.DispatcherQueue.EnqueueAsync(async() =>
            {
                if (SecondaryAppView.ViewMode == ApplicationViewMode.Default)
                {
                    var opt        = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
                    opt.CustomSize = new Windows.Foundation.Size(500, 280);
                    await SecondaryAppView.TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, opt);
                    IsCompactOverlay = true;
                    IsFullScreen     = false;
                }
                else
                {
                    await SecondaryAppView.TryEnterViewModeAsync(ApplicationViewMode.Default);
                    IsCompactOverlay = false;
                    IsFullScreen     = false;
                }
            });
        }
コード例 #12
0
        private async void ShowCompactView()
        {
            CoreApplicationView compactView = CoreApplication.CreateNewView();
            await compactView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var frame     = new Frame();
                compactViewId = ApplicationView.GetForCurrentView().Id;
                frame.Navigate(typeof(CompactOverlayPage));
                Window.Current.Content = frame;
                Window.Current.Activate();
                ApplicationView.GetForCurrentView().TitleBar.ButtonBackgroundColor = Colors.Transparent;
            });



            ViewModePreferences compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            compactOptions.CustomSize = new Windows.Foundation.Size(120, 120);
            bool viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(compactViewId, ApplicationViewMode.CompactOverlay, compactOptions);

            string X = XText.Text;
            string Y = YText.Text;
            string W = WText.Text;
            string H = HText.Text;
            await compactView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var frame          = (Frame)Window.Current.Content;
                var compactOverlay = (CompactOverlayPage)frame.Content;
                compactOverlay.SetMeasurements(X, Y, W, H);
            });
        }
コード例 #13
0
        async Task SwitchToCompact()
        {
            var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            preferences.CustomSize = new Windows.Foundation.Size(200, 200);
            await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, preferences);
        }
コード例 #14
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
#if WINDOWS_UWP
            var pref = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
            pref.CustomSize = new Windows.Foundation.Size(500, 500);

            await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, pref);

            await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
#elif __MACOS__
            NSApplication.SharedApplication.MainWindow.ToggleFullScreen(NSApplication.SharedApplication.MainWindow);
            NSApplication.SharedApplication.MainWindow.Level = NSWindowLevel.Floating;

            var process = new ProcessStartInfo("test.sh")
            {
                WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            };

            //var proc = new ProcessStartInfo("/Users/jimmygarrido/Desktop/test.sh");
            //proc.WorkingDirectory = "/Users/jimmygarrido/Desktop";

            Process.Start(process);
#endif
            await Navigation.PushAsync(new Page1());
        }
コード例 #15
0
ファイル: MainPage.xaml.cs プロジェクト: soyCracker/urlQR
        private async void PipButton_Click(object sender, RoutedEventArgs e)
        {
            if (ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay))
            {
                if (!pipMode)
                {
                    ViewModePreferences compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
                    compactOptions.CustomSize = new Size(200, 200);
                    await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, compactOptions);

                    //UrlTb.Visibility = Visibility.Collapsed;
                    //GeneQrBtn.Visibility = Visibility.Collapsed;
                    pipMode             = true;
                    PipButtonFont.Glyph = Char.ConvertFromUtf32(0xE92D);
                }
                else
                {
                    await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);

                    //UrlTb.Visibility = Visibility.Visible;
                    //GeneQrBtn.Visibility = Visibility.Visible;
                    pipMode             = false;
                    PipButtonFont.Glyph = Char.ConvertFromUtf32(0xE8AD);
                }
            }
        }
コード例 #16
0
        //private void btwebIcon_Click(object sender, RoutedEventArgs e)
        //{
        //}

        private async void ShowCompactView(bool isEnabled)
        {
            if (isEnabled)
            {
                rpWeb.Visibility = Visibility.Collapsed;
                mySplitsview.CompactPaneLength = 0;
                dspLeftPane.Margin             = new Thickness(0);
                mySplitsview.IsPaneOpen        = false;
                ViewModePreferences vmPreference = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
                vmPreference.CustomSize         = new Size(500, 500);
                vmPreference.ViewSizePreference = ViewSizePreference.UseMore;

                bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, vmPreference);
            }
            else
            {
                rpWeb.Visibility = Visibility.Visible;
                mySplitsview.CompactPaneLength = 50;
                mySplitsview.IsPaneOpen        = isMenuPinned;
                if (!isHideCompactMenu)
                {
                    dspLeftPane.Margin = new Thickness(15, 0, 0, 0);
                }
                bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default);
            }
            bthamburger.Visibility = rpWeb.Visibility;
        }
コード例 #17
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            await BrowserWindow.EnsureCoreWebView2Async();

            defaultUA = BrowserWindow.CoreWebView2.Settings.UserAgent;
            BrowserWindow.CoreWebView2.ContainsFullScreenElementChanged += BrowserWindow_ContainsFullScreenElementChanged;

            if (e.Parameter is Uri) // Protocol launch
            {
                string param = ((Uri)e.Parameter).AbsoluteUri;
                string uri   = Uri.UnescapeDataString(param.Split('=')[1]);
                AddressBox.Text = uri;
                OpenBrowser();

                // Change to CompactOverlay mode automatically
                var applicationView = ApplicationView.GetForCurrentView();
                ViewModePreferences compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
                compactOptions.CustomSize = new Windows.Foundation.Size(500, 500); // Max size
                bool modeSwitched = await applicationView.TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, compactOptions);

                if (modeSwitched)
                {
                    // modeSwitched is sometimes false. Why?
                    AOTButton.Visibility  = Visibility.Collapsed;
                    BackButton.Visibility = Visibility.Visible;
                }
            }
        }
コード例 #18
0
ファイル: CallUIPage.xaml.cs プロジェクト: agrucza/woadialer
        public async static Task <int> ShowInCallUI()
        {
            int compactViewId = 0;

            Size previoussize = new Size(0, 0);

            // Workaround for window spawn bug
            await CoreApplication.GetCurrentView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var view  = ApplicationView.GetForCurrentView();
                var frame = (Window.Current.Content as Frame);

                previoussize = new Size(frame.ActualWidth, frame.ActualHeight);
                view.SetPreferredMinSize(new Size {
                    Width = 400, Height = 100
                });
            });

            var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.Default);

            preferences.CustomSize = new Size {
                Width = 400, Height = 100
            };

            await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var frame = new Frame();
                var view  = ApplicationView.GetForCurrentView();

                compactViewId = view.Id;
                frame.Navigate(typeof(CallUIPage));
                Window.Current.Content = frame;

                Window.Current.Activate();

                view.Title = "Call";

                Window.Current.Closed += (object sender, CoreWindowEventArgs e) =>
                {
                    var view = ApplicationView.GetForCurrentView();

                    view.SetPreferredMinSize(new Size(0, 0));
                    view.TryResizeView(previoussize);
                };
            });

            bool viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(compactViewId, ApplicationViewMode.Default, preferences);

            // Workaround for window spawn bug
            await CoreApplication.GetCurrentView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var view = ApplicationView.GetForCurrentView();

                view.SetPreferredMinSize(new Size(0, 0));
                view.TryResizeView(previoussize);
            });

            return(compactViewId);
        }
コード例 #19
0
        private async void OnUnpinClick(object sender, RoutedEventArgs e)
        {
            var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.Default);
            await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default, preferences);

            _isInCompactOverlay = false;
            UpdateButtonsVisibility();
        }
コード例 #20
0
ファイル: MainPage.xaml.cs プロジェクト: Lu-YiFan/tv
        private async void TextBlock_Tapped(object sender, TappedRoutedEventArgs e)
        {
            ViewModePreferences compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            compactOptions.CustomSize = new Windows.Foundation.Size(320, 200);
            //  bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default, compactOptions);
            bool modeSwitched = await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay);
        }
コード例 #21
0
        private async void makeSmall()
        {
            //Make picture in picture
            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(5, 5));
            var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            preferences.CustomSize = new Windows.Foundation.Size(5, 5);
            await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, preferences);
        }
コード例 #22
0
ファイル: CompactPage.xaml.cs プロジェクト: jenius-apps/ambie
        private async void CloseCompactClicked(object sender, RoutedEventArgs e)
        {
            var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.Default);
            await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default, preferences);

            var navigator = App.Services.GetRequiredService <INavigator>();

            navigator.GoBack();
        }
コード例 #23
0
ファイル: UISystem.cs プロジェクト: dw5/W10CallsDialer
        public async void ShowCallUIWindow()
        {
            int  compactViewId = 0;
            Size previoussize  = new Size(0, 0);

            // Workaround for window spawn bug
            await MainWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var view  = ApplicationView.GetForCurrentView();
                var frame = (Window.Current.Content as Frame);

                previoussize = new Size(frame.ActualWidth, frame.ActualHeight);
                view.SetPreferredMinSize(new Size {
                    Width = 400, Height = 100
                });
            });

            ViewModePreferences preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            preferences.CustomSize = new Size {
                Width = 400, Height = 100
            };

            CoreApplicationView view = CoreApplication.CreateNewView();

            await view.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                CallUIWindow           = Window.Current;
                Frame frame            = new Frame();
                Window.Current.Content = frame;
                frame.Navigate(typeof(CallUIPage));
                Window.Current.Activate();

                ApplicationView view = ApplicationView.GetForCurrentView();
                view.Title           = App.Current.ResourceLoader.GetString(CALL_UI_PAGE);
                compactViewId        = view.Id;

                Window.Current.Closed += (object sender, CoreWindowEventArgs e) =>
                {
                    var view = ApplicationView.GetForCurrentView();

                    view.SetPreferredMinSize(new Size(0, 0));
                    view.TryResizeView(previoussize);
                };
            });

            bool viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(compactViewId, ApplicationViewMode.CompactOverlay, preferences);

            // Workaround for window spawn bug
            await CoreApplication.GetCurrentView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var view = ApplicationView.GetForCurrentView();

                view.SetPreferredMinSize(new Size(0, 0));
                view.TryResizeView(previoussize);
            });
        }
コード例 #24
0
        public static async void ShowCompactOverlayView()
        {
            bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(CompactOverlayView.Id);

            ViewModePreferences compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            compactOptions.CustomSize = new Windows.Foundation.Size(350, 100); //调整画中画模式的窗口初始大小
            await CompactOverlayView.TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, compactOptions);
        }
コード例 #25
0
        /// <summary>
        /// 开启迷你置顶模式
        /// </summary>
        public async void IntoCompactOverlayMode()
        {
            ViewModePreferences compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            compactOptions.CustomSize = new Windows.Foundation.Size(340, 160);
            if (await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, compactOptions))
            {
                Frame.Navigate(typeof(CompactOverlayPage));
            }
        }
コード例 #26
0
        private async void OnPinClick(object sender, RoutedEventArgs e)
        {
            var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            preferences.CustomSize = new Windows.Foundation.Size(_currentCompactOverlayAttribute.CustomWidth, _currentCompactOverlayAttribute.CustomHeight);
            await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, preferences);

            _isInCompactOverlay = true;
            UpdateButtonsVisibility();
        }
コード例 #27
0
        private async void OnUnpinClick(object sender, RoutedEventArgs e)
        {
            var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.Default);
            await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.Default, preferences);

            if (Frame.CanGoBack)
            {
                Frame.GoBack();
            }
        }
コード例 #28
0
        private async void ToCompactOverlay()
        {
            var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            preferences.CustomSize = new Size(330, viewHeight);
            await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, preferences);

            ApplicationView.PreferredLaunchViewSize      = new Size(3000, 3000);
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
        }
コード例 #29
0
        private async void CompactOverlayButton_Checked(object sender, RoutedEventArgs e)
        {
            var options = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);

            options.ViewSizePreference = ViewSizePreference.Custom;
            options.CustomSize         = new Size(450, 500);
            bool modeSwitched = await ApplicationView.GetForCurrentView()
                                .TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, options);

            (Window.Current.Content as Frame).Navigate(typeof(LlamaBingo), Bingo.ToDataString());
        }
コード例 #30
0
        public async void ToCompact()
        {
            if (Frame is Frame f)
            {
                // Ref: https://programmer.group/uwp-use-compact-overlay-mode-to-always-display-on-the-front-end.html
                var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
                preferences.CustomSize = new Windows.Foundation.Size(360, 500);
                await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(ApplicationViewMode.CompactOverlay, preferences);

                f.Navigate(typeof(CompactPage), null, new SuppressNavigationTransitionInfo());
            }
        }