private async void Button_Click(object sender, RoutedEventArgs e) { showWindowBtn.IsEnabled = false; // 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(); // 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)); // Attach the XAML content to our window ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame); } // Get DisplayRegion to position our window on DisplayRegion secondaryDisplayRegion = GetOtherDisplayRegion(ApplicationView.GetForCurrentView().GetDisplayRegions()[0]); if (secondaryDisplayRegion != null) { appWindow.RequestMoveToDisplayRegion(secondaryDisplayRegion); } // If the window is not visible, show it and/or bring it to foreground if (!appWindow.IsVisible) { await appWindow.TryShowAsync(); } showWindowBtn.IsEnabled = true; }
public void AddDisplayRegion(DisplayRegion displayRegion, Texture2D texture) { CollapseItem item = textureListBox.GetItem(texture); if (item != null) { item.AddItem(displayRegion.Name, displayRegion); } }
private void PaintGridAt(float x, float y, float z) { #region Paint Texture Texture2D newTexture = GuiData.ListWindow.HighlightedTexture; if (newTexture != null) { Texture2D lastTexture = CurrentSpriteGrid.PaintSprite(x, y, z, newTexture); if (lastTexture != newTexture) { tla.Add(new TextureLocation <Texture2D>(lastTexture, x, y)); } } #endregion #region Paint Display Region (FloatRectangle) DisplayRegion newDisplayRegion = GuiData.ListWindow.HighlightedDisplayRegion; FloatRectangle newAsFloatRectangle = null; if (newDisplayRegion != null) { newAsFloatRectangle = newDisplayRegion.ToFloatRectangle(); } else { // If the newDisplayRegion is null, then there's not a DisplayRegion selected in the // list box. Therefore, just use the TextureDisplayWindow's coordinates. newAsFloatRectangle = new FloatRectangle( GuiData.TextureCoordinatesSelectionWindow.TopTV, GuiData.TextureCoordinatesSelectionWindow.BottomTV, GuiData.TextureCoordinatesSelectionWindow.LeftTU, GuiData.TextureCoordinatesSelectionWindow.RightTU); } FloatRectangle lastFloatRectangle = CurrentSpriteGrid.PaintSpriteDisplayRegion( x, y, z, ref newAsFloatRectangle); #endregion #region Paint AnimationChainList AnimationChain newAnimationChain = GuiData.ListWindow.HighlightedAnimationChain; if (newAnimationChain != null) { CurrentSpriteGrid.PaintSpriteAnimationChain(x, y, z, newAnimationChain); // Paint AnimationChainList here } #endregion }
private void TextureListBoxClick(Window callingWindow) { object highlightedObject = textureListBox.GetFirstHighlightedObject(); if (highlightedObject is Texture2D) { mAnimationChainListWindow.HighlightObject(null, false); Texture2D asTexture2D = highlightedObject as Texture2D; GuiData.ToolsWindow.currentTextureDisplay.SetOverlayTextures(highlightedObject as Texture2D, null); GuiData.ToolsWindow.currentTextureDisplay.SetTextureCoordinates(0, 1, 0, 1); GuiData.TextureCoordinatesSelectionWindow.Visible = true; GuiData.TextureCoordinatesSelectionWindow.DisplayedTexture = asTexture2D; } else if (highlightedObject is DisplayRegion) { mAnimationChainListWindow.HighlightObject(null, false); DisplayRegion displayRegion = highlightedObject as DisplayRegion; Button button = GuiData.ToolsWindow.currentTextureDisplay; Texture2D parentTexture = textureListBox.GetFirstHighlightedParentObject() as Texture2D; // get the current CollapseItem's parent which is a texture button.SetOverlayTextures(parentTexture, null); button.SetTextureCoordinates( displayRegion.Top, displayRegion.Bottom, displayRegion.Left, displayRegion.Right); GuiData.TextureCoordinatesSelectionWindow.Visible = true; GuiData.TextureCoordinatesSelectionWindow.DisplayedTexture = parentTexture; GuiData.TextureCoordinatesSelectionWindow.LeftTU = displayRegion.Left; GuiData.TextureCoordinatesSelectionWindow.RightTU = displayRegion.Right; GuiData.TextureCoordinatesSelectionWindow.TopTV = displayRegion.Top; GuiData.TextureCoordinatesSelectionWindow.BottomTV = displayRegion.Bottom; } else { GuiData.ToolsWindow.currentTextureDisplay.SetOverlayTextures((Texture2D)null, (Texture2D)null); } }
private DisplayRegion GetOtherDisplayRegion(DisplayRegion currentAppDisplayRegion) { // Get the list of all DisplayRegions defined for the WindowingEnvironment that our application is currently in IReadOnlyList <DisplayRegion> displayRegions = ApplicationView.GetForCurrentView().WindowingEnvironment.GetDisplayRegions(); foreach (DisplayRegion displayRegion in displayRegions) { if (displayRegion != currentAppDisplayRegion && displayRegion.IsVisible) { return(displayRegion); } } return(null); }
private void AddDisplayRegionOk(Window callingWindow) { DisplayRegion displayRegion = new DisplayRegion( GuiData.TextureCoordinatesSelectionWindow.TopTV, GuiData.TextureCoordinatesSelectionWindow.BottomTV, GuiData.TextureCoordinatesSelectionWindow.LeftTU, GuiData.TextureCoordinatesSelectionWindow.RightTU); displayRegion.Name = ((TextInputWindow)callingWindow).Text; if (GuiData.TextureCoordinatesSelectionWindow.DisplayedTexture != null) { GuiData.ListWindow.AddDisplayRegion( displayRegion, GuiData.TextureCoordinatesSelectionWindow.DisplayedTexture); } }
public void Remove(DisplayRegion displayRegion) { this.TextureListBox.RemoveItemByObject(displayRegion); }
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); } }