Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Desktop"/> class.
 /// </summary>
 public Desktop()
 {
     Skin           = new Skin();
     CursorSet      = new CursorCollection();
     TooltipControl = new SimpleTooltip();
     DragDropSnap   = 0;
 }
        protected bool BuildTemplateFromPresentationData(IEnumerable<PresentationData> presentation, string theme,
            StringBuilder output, CursorCollection placeHolders, DirectiveCollection directives, RequestContext context)
        {
            RootTemplate result = new RootTemplate();
            foreach (PresentationData item in presentation)
            {
                if (item.DataType == Presentation.HtmlDocument)
                {
                    var key = item.Theme ?? "Default";
                    if (key.Equals(theme, StringComparison.OrdinalIgnoreCase))
                    {
                        result = result.FromString(item.Data);
                        break;
                    }
                    if (string.IsNullOrEmpty(result.Template))
                        result = result.FromString(item.Data);
                }
            }

            result = this.GetRootTemplate(result, context, theme);

            if (!String.IsNullOrEmpty(result.Template))
            {
                this.ProcessStringTemplate(result.Template, output, placeHolders, directives);
                return true;
            }
            return false;
        }
        protected override void BuildPageTemplateRecursive(IPageTemplate pageTemplate, string theme, RequestContext context, StringBuilder output, CursorCollection placeHolders, DirectiveCollection directives, List<IControlsContainer> controlConatiners)
        {
            controlConatiners.Add(pageTemplate);

            if (!String.IsNullOrEmpty(pageTemplate.MasterPage))
            {
                this.BuildWithMasterPage(pageTemplate.MasterPage, context, output, placeHolders, directives);
                return;
            }

            if (!String.IsNullOrEmpty(pageTemplate.ExternalPage))
            {
                this.BuildWithExternalPage(pageTemplate.ExternalPage, context, output, placeHolders, directives);
                return;
            }

            if (this.BuildTemplateFromPresentationData(pageTemplate.Presentation, theme, output, placeHolders, directives, context))
                return;

            if (pageTemplate.ParentTemplate != null)
            {
                BuildPageTemplateRecursive(pageTemplate.ParentTemplate, theme, context, output, placeHolders, directives, controlConatiners);
                return;
            }

            var defaultRootTemplate = new RootTemplate();
            defaultRootTemplate.FromString(ControlUtilities.GetSitefinityTextResource(Constants.DefaultFrontendPageTemplate));
            RootTemplate result = this.GetRootTemplate(defaultRootTemplate, context, theme);
            this.ProcessStringTemplate(result.Template, output, placeHolders, directives);
        }
 /// <summary>
 /// Appends the layout.
 /// </summary>
 /// <remarks>
 /// If the layout is not found error message will be rendered instead.
 /// </remarks>
 /// <param name="layoutTemplate">The layout template.</param>
 /// <param name="assemblyInfo">The assembly information.</param>
 /// <param name="parentPlaceHolder">The parent place holder.</param>
 /// <param name="placeHolders">The place holders.</param>
 /// <param name="layoutId">The layout identifier.</param>
 /// <param name="directives">The directives.</param>
 protected override void AppendLayout(string layoutTemplate, string assemblyInfo, PlaceHolderCursor parentPlaceHolder, CursorCollection placeHolders, string layoutId, DirectiveCollection directives)
 {
     try
     {
         base.AppendLayout(layoutTemplate, assemblyInfo, parentPlaceHolder, placeHolders, layoutId, directives);
     }
     catch (FileNotFoundException)
     {
         parentPlaceHolder.Output.Append(Res.Get<ErrorMessages>("CannotFindTemplate", layoutTemplate));
     }
 }
 /// <summary>
 /// Appends markup to the virtual page file depending on the current master page.
 /// </summary>
 /// <param name="virtualPath">The master page virtual path.</param>
 /// <param name="context">The context.</param>
 /// <param name="output">The output.</param>
 /// <param name="placeHolders">The place holders.</param>
 /// <param name="directives">The directives.</param>
 protected override void BuildWithMasterPage(string virtualPath, RequestContext context, StringBuilder output, CursorCollection placeHolders, DirectiveCollection directives)
 {
     if (LayoutMvcPageResolver.IsLayoutPath(virtualPath))
     {
         var httpContext = new HttpContextWrapper(new HttpContext(HttpContext.Current.Request, HttpContext.Current.Response));
         httpContext.Items[PackageManager.CurrentPackageKey] = context.HttpContext.Items[PackageManager.CurrentPackageKey];
         SystemManager.RunWithHttpContext(httpContext, () => base.BuildWithMasterPage(virtualPath, context, output, placeHolders, directives));
     }
     else
     {
         base.BuildWithMasterPage(virtualPath, context, output, placeHolders, directives);
     }
 }
        public void ObtainRootTemplateFromRegisteredWebFormsTemplateResolver_WhenBuildPageTemplateRecursiveMethodIsCalledForWebFormsPages()
        {
            PowerTools.Instance
                      .RootTemplates
                      .RegisterWebFormsTemplateResolver<TestRootTemplateResolver>();

            IPageTemplate pageTemplate = new PageTemplateMock();
            string theme = null;
            RequestContext context = new RequestContext();
            StringBuilder output = new StringBuilder();
            CursorCollection placeHolders = new CursorCollection();
            DirectiveCollection directives = new DirectiveCollection();
            List<IControlsContainer> controlContainers = new List<IControlsContainer>();

            var mvcPageResolver = new ExtendedWebFormsPageResolverWrapper();
            mvcPageResolver.InvokeBuildPageTemplateRecursive(pageTemplate, theme, context, output, placeHolders, directives, controlContainers);

            Assert.AreEqual("This is test root template", output.ToString());
        }
 public void InvokeBuildPageTemplateRecursive(IPageTemplate pageTemplate, string theme, RequestContext context, StringBuilder output, CursorCollection placeHolders, DirectiveCollection directives, List<IControlsContainer> controlConatiners)
 {
     this.BuildPageTemplateRecursive(pageTemplate, theme, context, output, placeHolders, directives, controlConatiners);
 }
 /// <summary>
 /// Appends the layout.
 /// </summary>
 /// <remarks>
 /// If the layout is not found error message will be rendered instead.
 /// </remarks>
 /// <param name="layoutTemplate">The layout template.</param>
 /// <param name="assemblyInfo">The assembly information.</param>
 /// <param name="parentPlaceHolder">The parent place holder.</param>
 /// <param name="placeHolders">The place holders.</param>
 /// <param name="layoutId">The layout identifier.</param>
 /// <param name="directives">The directives.</param>
 protected override void AppendLayout(string layoutTemplate, string assemblyInfo, PlaceHolderCursor parentPlaceHolder, CursorCollection placeHolders, string layoutId, DirectiveCollection directives)
 {
     try
     {
         base.AppendLayout(layoutTemplate, assemblyInfo, parentPlaceHolder, placeHolders, layoutId, directives);
     }
     catch (FileNotFoundException)
     {
         parentPlaceHolder.Output.Append(Res.Get <ErrorMessages>("CannotFindTemplate", layoutTemplate));
     }
 }
 /// <summary>
 /// Appends markup to the virtual page file depending on the current master page.
 /// </summary>
 /// <param name="virtualPath">The master page virtual path.</param>
 /// <param name="context">The context.</param>
 /// <param name="output">The output.</param>
 /// <param name="placeHolders">The place holders.</param>
 /// <param name="directives">The directives.</param>
 protected override void BuildWithMasterPage(string virtualPath, RequestContext context, StringBuilder output, CursorCollection placeHolders, DirectiveCollection directives)
 {
     if (LayoutMvcPageResolver.IsLayoutPath(virtualPath))
     {
         SystemManager.RunWithElevatedPrivilege((args) =>
         {
             HttpContext.Current.Items[PackageManager.CurrentPackageKey] = context.HttpContext.Items[PackageManager.CurrentPackageKey];
             base.BuildWithMasterPage(virtualPath, context, output, placeHolders, directives);
         });
     }
     else
     {
         base.BuildWithMasterPage(virtualPath, context, output, placeHolders, directives);
     }
 }
