public static TabData AddTab(string tab_caption, string page_caption, SmartPage page2open, int frame_index, string unique_id = null) { if (unique_id != null) { if (unique_id.Contains("/")) { throw new ArgumentException("The unique_id cannot contain a '/' character."); } var found = _shell_data.FindTabData(m => m.UniqueID != null && m.UniqueID == unique_id); if (found != null) { var frame = _shell_data.FindFrameData(found); frame.SelectedTab = found; _shell_data.ActiveFrameIndex = frame.Index; return(found); } } if (unique_id == null) { unique_id = Guid.NewGuid().ToString(); } if (frame_index < 0 || frame_index >= _shell_data.Frames.Count) { throw new ArgumentOutOfRangeException($"frame_index must be a number between 0 and {_shell_data.Frames.Count - 1}."); } // Make sure the screen is split if (frame_index == 1) { _shell_data.SplitScreen = true; } _shell_data.ActiveFrameIndex = frame_index; FrameData frame_data = _shell_data.Frames[frame_index]; var color_info = _colors.GetNextColor(); TabData tabdata = new TabData(tab_caption, page_caption, page2open, color_info, unique_id); frame_data.Tabs.Add(tabdata); frame_data.SelectedTab = tabdata; //await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => frame_data.SelectedTab = tabdata); return(tabdata); }
/// <summary> /// Close the Modal page or close the Tab. /// </summary> public void ClosePage(object retvar = null) { ShellData shell_data = Navigator.ShellData; if (shell_data.ManagesSmartPage(this) == false) { throw new InvalidOperationException("This Page object is not managed by the Ventura Navigator."); } // Find the tab that holds the page in its modalstack. TabData tabdata = shell_data.FindTabData(this); if (tabdata.TopMost() != this) { throw new InvalidOperationException("Only call CloseModal for the topmost Page object."); } Navigator.CloseAllSatelliteTabs(tabdata.UniqueID); tabdata.PopPage(); // The topmost will be null if no pages left on the stack. var topmost = tabdata.TopMost(); if (this.CloseAction == CloseActionKind.CloseTab) { Navigator.InternalCloseTab(tabdata); } else if (this.CloseAction == CloseActionKind.ReleaseTCS) { this.TCS.SetResult(retvar); } else if (this.CloseAction == CloseActionKind.CloseTab_With_SatelliteClosedEventOnMasterTab) { Navigator.InternalCloseTab(tabdata); TabData tabdata_master = shell_data.FindTabData(tabdata.MasterTabID); if (tabdata_master != null) { FrameData framedata_master = shell_data.FindFrameData(tabdata_master); // Make the frame containing the master page (for the satellite page) active. shell_data.ActiveFrameIndex = framedata_master.Index; // Make the master page the selected tab. framedata_master.SelectedTab = tabdata_master; SmartPage topmost_master = tabdata_master.TopMost(); if (topmost_master != null) { topmost_master.SatellitePageClosed(this.InstanceID, retvar); } } } else if (this.CloseAction == CloseActionKind.CloseModal_SatelliteClosedEventOnParentPage) { topmost.SatellitePageClosed(this.InstanceID, retvar); //await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => topmost.SatellitePageClosed(this.InstanceID, retvar)); } }