Example #1
0
 internal SideBarController(AxemasApplication app)
 {
     appref = new WeakReference(app);
 }
Example #2
0
        internal int getBackStackDepth()
        {
            AxemasApplication app = Application.Current as AxemasApplication;

            return(app.RootFrame.BackStackDepth + 1);  // First element doesn't count on the backstack
        }
Example #3
0
        public void goTo(JObject data, bool closeSidebar = false)
        {
            //Debug.WriteLine("GOTO: " + JsonConvert.SerializeObject(data, Formatting.Indented));
            AxemasApplication app = Application.Current as AxemasApplication;

            int stackPopElements = -1;

            if (data["stackPopElements"] != null)
            {
                stackPopElements = data["stackPopElements"].Value <int>();
            }

            int stackMaintainedElements = -1;

            if (data["stackMaintainedElements"] != null)
            {
                stackMaintainedElements = Math.Max(data["stackMaintainedElements"].Value <int>(), 0);
            }

            if (stackPopElements >= getBackStackDepth())
            {
                // Special case, popping more than available means keeping 0
                stackPopElements        = -1;
                stackMaintainedElements = 0;
            }

            if (stackPopElements > 0)
            {
                while (stackPopElements-- > 0)
                {
                    if (app.RootFrame.CanGoBack)
                    {
                        app.RootFrame.GoBack();
                    }
                    else
                    {
                        break;
                    }
                }
            }

            bool navigate = data.Value <string>("url") != null;

            if (stackMaintainedElements == 0)
            {
                if (!navigate)
                {
                    throw new ArgumentException("Is not possibile to maintain 0 elements if no navigation page is provided");
                }

                // 0 Maintaned elements is special case as we cannot pop the last view.
                // so we insert the new one at the begin of the stack instead of navigating to it.
                navigate = false;
                stackMaintainedElements = 1;
                app.RootFrame.BackStack.Insert(
                    0,
                    new PageStackEntry(typeof(Controls.SectionViewPage), Controls.SectionViewPage.BuildNavigationData(data), null)
                    );
            }

            if (stackMaintainedElements > 0)
            {
                while (getBackStackDepth() > stackMaintainedElements)
                {
                    if (app.RootFrame.CanGoBack)
                    {
                        app.RootFrame.GoBack();
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (navigate)
            {
                Controls.SectionViewPage.Navigate(app.RootFrame, typeof(Controls.SectionViewPage), data);
            }

            if (closeSidebar)
            {
                getSidebarController().toggleSidebar(false);
            }
        }
Example #4
0
 internal AXMNavigationController(AxemasApplication app)
 {
     appref = new WeakReference(app);
 }