Beispiel #1
0
        protected T CreateShellSection <T>(
            TemplatedPage page       = null,
            bool asImplicit          = false,
            string shellContentRoute = null,
            string shellSectionRoute = null,
            bool templated           = false) where T : ShellSection
        {
            var content = CreateShellContent(page, asImplicit, shellContentRoute, templated: templated);

            T section = null;

            if (!String.IsNullOrWhiteSpace(shellSectionRoute))
            {
                section       = Activator.CreateInstance <T>();
                section.Route = shellSectionRoute;
                section.Items.Add(content);
            }
            else if (asImplicit)
            {
                section = (T)ShellSection.CreateFromShellContent(content);
            }
            else
            {
                section = Activator.CreateInstance <T>();
                section.Items.Add(content);
            }

            return(section);
        }
Beispiel #2
0
        protected ShellContent CreateShellContent(TemplatedPage page = null, bool asImplicit = false, string shellContentRoute = null)
        {
            page = page ?? new ContentPage();
            ShellContent content = null;

            if (!String.IsNullOrWhiteSpace(shellContentRoute))
            {
                content = new ShellContent()
                {
                    Content = page
                };
                content.Route = shellContentRoute;
            }
            else if (asImplicit)
            {
                content = (ShellContent)page;
            }
            else
            {
                content = new ShellContent()
                {
                    Content = page
                }
            };


            return(content);
        }
    }
Beispiel #3
0
        protected T CreateShellItem <T>(
            TemplatedPage page       = null,
            bool asImplicit          = false,
            string shellContentRoute = null,
            string shellSectionRoute = null,
            string shellItemRoute    = null,
            bool templated           = false) where T : ShellItem
        {
            T   item    = null;
            var section = CreateShellSection(page, asImplicit, shellContentRoute, shellSectionRoute, templated: templated);

            if (!String.IsNullOrWhiteSpace(shellItemRoute))
            {
                item       = Activator.CreateInstance <T>();
                item.Route = shellItemRoute;
                item.Items.Add(section);
            }
            else if (asImplicit)
            {
                item = (T)ShellItem.CreateFromShellSection(section);
            }
            else
            {
                item = Activator.CreateInstance <T>();
                item.Items.Add(section);
            }

            return(item);
        }
Beispiel #4
0
        protected ShellItem CreateShellItem(
            TemplatedPage page       = null,
            bool asImplicit          = false,
            string shellContentRoute = null,
            string shellSectionRoute = null,
            string shellItemRoute    = null,
            bool templated           = false)
        {
            ShellItem item    = null;
            var       section = CreateShellSection(page, asImplicit, shellContentRoute, shellSectionRoute, templated: templated);

            if (!String.IsNullOrWhiteSpace(shellItemRoute))
            {
                item       = new ShellItem();
                item.Route = shellItemRoute;
                item.Items.Add(section);
            }
            else if (asImplicit)
            {
                item = ShellItem.CreateFromShellSection(section);
            }
            else
            {
                item = new ShellItem();
                item.Items.Add(section);
            }

            return(item);
        }
