Inheritance: INotifyPropertyChanged
コード例 #1
0
        public void PageStackDefault()
        {
            PageStack stack = new PageStack();

            stack.RegisterDefaultRoute("home", () => new Page());
            Assert.IsNull(stack.CurrentPage);
            stack.Navigate("");
            Assert.IsNotNull(stack.CurrentPage);
        }
コード例 #2
0
ファイル: BreadcrumbBar.cs プロジェクト: floatas/PowerArgs
        internal void Compose()
        {
            var  pageStack = (Application as ConsolePageApp).PageStack;
            bool hadFocus  = this.Controls.Where(c => c.HasFocus).Count() > 0;

            this.Controls.Clear();

            string builtUpPath = "";

            foreach (var s in PageStack.GetSegments(pageStack.CurrentPath))
            {
                string myPath;

                if (builtUpPath == "")
                {
                    builtUpPath = s;
                    myPath      = s;
                }
                else
                {
                    var label = Add(new Label()
                    {
                        Mode = LabelRenderMode.SingleLineAutoSize, Text = "->".ToConsoleString(DefaultColors.H1Color)
                    });
                    builtUpPath += "/" + s;
                    myPath       = builtUpPath;
                }

                var crumb = Add(new BreadcrumbElement(() => { pageStack.TryNavigate(myPath); })
                {
                    Text = s.ToConsoleString()
                });
                crumb.Width = 10;
                if (hadFocus && builtUpPath.Contains("/") == false)
                {
                    var worked = crumb.TryFocus();
                }
            }

            this.Width = Layout.StackHorizontally(1, this.Controls);
        }
コード例 #3
0
        public void PageStackBasic()
        {
            PageStack stack = new PageStack();

            bool observableWorked = false;

            PropertyChangedEventHandler firstChecker = (sender, e) =>
            {
                if(e.PropertyName != nameof(PageStack.CurrentPage))
                {
                    return;
                }

                Assert.IsNotNull(stack.CurrentPage);
                Assert.AreEqual(0, stack.CurrentPage.RouteVariables.Count);
                observableWorked = true;
            };

            stack.PropertyChanged += firstChecker;
            stack.RegisterRoute("Home", () => new Page());
            stack.Navigate("Home");
            Assert.IsTrue(observableWorked);
            stack.PropertyChanged -= firstChecker;

            try
            {
                stack.Navigate("BadRoute");
                Assert.Fail("An exception should have been thrown");
            }
            catch (KeyNotFoundException)
            {

            }

            stack.RegisterRoute("Applications/{ApplicationId}/Components/{ComponentId}", () => new Page());

            stack.Navigate("Applications/foo/Components/bar");
            Assert.IsTrue(stack.CurrentPage.RouteVariables.Count == 2);
            Assert.AreEqual("foo", stack.CurrentPage.RouteVariables["ApplicationId"]);
            Assert.AreEqual("bar", stack.CurrentPage.RouteVariables["ComponentId"]);
        }
コード例 #4
0
 public ConsolePageApp(IEnumerable <string> markupFiles)
 {
     InitCommon();
     MarkupParser.Parse(this, markupFiles);
     PageStack.Navigate("");
 }
コード例 #5
0
 private void ExpectGoodRoute(string goodRoute)
 {
     PageStack stack = new PageStack();
     stack.RegisterRoute(goodRoute, () => new Page());
 }
コード例 #6
0
 private void ExpectBadRoute(string badRoute)
 {
     PageStack stack = new PageStack();
     try
     {
         stack.RegisterRoute(badRoute, () => new Page());
         Assert.Fail("An exception should have been thrown for bad route: "+ badRoute);
     }
     catch (FormatException) { }
 }