private async void LibraryProperties_Click(object sender, RoutedEventArgs e) { if (LibraryGrid.SelectedItem is LibraryFolder Library) { if (await FileSystemStorageItemBase.CreateFromStorageItemAsync(Library.Folder) is FileSystemStorageFolder Folder) { await Folder.LoadMorePropertiesAsync(); AppWindow NewWindow = await AppWindow.TryCreateAsync(); NewWindow.RequestSize(new Size(420, 600)); NewWindow.RequestMoveRelativeToCurrentViewContent(new Point(Window.Current.Bounds.Width / 2 - 200, Window.Current.Bounds.Height / 2 - 300)); NewWindow.PersistedStateId = "Properties"; NewWindow.Title = Globalization.GetString("Properties_Window_Title"); NewWindow.TitleBar.ExtendsContentIntoTitleBar = true; NewWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent; NewWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; ElementCompositionPreview.SetAppWindowContent(NewWindow, new PropertyBase(NewWindow, Folder)); WindowManagementPreview.SetPreferredMinSize(NewWindow, new Size(420, 600)); await NewWindow.TryShowAsync(); } } }
public async void ToPage() { appWindow = await AppWindow.TryCreateAsync(); Frame appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(typeof(RecentList), RecognizerViewModel); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); appWindow.RequestSize(new Size(500, 900)); await appWindow.TryShowAsync(); //this.mainPage.IsEnabled = false; appWindow.Closed += delegate { // //Task.Delay(1000); // dictationTextBox.Text = ""; // appWindowContentFrame.Content = null; // appWindow = null; //this.mainPage.IsEnabled = true; // recentFile = RecentList.openFile; // RecentList.openFile = null; // OpenFileDialog_Click(null, null); // }; }
private async void AppBarButton_Click_3(object sender, RoutedEventArgs e) { try { StoreServicesCustomEventLogger logger = StoreServicesCustomEventLogger.GetDefault(); logger.Log("ChartEvent"); blankPagePlot = new BlankPagePlot(); appWindow = await AppWindow.TryCreateAsync(); ElementCompositionPreview.SetAppWindowContent(appWindow, blankPagePlot); v = await appWindow.TryShowAsync(); if (v) { blankPagePlot.iniPlot(device.namea); blankPagePlot.PlotModel.addSeries(); Size size = new Size() { Height = 100, Width = 100 }; appWindow.RequestSize(size); appWindow.Closed += delegate { v = false; blankPagePlot = null; appWindow = null; }; } } catch (Exception) { } }
// todo: work out a huge mem leak, the windowContent is still running even when we destroy the appWindow ???? // i.e. the mediaPlayerElement is still running , i can here the media playing public static async void OpenWindow(UIElement windowContent, double width, double height, Action finishedOpeningAction) { AppWindow appWindow = await AppWindow.TryCreateAsync(); appWindow.Title = "desktopxx"; appWindow.RequestSize(new Size(width, height)); Grid appWindowRootGrid = new Grid(); appWindowRootGrid.Children.Add(windowContent); ElementCompositionPreview.SetAppWindowContent(appWindow, windowContent); appWindow.Closed += (a, o) => { appWindowRootGrid.Children.Remove(windowContent); appWindowRootGrid = null; windowContent = null; appWindow = null; }; await appWindow.TryShowAsync(); finishedOpeningAction?.Invoke(); //DesktopHelper.SendWindowToBackground("desktopxx"); }
private async void ShowNewAppWindow_Click(object sender, RoutedEventArgs e) { // Only ever create and show one window. If the AppWindow exists call TryShow on it to bring it to foreground. if (appWindow == null) { // Create a new window appWindow = await AppWindow.TryCreateAsync(); // Navigate our frame to the page we want to show in the new window appWindowFrame.Navigate(typeof(AppWindowMainPage)); // Attach the XAML content to our window ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame); // Set up event handlers for the window // This is not really needed for this demo, but I mention this in the blogpost so it's here for reference. RegisterEventHandlersForWindow(appWindow); // Let's make this new window 500x500, just to show that the new window doesn't have to be of the same size as the main app window appWindow.RequestSize(new Windows.Foundation.Size(500, 500)); // Show the window appWindow.TryShowAsync(); } else { appWindow.TryShowAsync(); } }
private async void ShowProperties(object parameter) { if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) { AppWindow appWindow = await AppWindow.TryCreateAsync(); Frame frame = new Frame(); appWindow.TitleBar.ExtendsContentIntoTitleBar = true; frame.Navigate(typeof(Properties), null, new SuppressNavigationTransitionInfo()); WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(400, 475)); appWindow.RequestSize(new Size(400, 475)); appWindow.Title = ResourceController.GetTranslation("PropertiesTitle"); ElementCompositionPreview.SetAppWindowContent(appWindow, frame); AppWindows.Add(frame.UIContext, appWindow); appWindow.Closed += delegate { AppWindows.Remove(frame.UIContext); frame.Content = null; appWindow = null; }; await appWindow.TryShowAsync(); } else { App.PropertiesDialogDisplay.propertiesFrame.Tag = App.PropertiesDialogDisplay; App.PropertiesDialogDisplay.propertiesFrame.Navigate(typeof(Properties), parameter, new SuppressNavigationTransitionInfo()); await App.PropertiesDialogDisplay.ShowAsync(ContentDialogPlacement.Popup); } }
private async Task CreateChildWindowAsync() { _newWindow = await AppWindow.TryCreateAsync(); _newWindow.RequestSize(new Size(200, 200)); _newWindow.RequestMoveAdjacentToCurrentView(); _newWindow.Frame.SetFrameStyle(AppWindowFrameStyle.NoFrame); _newWindow.Presenter.RequestPresentation(AppWindowPresentationKind.CompactOverlay); await _newWindow.TryShowAsync(); }
private async void ShowWindowBtn_Click(object sender, RoutedEventArgs e) { // Clear any previous message. MainPage.Current.NotifyUser(string.Empty, NotifyType.StatusMessage); if (!Double.TryParse(windowOffsetXTxt.Text, out var horizontalOffset) || !Double.TryParse(windowOffsetYTxt.Text, out var verticalOffset)) { MainPage.Current.NotifyUser($"Please specify valid numeric offsets.", NotifyType.ErrorMessage); return; } showWindowBtn.IsEnabled = false; // Only ever create and show one window. if (appWindow == null) { // Create a new window appWindow = await AppWindow.TryCreateAsync(); // Make sure we release the reference to this window, and release XAML resources, when it's closed appWindow.Closed += delegate { appWindow = null; appWindowFrame.Content = null; }; // Request the size of our window appWindow.RequestSize(new Size(500, 320)); // Navigate the frame to the page we want to show in the new window appWindowFrame.Navigate(typeof(SecondaryAppWindowPage)); // Attach the XAML content to our window ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame); } // Make a point for our offset. Point offset = new Point(horizontalOffset, verticalOffset); // Check if we should be setting our position relative to ApplicationView or DisplayRegion if (positionOffsetDisplayRegionRB.IsChecked.Value) { // Request an offset relative to the DisplayRegion we're on appWindow.RequestMoveRelativeToDisplayRegion(ApplicationView.GetForCurrentView().GetDisplayRegions()[0], offset); } else { // Relative to our ApplicationView appWindow.RequestMoveRelativeToCurrentViewContent(offset); } // If the window is not visible, show it and/or bring it to foreground if (!appWindow.IsVisible) { await appWindow.TryShowAsync(); } showWindowBtn.IsEnabled = true; }
private async void OpenEditDialog() { AppWindow appWindow = await AppWindow.TryCreateAsync(); Frame appWindowContentFrame = new Frame(); appWindow.Title = "Marker Infocard Window"; appWindow.RequestSize(new Size(200, 250)); appWindowContentFrame.Navigate(typeof(EditPage), SelectedLocation); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); await appWindow.TryShowAsync(); }
private async void Recent_Click(object sender, RoutedEventArgs e) { List <StorageFile> files = new List <StorageFile>(); var mru = Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList; //StorageFile retrievedFile = await mru.GetFileAsync(token); foreach (Windows.Storage.AccessCache.AccessListEntry entry in mru.Entries) { string mruToken = entry.Token; string mruMetadata = entry.Metadata; try { Windows.Storage.IStorageItem item = await mru.GetItemAsync(mruToken); if (item is StorageFile) { //StorageFile item = await mru.GetFileAsync(mruToken); files.Add((StorageFile)item); } } catch (FileNotFoundException) {} } appWindow = await AppWindow.TryCreateAsync(); Frame appWindowContentFrame = new Frame(); appWindowContentFrame.Navigate(typeof(RecentList), RecognizerViewModel); ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame); appWindow.RequestSize(new Size(500, 900)); await appWindow.TryShowAsync(); this.mainPage.IsEnabled = false; appWindow.Closed += delegate { // //Task.Delay(1000); // dictationTextBox.Text = ""; // appWindowContentFrame.Content = null; // appWindow = null; this.mainPage.IsEnabled = true; // recentFile = RecentList.openFile; // RecentList.openFile = null; // OpenFileDialog_Click(null, null); // }; }
private async void Compact_Click(object sender, RoutedEventArgs e) { if (_window == null) { OnBackRequestedOverride(this, new HandledRoutedEventArgs()); // Create a new AppWindow _window = await AppWindow.TryCreateAsync(); // Make sure we release the reference to this window, and release XAML resources, when it's closed _window.Closed += delegate { _window = null; _surface.NavigateToString(string.Empty); }; // Is CompactOverlay supported for this AppWindow? If not, then stop. if (_window.Presenter.IsPresentationSupported(AppWindowPresentationKind.CompactOverlay)) { // Create a new frame for the window // Navigate the frame to the CompactOverlay page inside it. //appWindowFrame.Navigate(typeof(SecondaryAppWindowPage)); // Attach the frame to the window Presenter.Child = new Border(); var w = Math.Max(_webPage.EmbedWidth, 340); var h = Math.Max(_webPage.EmbedHeight, 200); double ratioX = (double)340 / w; double ratioY = (double)340 / h; double ratio = Math.Min(ratioX, ratioY); ElementCompositionPreview.SetAppWindowContent(_window, _surface); // Let's set the title so that we can tell the windows apart _window.Title = _webPage.Title; _window.TitleBar.ExtendsContentIntoTitleBar = true; _window.RequestSize(new Size(w * ratio, h * ratio)); // Request the Presentation of the window to CompactOverlay var switched = _window.Presenter.RequestPresentation(AppWindowPresentationKind.CompactOverlay); if (switched) { // If the request was satisfied, show the window await _window.TryShowAsync(); } } } else { await _window.TryShowAsync(); } }
private async void ShowWindowBtn_Click(object sender, RoutedEventArgs e) { // Clear any previous message. MainPage.Current.NotifyUser(string.Empty, NotifyType.StatusMessage); Double.TryParse(windowWidthTxt.Text, out var windowWidth); Double.TryParse(windowHeightTxt.Text, out var windowHeight); if (windowWidth < MinWindowWidth || windowHeight < MinWindowHeight) { MainPage.Current.NotifyUser($"Please specify a width of at least {MinWindowWidth} and a height of at least {MinWindowHeight}.", NotifyType.ErrorMessage); return; } showWindowBtn.IsEnabled = false; // Only ever create and show one window. If the AppWindow exists use it if (appWindow == null) { // Create a new window appWindow = await AppWindow.TryCreateAsync(); // Make sure we release the reference to this window, and release XAML resources, when it's closed appWindow.Closed += delegate { appWindow = null; appWindowFrame.Content = null; }; // Navigate the frame to the page we want to show in the new window appWindowFrame.Navigate(typeof(SecondaryAppWindowPage)); } // If specified size is smaller than the default min size for a window we need to set a new preferred min size first. // Let's set it to the smallest allowed and leave it at that. if (windowWidth < 500 || windowHeight < 320) { WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(MinWindowWidth, MinWindowHeight)); } // Request the size of our window appWindow.RequestSize(new Size(windowWidth, windowHeight)); // Attach the XAML content to our window ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame); // If the window is not visible, show it and/or bring it to foreground if (!appWindow.IsVisible) { await appWindow.TryShowAsync(); } showWindowBtn.IsEnabled = true; }
private async void _MenuItem_ReferencePicture_Click(object sender, RoutedEventArgs e) { FileOpenPicker fileOpenPicker1 = new FileOpenPicker(); fileOpenPicker1.FileTypeFilter.Add(".bmp"); fileOpenPicker1.FileTypeFilter.Add(".jpg"); fileOpenPicker1.FileTypeFilter.Add(".jpeg"); fileOpenPicker1.FileTypeFilter.Add(".png"); fileOpenPicker1.FileTypeFilter.Add(".gif"); fileOpenPicker1.FileTypeFilter.Add(".tif"); StorageFile file = await fileOpenPicker1.PickSingleFileAsync(); if (file == null) { return; } AppWindow referencePicture = await AppWindow.TryCreateAsync(); Image imageControl = new Image(); var img1 = new BitmapImage(); try { await img1.SetSourceAsync(await file.OpenReadAsync()); imageControl.Source = img1; ElementCompositionPreview.SetAppWindowContent(referencePicture, imageControl); if (referencePicture.Presenter.IsPresentationSupported(AppWindowPresentationKind.CompactOverlay)) { referencePicture.Title = "参考图片"; if (referencePicture.Presenter.RequestPresentation(AppWindowPresentationKind.CompactOverlay)) { referencePicture.RequestSize(new Size(img1.PixelWidth, img1.PixelHeight)); await referencePicture.TryShowAsync(); img1.Play(); } } } catch { } }
private async void Attribute_Click(object sender, RoutedEventArgs e) { if (SearchResultList.SelectedItem is FileSystemStorageItemBase Item) { AppWindow NewWindow = await AppWindow.TryCreateAsync(); NewWindow.RequestSize(new Size(420, 600)); NewWindow.RequestMoveRelativeToCurrentViewContent(new Point(Window.Current.Bounds.Width / 2 - 200, Window.Current.Bounds.Height / 2 - 300)); NewWindow.PersistedStateId = "Properties"; NewWindow.Title = Globalization.GetString("Properties_Window_Title"); NewWindow.TitleBar.ExtendsContentIntoTitleBar = true; NewWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent; NewWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; ElementCompositionPreview.SetAppWindowContent(NewWindow, new PropertyBase(NewWindow, Item)); WindowManagementPreview.SetPreferredMinSize(NewWindow, new Size(420, 600)); await NewWindow.TryShowAsync(); } }
public async Task ShowWebView(int width, int height) { appWindow = await AppWindow.TryCreateAsync(); webView.Width = width; webView.Height = height; appWindow.RequestSize(new Windows.Foundation.Size(width, height)); ElementCompositionPreview.SetAppWindowContent(appWindow, webView); httpRequestMessage.Method = HttpMethod.Get; httpRequestMessage.RequestUri = new Uri(loginUri); appWindow.Closed += delegate { appWindow = null; httpRequestMessage.Dispose(); filter.Dispose(); webView.Stop(); }; webView.NavigateWithHttpRequestMessage(httpRequestMessage); await appWindow.TryShowAsync(); }
public async Task<bool> TryCreateNewWindowAsync(TabViewViewModel tabView, Size size) { AppWindow appWindow = await AppWindow.TryCreateAsync(); Frame frame = new Frame(); frame.Navigate(typeof(AppWindowPage), new TabViewNavigationParameters(tabView, appWindow)); ElementCompositionPreview.SetAppWindowContent(appWindow, frame); WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(MinWindowWidth, MinWindowHeight)); appWindow.RequestSize(size); appWindow.TitleBar.ExtendsContentIntoTitleBar = true; appWindow.TitleBar.ButtonBackgroundColor = Colors.Transparent; appWindow.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; appWindow.RequestMoveAdjacentToCurrentView(); bool success = await appWindow.TryShowAsync(); return success; }
private async void AppBarButton_Click_3(object sender, RoutedEventArgs e) { try { blankPagePlot = new BlankPagePlot(); appWindow = await AppWindow.TryCreateAsync(); ElementCompositionPreview.SetAppWindowContent(appWindow, blankPagePlot); v = await appWindow.TryShowAsync(); if (v) { blankPagePlot.iniPlot(bluetoothConnectionHandler.naame); blankPagePlot.PlotModel.addSeries(); Size size = new Size() { Height = 100, Width = 100 }; appWindow.RequestSize(size); appWindow.Closed += delegate { v = false; blankPagePlot = null; appWindow = null; bluetoothConnectionHandler.blankPagePlot = null; bluetoothConnectionHandler.v = false; bluetoothConnectionHandler.appWindow = null; }; bluetoothConnectionHandler.blankPagePlot = blankPagePlot; bluetoothConnectionHandler.v = v; bluetoothConnectionHandler.appWindow = appWindow; } } catch (Exception) { } }
public async Task ToggleCompactOverlayAsync() { if (!_appWindow.Presenter.IsPresentationSupported(AppWindowPresentationKind.CompactOverlay)) { return; } var currentConfig = _appWindow.Presenter.GetConfiguration(); if (currentConfig.Kind is AppWindowPresentationKind.CompactOverlay) { _appWindow.Presenter.RequestPresentation(AppWindowPresentationKind.Default); IsCompactOverlay = false; IsFullScreen = false; } else { _appWindow.Presenter.RequestPresentation(AppWindowPresentationKind.CompactOverlay); _appWindow.RequestSize(new Size(500, 282)); IsCompactOverlay = true; IsFullScreen = false; } }
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 void PropertyBase_Loaded(object sender, RoutedEventArgs e) { Window.RequestSize(new Size(400, 600)); }