Beispiel #10
0
 /// <summary>
 /// Appends markup to the virtual page file depending on the current master page.
 /// </summary>
 /// <param name="virtualPath">The master page virtual path.</param>
 /// <param name="context">The context.</param>
 /// <param name="output">The output.</param>
 /// <param name="placeHolders">The place holders.</param>
 /// <param name="directives">The directives.</param>
 protected override void BuildWithMasterPage(string virtualPath, RequestContext context, StringBuilder output, CursorCollection placeHolders, DirectiveCollection directives)
 {
     if (LayoutMvcPageResolver.IsLayoutPath(virtualPath))
     {
         var httpContext = new HttpContextWrapper(new HttpContext(HttpContext.Current.Request, HttpContext.Current.Response));
         httpContext.Items[PackageManager.CurrentPackageKey] = context.HttpContext.Items[PackageManager.CurrentPackageKey];
         SystemManager.RunWithHttpContext(httpContext, () => base.BuildWithMasterPage(virtualPath, context, output, placeHolders, directives));
     }
     else
     {
         base.BuildWithMasterPage(virtualPath, context, output, placeHolders, directives);
     }
 }
        /// <summary>
        /// Loads the image's texture resource from the specified content manager.
        /// </summary>
        /// <param name="content">The content manager with which to load the image's texture resource.</param>
        public void Load(ContentManager content)
        {
            Contract.Require(content, nameof(content));

            if (!cursorCollectionID.IsValid || String.IsNullOrEmpty(cursorName))
                return;

            cursorCollection = content.Load<CursorCollection>(CursorCollectionID);
            cursor = cursorCollection[cursorName];
        }