public ToolboxViewModel Toolbox()
        {
            var vm = new ToolboxViewModel();

            var allItems      = new ToolboxManager().Find();
            var allCategories = allItems.Select(x => x.Category).Distinct();

            foreach (var category in allCategories)
            {
                vm.ToolboxCategories.Add(new ToolboxCategory
                {
                    IsClientSide = false,
                    CategoryName = category,
                    Items        = allItems.Where(x => x.Category == category)
                                   .Select(x => new ToolboxItemViewModel
                    {
                        Name           = x.FriendlyName,
                        Description    = x.Description,
                        WidgetTypeCode = x.WidgetUid
                    }).ToList()
                });
            }


            return(vm);
        }
        //public bool NeedsADataSource(PageContent pageContent)
        //{
        //    var toolboxItem = new ToolboxManager().GetToolboxItemByCode(pageContent.WidgetTypeCode);
        //    var toolboxItemType = Type.GetType(toolboxItem.AssemblyQualifiedTypeName);
        //    var needsADataSource = typeof(IRequiresDataSource).IsAssignableFrom(toolboxItemType);
        //    return needsADataSource;
        //}

        public PageCompositionElement ActivateCmsPageContent(PageContent pageContent)
        {
            var parameters     = pageContent.Parameters;
            var widgetTypeCode = pageContent.WidgetTypeCode;
            var toolboxItem    = new ToolboxManager().GetToolboxItemByCode(widgetTypeCode);

            var toolboxItemType = GetToolboxItemNativeType(toolboxItem);


            PageCompositionElement pp;
            var wasCreatedViaCache = _contentContentCacheElementFactory.TryCreateCachedContentElement(toolboxItemType, pageContent, out pp, out var cacheKey);

            if (!wasCreatedViaCache)
            {
                var activator       = GetActivator(toolboxItemType);
                var activatedObject = activator.ActivateType(toolboxItemType);
                activatedObject.SetPropertyValues(parameters, ToolboxPropertyFilter.SupportsDesigner);
                pp = activator.CreateRenderingForObject(activatedObject);
            }

            pp.CacheKey        = cacheKey;
            pp.ContentId       = pageContent.Id;
            pp.FriendlyName    = toolboxItem.FriendlyName;
            pp.LocalId         = $"Layout{pageContent.Id}";
            pp.LayoutBuilderId = pageContent.Id;

            return(pp);
        }
Exemplo n.º 3
0
    //Called at the beginning of the level
    void Start()
    {
        myInstance = this;
        button.GetComponent <SpriteRenderer>().sortingLayerName = "GUI";
        itemContainerPos = itemContainer.transform.position;

        items         = new List <ToolboxItemType>();
        inactiveItems = new List <ToolboxItemType>();
    }
Exemplo n.º 4
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        _animationManager = GetComponent <AnimationManager>();
        _sequenceManager  = GetComponent <SequenceManager>();
    }
        public EditingSession InitializeEditingSession(StructureNode structureNode)
        {
            var toolboxItem           = new ToolboxManager().GetToolboxItemByCode(structureNode.WidgetTypeCode);
            var toolboxItemNativeType = new CmsPageContentActivator().GetToolboxItemNativeType(toolboxItem);
            var defaultForm           = new ConfiguratorCmsPageContentBuilder().GenerateDefaultForm(toolboxItemNativeType, FormStyle.Edit);

            var runtime = new FormsRuntime();

            return(runtime.EditingSession(defaultForm, toolboxItemNativeType, structureNode.Parameters));
        }
Exemplo n.º 6
0
        public IReadOnlyCollection <CmsPageContent> GetClientSideWidets(CmsForm form)
        {
            //todo: better options??
            var toolboxManager = new ToolboxManager();
            var widgetsOnPage  = form
                                 .GetAllDescendents()
                                 .Where(x => x.WidgetTypeCode != null);

            return
                (widgetsOnPage.Where(x => toolboxManager.GetToolboxItemByCode(x.WidgetTypeCode).UseClientSidePresentationEngine).ToList());
        }
