Esempio n. 1
0
        protected void BuildBooks()
        {
            PageRepository.DeleteAll();
              BookRepository.DeleteAll();

              Console.WriteLine("Add books");

              Book b = new Book("mexikansk-mad", "Mexikansk mad", "En samling af mine yndlingsopskrifter fra Mexiko",
                        TestDataConstants.Profiles.SimonProfileId);
              b.PublishedDate = DateTime.UtcNow;

              Page p1 = new TextPage("Velbekomme", 1, "Demo");
              PageRepository.Add(p1);
              b.AddPage(p1.Id);

              RecipePage p2 = new RecipePage(MexicanskeBurritosRecipe.Title, 2, MexicanskeBurritosRecipe.Id);
              PageRepository.Add(p2);
              b.AddPage(p2.Id);

              RecipePage p3 = new RecipePage(BonneMosRecipe.Title, 3, BonneMosRecipe.Id);
              PageRepository.Add(p3);
              b.AddPage(p3.Id);

              BookRepository.Add(b);
        }
Esempio n. 2
0
        private ErrorPages GetErrorPages()
        {
            var error403 = new TextPage
            {
                Name               = "403",
                UrlSegment         = "403",
                BodyContent        = "<h1>403</h1><p>Sorry, you are not authorized to view this page.</p>",
                RevealInNavigation = false,
            };
            var error404 = new TextPage
            {
                Name               = "404",
                UrlSegment         = "404",
                BodyContent        = "<h1>404</h1><p>Sorry, this page cannot be found.</p>",
                RevealInNavigation = false,
            };
            var error500 = new TextPage
            {
                Name               = "500",
                UrlSegment         = "500",
                BodyContent        = "<h1>500</h1><p>Sorry, there has been an error.</p>",
                RevealInNavigation = false,
            };

            return(new ErrorPages
            {
                Error403 = error403,
                Error404 = error404,
                Error500 = error500
            });
        }
Esempio n. 3
0
        /// <summary>
        /// Осуществляет просмотр текста в обратном направлении (с последней страницы к первой) с подгрузкой страниц в указанном диапазоне
        /// </summary>
        /// <param name="startIndex">начала диапазона - правая граница, двигаемся влево</param>
        /// <param name="count">длина диапазона</param>
        /// <param name="func">f(pageText, startIndex, count) ret index, -1 means continue</param>
        /// <returns>возвращает найденный индекс или -1, если ничего не найдено</returns>
        protected int LookBackward(int startIndex, int count, Func <string, int, int, int> func)
        {
            if (startIndex - count < -1)
            {
                throw new ArgumentOutOfRangeException("count", count, "startIndex and count should be inside range");
            }

            int      index = -1;
            TextPage page  = null;

            while (index == -1 && count > 0)
            {
                page = _getPage(startIndex);
                // Относительная страницы позиция, откуда начинать просмотр (правая граница внутри страницы)
                int localStartIndex = startIndex - page.Segment.Offset;
                // Относительная страницы длина, Сколько просматривать
                int localCount = Math.Min(localStartIndex + 1, count);

                // Вызов функции
                index = func(page.Text, localStartIndex, localCount);

                startIndex -= localCount;
                count      -= localCount;
            }
            // вернуть абсолютный индекс или -1
            if (index != -1)
            {
                index += page.Segment.Offset;
            }
            return(index);
        }
Esempio n. 4
0
        public void Init(TextControl textControl, TextPage textPage)
        {
            _textControl = textControl;
            _textPage    = textPage;

            _animators.Clear();
        }
Esempio n. 5
0
        private void barHelp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TextPage richPage = new TextPage();

            richPage.StartPosition = FormStartPosition.Manual;
            richPage.Top           = this.Top;
            richPage.Height        = this.Height;
            if (this.WindowState == FormWindowState.Maximized)
            {
                richPage.Left = this.Left + this.Width - richPage.Width;
            }
            else
            {
                richPage.Left = this.Left + this.Width;
            }
            richPage.FormClosing += delegate
            {
                CurMenu.Menu_Help = richPage.EditValue;
                List <MyParameter> mps = new List <MyParameter>();
                mps.Add("@Help_Rtf", DbType.String, CurMenu.Menu_Help, null);
                mps.Add("@Help_Menu", DbType.String, CurMenu.Menu_Id, null);
                BaseService.ExecuteAsync("SystemMenu_Help", mps, "U");
            };
            richPage.EditValue = CurMenu.Menu_Help;
            richPage.Show();
        }
