Beispiel #1
0
        /// <summary>
        /// Binds the control.
        /// </summary>
        /// <param name="dci">The dci.</param>
        /// <returns></returns>
        private string bindControl(DynamicControlInfo dci, string collapsed, int counter, string instanseUid, ref string sourceInfo)
        {
            StringBuilder sb = new StringBuilder();
            Control ctrl;

            if (dci != null)
                ctrl = DynamicControlFactory.Create(this.Page, dci.Uid);
            else
                ctrl = this.Page.LoadControl("~/" + dci.Uid.Replace("..\\", string.Empty).Replace("\\", "/"));

            //esli kontrol udalili, a v preferensah on ostalsa to nichego ne delaem
            if (ctrl == null)
                return string.Empty;

            HtmlGenericControl divContainer = new HtmlGenericControl("div");
            HtmlGenericControl divHeader = new HtmlGenericControl("div");

            bool isAdmin = IbnControlPlaceManager.GetCurrent(this.Page).IsAdmin;
            bool checkPersonalization = Mediachase.Ibn.Business.Customization.ProfileManager.CheckPersonalization();

            #region Image ExpandCollapse
            ImageButton imgOpen = new ImageButton();
            imgOpen.ID = String.Format("imgOpen_{0}", instanseUid/*counter*/);
            if (!Convert.ToBoolean(collapsed, CultureInfo.InvariantCulture))
            {
                imgOpen.ImageUrl = this.ResolveUrl("~/Images/IbnFramework/btn_up.gif");
                imgOpen.Attributes.Add("changeUrl", this.ResolveUrl("~/Images/IbnFramework/btn_down.gif"));
            }
            else
            {
                imgOpen.ImageUrl = this.ResolveUrl("~/Images/IbnFramework/btn_down.gif");
                imgOpen.Attributes.Add("changeUrl", this.ResolveUrl("~/Images/IbnFramework/btn_up.gif"));
            }
            imgOpen.Attributes.Add("class", "IbnHeaderWidgetButton");

            if (!(isAdmin || checkPersonalization))
            {
                imgOpen.Style.Add("right", "5px");
            }
            else
            {
                imgOpen.Style.Add("right", "25px");
            }
            imgOpen.OnClientClick = "return false;";
            imgOpen.Visible = true;// (isAdmin || checkPersonalization);
            #endregion

            #region Image Close
            ImageButton imgClose = new ImageButton();
            imgClose.ID = String.Format("imgClose_{0}", instanseUid/*counter*/);
            imgClose.ImageUrl = this.ResolveUrl("~/Images/IbnFramework/btn_close.gif");
            imgClose.Visible = (isAdmin || checkPersonalization);
            imgClose.Attributes.Add("class", "IbnHeaderWidgetButton");
            imgClose.Style.Add("right", "5px");
            imgClose.OnClientClick = "return false;";
            #endregion

            #region Image PropertyPage
            ImageButton imgProperty = new ImageButton();
            imgProperty.ID = String.Format("imgProperty_{0}", instanseUid/*counter*/);
            imgProperty.ImageUrl = this.ResolveUrl("~/Images/IbnFramework/btn_prop.gif");
            imgProperty.Attributes.Add("class", "IbnHeaderWidgetButton");
            imgProperty.Style.Add("right", "45px");
            imgProperty.OnClientClick = "return false;";
            imgProperty.Visible = (isAdmin || checkPersonalization);
            #endregion

            #region Label Title
            Label lblTitle = new Label();
            lblTitle.CssClass = "x-panel-header IbnHeaderWidgetButton";
            lblTitle.Style.Add("left", "2px");
            lblTitle.Style.Add("top", "1px");
            lblTitle.Style.Add("right", "75px");
            lblTitle.Style.Add(HtmlTextWriterStyle.BorderWidth, "0px");
            #endregion

            List<WsButton> buttonList = new List<WsButton>();

            if ((isAdmin || checkPersonalization))
            {
                divHeader.Attributes.Add("class", "IbnWidgetHeader");
            }
            else
            {
                divHeader.Attributes.Add("class", "IbnWidgetHeaderNoCursor");
            }

            divHeader.Attributes.Add("dragObj", "0");

            ctrl.ID = String.Format("wrapControl{0}_{1}", dci.Uid.Replace("-", ""), instanseUid);
            IbnWidgetContainer c = new IbnWidgetContainer(ctrl, Convert.ToBoolean(collapsed, CultureInfo.InvariantCulture));
            c.ID = String.Format("id{0}{1}", dci.Uid.Replace("-", ""), instanseUid/*counter*/);

            divContainer.Controls.Add(divHeader);
            divContainer.Controls.Add(c);
            //this.Controls.Add(divHeader);
            this.Controls.Add(divContainer);

            c.DataBind();

            sourceInfo += String.Format("{0}^{1}^{2}:", dci.Uid, collapsed, instanseUid); // _uid + ":";

            if (dci != null)
            {
                divHeader.Controls.Add(imgClose);
                divHeader.Controls.Add(imgOpen);
                divHeader.Controls.Add(lblTitle);
                buttonList.Add(new WsButton(imgClose.ClientID, "close", false));
                buttonList.Add(new WsButton(imgOpen.ClientID, "expand", true));
                if (ControlProperties.Provider.GetValue(ctrl.ID, ControlProperties._titleKey) != null)
                {
                    lblTitle.Text = CHelper.GetResFileString(ControlProperties.Provider.GetValue(ctrl.ID, ControlProperties._titleKey).ToString());
                }
                else
                {
                    lblTitle.Text = CHelper.GetResFileString(dci.Title);
                }

                if (collapsed == "true" && ControlProperties.Provider.GetValue(ctrl.ID, ControlProperties._countKey) != null)
                {
                    lblTitle.Text += String.Format(" ({0})", ControlProperties.Provider.GetValue(ctrl.ID, ControlProperties._countKey).ToString());
                }

                if (!string.IsNullOrEmpty(dci.PropertyPagePath) || !string.IsNullOrEmpty(dci.PropertyPageType))
                {
                    divHeader.Controls.Add(imgProperty);
                    buttonList.Add(new WsButton(imgProperty.ClientID, "property", false));
                    sb.AppendFormat("{{ title: '{2}', tools: layoutExtender_tools2, contentEl: '{0}', id:'{4}_{1}', collapsed:{3}, buttons:{5} }},", c.ClientID, instanseUid, CHelper.GetResFileString(dci.Title), collapsed, dci.Uid, UtilHelper.JsonSerialize<List<WsButton>>(buttonList));
                }
                else
                {
                    sb.AppendFormat("{{ title: '{2}', tools: layoutExtender_tools, contentEl: '{0}', id:'{4}_{1}', collapsed:{3}, buttons:{5} }},", c.ClientID, instanseUid, CHelper.GetResFileString(dci.Title), collapsed, dci.Uid, UtilHelper.JsonSerialize<List<WsButton>>(buttonList));
                    //if (Convert.ToBoolean(collapsed, CultureInfo.InvariantCulture))
                    //    c.Style.Add(HtmlTextWriterStyle.Display, "none");
                }
            }
            else
            {
                sb.AppendFormat("{{ title: '', tools: layoutExtender_tools, contentEl: '{0}', id:'{3}_{1}', collapsed:{2} }},", c.ClientID, instanseUid/*dci.Uid.Replace("..\\", string.Empty).Replace("\\", "/")*/, collapsed, dci.Uid.Replace("..\\", string.Empty).Replace("\\", "/"));
            }

            return sb.ToString();
        }