Exemplo n.º 7
0
        public CmsPageContent CreateCmsPageContent(SettingProperty property, string widgetTypeCode, FormStyle parentFormStyle)
        {
            var setup = new ConfiguratorSetup
            {
                PropertyType = property.PropertyInfo.PropertyType.FullName,
                DisplayName  = property.DisplayName,
                PropertyName = property.PropertyInfo.Name
            };

            var cmsPageContent = new CmsPageContent
            {
                Id             = Guid.NewGuid(),
                WidgetTypeCode = widgetTypeCode
            };

            var standardParameters   = setup.GetPropertyValues(x => true).ToDictionary(x => x.Key, x => x.Value);
            var datasourceParameters = new Dictionary <string, string>();

            var toolboxItem = new ToolboxManager().GetToolboxItemByCode(widgetTypeCode);

            if (toolboxItem.RequiresDataSource)
            {
                var dataRelationDs = InferDataSourceFromDataRelation(property);
                if (dataRelationDs != null)
                {
                    datasourceParameters = dataRelationDs.GetPropertyValues(x => true).ToDictionary(x => x.Key, x => x.Value);
                }
            }

            if (toolboxItem.SupportsSubContent)
            {
                var propType    = property.PropertyInfo.PropertyType;
                var defaultForm = GenerateDefaultForm(propType, parentFormStyle);
                cmsPageContent.AllContent = defaultForm.ChildNodes;
            }


            var mergedParameters = new Dictionary <string, string>();

            foreach (var parameter in standardParameters)
            {
                mergedParameters.Add(parameter.Key, parameter.Value);
            }
            foreach (var parameter in datasourceParameters)
            {
                mergedParameters.Add(parameter.Key, parameter.Value);
            }
            cmsPageContent.Parameters = mergedParameters;

            return(cmsPageContent);
        }
Exemplo n.º 8
0
        public CmsPageContent BuildCmsPageContentFromToolboxItemTemplate(object activated)
        {
            var toolboxMetadata = ToolboxMetadataReader.ReadMetadata(activated.GetType());
            var toolboxItem     = new ToolboxManager().GetToolboxItemByCode(toolboxMetadata.WidgetUid);

            IDictionary <string, string> settings = activated.GetPropertyValues(ToolboxPropertyFilter.SupportsDesigner);

            return(new CmsPageContent
            {
                Id = Guid.NewGuid(),
                WidgetTypeCode = toolboxItem.WidgetUid,
                Parameters = settings.ToDictionary(x => x.Key, x => x.Value)
            });
        }
        public ConfiguratorFormDescription GetConfiguratorForm(string widgetTypeCode)
        {
            var toolboxItem           = new ToolboxManager().GetToolboxItemByCode(widgetTypeCode);
            var toolboxItemNativeType = new CmsPageContentActivator().GetToolboxItemNativeType(toolboxItem);
            var defaultForm           = new ConfiguratorCmsPageContentBuilder().GenerateDefaultForm(toolboxItemNativeType, FormStyle.Edit);

            // new CmsPageContentActivator().GetDefaultContentParameterValues(toolboxItem)
            //.ToDictionary(x => x.Key, x => x.Value)

            var description =
                new ConfiguratorFormDescription
            {
                Layout        = new StructureNodeConverter().GetPageStructure(defaultForm),
                DefaultValues = new Dictionary <string, string>()
            };

            return(description);
        }
        private void WriteMetadata()
        {
            CmsPageContent contentPlacement = null;

            if (CurrentNode.Type == NodeType.Element)
            {
                contentPlacement = _draft.FindContentById(CurrentNode.ContentId);
            }

            if (contentPlacement == null)
            {
                CurrentNode.IsFromLayout = true;
            }
            else
            {
                CurrentNode.Parameters = contentPlacement.Parameters;
                var toolboxItem = new ToolboxManager().GetToolboxItemByCode(contentPlacement.WidgetTypeCode);
                CurrentNode.FriendlyName = toolboxItem.FriendlyName;
            }
        }
Exemplo n.º 11
0
        public void SetupToolbox()
        {
            var tbx = new ToolboxManager();

            tbx.Save(new ToolboxItem
            {
                AscxPath     = "/App_Data/BackendWidgets/EntityBuilder.ascx",
                WidgetUid    = "wc-entitybuilder",
                FriendlyName = "Entity Builder"
            });
            tbx.Save(new ToolboxItem
            {
                AscxPath     = "/App_Data/BackendWidgets/FormDesigner.ascx",
                WidgetUid    = "wc-formdesigner",
                FriendlyName = "Form Designer"
            });
            //tbx.Save(new ToolboxItem
            //{
            //    AscxPath = "/App_Data/Forms/DynamicForm.ascx",
            //    WidgetUid = DynamicForm.ApiId,
            //    FriendlyName = "Dynamic Form"
            //});
            tbx.Save(new ToolboxItem
            {
                AscxPath     = "/App_Data/BackendWidgets/EntityList.ascx",
                WidgetUid    = "wc-entity-list",
                FriendlyName = "Entity List"
            });


            //
            tbx.Save(new ToolboxItem
            {
                AscxPath     = "/App_Data/BackendWidgets/AddPageWizard.ascx",
                WidgetUid    = AddPageWizard.ApiId,
                FriendlyName = "Add Page Wizard"
            });
        }
