Пример #1
0
            public PanelTab()
            {
                MinSize    = new Vector2(TabMinWidth, TabHeight);
                MaxSize    = new Vector2(TabMaxWidth, TabHeight);
                LayoutCell = new LayoutCell(Alignment.LeftTop);
                Size       = MinSize;
                Layout     = new HBoxLayout();
                var caption = new SimpleText {
                    Id             = "TextPresenter",
                    Padding        = Theme.Metrics.ControlsPadding,
                    ForceUncutText = false,
                    FontHeight     = Theme.Metrics.TextHeight,
                    HAlignment     = HAlignment.Center,
                    VAlignment     = VAlignment.Center,
                    OverflowMode   = TextOverflowMode.Ellipsis,
                    LayoutCell     = new LayoutCell(Alignment.Center),
                };
                var presenter = new TabPresenter(caption);

                CompoundPresenter.Add(presenter);
                DefaultAnimation.AnimationEngine = new AnimationEngineDelegate {
                    OnRunAnimation = (animation, markerId, animationTimeCorrection) => {
                        presenter.SetState(markerId);
                        return(true);
                    }
                };
                AddNode(caption);
                HitTestTarget = true;
                LateTasks.Add(Theme.MouseHoverInvalidationTask(this));
                this.AddChangeWatcher(() => Active,
                                      isActive => Padding = isActive ? new Thickness {
                    Top = -1f, Bottom = 1f
                } : new Thickness());
            }
Пример #2
0
        public void InvokeBackTest()
        {
            var tabHistory = new MockTabHistory();

            var view      = new MockTabView();
            var presenter = new TabPresenter(
                view,
                new MockFavorites(),
                new MockConfig(),
                new MockFaviconCache(),
                new MockHistory(),
                tabHistory);

            var url1 = Url.FromString("www.first.com");
            var url2 = Url.FromString("www.second.com");

            presenter.Push(url1);
            presenter.Push(url2);

            Assert.AreEqual(url2, tabHistory.Current().Url);

            view.InvokeBack();

            Assert.AreEqual(url1, tabHistory.Current().Url);
        }
Пример #3
0
        public ThemedTab()
        {
            Padding = Theme.Metrics.ControlsPadding;
            MinSize = Theme.Metrics.MinTabSize;
            MaxSize = Theme.Metrics.MaxTabSize;
            Size    = MinSize;
            Layout  = new HBoxLayout();
            var caption = new SimpleText {
                Id             = "TextPresenter",
                ForceUncutText = false,
                FontHeight     = Theme.Metrics.TextHeight,
                HAlignment     = HAlignment.Center,
                VAlignment     = VAlignment.Center,
                OverflowMode   = TextOverflowMode.Ellipsis,
                LayoutCell     = new LayoutCell(Alignment.Center)
            };
            var presenter = new TabPresenter(caption);

            Presenter = presenter;
            DefaultAnimation.AnimationEngine = new AnimationEngineDelegate {
                OnRunAnimation = (animation, markerId, animationTimeCorrection) => {
                    presenter.SetState(markerId);
                    return(true);
                }
            };
            var closeButton = new ThemedTabCloseButton {
                Id = "CloseButton"
            };

            AddNode(caption);
            AddNode(closeButton);
            LateTasks.Add(Theme.MouseHoverInvalidationTask(this));
        }
Пример #4
0
        /// <summary>
        /// Does the setup.
        /// </summary>
        private void DoSetup()
        {
            var presenter = new TabPresenter(MainWindow);

            Setup setup = new Setup(Dispatcher, presenter);

            setup.Initialize();

            IMvxAppStart start = Mvx.Resolve <IMvxAppStart>();

            start.Start();

            this.setupComplete = true;
        }
Пример #5
0
        public void PushTest()
        {
            var tabHistory = new MockTabHistory();

            var presenter = new TabPresenter(
                new MockTabView(),
                new MockFavorites(),
                new MockConfig(),
                new MockFaviconCache(),
                new MockHistory(),
                tabHistory);

            var url = Url.FromString("www.test.com");

            presenter.Push(url);
            Assert.AreEqual(url, tabHistory.Current().Url);
        }
Пример #6
0
        public void InvokeGoHomeTest()
        {
            var config     = new MockConfig();
            var tabHistory = new MockTabHistory();

            var view      = new MockTabView();
            var presenter = new TabPresenter(
                view,
                new MockFavorites(),
                config,
                new MockFaviconCache(),
                new MockHistory(),
                tabHistory);

            view.InvokeGoHome();
            Assert.AreEqual(config.Home, tabHistory.Current().Url);
        }
Пример #7
0
        public void InvokeSubmitTest()
        {
            var tabHistory = new MockTabHistory();

            var view      = new MockTabView();
            var presenter = new TabPresenter(
                view,
                new MockFavorites(),
                new MockConfig(),
                new MockFaviconCache(),
                new MockHistory(),
                tabHistory);

            var url = Url.FromString("www.test.com");

            view.InvokeSubmit(url);
            Assert.AreEqual(url, tabHistory.Current().Url);
        }
Пример #8
0
        public void InvokeReloadTest()
        {
            var view      = new MockTabView();
            var presenter = new TabPresenter(
                view,
                new MockFavorites(),
                new MockConfig(),
                new MockFaviconCache(),
                new MockHistory(),
                new MockTabHistory());

            presenter.Push(Url.FromString("www.test.com"));

            int pageloads = view.PageLoads;

            view.InvokeReload();
            Assert.AreEqual(++pageloads, view.PageLoads);
        }
Пример #9
0
        public void InvokeAddFavoriteTest()
        {
            var favorites = new MockFavorites();

            var view      = new MockTabView();
            var presenter = new TabPresenter(
                view,
                favorites,
                new MockConfig(),
                new MockFaviconCache(),
                new MockHistory(),
                new MockTabHistory());

            var url = Url.FromString("www.test.com");

            presenter.Push(url);
            view.InvokeAddFavorite();
            Assert.IsNotNull(favorites.GetViewModel().Single(model => model.Url == url.ToString()));
        }
Пример #10
0
 public TabRegionConfiguration(TabPresenter presenter, FrameworkElement view)
 {
     this.presenter = presenter;
     this.view      = view;
 }