Beispiel #5
0
        protected ShellSection CreateShellSection(
            TemplatedPage page       = null,
            bool asImplicit          = false,
            string shellContentRoute = null,
            string shellSectionRoute = null,
            bool templated           = false)
        {
            var content = CreateShellContent(page, asImplicit, shellContentRoute, templated: templated);

            ShellSection section = null;

            if (!String.IsNullOrWhiteSpace(shellSectionRoute))
            {
                section       = new ShellSection();
                section.Route = shellSectionRoute;
                section.Items.Add(content);
            }
            else if (asImplicit)
            {
                section = ShellSection.CreateFromShellContent(content);
            }
            else
            {
                section = new ShellSection();
                section.Items.Add(content);
            }

            return(section);
        }
        public override void ApplyTo(TemplatedPage page)
        {
            Control ctlHeader = page.LoadControl(header);
            Control ctlFooter = page.LoadControl(footer);

            ctlHeader.ID = "__ctlTemplateHeader";
            ctlFooter.ID = "__ctlTemplateFooter";

            if (ctlHeader is ISkinnable)
            {
                ((ISkinnable)ctlHeader).SkinID = page.SkinID;
            }
            if (ctlFooter is ISkinnable)
            {
                ((ISkinnable)ctlFooter).SkinID = page.SkinID;
            }

            if (page.Controls.Count >= 3)
            {
                page.Controls.RemoveAt(0);
                page.Controls.RemoveAt(page.Controls.Count - 1);
            }

            page.Controls.AddAt(0, ctlHeader);
            page.Controls.Add(ctlFooter);
        }
        public TemplatedPageDto CreateTemplatedPage(TemplatedPageDto templatePageDto)
        {
            using (ConsoleRepository)
            {
                var templatedPage = ConsoleRepository.Query <TemplatedPage>().FirstOrDefault(tp => tp.PageTitle.Equals(templatePageDto.PageTitle));

                if (templatedPage != null)
                {
                    throw new Exception("Templated Page Already Exists");
                }

                var newTemplatePage = new TemplatedPage
                {
                    PageTitle         = templatePageDto.PageTitle,
                    ViewModel         = templatePageDto.ViewModel,
                    IsMenuLinkVisible = templatePageDto.IsMenuLinkVisible
                };
                // Add Templated Page
                ConsoleRepository.Add <TemplatedPage>(newTemplatePage);

                // Add Page Templates for all Teams
                var teams             = ConsoleRepository.Query <Team>().ToList();
                var structureTemplate = ConsoleRepository.Query <Template>().FirstOrDefault(t => t.Title.Equals("8 Section Template"));
                var holdingTemplate   = ConsoleRepository.Query <Template>().FirstOrDefault(t => t.Title.Equals("Holding Template"));

                CreateDefaultPageTemplatesPerTeam(ConsoleRepository, newTemplatePage, teams, structureTemplate, holdingTemplate);

                ConsoleRepository.SaveChanges();

                templatePageDto.Id = newTemplatePage.Id;
            }

            return(templatePageDto);
        }
Beispiel #8
0
        protected ShellContent CreateShellContent(TemplatedPage page = null, bool asImplicit = false, string shellContentRoute = null, bool templated = false)
        {
            ShellContent content = null;

            if (!String.IsNullOrWhiteSpace(shellContentRoute))
            {
                if (templated)
                {
                    content = new ShellContent()
                    {
                        ContentTemplate = new DataTemplate(() => page ?? new ContentPage())
                    }
                }
                ;
                else
                {
                    content = new ShellContent()
                    {
                        Content = page ?? new ContentPage()
                    }
                };

                content.Route = shellContentRoute;
            }
            else if (asImplicit)
            {
                content = (ShellContent)page;
            }
            else
            {
                if (templated)
                {
                    content = new ShellContent()
                    {
                        ContentTemplate = new DataTemplate(() => page ?? new ContentPage())
                    }
                }
                ;
                else
                {
                    content = new ShellContent()
                    {
                        Content = page ?? new ContentPage()
                    }
                };
            }


            return(content);
        }
    }
Beispiel #9
0
 protected ShellSection CreateShellSection(
     TemplatedPage page       = null,
     bool asImplicit          = false,
     string shellContentRoute = null,
     string shellSectionRoute = null,
     bool templated           = false)
 {
     return(CreateShellSection <ShellSection>(
                page,
                asImplicit,
                shellContentRoute,
                shellSectionRoute,
                templated));
 }