Exemplo n.º 12
0
        private static IEnumerable <SiteRoute> DiscoverContentRoutes(CmsPage page, IEnumerable <ContentPageRoute> pageRoutes)
        {
            var contentRoutes = new List <SiteRoute>();


            foreach (var content in page.PageContent)
            {
                var toolboxManager = new ToolboxManager();
                var toolboxItem    = toolboxManager.GetToolboxItemByCode(content.WidgetTypeCode);


                var toolboxItemType = default(Type);//todo: add content routing.
                continue;
                var contentRouteAttributes = toolboxItemType.GetCustomAttributes(typeof(ContentRouteAttribute)).Cast <ContentRouteAttribute>().ToList();

                foreach (var contentRouteAttribute in contentRouteAttributes)
                {
                    var pageRoutesToCopy = pageRoutes.ToList();
                    foreach (var pageRoute in pageRoutesToCopy)
                    {
                        var contentRoute = new ContentPageRoute
                        {
                            Authority       = pageRoute.Authority,
                            ContentTypeCode = contentRouteAttribute.ContentTypeCode,
                            PageId          = pageRoute.PageId,
                            Priority        = pageRoute.Priority,
                            SiteId          = pageRoute.SiteId,
                            VirtualPath     = new Uri(pageRoute.VirtualPath + "/" + contentRouteAttribute.RouteTemplate),
                            RequireSsl      = pageRoute.RequireSsl
                        };
                        contentRoutes.Add(contentRoute);
                    }
                }
            }
            return(contentRoutes);
        }
Exemplo n.º 13
0
    void Start()
    {
        PanelBase = Resources.Load <GameObject>("Models/BluePanel");
        //GameObject.Find("BluePanel");//
        LoadedSceneSetup = ResourcesMaster.SceneSetup;
        GetComponent <SetupHolder>().SceneSetup = LoadedSceneSetup;

        TrackedAnimationTags = new List <TrackedAnimationTag>(LoadedSceneSetup.TrackedAnimationTags);
        TrackedToolboxTags   = new List <TrackedToolboxTag>(LoadedSceneSetup.TrackedToolboxTags);

        ModelsFather = GameObject.Find("ModelsFather").transform;

        PieceEventManagers = new List <PieceEventManager>();

        for (int i = 0; i < ModelsFather.childCount; i++)
        {
            //ToolboxManager TM = new ToolboxManager();

            GameObject ChildModel = ModelsFather.GetChild(i).gameObject;

            TrackedAnimationTag TkAnimationTag = TrackedAnimationTags.Find(Tag => Tag.Name.Equals(ChildModel.name));
            TrackedToolboxTag   TkToolboxTag   = TrackedToolboxTags.Find(Tag => Tag.Name.Equals(ChildModel.name));

            if (TkAnimationTag == null && TkToolboxTag == null)
            {
                Debug.Log("Couldnt find such Tag " + ChildModel.name + " " + i);
                continue;
            }
            if (TkAnimationTag != null)
            {
                PieceEventManager PEM = ChildModel.AddComponent <PieceEventManager>();
                PEM.Enableds(Models: false, Buttons: false, Warnings: true);

                Transform PanelsFather = ChildModel.transform.Find("Panels");
                foreach (PieceModel Panel in TkAnimationTag.Panels)
                {
                    GameObject NewPanel = Instantiate(PanelBase, PanelsFather);
                    NewPanel.name = Panel.Name;
                    NewPanel.transform.localPosition = Panel.ModelPositionVector;
                    NewPanel.transform.localRotation = Panel.ModelRotationVector;
                    NewPanel.transform.localScale    = Panel.ModelScaleVector;
                }

                //Transform Models = ChildModel.transform.Find("Models");
                //foreach (PieceModel Model in TkAnimationTag.Models){
                //	GameObject NewModel = Instantiate(PanelBase, Models);
                //	NewModel.name = Model.Name;
                //	NewModel.transform.localPosition = Model.ModelPositionVector;
                //	NewModel.transform.localRotation = Model.ModelRotationVector;
                //	NewModel.transform.localScale = Model.ModelScaleVector;
                //}

                PEM.FullyLoad(TkAnimationTag.PieceEvents);
                Debug.Log(PEM.PieceEvents.Count);
                PieceEventManagers.Add(PEM);
            }
            if (TkToolboxTag != null)
            {
                ToolboxManager TM = ChildModel.AddComponent <ToolboxManager>();
                TM.Enableds(Models: false);
                ToolboxManagers.Add(TM);

                Transform PanelsFather = ChildModel.transform.Find("Panels");
                foreach (PieceTool Tool in TkToolboxTag.Tools)
                {
                    foreach (PieceModel Panel in Tool.Panels)
                    {
                        GameObject NewPanel = Instantiate(PanelBase, PanelsFather);
                        NewPanel.name = Panel.Name;
                        NewPanel.transform.localPosition = Panel.ModelPositionVector;
                        NewPanel.transform.localRotation = Panel.ModelRotationVector;
                        NewPanel.transform.localScale    = Panel.ModelScaleVector;
                    }
                }
            }
        }

        PieceEventManagers[0].Enableds(Models: true, Buttons: true, Warnings: false);
        OngoingGlobalEvent = PieceEventManagers[0].OngoingManagerEvent;

        Debug.Log("PEM amount: " + PieceEventManagers.Count);

        PlayEvent(PieceEventManagers[0]);
    }
