@*   Xafari Framework version : 17.2.3011.1336   *@

@using DevExpress.ExpressApp.Layout
@using Xafari.Mvc.Layout
@using Xafari.Mvc.MVCx.Helpers

@model LayoutGroupContainer

@{
    var controlPartialView = this.ViewData[LayoutGroupContainer.ControlPartialViewKey] as string;
    if (string.IsNullOrEmpty(controlPartialView)) { return; }
    
    DevExpress.ExpressApp.Web.Layout.LayoutCSSInfo cssInfo = this.Model.LayoutManager.LayoutCSSInfo;
    DevExpress.ExpressApp.Web.Layout.LayoutItemCSSInfoBase layoutCSSInfo = cssInfo.GetCssInfo(this.Model.Model);
    
    var roundPanelSettings = new RoundPanelSettings();
    roundPanelSettings.Name = DevExpress.ExpressApp.Web.SystemModule.WebIdHelper.GetCorrectedLayoutItemId(this.Model.Model, "", "_CardTable");
    if (layoutCSSInfo.ParentDirection == FlowDirection.Horizontal)
    {
        roundPanelSettings.ControlStyle.CssClass = layoutCSSInfo.EditorContainerCssClassName;
    }
    else
    {
        roundPanelSettings.ControlStyle.CssClass = layoutCSSInfo.CardCssClassNameCore;
    }
    //SetCustomCSSClass
    if (this.Model.Model is DevExpress.ExpressApp.Web.SystemModule.IModelViewLayoutElementWeb)
    {
        string customCSSClassName = ((DevExpress.ExpressApp.Web.SystemModule.IModelViewLayoutElementWeb)this.Model.Model).CustomCSSClassName;
        if (!string.IsNullOrEmpty(customCSSClassName))
        {
            roundPanelSettings.ControlStyle.CssClass = roundPanelSettings.ControlStyle.CssClass + " " + customCSSClassName;
        }
    }
    //
    if (this.Model.ShowCaption && (!this.Model.IsOnTabPage || (this.Model.ParentGroupDirection == FlowDirection.Vertical)))
    {
        roundPanelSettings.AllowCollapsingByHeaderClick = false;
        roundPanelSettings.ShowCollapseButton = true;
        roundPanelSettings.Styles.Header.CssClass = "GroupHeader Label";
        roundPanelSettings.Styles.Header.Width = Unit.Percentage(100.0);
        if (this.Model.HasHeaderImage)
        {
            roundPanelSettings.HeaderImage.AlternateText = this.Model.Caption;
            //ASPxImageHelper.SetImageProperties(panel.HeaderImage, container.HeaderImageInfo, -1, -1);
            roundPanelSettings.HeaderImage.SpriteProperties.SetImageProperties(this.Model.HeaderImageInfo);
        }
        if (MvcApplicationStyleManager.EnableGroupUpperCase)
        {
            roundPanelSettings.HeaderText = this.Model.Caption.ToUpper();
        }
        else
        {
            roundPanelSettings.HeaderText = this.Model.Caption;
        }
        if (this.Model.Model != null && !string.IsNullOrEmpty(this.Model.Model.ToolTip))
        {
            roundPanelSettings.Attributes.Add("title", this.Model.Model.ToolTip);
        }
    }
    else
    {
        roundPanelSettings.ShowHeader = false;

    }
    roundPanelSettings.SetContent(() =>
    {
        ViewContext.Writer.Write("<div class=\"{0}\">", layoutCSSInfo.LayoutGroupCSSInfo().CardGroupContentCssClass);

        Html.Xafari().RenderRelativePartial(controlPartialView);
        
        ViewContext.Writer.Write("</div>");
    });

    @Html.DevExpress().RoundPanel(roundPanelSettings).GetHtml()
}