Beispiel #10
0
        public void TemplatedPage_should_have_the_InternalChildren_correctly_when_ControlTemplate_changed()
        {
            var             sut = new TemplatedPage();
            IList <Element> internalChildren = ((IControlTemplated)sut).InternalChildren;

            internalChildren.Add(new VisualElement());
            internalChildren.Add(new VisualElement());
            internalChildren.Add(new VisualElement());

            sut.ControlTemplate = new ControlTemplate(typeof(ExpectedView));

            Assert.AreEqual(1, internalChildren.Count);
            Assert.IsInstanceOf <ExpectedView>(internalChildren[0]);
        }
		public override void ApplyTo(TemplatedPage page)
		{
			Control ctlHeader = page.LoadControl(header);
			Control ctlFooter = page.LoadControl(footer);

			ctlHeader.ID = "__ctlTemplateHeader";
			ctlFooter.ID = "__ctlTemplateFooter";

			if (ctlHeader is ISkinnable) ((ISkinnable) ctlHeader).SkinID = page.SkinID;
			if (ctlFooter is ISkinnable) ((ISkinnable) ctlFooter).SkinID = page.SkinID;

			if (page.Controls.Count >= 3) 
			{
				page.Controls.RemoveAt(0);
				page.Controls.RemoveAt(page.Controls.Count - 1);
			}
			
			page.Controls.AddAt(0, ctlHeader);
			page.Controls.Add(ctlFooter);
		}
		public abstract void ApplyTo(TemplatedPage page);
        public static void SetPageTemplates(IConsoleRepository ConsoleRepository, TemplatedPage templatedPage,
                                            Template structureTemplate, Template holdingTemplate, Team team)
        {
            var pageStructureTemplate = new PageTemplate
            {
                IsVisible     = true,
                Team          = team,
                TemplatedPage = templatedPage,
                Template      = structureTemplate,
                PageSectionId = 0
            };

            ConsoleRepository.Add <PageTemplate>(pageStructureTemplate);

            var holdingTempl_1 = new PageTemplate
            {
                IsVisible     = true,
                Team          = team,
                TemplatedPage = templatedPage,
                Template      = holdingTemplate,
                PageSectionId = 1
            };

            ConsoleRepository.Add <PageTemplate>(holdingTempl_1);

            var holdingTempl_2 = new PageTemplate
            {
                IsVisible     = true,
                Team          = team,
                TemplatedPage = templatedPage,
                Template      = holdingTemplate,
                PageSectionId = 2
            };

            ConsoleRepository.Add <PageTemplate>(holdingTempl_2);

            var holdingTempl_3 = new PageTemplate
            {
                IsVisible     = true,
                Team          = team,
                TemplatedPage = templatedPage,
                Template      = holdingTemplate,
                PageSectionId = 3
            };

            ConsoleRepository.Add <PageTemplate>(holdingTempl_3);

            var holdingTempl_4 = new PageTemplate
            {
                IsVisible     = true,
                Team          = team,
                TemplatedPage = templatedPage,
                Template      = holdingTemplate,
                PageSectionId = 4
            };

            ConsoleRepository.Add <PageTemplate>(holdingTempl_4);

            var holdingTempl_5 = new PageTemplate
            {
                IsVisible     = true,
                Team          = team,
                TemplatedPage = templatedPage,
                Template      = holdingTemplate,
                PageSectionId = 5
            };

            ConsoleRepository.Add <PageTemplate>(holdingTempl_5);

            var holdingTempl_6 = new PageTemplate
            {
                IsVisible     = true,
                Team          = team,
                TemplatedPage = templatedPage,
                Template      = holdingTemplate,
                PageSectionId = 6
            };

            ConsoleRepository.Add <PageTemplate>(holdingTempl_6);

            var holdingTempl_7 = new PageTemplate
            {
                IsVisible     = true,
                Team          = team,
                TemplatedPage = templatedPage,
                Template      = holdingTemplate,
                PageSectionId = 7
            };

            ConsoleRepository.Add <PageTemplate>(holdingTempl_7);

            var holdingTempl_8 = new PageTemplate
            {
                IsVisible     = true,
                Team          = team,
                TemplatedPage = templatedPage,
                Template      = holdingTemplate,
                PageSectionId = 8
            };

            ConsoleRepository.Add <PageTemplate>(holdingTempl_8);
        }
 public static void CreateDefaultPageTemplatesPerTeam(IConsoleRepository ConsoleRepository, TemplatedPage templatedPage, List <Team> teams, Template structureTemplate, Template holdingTemplate)
 {
     foreach (var team in teams)
     {
         SetPageTemplates(ConsoleRepository, templatedPage, structureTemplate, holdingTemplate, team);
     }
 }
Beispiel #15
0
 public abstract void ApplyTo(TemplatedPage page);