Esempio n. 6
0
 public InfoPage() : base("個人資訊")
 {
     {
         TCmain = new MyTabControl();
         TCmain.TabPages.Add(name            = new TextPage("暱稱 (name)", "loser"));
         TCmain.TabPages.Add(age             = new TextPage("年齡 (age)", "23"));
         TCmain.TabPages.Add(gender          = new TextPage("性別 (gender)", "male"));
         TCmain.TabPages.Add(introduction    = new TextPage("自介 (introduction)", "I get hurt a lot in that chatroom war..."));
         TCmain.TabPages.Add(filter_function = new TextPage("篩選函式 (filter_function)", "int filter_function(struct User user)\r\n" +
                                                            "{\r\n" +
                                                            "    if(user.age<18 || user.age>25) return 0;//這樣可以篩掉不是大學年紀的人\r\n" +
                                                            "    return 1;\r\n" +
                                                            "}\r\n" +
                                                            "/*(修改上面這個函式來篩選欲匹配的對象,下面是User的定義。程式語言:C(不是C++))\r\n" +
                                                            "struct User {\r\n" +
                                                            "    char name[33],\r\n" +
                                                            "    unsigned int age,\r\n" +
                                                            "    char gender[7],\r\n" +
                                                            "    char introduction[1025]\r\n" +
                                                            "};*/"));
         filter_function.TXB.Font = new Font("Consolas", 15);
         TCmain.TabPages.Add(ip   = new TextPage("IP", "140.112.30.32"));
         TCmain.TabPages.Add(port = new TextPage("Port", "10000"));
         this.Controls.Add(TCmain);
     }
 }
Esempio n. 7
0
        public void ScreenshotOnFailedAssert()
        {
            TextPage.Go();

            var c = Config.Settings.ScreenshotOnFailedAssert;

            Config.ScreenshotOnFailedAssert(true);
            try
            {
                var lastFile = MostRecentTempFile()?.Name ?? "xx.xx";

                Assert.Throws <FluentException>(() => I.Assert.True(() => false));

                var newFile = MostRecentTempFile();

                I.Assert
                .True(() => newFile != null)
                .True(() => newFile.Name != lastFile)
                .True(() => newFile.Exists)
                .True(() => newFile.Length > 0);

                newFile.Delete();
            }
            finally
            {
                Config.ScreenshotOnFailedAssert(c);
            }
        }
Esempio n. 8
0
        public void StartTalk(TalkCloudBase cloud, TalkData talkData)
        {
            if (!_isTalking)
            {
                _talkCloud = cloud;

                _talkCloud.Init(talkData.PagesCount);

                _talkCloud.OnCloudShown  += OnCloudShown;
                _talkCloud.OnCloudHidden += OnCloudHidden;

                _talkData = talkData;

                _currentPage = _talkData.GetPage(_firstPage);
                _talkCloud.SetPage(_currentPage, _firstPage);

                if (_talkData)
                {
                    _isTalking = true;

                    _pageIndex       = default;
                    _isLastPage      = default;
                    _canShowNextPage = default;

                    _writerControl.Init(_currentPage, _talkCloud.TextControl);

                    _talkCloud.OnShowCloud();
                    _talkCallback?.Invoke(TalkEvent.Started);
                }
                else
                {
                    Debug.LogError($"Talk Data is null");
                }
            }
        }
Esempio n. 9
0
        private IEnumerable <Webpage> GetBasicPages()
        {
            var homePage = new TextPage
            {
                Name        = "Home",
                UrlSegment  = "home",
                BodyContent =
                    "<h1>Mr CMS</h1> <p>Welcome to Mr CMS, the only CMS you will need.</p><p> Turn on inline editing above, then click here. Pretty cool huh? </p>",
                RevealInNavigation = true,
            };

            CurrentRequestData.HomePage = homePage;
            yield return(homePage);

            yield return(new TextPage
            {
                Name = "Page 2",
                UrlSegment = "page-2",
                BodyContent = "<h1>Another page</h1><p>Just another page!</p>",
                RevealInNavigation = true,
            });

            //contact us
            var contactUs = new TextPage
            {
                Name               = "Contact us",
                UrlSegment         = "contact-us",
                BodyContent        = "<h1>Contact</h1>Contact us at www.mrcms.com (coming soon). <p>Test form</a> [form]",
                RevealInNavigation = true,
            };

            AddFormToContactUs(contactUs);
            yield return(contactUs);
        }
