Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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();
                }
            }
        }
        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;
        }
Exemplo n.º 4
0
        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();
            }
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        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);
            }
        }