Exemplo n.º 14
0
        private static IEnumerable <SiteRoute> DiscoverPageRoutesRecursive(SitemapNode node, Site site)
        {
            if (node.Page.PageType == null)
            {
                throw new Exception("Undefined page type.");
            }

            var pageRoutes = new List <SiteRoute>();

            SiteRoute primaryRoute = null;

            if (PageType.RedirectPage == node.Page.PageType)
            {
                var redirectUri = node.Page.RedirectUri;
                if (redirectUri.IsWarpCoreDataScheme())
                {
                    primaryRoute = new RedirectPageRoute
                    {
                        InternalRedirectPageId     = new WarpCorePageUri(node.Page.RedirectUri.OriginalString).ContentId,
                        InternalRedirectParameters = node.Page.InternalRedirectParameters
                    }
                }
                ;
                else
                {
                    primaryRoute = new RedirectPageRoute
                    {
                        RedirectExternalUrl = node.Page.RedirectUri.ToString()
                    }
                };
            }

            if (PageType.GroupingPage == node.Page.PageType)
            {
                var first = node.ChildNodes.FirstOrDefault();
                primaryRoute = new GroupingPageRoute
                {
                    InternalRedirectPageId = first?.Page?.ContentId
                };
            }

            if (PageType.ContentPage == node.Page.PageType)
            {
                primaryRoute = new ContentPageRoute
                {
                    RequireSsl = node.Page.RequireSsl
                };

                //foreach (var route in node.Page.AlternateRoutes)
                //{
                //    var alternatePageRoute = new ContentPageRoute
                //    {
                //        Authority = site.UriAuthority,
                //        Priority = route.Priority,
                //        SiteId = site.ContentId.Value,
                //        PageId = node.Page.ContentId.Value,
                //        VirtualPath = MakeRelativeUri(site, route.VirtualPath),
                //        RequireSsl = node.Page.RequireSsl
                //    };
                //    pageRoutes.Add(alternatePageRoute);
                //}

                foreach (var content in node.Page.PageContent)
                {
                    var toolboxManager = new ToolboxManager();
                    var toolboxItem    = toolboxManager.GetToolboxItemByCode(content.WidgetTypeCode);

                    //todo: fix this, we need a separate toolbox item activator outside of the page composer.
                    //      add cache too.
                    var typeName = toolboxItem?.AssemblyQualifiedTypeName;
                    if (typeName != null)
                    {
                        var type         = Type.GetType(typeName);
                        var hasInterface = type.GetInterface(nameof(IHostsClientSideRoutes)) != null;
                        primaryRoute.HostsClientSideRoutes = hasInterface;
                    }
                }
            }

            if (primaryRoute == null)
            {
                throw new Exception("Unsupported page type: " + node.Page.PageType);
            }

            primaryRoute.Authority   = site.UriAuthority;
            primaryRoute.Priority    = (int)RoutePriority.Primary;
            primaryRoute.SiteId      = site.ContentId;
            primaryRoute.PageId      = node.Page.ContentId;
            primaryRoute.VirtualPath = MakeRelativeUri(site, node.VirtualPath.ToString());



            pageRoutes.Add(primaryRoute);

            var localRoutes = new List <SiteRoute>();

            if (PageType.ContentPage == node.Page.PageType)
            {
                var contentRoutes = DiscoverContentRoutes(node.Page, pageRoutes.Cast <ContentPageRoute>());
                localRoutes.AddRange(contentRoutes);
            }
            localRoutes.AddRange(pageRoutes);

            var allChildRoutes = new List <SiteRoute>();

            foreach (var child in node.ChildNodes)
            {
                var childRoutes = DiscoverPageRoutesRecursive(child, site).ToList();
                allChildRoutes.AddRange(childRoutes);
            }

            var allRoutes = new List <SiteRoute>();

            allRoutes.AddRange(localRoutes);
            allRoutes.AddRange(allChildRoutes);

            return(allRoutes);
        }
