@*   Xafari Framework version : 17.2.3011.1336   *@

@using DevExpress.ExpressApp.Model
@using DevExpress.ExpressApp.Utils
@using Xafari.Mvc.Layout

@model TabbedGroupContainer

@{
	var model = this.Model.Model;

	var id = DevExpress.ExpressApp.Web.SystemModule.WebIdHelper.GetCorrectedLayoutItemId(model, "", "_CardTable_" + this.Model.GetHashCode().ToString());
	var css = string.Empty;

	var layoutCSSInfo = this.Model.LayoutManager.LayoutCSSInfo;
	if (layoutCSSInfo != null)
	{
		DevExpress.ExpressApp.Web.Layout.LayoutItemCSSInfoBase cssInfo = layoutCSSInfo.GetCssInfo(model);
		if (cssInfo != null)
		{
			if (cssInfo.CardItem)
			{
				css = css + cssInfo.CardCssClassNameCore;
			}
			else
			{
				css = css + cssInfo.EditorContainerCssClassName;
			}
		}

	}
	else
	{
		css = "LayoutTabbedGroupContainer";
	}
}

<div id="@(id)" class="@(css)">
	@{
		var pageControlSettings = new PageControlSettings();
		pageControlSettings.Name = DevExpress.ExpressApp.Web.SystemModule.WebIdHelper.GetCorrectedLayoutItemId(model, "", "_pg_" + this.Model.GetHashCode().ToString());
		pageControlSettings.SaveStateToCookies = true;
		pageControlSettings.SaveStateToCookiesID = this.Model.GetCookiesIdFromCurrentTabbedGroup(model);
		pageControlSettings.Width = Unit.Percentage(100);
		pageControlSettings.Styles.Content.Paddings.Padding = Unit.Pixel(0);
		pageControlSettings.Styles.Content.CssClass = "TabControlContent";
		if (model is DevExpress.ExpressApp.Web.SystemModule.IModelViewLayoutElementWeb)
		{
			ContentStyle contentStyle = pageControlSettings.Styles.Content;
			contentStyle.CssClass = contentStyle.CssClass + " " + ((DevExpress.ExpressApp.Web.SystemModule.IModelViewLayoutElementWeb)model).CustomCSSClassName;
		}
		if (this.Model.LayoutManager.LayoutCSSInfo != null)
		{
			pageControlSettings.EnableTabScrolling = true;
		}

		//CreateTabPages
		foreach (LayoutItemContainerBase base2 in this.Model.Items.Values)
		{
			if (base2.Visibility)
			{
				IModelLayoutGroup modelLayoutGroup = (IModelLayoutGroup)base2.Model;
				MVCxTabPage element = pageControlSettings.TabPages.Add(modelLayoutGroup.Caption);
				element.Name = modelLayoutGroup.Id;
				var imageInfo = ImageLoader.Instance.GetImageInfo(modelLayoutGroup.ImageName);
				if (!imageInfo.IsEmpty)
				{
					//ASPxImageHelper.SetImageProperties(element.TabImage, imageInfo, -1, -1);
					element.TabImage.SpriteProperties.SetImageProperties(imageInfo);
					element.TabImage.AlternateText = modelLayoutGroup.Caption;
				}
				element.ToolTip = modelLayoutGroup.ToolTip ?? string.Empty;

				var base3 = base2;
				element.SetContent(() =>
				{
					var tabCss = "LayoutTabContainer";
					if (this.Model.IsNestedFrame((LayoutGroupContainer)base3))
					{
						tabCss = tabCss + " LayoutTabContainerWithNestedFrame";
					}

					ViewContext.Writer.Write("<div class=\"{0}\">", tabCss);

					this.ViewData[MvcLayoutManager.ContainerKeyForViewData] = base3;
					Html.Xafari().RenderRelativePartial("../_ProcessItem", this.Model.LayoutManager);

					ViewContext.Writer.Write("</div>");
				});
			}
		}
		//
		pageControlSettings.PreRender += (sender, args) =>
		{
			var pageControl = sender as MVCxPageControl;
			if (pageControl == null) return;

			if (!string.IsNullOrEmpty(this.Model.ActiveTabName))
			{
				TabPage page = pageControl.TabPages.FindByName(this.Model.ActiveTabName);
				if (page != null)
				{
					pageControl.ActiveTabPage = page;
				}
			}
		};
	}

	@Html.DevExpress().PageControl(pageControlSettings).GetHtml()
</div>
<div class="LayoutTabContainer"></div>