/// <summary> /// Called when the app view is activated. Activates the app's CoreWindow. /// </summary> private void OnViewActivated(CoreApplicationView sender, IActivatedEventArgs args) { sender.CoreWindow.Activate(); }
public void Initialize(CoreApplicationView applicationView) { Debug.WriteLine("Initialize"); applicationView.Activated += OnActivated; }
/// <summary> /// Called when the app view is activated. Activates the app's CoreWindow. /// </summary> private void OnViewActivated(CoreApplicationView sender, IActivatedEventArgs args) { // Run() won't start until the CoreWindow is activated. sender.CoreWindow.Activate(); }
//------------------------------------------------------------------------------ // // VisualProperties.Initialize // // This method is called during startup to associate the IFrameworkView with the // CoreApplicationView. // //------------------------------------------------------------------------------ void IFrameworkView.Initialize(CoreApplicationView view) { _view = view; _random = new Random(); }
/// <summary> /// Adds a root view to the hierarchy. /// </summary> /// <param name="tag">The root view tag.</param> /// <param name="rootView">The root view.</param> /// <param name="themedRootContext">The React context.</param> public void AddRootView( int tag, SizeMonitoringCanvas rootView, ThemedReactContext themedRootContext) { // This is called on layout manager thread // Extract dispatcher var rootViewDispatcher = rootView.Dispatcher; // _dispatcherToOperationQueueInfo contains a mapping of CoreDispatcher to <UIViewOperationQueueInstance, # of ReactRootView instances>. // Operation queue instances are created lazily whenever an "unknown" CoreDispatcher is detected. Each operation queue instance // works together with one dedicated NativeViewHierarchyManager and one ReactChoreographer. // One operation queue is the "main" one: // - is coupled with the CoreApplication.MainView dispatcher // - drives animations in ALL views if (!_dispatcherToOperationQueueInfo.TryGetValue(rootViewDispatcher, out var queueInfo)) { // Queue instance doesn't exist for this dispatcher, we need to create // Find the CoreApplicationView associated to the new CoreDispatcher CoreApplicationView foundView = CoreApplication.Views.First(v => v.Dispatcher == rootViewDispatcher); // Create new ReactChoreographer for this view/dispatcher. It will only be used for its DispatchUICallback services var reactChoreographer = ReactChoreographer.CreateSecondaryInstance(foundView); queueInfo = new QueueInstanceInfo() { queueInstance = new UIViewOperationQueueInstance( _reactContext, new NativeViewHierarchyManager(_viewManagerRegistry, rootViewDispatcher, OnViewsDropped), reactChoreographer), rootViewCount = 1 }; lock (_lock) { // Add new tuple to map _dispatcherToOperationQueueInfo.AddOrUpdate(rootViewDispatcher, queueInfo, (k, v) => throw new InvalidOperationException("Duplicate key")); if (_active) { // Simulate an OnResume from the correct dispatcher thread // (OnResume/OnSuspend/OnDestroy have this thread affinity, all other methods do enqueuings in a thread safe manner) // (No inlining here so we don't hold lock during call outs. Not a big deal since inlining // is only useful for main UI thread, and this code is not executed for that one) DispatcherHelpers.RunOnDispatcher(rootViewDispatcher, queueInfo.queueInstance.OnResume); } } } else { // Queue instance does exist. // Increment the count of root views. This is helpful for the case the count reaches 0 so we can cleanup the queue. queueInfo.rootViewCount++; } // Add tag _reactTagToOperationQueue.Add(tag, queueInfo.queueInstance); // Send forward queueInfo.queueInstance.AddRootView(tag, rootView, themedRootContext); }
void OnActivated(CoreApplicationView applicationView, IActivatedEventArgs args) { CoreWindow.GetForCurrentThread().Activate(); }
public static void Execute(CoreApplicationView whichView, Action action) { Exception exception = null; var dispatcher = whichView.Dispatcher; if (dispatcher.HasThreadAccess #if __WASM__ || !dispatcher.IsThreadingSupported #endif ) { action(); } else { // We're not on the UI thread, queue the work. Make sure that the action is not run until // the splash screen is dismissed (i.e. that the window content is present). var workComplete = new AutoResetEvent(false); #if MUX App.RunAfterSplashScreenDismissed(() => #endif { // If the Splash screen dismissal happens on the UI thread, run the action right now. if (dispatcher.HasThreadAccess) { try { action(); } catch (Exception e) { exception = e; throw; } finally // Unblock calling thread even if action() throws { workComplete.Set(); } } else { // Otherwise queue the work to the UI thread and then set the completion event on that thread. var ignore = dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { try { action(); } catch (Exception e) { exception = e; throw; } finally // Unblock calling thread even if action() throws { workComplete.Set(); } }); } } #if MUX ); #endif workComplete.WaitOne(); if (exception != null) { Verify.Fail("Exception thrown by action on the UI thread: " + exception.ToString()); } } }
public void Initialize(CoreApplicationView applicationView) { applicationView.Activated += applicationView_Activated; }
async void CloseDemoView() { ApplicationView.GetForCurrentView().Consolidated -= DemoView_Consolidated; await LaunchButton.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { LaunchButton.IsEnabled = true; this.hamburgerMenuFrameView = null; }); Window.Current.Close(); }
private async void viewActivated(CoreApplicationView sender, IActivatedEventArgs args1) { FileOpenPickerContinuationEventArgs args = args1 as FileOpenPickerContinuationEventArgs; if (args != null) { if (args.Files.Count == 0) { return; } view.Activated -= viewActivated; StorageFile storageFile = args.Files[0]; string root = Windows.ApplicationModel.Package.Current.InstalledLocation.Path; string path = root + @"\Assets"; var copyFolder = await StorageFolder.GetFolderFromPathAsync(path); if (!string.IsNullOrWhiteSpace(_transaction.PhotoPath)) { string fileName = _transaction.PhotoPath.Replace(path + "\\", ""); var oldFile = await copyFolder.GetFileAsync(fileName); await oldFile.DeleteAsync(); } int counter = (int)Windows.Storage.ApplicationData.Current.LocalSettings.Values["counter"]; counter = counter + 1; StorageFile file; try { file = await copyFolder.GetFileAsync(storageFile.DisplayName + "PHOTO" + counter); await file.DeleteAsync(); file = await storageFile.CopyAsync(copyFolder); await file.RenameAsync(file.DisplayName + "PHOTO" + counter); } catch (FileNotFoundException) { try { file = await copyFolder.GetFileAsync(storageFile.Name); await file.DeleteAsync(); } catch (FileNotFoundException) { } file = await storageFile.CopyAsync(copyFolder); await file.RenameAsync(file.DisplayName + "PHOTO" + counter); } _transaction.PhotoPath = file.Path; Windows.Storage.ApplicationData.Current.LocalSettings.Values["counter"] = counter; imgPhoto.Source = new BitmapImage(new Uri(@_transaction.PhotoPath, UriKind.RelativeOrAbsolute)); var db = new DatabaseHelper(); db.UpdateTransaction(_transaction); MessageDialog msg = new MessageDialog("Picture updated!"); await msg.ShowAsync(); DataContext = _transaction; } }
public DetailsTran() { this.InitializeComponent(); view = CoreApplication.GetCurrentView(); }
public static async Task OpenPropertiesWindowAsync(object item, IShellPage associatedInstance) { if (item == null) { return; } if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { if (WindowDecorationsHelper.IsWindowDecorationsAllowed) { AppWindow appWindow = await AppWindow.TryCreateAsync(); Frame frame = new Frame(); frame.RequestedTheme = ThemeHelper.RootTheme; frame.Navigate(typeof(Properties), new PropertiesPageNavigationArguments() { Item = item, AppInstanceArgument = associatedInstance }, new SuppressNavigationTransitionInfo()); ElementCompositionPreview.SetAppWindowContent(appWindow, frame); (frame.Content as Properties).appWindow = appWindow; appWindow.TitleBar.ExtendsContentIntoTitleBar = true; appWindow.Title = "PropertiesTitle".GetLocalized(); appWindow.PersistedStateId = "Properties"; WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(460, 550)); bool windowShown = await appWindow.TryShowAsync(); if (windowShown) { // Set window size again here as sometimes it's not resized in the page Loaded event appWindow.RequestSize(new Size(460, 550)); DisplayRegion displayRegion = ApplicationView.GetForCurrentView().GetDisplayRegions()[0]; Point pointerPosition = CoreWindow.GetForCurrentThread().PointerPosition; appWindow.RequestMoveRelativeToDisplayRegion(displayRegion, new Point(pointerPosition.X - displayRegion.WorkAreaOffset.X, pointerPosition.Y - displayRegion.WorkAreaOffset.Y)); } } else { CoreApplicationView newWindow = CoreApplication.CreateNewView(); ApplicationView newView = null; await newWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { Frame frame = new Frame(); frame.RequestedTheme = ThemeHelper.RootTheme; frame.Navigate(typeof(Properties), new PropertiesPageNavigationArguments() { Item = item, AppInstanceArgument = associatedInstance }, new SuppressNavigationTransitionInfo()); Window.Current.Content = frame; Window.Current.Activate(); newView = ApplicationView.GetForCurrentView(); newWindow.TitleBar.ExtendViewIntoTitleBar = true; newView.Title = "PropertiesTitle".GetLocalized(); newView.PersistedStateId = "Properties"; newView.SetPreferredMinSize(new Size(460, 550)); bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newView.Id); if (viewShown && newView != null) { // Set window size again here as sometimes it's not resized in the page Loaded event newView.TryResizeView(new Size(460, 550)); } }); } } else { var propertiesDialog = new PropertiesDialog(); propertiesDialog.propertiesFrame.Tag = propertiesDialog; propertiesDialog.propertiesFrame.Navigate(typeof(Properties), new PropertiesPageNavigationArguments() { Item = item, AppInstanceArgument = associatedInstance }, new SuppressNavigationTransitionInfo()); await propertiesDialog.ShowAsync(ContentDialogPlacement.Popup); } }
private async void OnRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args) { var deferral = args.GetDeferral(); var message = args.Request.Message; try { if (message.ContainsKey("caption") && message.ContainsKey("request")) { var caption = message["caption"] as string; var buffer = message["request"] as string; var req = TLSerializationService.Current.Deserialize(buffer); if (caption.Equals("voip.getUser") && req is TLPeerUser userPeer) { var user = InMemoryCacheService.Current.GetUser(userPeer.UserId); if (user != null) { await args.Request.SendResponseAsync(new ValueSet { { "result", TLSerializationService.Current.Serialize(user) } }); } else { await args.Request.SendResponseAsync(new ValueSet { { "error", TLSerializationService.Current.Serialize(new TLRPCError { ErrorMessage = "USER_NOT_FOUND", ErrorCode = 404 }) } }); } } else if (caption.Equals("voip.getConfig")) { var config = InMemoryCacheService.Current.GetConfig(); await args.Request.SendResponseAsync(new ValueSet { { "result", TLSerializationService.Current.Serialize(config) } }); } else if (caption.Equals("voip.callInfo") && req is byte[] data) { using (var from = new TLBinaryReader(data)) { var tupleBase = new TLTuple <int, TLPhoneCallBase, TLUserBase, string>(from); var tuple = new TLTuple <TLPhoneCallState, TLPhoneCallBase, TLUserBase, string>((TLPhoneCallState)tupleBase.Item1, tupleBase.Item2, tupleBase.Item3, tupleBase.Item4); if (tuple.Item2 is TLPhoneCallDiscarded) { if (_phoneView != null) { var newView = _phoneView; _phoneViewExists = false; _phoneView = null; await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { newView.SetCall(tuple); newView.Dispose(); Window.Current.Close(); }); } return; } if (_phoneViewExists == false) { VoIPCallTask.Log("Creating VoIP UI", "Creating VoIP UI"); _phoneViewExists = true; PhoneCallPage newPlayer = null; CoreApplicationView newView = CoreApplication.CreateNewView(); var newViewId = 0; await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { newPlayer = new PhoneCallPage(); Window.Current.Content = newPlayer; Window.Current.Activate(); newViewId = ApplicationView.GetForCurrentView().Id; newPlayer.SetCall(tuple); _phoneView = newPlayer; }); await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { if (ApiInformation.IsMethodPresent("Windows.UI.ViewManagement.ApplicationView", "IsViewModeSupported") && ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay)) { var preferences = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay); preferences.CustomSize = new Size(340, 200); var viewShown = await ApplicationViewSwitcher.TryShowAsViewModeAsync(newViewId, ApplicationViewMode.CompactOverlay, preferences); } else { //await ApplicationViewSwitcher.SwitchAsync(newViewId); await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId); } }); } else if (_phoneView != null) { VoIPCallTask.Log("VoIP UI already exists", "VoIP UI already exists"); await _phoneView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { _phoneView.SetCall(tuple); }); } } } else if (caption.Equals("voip.setCallRating") && req is TLInputPhoneCall peer) { Execute.BeginOnUIThread(async() => { var dialog = new PhoneCallRatingView(); var confirm = await dialog.ShowQueuedAsync(); if (confirm == ContentDialogResult.Primary) { await MTProtoService.Current.SetCallRatingAsync(peer, dialog.Rating, dialog.Rating >= 0 && dialog.Rating <= 3 ? dialog.Comment : null); } }); } else { var response = await MTProtoService.Current.SendRequestAsync <object>(caption, req as TLObject); if (response.IsSucceeded) { await args.Request.SendResponseAsync(new ValueSet { { "result", TLSerializationService.Current.Serialize(response.Result) } }); } else { await args.Request.SendResponseAsync(new ValueSet { { "error", TLSerializationService.Current.Serialize(response.Error) } }); } } } } finally { deferral.Complete(); } }
private void RemoveLibraryItems(CoreApplicationView sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args) { RemoveLibrarySideBarItemsUI(); CoreApplication.MainView.Activated -= RemoveLibraryItems; }
void VerifyLights(CoreApplicationView whichView, bool forceLightAttachDuringLayout, bool resetWindowContent) { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2)) { Log.Warning("Lights don't work on RS1 and earlier, nothing to verify."); return; } AutoResetEvent popupOpened = null; Popup myPopup = null; StackPanel mySPRoot = null; RunOnUIThread.Execute(whichView, () => { mySPRoot = new StackPanel(); // Lights will be created when the first RevealBrush enters the tree if (!forceLightAttachDuringLayout) { Button myButton = new Button(); myButton.Width = 75; myButton.Height = 50; myButton.Style = Application.Current.Resources["ButtonRevealStyle"] as Style; mySPRoot.Children.Add(myButton); } else { string popupWithGridview = TestUtilities.ProcessTestXamlForRepo( @"<Popup xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:controls='using:Microsoft.UI.Xaml.Controls' x:Name='MarkupPopup' IsOpen='False'> <Popup.Resources> <Style TargetType='GridViewItem' x:Key='RevealExampleGridViewItem'> <Setter Property='Background' Value='Transparent' /> <Setter Property='HorizontalContentAlignment' Value='Center' /> <Setter Property='VerticalContentAlignment' Value='Center' /> <Setter Property='Template'> <Setter.Value> <ControlTemplate TargetType='GridViewItem'> <controls:RevealListViewItemPresenter ContentTransitions='{TemplateBinding ContentTransitions}' SelectionCheckMarkVisualEnabled='{ThemeResource GridViewItemSelectionCheckMarkVisualEnabled}' CheckBrush='Transparent' CheckBoxBrush='Transparent' DragBackground='{ThemeResource GridViewItemDragBackground}' DragForeground='{ThemeResource GridViewItemDragForeground}' FocusBorderBrush='{ThemeResource GridViewItemFocusBorderBrush}' FocusSecondaryBorderBrush='{ThemeResource GridViewItemFocusSecondaryBorderBrush}' PlaceholderBackground='Transparent' PointerOverBackground='Transparent' PointerOverForeground='{ThemeResource GridViewItemForegroundPointerOver}' SelectedBackground='Transparent' SelectedForeground='{ThemeResource GridViewItemForegroundSelected}' SelectedPointerOverBackground='Transparent' PressedBackground='Transparent' SelectedPressedBackground='Transparent' DisabledOpacity='{ThemeResource ListViewItemDisabledThemeOpacity}' DragOpacity='{ThemeResource ListViewItemDragThemeOpacity}' ReorderHintOffset='{ThemeResource GridViewItemReorderHintThemeOffset}' HorizontalContentAlignment='{TemplateBinding HorizontalContentAlignment}' VerticalContentAlignment='{TemplateBinding VerticalContentAlignment}' ContentMargin='{TemplateBinding Padding}' CheckMode='{ThemeResource GridViewItemCheckMode}' /> </ControlTemplate> </Setter.Value> </Setter> </Style> <DataTemplate x:Key='BackgroundBrushDataTemplate'> <Grid Margin='5' Background='{Binding Value}' > <TextBlock Margin='3' FontSize='12' MinWidth='200' MinHeight='36' MaxWidth='330' TextWrapping='Wrap' Text='{Binding Key}' /> </Grid> </DataTemplate> <DataTemplate x:Key='BorderBrushDataTemplate'> <Border Margin='5' BorderBrush='{Binding Value}' BorderThickness='3'> <TextBlock Margin='3' FontSize='12' MinWidth='200' MinHeight='36' MaxWidth='330' TextWrapping='Wrap' Text='{Binding Key}' /> </Border> </DataTemplate> </Popup.Resources> <GridView Name='BackgroundList' ItemsSource='{Binding RevealBackgroundBrushes, Mode=OneWay}' ItemContainerStyle='{StaticResource RevealExampleGridViewItem}' ItemTemplate='{StaticResource BackgroundBrushDataTemplate}' MaxWidth='700' Margin='10' MaxHeight='200'/> </Popup>"); myPopup = XamlReader.Load(popupWithGridview) as Popup; myPopup.DataContext = this; mySPRoot.Children.Add(myPopup); } if (whichView != CoreApplication.MainView) { Window.Current.Content = mySPRoot; } else { Content = mySPRoot; } }); IdleSynchronizer.Wait(); if (resetWindowContent) { RunOnUIThread.Execute(whichView, () => { StackPanel newSPRoot = new StackPanel(); Button myButton = new Button(); myButton.Width = 75; myButton.Height = 50; myButton.Style = Application.Current.Resources["ButtonRevealStyle"] as Style; newSPRoot.Children.Add(myButton); if (whichView != CoreApplication.MainView) { Window.Current.Content = newSPRoot; } else { Content = newSPRoot; } }); IdleSynchronizer.Wait(); } RunOnUIThread.Execute(whichView, () => { if (forceLightAttachDuringLayout) { myPopup.IsOpen = true; } // Find and store public Visual Root _visualRoot = GetTopParent(Window.Current.Content); popupOpened = new AutoResetEvent(false); // Make an unparented popup and open it so we can check that the popup root has lights set on it too. Popup popup = new Popup(); popup.Child = new Grid(); popup.Opened += (sender, args) => { // Find and store Popup Root _popupRoot = GetTopParent(popup.Child); Verify.AreNotEqual(_visualRoot, _popupRoot); popup.IsOpen = false; popupOpened.Set(); }; popup.IsOpen = true; }); IdleSynchronizer.Wait(); Verify.IsTrue(popupOpened.WaitOne(TimeSpan.FromMinutes(2)), "Waiting for popup to open "); IdleSynchronizer.Wait(); RunOnUIThread.Execute(whichView, () => { _mediaFullScreened = new AutoResetEvent(false); Log.Comment("Creating MediaPlayerElement and going to full screen."); _mpe = new MediaPlayerElement(); _mpe.AreTransportControlsEnabled = true; mySPRoot.Children.Add(_mpe); _mpe.IsFullWindow = true; XamlControlsResources.EnsureRevealLights(_mpe.TransportControls); CompositionTarget.Rendering += CompositionTarget_Rendering; }); Verify.IsTrue(_mediaFullScreened.WaitOne(TimeSpan.FromMinutes(2)), "Waiting for media player to go full screen"); IdleSynchronizer.Wait(); // Validate each root has the expected lights RunOnUIThread.Execute(whichView, () => { _pollRetry = 0; _validationCompleted = new AutoResetEvent(false); _lightValidationTimer = new DispatcherTimer(); _lightValidationTimer.Interval = _pollInterval; _lightValidationTimer.Tick += PollTimer_Tick; _lightValidationTimer.Start(); }); Verify.IsTrue(_validationCompleted.WaitOne(TimeSpan.FromMinutes(2)), "Waiting for light validation to complete"); IdleSynchronizer.Wait(); RunOnUIThread.Execute(whichView, () => { if (whichView == CoreApplication.MainView) { Content = null; } else { Window.Current.Content = null; } }); IdleSynchronizer.Wait(); _cleanupVerified = new AutoResetEvent(false); RunOnUIThread.Execute(whichView, () => { // RevealBrush cleans itself up in a CompositionTarget.Rendering callback. Put the cleanup validation in CT.R // as well to let the cleanup code run. CompositionTarget.Rendering += CTR_CheckCleanup; }); Verify.IsTrue(_cleanupVerified.WaitOne(TimeSpan.FromMinutes(1)), "Waiting for cleanup validation"); }
public AppShellView() { this.InitializeComponent(); coreApplicationView = CoreApplication.GetCurrentView(); //if (coreApplicationView != null) // coreApplicationView.TitleBar.ExtendViewIntoTitleBar = true; applicationView = ApplicationView.GetForCurrentView(); applicationView.TitleBar.BackgroundColor = Colors.Transparent; applicationView.TitleBar.ButtonBackgroundColor = Colors.Transparent; applicationView.TitleBar.InactiveBackgroundColor = Colors.Transparent; uiSettings = new Windows.UI.ViewManagement.UISettings(); NavView.SetBinding(Microsoft.UI.Xaml.Controls.NavigationView.MenuItemsSourceProperty, NepApp.CreateBinding(NepApp.UI, nameof(NepApp.UI.NavigationItems))); inlineNavigationService = WindowManager.GetNavigationManagerForCurrentView().RegisterFrameAsNavigationService(InlineFrame, FrameLevel.Two); windowService = WindowManager.GetWindowServiceForCurrentView(); UpdateSelectedNavigationItems(); NepApp.UI.SetNavigationService(inlineNavigationService); inlineNavigationService.Navigated += InlineNavigationService_Navigated; NepApp.UI.SetOverlayParentAndSnackBarContainer(OverlayPanel, snackBarGrid); App.RegisterUIDialogs(); nowPlayingOverlayCoordinator = new AppShellViewModelNowPlayingOverlayCoordinator(this); NavView.SetBinding(Microsoft.UI.Xaml.Controls.NavigationView.HeaderProperty, NepApp.CreateBinding(NepApp.UI, nameof(NepApp.UI.ViewTitle))); NowPlayingButton.SetBinding(Button.DataContextProperty, NepApp.CreateBinding(NepApp.SongManager, nameof(NepApp.SongManager.CurrentSong))); NepApp.MediaPlayer.MediaEngagementChanged += MediaPlayer_MediaEngagementChanged; NepApp.MediaPlayer.IsPlayingChanged += MediaPlayer_IsPlayingChanged; NepApp.UI.Overlay.OverlayedDialogShown += Overlay_DialogShown; NepApp.UI.Overlay.OverlayedDialogHidden += Overlay_DialogHidden; Messenger.AddTarget(this); DeviceInformation.SubplatformChanged += DeviceInformation_SubplatformChanged; if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase") && Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush")) { //Add acrylic. Windows.UI.Xaml.Media.AcrylicBrush myBrush = new Windows.UI.Xaml.Media.AcrylicBrush(); myBrush.BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.HostBackdrop; myBrush.TintColor = uiSettings.GetColorValue(UIColorType.AccentDark2); myBrush.FallbackColor = uiSettings.GetColorValue(UIColorType.AccentDark2); myBrush.Opacity = 0.6; myBrush.TintOpacity = 0.5; bottomAppBar.Background = myBrush; } else { bottomAppBar.Background = new SolidColorBrush(uiSettings.GetColorValue(UIColorType.Accent)); } }
/// <summary> /// Call this method in Unity App Thread can switch to Plan View, create and show a new Xaml View. /// </summary> /// <typeparam name="TReturnValue"></typeparam> /// <param name="xamlPageName"></param> /// <param name="callback"></param> /// <returns></returns> public IEnumerator OnLaunchXamlView <TReturnValue>(string xamlPageName, Action <TReturnValue> callback, object pageNavigateParameter = null) { bool isCompleted = false; #if !UNITY_EDITOR && UNITY_WSA object returnValue = null; CoreApplicationView newView = CoreApplication.CreateNewView(); int newViewId = 0; var dispt = newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { //This happens when User switch view back to Main App manually void CoreWindow_VisibilityChanged(CoreWindow sender, VisibilityChangedEventArgs args) { if (args.Visible == false) { CallbackReturnValue(null); } } newView.CoreWindow.VisibilityChanged += CoreWindow_VisibilityChanged; Frame frame = new Frame(); var pageType = Type.GetType(Windows.UI.Xaml.Application.Current.GetType().AssemblyQualifiedName.Replace(".App,", $".{xamlPageName},")); var appv = ApplicationView.GetForCurrentView(); newViewId = appv.Id; var cb = new Action <object>(rval => { returnValue = rval; isCompleted = true; }); frame.Navigate(pageType, pageNavigateParameter); CallbackDictionary[newViewId] = cb; Window.Current.Content = frame; Window.Current.Activate(); }).AsTask(); yield return(new WaitUntil(() => dispt.IsCompleted || dispt.IsCanceled || dispt.IsFaulted)); Task viewShownTask = null; UnityEngine.WSA.Application.InvokeOnUIThread( () => { viewShownTask = ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId).AsTask(); }, true); yield return(new WaitUntil(() => viewShownTask.IsCompleted || viewShownTask.IsCanceled || viewShownTask.IsFaulted)); yield return(new WaitUntil(() => isCompleted)); try { if (returnValue is TReturnValue) { callback?.Invoke((TReturnValue)returnValue); } else { callback?.Invoke(default(TReturnValue)); } } catch (Exception ex) { Debug.LogError(ex); } #else isCompleted = true; yield return(new WaitUntil(() => isCompleted)); #endif }
public void Initialize(CoreApplicationView applicationView) { _applicationView = applicationView; _applicationView.Activated += ViewActivated; }
private async void RefreshUI(CoreApplicationView sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args) { CoreApplication.MainView.Activated -= RefreshUI; await SyncSideBarItemsUI(); }
public static async Task CreateAndShowNewView(Type targetPage, object parameter = null, CoreApplicationView view = null) { var newView = view ?? CoreApplication.CreateNewView(); await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { var newAppView = ApplicationView.GetForCurrentView(); newAppView.SetPreferredMinSize(new Size(380, 300)); var titleBar = ApplicationView.GetForCurrentView().TitleBar; titleBar.ButtonBackgroundColor = Windows.UI.Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.Transparent; CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; var frame = new Frame(); frame.Navigate(targetPage, parameter); Window.Current.Content = frame; // You have to activate the window in order to show it later. Window.Current.Activate(); var newViewId = ApplicationView.GetForCurrentView().Id; await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId); newAppView.TryResizeView(new Size(380, 640)); }); }
public ClientViewModel(CoreApplicationView view) : base(view) { }
void IFrameworkView.Initialize(CoreApplicationView view) { _view = view; }
private async void EnumerateDrivesAsync(CoreApplicationView sender, Windows.ApplicationModel.Activation.IActivatedEventArgs args) { await SyncSideBarItemsUI(); CoreApplication.MainView.Activated -= EnumerateDrivesAsync; }
void IFrameworkView.Initialize(CoreApplicationView applicationView) { CoreApplicationView = applicationView; applicationView.Activated += ApplicationView_Activated; }
public void Initialize(CoreApplicationView applicationView) { applicationView.Activated += OnActivated; CoreApplication.Suspending += OnSuspending; CoreApplication.Resuming += OnResuming; }
private WindowInformation(CoreApplicationView coreView, ApplicationView view) { CoreView = coreView; View = view; Manager = ViewLifetimeManager.CreateForCurrentView(); }
/// <summary> /// 当应用启动时将执行此方法。进行必要的初始化。 /// </summary> public void Initialize(CoreApplicationView applicationView) { }
public static async Task <WindowInformation> CreateViewAsync(Action a, bool mainView) { WindowInformation info = null; CoreApplicationView view = null; if (mainView) { view = CoreApplication.MainView; } else { if (CoreApplication.MainView.Properties.ContainsKey(nameof(MainWindow))) { view = CoreApplication.CreateNewView(); } else { view = CoreApplication.MainView; } } void Create() { a(); info = WindowInformation.CreateForCurrentView(); if (!mainView) { info.View.SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible); } if (view != CoreApplication.MainView) { info.Manager.StartViewInUse(); info.Manager.Released += Manager_Released; AddChildWindow(info); } else { view.Properties[nameof(MainWindow)] = info; if (mainView) { MainWindow = info; } } var settings = ResourceHelper.AppSettings; settings.UpdateTransparency(settings.IsTransparencyEnabled); } if (view.Dispatcher.HasThreadAccess) { Create(); } else { await view.Dispatcher.RunAsync(CoreDispatcherPriority.High, Create); } return(info); }
private void ApplicationView_Activated(CoreApplicationView sender, IActivatedEventArgs args) { CoreWindow.GetForCurrentThread().Activate(); }
public ApplicationViewAwareViewModel(CoreApplicationView view) { _view = view; }