Exemplo n.º 15
0
        public Site SetupTestSite()
        {
            var tbx = new ToolboxManager();

            var myLayout = new Layout
            {
                Name           = "Demo",
                MasterPagePath = "/Demo.Master",
            };

            myLayout.PageContent.Add(new CmsPageContent
            {
                Id             = Guid.NewGuid(),
                WidgetTypeCode = "Client-CustomNavigation",
                PlacementContentPlaceHolderId = "NavigationContentPlaceHolder"
            });
            var layoutRepository = new LayoutRepository();

            layoutRepository.Save(myLayout);

            var siteRepo = new SiteRepository();
            var newSite  = new Site
            {
                Name           = "WarpCore Demo",
                IsFrontendSite = true
            };

            siteRepo.Save(newSite);

            var homePage = new CmsPage
            {
                Name        = "Homepage",
                SiteId      = newSite.ContentId,
                LayoutId    = myLayout.ContentId,
                Keywords    = "WarpCore,CMS,Demo",
                Description = "WarpCore CMS Demo"
            };

            var lbId = Guid.NewGuid();
            var row  = new CmsPageContent
            {
                Id             = Guid.NewGuid(),
                WidgetTypeCode = RowLayout.ApiId,
                PlacementContentPlaceHolderId = "Body",
                Parameters = new Dictionary <string, string>
                {
                    //[nameof(RowLayout.LayoutBuilderId)] = lbId.ToString(),
                    [nameof(RowLayout.NumColumns)] = 3.ToString()
                }
            };

            var helloWorld0 = new CmsPageContent
            {
                Id = Guid.NewGuid(),
                PlacementContentPlaceHolderId = "0",
                PlacementLayoutBuilderId      = lbId,
                WidgetTypeCode = ContentBlock.ApiId,
                Parameters     = new Dictionary <string, string> {
                    ["AdHocHtml"] = "Hello World (0)"
                }
            };

            var helloWorld1 = new CmsPageContent
            {
                Id = Guid.NewGuid(),
                PlacementContentPlaceHolderId = "1",
                PlacementLayoutBuilderId      = lbId,
                WidgetTypeCode = ContentBlock.ApiId,
                Parameters     = new Dictionary <string, string> {
                    ["AdHocHtml"] = "Hello World (1)"
                }
            };

            row.AllContent.Add(helloWorld0);
            row.AllContent.Add(helloWorld1);

            homePage.PageContent.Add(row);



            var aboutUs = new CmsPage
            {
                Name     = "About Us",
                SiteId   = newSite.ContentId,
                LayoutId = myLayout.ContentId
            };
            var contactUs = new CmsPage
            {
                Name     = "Contact Us",
                SiteId   = newSite.ContentId,
                LayoutId = myLayout.ContentId
            };

            var pageRepository = new CmsPageRepository();

            pageRepository.Save(homePage, SitemapRelativePosition.Root);
            pageRepository.Save(aboutUs, SitemapRelativePosition.Root);
            pageRepository.Save(contactUs, SitemapRelativePosition.Root);
            newSite.HomepageId = homePage.ContentId;
            siteRepo.Save(newSite);

            var subPage1 = new CmsPage
            {
                Name   = "Subpage 1",
                SiteId = newSite.ContentId
            };

            pageRepository.Save(subPage1, new PageRelativePosition {
                ParentPageId = homePage.ContentId
            });

            var subPage0 = new CmsPage
            {
                Name   = "Subpage 0",
                SiteId = newSite.ContentId
            };

            pageRepository.Save(subPage0, new PageRelativePosition {
                ParentPageId = homePage.ContentId, BeforePageId = subPage1.ContentId
            });

            return(newSite);
        }