Exemple #1
0
        /// <summary>
        /// Creates the specified page.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="controlUid">The control uid.</param>
        /// <param name="instanseUid">The instanse uid.</param>
        /// <returns></returns>
        public static Control Create(TemplateControl page, string controlUid, string instanseUid)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }

            if (controlUid == null)
            {
                throw new ArgumentNullException("controlUid");
            }

            Initialize();
            Control retVal = null;

            // Load Control Info
            DynamicControlInfo info = GetControlInfo(controlUid);

            if (info == null)
            {
                return(null);
            }
            //throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid control Uid '{0}'", controlUid), "controlUid");

            // Try Load Control
            if (!string.IsNullOrEmpty(info.Path))
            {
                retVal = page.LoadControl(CreateControlVirtualPath(info.Path));
            }
            else if (!string.IsNullOrEmpty(info.Type))
            {
                retVal = (Control)AssemblyUtil.LoadObject(info.Type);
            }

            // Try Load Adapter
            if (retVal != null && (!string.IsNullOrEmpty(info.AdapterPath) || !string.IsNullOrEmpty(info.AdapterType)))
            {
                Control adapter = null;

                if (!string.IsNullOrEmpty(info.Path))
                {
                    adapter = page.LoadControl(CreateControlVirtualPath(info.AdapterPath));
                }
                else if (!string.IsNullOrEmpty(info.Type))
                {
                    adapter = (Control)AssemblyUtil.LoadObject(info.AdapterType);
                }

                if (adapter != null)
                {
                    // Add Control to adapter
                    adapter.Controls.Add(retVal);

                    // Return adapter
                    retVal = adapter;
                }
            }

            return(retVal);
        }
Exemple #2
0
        /// <summary>
        /// Creates the property page.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <param name="controlUid">The control uid.</param>
        /// <returns></returns>
        public static Control CreatePropertyPage(TemplateControl page, string controlUid)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }

            if (controlUid == null)
            {
                throw new ArgumentNullException("controlUid");
            }

            Initialize();
            Control retVal = null;

            // Load Control Info
            DynamicControlInfo info = GetControlInfo(controlUid.Split('_')[0]);

            if (info == null)
            {
                return(null);
            }
            //    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid control Uid '{0}'", controlUid), "controlUid");

            // Try Load Control
            if (!string.IsNullOrEmpty(info.PropertyPagePath))
            {
                retVal = page.LoadControl(CreateControlVirtualPath(info.PropertyPagePath));
            }
            else if (!string.IsNullOrEmpty(info.PropertyPageType))
            {
                retVal = (Control)AssemblyUtil.LoadObject(info.PropertyPageType);
            }

            //TODO: Load default PP control
            //if (retVal == null)
            //    retVal = page.LoadControl();

            if (retVal == null)
            {
                throw new InvalidOperationException(String.Format("Cant load PropertyPageControl for control: {0}", controlUid));
            }

            return(retVal);
        }
        /// <summary>
        /// Loads all controls from given directory and its subdirectories.
        /// </summary>
        /// <returns></returns>
        public static DynamicControlInfo[] Load()
        {
            List <DynamicControlInfo> list = new List <DynamicControlInfo>();

            //string structureVirtualPath
            //string structurePath = HostingEnvironment.MapPath(structureVirtualPath);
            FileDescriptor[] files = FileResolver.GetFiles(ControlsDir + Path.DirectorySeparatorChar + "Configs", "*.xml");
            foreach (FileDescriptor file in files)
            {
                string controlDir = Path.GetDirectoryName(file.FilePath);

                if (!string.IsNullOrEmpty(controlDir))
                {
                    string configsDir           = Path.DirectorySeparatorChar + ConfigDir;
                    string tempControlDirString = controlDir.EndsWith(Convert.ToString(Path.DirectorySeparatorChar)) ? controlDir.Substring(0, controlDir.Length - 1) : controlDir;
                    if (controlDir.EndsWith(configsDir, StringComparison.OrdinalIgnoreCase))
                    {
                        controlDir = controlDir.Substring(0, controlDir.LastIndexOf(configsDir));
                    }
                }

                DynamicControlInfo dci = McXmlSerializer.GetObjectFromFile <DynamicControlInfo>(file.FilePath);

                if (string.IsNullOrEmpty(dci.Uid))
                {
                    dci.Uid = Path.GetFileNameWithoutExtension(file.FilePath);
                }
                dci.AdapterPath      = MakeVirtualPath(controlDir, dci.AdapterPath);
                dci.IconPath         = dci.IconPath;
                dci.Path             = dci.Path;             //MakeVirtualPath(structurePath, structureVirtualPath, controlDir, dci.Path);
                dci.PropertyPagePath = dci.PropertyPagePath; //MakeVirtualPath(structurePath, structureVirtualPath, controlDir, dci.PropertyPagePath);
                dci.LargeThumbnail   = dci.LargeThumbnail;
                dci.SmallThumbnail   = dci.SmallThumbnail;

                list.Add(dci);
            }

            return(list.ToArray());
        }
Exemple #4
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();
        }