Esempio n. 10
0
        protected void BuildBooks()
        {
            PageRepository.DeleteAll();
            BookRepository.DeleteAll();

            Console.WriteLine("Add books");

            Book b = new Book("mexikansk-mad", "Mexikansk mad", "En samling af mine yndlingsopskrifter fra Mexiko",
                              TestDataConstants.Profiles.SimonProfileId);

            b.PublishedDate = DateTime.UtcNow;

            Page p1 = new TextPage("Velbekomme", 1, "Demo");

            PageRepository.Add(p1);
            b.AddPage(p1.Id);

            RecipePage p2 = new RecipePage(MexicanskeBurritosRecipe.Title, 2, MexicanskeBurritosRecipe.Id);

            PageRepository.Add(p2);
            b.AddPage(p2.Id);

            RecipePage p3 = new RecipePage(BonneMosRecipe.Title, 3, BonneMosRecipe.Id);

            PageRepository.Add(p3);
            b.AddPage(p3.Id);

            BookRepository.Add(b);
        }
        public TakeScreenshotTests()
            : base()
        {
            tempPath = Path.GetTempPath();
            Config.ScreenshotPath(tempPath);

            TextPage.Go();
        }
Esempio n. 12
0
        public override void Init(TextControl textControl, TextPage page)
        {
            base.Init(textControl, page);

            SetCharsStartPositions(textControl, page);

            SetOffset(textControl, page);
        }
Esempio n. 13
0
 public void FocusBlockElement()
 {
     TextPage.Go();
     I.Assert.Css("color", Colors.ALICE_BLUE).Not.On(TextPage.TitleSelector);
     // This shouldn't actually do anything. Focusing a block element makes no sense.
     I.Focus(TextPage.TitleSelector)
     .Assert.Css("color", Colors.ALICE_BLUE).Not.On(TextPage.TitleSelector);
 }
Esempio n. 14
0
        public void WebpageController_PublishNow_CallsDocumentServicePublishNow()
        {
            var textPage = new TextPage();

            _webpageController.PublishNow(textPage);

            A.CallTo(() => _webpageAdminService.PublishNow(textPage)).MustHaveHappened();
        }
Esempio n. 15
0
        public void FormController_Posting_ReturnsTheResultOfTheCallToGetFormPostings()
        {
            var textPage      = new TextPage();
            var postingsModel = new PostingsModel(PagedList <FormPosting> .Empty, 1);

            A.CallTo(() => _formAdminService.GetFormPostings(textPage, 1, null)).Returns(postingsModel);
            _formController.Postings(textPage, 1, null).As <PartialViewResult>().Model.Should().Be(postingsModel);
        }
Esempio n. 16
0
        public void FocusLink()
        {
            TextPage.Go();

            I.Assert.Css("color", InputsPage.FocusColor).Not.On(TextPage.Link1Selector);
            I.Focus(TextPage.Link1Selector)
            .Assert.Css("color", InputsPage.FocusColor).On(TextPage.Link1Selector);
        }
Esempio n. 17
0
        public void WebpageController_Delete_CallsDeleteDocumentOnThePassedObject()
        {
            var textPage = new TextPage();

            _webpageController.Delete(textPage);

            A.CallTo(() => _documentService.DeleteDocument <Webpage>(textPage)).MustHaveHappened();
        }
Esempio n. 18
0
        public void WebpageController_Unpublish_CallsDocumentServicePublishNow()
        {
            var textPage = new TextPage();

            _webpageController.Unpublish(textPage);

            A.CallTo(() => _documentService.Unpublish(textPage)).MustHaveHappened();
        }
