Exemplo n.º 1
0
        /// <summary>
        /// Adds the Page to the stack and makes it visible.
        /// (sets the Page as the Content property).
        /// </summary>
        internal void PushPage(SmartPage newpage)
        {
            SmartPage oldpage = this.TopMost();

            _pages.Add(newpage);

            PagePushedEvent?.Invoke(oldpage, newpage);

            NotifyPropertyChanged(nameof(PageStack));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns true if the ModalStack contains the referenced Page.
        /// </summary>
        public bool ContainsPage(SmartPage page)
        {
            foreach (SmartPage item in _pages)
            {
                if (item.Equals(page))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public static void CloseTab(SmartPage page)
        {
            if (_shell_data.ManagesSmartPage(page) == false)
            {
                throw new InvalidOperationException("This Page object is not managed by the Ventura Navigator.");
            }

            // Since the page is managed, we are 100% sure the FrameData and TabData will also be found.

            TabData tabdata = _shell_data.FindTabData(page);

            CloseAllSatelliteTabs(tabdata.UniqueID);

            tabdata.CloseAllPagesAtOnce();
        }
Exemplo n.º 5
0
        public FrameData FindFrameData(SmartPage page)
        {
            foreach (FrameData framedata in _frames)
            {
                foreach (TabData tabdata in framedata.Tabs)
                {
                    if (tabdata.ContainsPage(page) == true)
                    {
                        return(framedata);
                    }
                }
            }

            return(null);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Removes the topmost Page from the stack and makes the previous Page visible.
        /// (sets the previous Page as the Content property).
        /// The stack must contain at least 2 Pages when calling this method.
        /// </summary>
        internal void PopPage()
        {
            if (_pages.Count == 0)
            {
                throw new InvalidOperationException("The stack must contain at least 1 SmartPage");
            }

            SmartPage oldpage = this.TopMost();

            _pages.RemoveAt(_pages.Count - 1); // Remove the last one.

            SmartPage newpage = this.TopMost();

            PagePoppedEvent?.Invoke(oldpage, newpage);

            NotifyPropertyChanged(nameof(PageStack));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Returns true if the SmartPage is managed by Ventura's Navigator.
        /// </summary>
        public bool ManagesSmartPage(SmartPage page)
        {
            foreach (FrameData framedata in _frames)
            {
                foreach (TabData tabdata in framedata.Tabs)
                {
                    foreach (SmartPage page_item in tabdata.PageStack)
                    {
                        if (page_item.Equals(page) == true)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 8
0
        internal TabData(string tab_caption, string page_caption, SmartPage page, DistinctColorInfo colorinfo, string unique_id)
        {
            if (unique_id == null || unique_id.Length == 0)
            {
                throw new ArgumentOutOfRangeException("a unique_id must be specified");
            }

            _tab_caption = tab_caption;
            _colorinfo   = colorinfo;
            _unique_id   = unique_id;
            _is_selected = false;

            _pages = new ObservableCollection <SmartPage>();

            page.PageCaption = page_caption;

            _pages.Add(page);
        }
Exemplo n.º 9
0
        internal void CloseAllPagesAtOnce()
        {
            for (int i = _pages.Count - 1; i >= 0; i--)
            {
                SmartPage page = _pages[i];

                page.ClosePage(null);

                //if (page.TCS != null)
                //    page.TCS.SetResult(null);
            }

            if (_pages.Count > 0)
            {
                throw new Exception("should not happen");
            }

            NotifyPropertyChanged(nameof(PageStack));
        }
Exemplo n.º 10
0
 public static TabData AddTab(string tab_caption, string page_caption, SmartPage page, string unique_id = null)
 {
     // The active frame can be found at: _shell_data.ActiveFrameIndex
     return(AddTab(tab_caption, page_caption, page, 0, unique_id));
 }
Exemplo n.º 11
0
        private void CurrentlySelectedTab_PagePoppedEvent(SmartPage oldpage, SmartPage newpage)
        {
            ShelvePageEvent?.Invoke(oldpage);

            DisplayAnotherPageEvent?.Invoke(PageDisplayReason.PopPage, newpage);
        }