Beispiel #2
0
        /// <summary>
        /// Binds the control.
        /// </summary>
        /// <param name="dci">The dci.</param>
        /// <returns></returns>
        private string bindControl(DynamicControlInfo dci, string collapsed, int counter, string instanseUid, ref string sourceInfo)
        {
            StringBuilder sb = new StringBuilder();
            Control       ctrl;

            if (dci != null)
            {
                ctrl = DynamicControlFactory.Create(this.Page, dci.Uid);
            }
            else
            {
                ctrl = this.Page.LoadControl("~/" + dci.Uid.Replace("..\\", string.Empty).Replace("\\", "/"));
            }

            //esli kontrol udalili, a v preferensah on ostalsa to nichego ne delaem
            if (ctrl == null)
            {
                return(string.Empty);
            }

            HtmlGenericControl divContainer = new HtmlGenericControl("div");
            HtmlGenericControl divHeader    = new HtmlGenericControl("div");

            bool isAdmin = IbnControlPlaceManager.GetCurrent(this.Page).IsAdmin;
            bool checkPersonalization = Mediachase.Ibn.Business.Customization.ProfileManager.CheckPersonalization();

            #region Image ExpandCollapse
            ImageButton imgOpen = new ImageButton();
            imgOpen.ID = String.Format("imgOpen_{0}", instanseUid /*counter*/);
            if (!Convert.ToBoolean(collapsed, CultureInfo.InvariantCulture))
            {
                imgOpen.ImageUrl = this.ResolveUrl("~/Images/IbnFramework/btn_up.gif");
                imgOpen.Attributes.Add("changeUrl", this.ResolveUrl("~/Images/IbnFramework/btn_down.gif"));
            }
            else
            {
                imgOpen.ImageUrl = this.ResolveUrl("~/Images/IbnFramework/btn_down.gif");
                imgOpen.Attributes.Add("changeUrl", this.ResolveUrl("~/Images/IbnFramework/btn_up.gif"));
            }
            imgOpen.Attributes.Add("class", "IbnHeaderWidgetButton");

            if (!(isAdmin || checkPersonalization))
            {
                imgOpen.Style.Add("right", "5px");
            }
            else
            {
                imgOpen.Style.Add("right", "25px");
            }
            imgOpen.OnClientClick = "return false;";
            imgOpen.Visible       = true;      // (isAdmin || checkPersonalization);
            #endregion

            #region Image Close
            ImageButton imgClose = new ImageButton();
            imgClose.ID       = String.Format("imgClose_{0}", instanseUid /*counter*/);
            imgClose.ImageUrl = this.ResolveUrl("~/Images/IbnFramework/btn_close.gif");
            imgClose.Visible  = (isAdmin || checkPersonalization);
            imgClose.Attributes.Add("class", "IbnHeaderWidgetButton");
            imgClose.Style.Add("right", "5px");
            imgClose.OnClientClick = "return false;";
            #endregion

            #region Image PropertyPage
            ImageButton imgProperty = new ImageButton();
            imgProperty.ID       = String.Format("imgProperty_{0}", instanseUid /*counter*/);
            imgProperty.ImageUrl = this.ResolveUrl("~/Images/IbnFramework/btn_prop.gif");
            imgProperty.Attributes.Add("class", "IbnHeaderWidgetButton");
            imgProperty.Style.Add("right", "45px");
            imgProperty.OnClientClick = "return false;";
            imgProperty.Visible       = (isAdmin || checkPersonalization);
            #endregion

            #region Label Title
            Label lblTitle = new Label();
            lblTitle.CssClass = "x-panel-header IbnHeaderWidgetButton";
            lblTitle.Style.Add("left", "2px");
            lblTitle.Style.Add("top", "1px");
            lblTitle.Style.Add("right", "75px");
            lblTitle.Style.Add(HtmlTextWriterStyle.BorderWidth, "0px");
            #endregion

            List <WsButton> buttonList = new List <WsButton>();

            if ((isAdmin || checkPersonalization))
            {
                divHeader.Attributes.Add("class", "IbnWidgetHeader");
            }
            else
            {
                divHeader.Attributes.Add("class", "IbnWidgetHeaderNoCursor");
            }

            divHeader.Attributes.Add("dragObj", "0");

            ctrl.ID = String.Format("wrapControl{0}_{1}", dci.Uid.Replace("-", ""), instanseUid);
            IbnWidgetContainer c = new IbnWidgetContainer(ctrl, Convert.ToBoolean(collapsed, CultureInfo.InvariantCulture));
            c.ID = String.Format("id{0}{1}", dci.Uid.Replace("-", ""), instanseUid /*counter*/);

            divContainer.Controls.Add(divHeader);
            divContainer.Controls.Add(c);
            //this.Controls.Add(divHeader);
            this.Controls.Add(divContainer);

            c.DataBind();

            sourceInfo += String.Format("{0}^{1}^{2}:", dci.Uid, collapsed, instanseUid);             // _uid + ":";

            if (dci != null)
            {
                divHeader.Controls.Add(imgClose);
                divHeader.Controls.Add(imgOpen);
                divHeader.Controls.Add(lblTitle);
                buttonList.Add(new WsButton(imgClose.ClientID, "close", false));
                buttonList.Add(new WsButton(imgOpen.ClientID, "expand", true));
                if (ControlProperties.Provider.GetValue(ctrl.ID, ControlProperties._titleKey) != null)
                {
                    lblTitle.Text = CHelper.GetResFileString(ControlProperties.Provider.GetValue(ctrl.ID, ControlProperties._titleKey).ToString());
                }
                else
                {
                    lblTitle.Text = CHelper.GetResFileString(dci.Title);
                }

                if (collapsed == "true" && ControlProperties.Provider.GetValue(ctrl.ID, ControlProperties._countKey) != null)
                {
                    lblTitle.Text += String.Format(" ({0})", ControlProperties.Provider.GetValue(ctrl.ID, ControlProperties._countKey).ToString());
                }

                if (!string.IsNullOrEmpty(dci.PropertyPagePath) || !string.IsNullOrEmpty(dci.PropertyPageType))
                {
                    divHeader.Controls.Add(imgProperty);
                    buttonList.Add(new WsButton(imgProperty.ClientID, "property", false));
                    sb.AppendFormat("{{ title: '{2}', tools: layoutExtender_tools2, contentEl: '{0}', id:'{4}_{1}', collapsed:{3}, buttons:{5} }},", c.ClientID, instanseUid, CHelper.GetResFileString(dci.Title), collapsed, dci.Uid, UtilHelper.JsonSerialize <List <WsButton> >(buttonList));
                }
                else
                {
                    sb.AppendFormat("{{ title: '{2}', tools: layoutExtender_tools, contentEl: '{0}', id:'{4}_{1}', collapsed:{3}, buttons:{5} }},", c.ClientID, instanseUid, CHelper.GetResFileString(dci.Title), collapsed, dci.Uid, UtilHelper.JsonSerialize <List <WsButton> >(buttonList));
                    //if (Convert.ToBoolean(collapsed, CultureInfo.InvariantCulture))
                    //    c.Style.Add(HtmlTextWriterStyle.Display, "none");
                }
            }
            else
            {
                sb.AppendFormat("{{ title: '', tools: layoutExtender_tools, contentEl: '{0}', id:'{3}_{1}', collapsed:{2} }},", c.ClientID, instanseUid /*dci.Uid.Replace("..\\", string.Empty).Replace("\\", "/")*/, collapsed, dci.Uid.Replace("..\\", string.Empty).Replace("\\", "/"));
            }

            return(sb.ToString());
        }