Esempio n. 19
0
        public void WebpageController_Unpublish_ReturnsRedirectToRouteResult()
        {
            var textPage = new TextPage {
                Id = 1
            };

            _webpageController.Unpublish(textPage).Should().BeOfType <RedirectToRouteResult>();
        }
Esempio n. 20
0
        public void FormController_Postings_CallsFormServiceGetFormPostingsWithPassedArguments()
        {
            var textPage = new TextPage();

            _formController.Postings(textPage, 1, null);

            A.CallTo(() => _formAdminService.GetFormPostings(textPage, 1, null)).MustHaveHappened();
        }
Esempio n. 21
0
        public void WebpageController_Sort_ShouldCallGetDocumentsByParentId()
        {
            var textPage = new TextPage();

            _webpageController.Sort(textPage);

            A.CallTo(() => _documentService.GetDocumentsByParent <Webpage>(textPage)).MustHaveHappened();
        }
Esempio n. 22
0
        public void HoverLink()
        {
            TextPage.Go();

            I.Assert.Css("color", Colors.RED).Not.On(TextPage.Link1Selector);
            I.Hover(TextPage.Link1Selector)
            .Assert.Css("color", Colors.RED).On(TextPage.Link1Selector);
        }
Esempio n. 23
0
        public void HoverBlockElement()
        {
            TextPage.Go();

            I.Assert.Css("color", Colors.RED).Not.On(TextPage.TitleSelector);
            I.Hover(TextPage.TitleSelector);
            I.Assert.Css("color", Colors.RED).On(TextPage.TitleSelector);
        }
Esempio n. 24
0
        public Page BuildPage(string title = "Some page", int pageNo = 1)
        {
            Page p = new TextPage(title, pageNo, "Blah");

            RegisterInstance(p);
            PageRepository.Add(p);
            return(p);
        }
Esempio n. 25
0
 public TextViewModel(TextPage page, Action toggleButtonVisibility) : base(toggleButtonVisibility)
 {
     Text               = page.Text;
     FontFamily         = page.FontFamily;
     Headline           = page.Title;
     Description        = page.Description;
     BottomSheetVisible = !(string.IsNullOrEmpty(Headline) && string.IsNullOrEmpty(Description));
 }
Esempio n. 26
0
        public void HoverLink()
        {
            TextPage.Go();

            I.Assert.Css("color", InputsPage.HoverColor).Not.On(TextPage.Link1Selector);
            I.Hover(TextPage.Link1Selector)
            .Wait(3)
            .Assert.Css("color", InputsPage.HoverColor).On(TextPage.Link1Selector);
        }
Esempio n. 27
0
        private void SetCharsStartPositions(TextControl textControl, TextPage page)
        {
            _startPos.Clear();

            for (int i = 0; i < page.Text.Length; i++)
            {
                _startPos.Add(textControl.GetCharPos(i));
            }
        }
Esempio n. 28
0
        public void WebpageController_EditGet_ShouldSetViewData()
        {
            var textPage = new TextPage();

            _webpageController.Edit_Get(textPage);

            A.CallTo(() => _baseViewDataService.SetEditPageViewData(_webpageController.ViewData, textPage))
            .MustHaveHappened();
        }
Esempio n. 29
0
 public TextViewModel(TextPage page)
 {
     Text = page.Text;
     // Legacy code: specific font families for text pages are no longer used
     // FontFamily = page.FontFamily;
     Headline           = page.Title;
     Description        = page.Description;
     BottomSheetVisible = !(string.IsNullOrEmpty(Headline) && string.IsNullOrEmpty(Description));
 }
Esempio n. 30
0
        private void SetOffset(TextControl textControl, TextPage page)
        {
            var dir = GetStartOffsetDir(page.CharByCharInfo.OffsetType, page.CharByCharInfo.Offset);

            _offsetToMoveBack = -dir;

            //i have to find a way to offset the chars individually and not moving the entire rectTransform.
            textControl.OffsetText(dir);
        }
Esempio n. 31
0
        public void WebpageController_Unpublish_RedirectsToEditForId()
        {
            var textPage = new TextPage {
                Id = 1
            };
            var result = _webpageController.Unpublish(textPage).As <RedirectToRouteResult>();

            result.RouteValues["action"].Should().Be("Edit");
            result.RouteValues["id"].Should().Be(1);
        }