Esempio n. 1
0
        /// <summary>
        /// Adds icons to the configuration area of a block instance.  Can be overridden to
        /// add additionsl icons
        /// </summary>
        /// <param name="canConfig"></param>
        /// <param name="canEdit"></param>
        /// <returns></returns>
        public virtual List <Control> GetConfigurationControls(bool canConfig, bool canEdit)
        {
            List <Control> configControls = new List <Control>();

            if (canConfig || canEdit)
            {
                // Attributes
                CompiledTemplateBuilder upContent = new CompiledTemplateBuilder(
                    delegate(Control content)
                {
                    Button trigger       = new Button();
                    trigger.ClientIDMode = System.Web.UI.ClientIDMode.Static;
                    trigger.ID           = string.Format("blck-cnfg-trggr-{0}", BlockInstance.Id.ToString());
                    trigger.Click       += trigger_Click;
                    content.Controls.Add(trigger);

                    HiddenField triggerData  = new HiddenField();
                    triggerData.ClientIDMode = System.Web.UI.ClientIDMode.Static;
                    triggerData.ID           = string.Format("blck-cnfg-trggr-data-{0}", BlockInstance.Id.ToString());
                    content.Controls.Add(triggerData);
                }
                    );

                UpdatePanel upTrigger = new UpdatePanel();
                upTrigger.ContentTemplate = upContent;
                configControls.Add(upTrigger);
                upTrigger.Attributes.Add("style", "display:none");

                // Icon to display block properties
                HtmlGenericControl aAttributes = new HtmlGenericControl("a");
                aAttributes.Attributes.Add("class", "properties icon-button show-modal-iframe");
                aAttributes.Attributes.Add("height", "500px");
                aAttributes.Attributes.Add("href", ResolveUrl(string.Format("~/BlockProperties/{0}?t=Block Properties", BlockInstance.Id)));
                //aAttributes.Attributes.Add( "instance-id", BlockInstance.Id.ToString() );
                configControls.Add(aAttributes);
            }

            if (canConfig)
            {
                // Security
                HtmlGenericControl aSecureBlock = new HtmlGenericControl("a");
                aSecureBlock.Attributes.Add("class", "security icon-button show-modal-iframe");
                aSecureBlock.Attributes.Add("height", "500px");
                aSecureBlock.Attributes.Add("href", ResolveUrl(string.Format("~/Secure/{0}/{1}?t=Block Security",
                                                                             Security.Authorization.EncodeEntityTypeName(BlockInstance.GetType()), BlockInstance.Id)));
                configControls.Add(aSecureBlock);

                // Move
                HtmlGenericControl aMoveBlock = new HtmlGenericControl("a");
                aMoveBlock.Attributes.Add("class", "block-move icon-button blockinstance-move");
                aMoveBlock.Attributes.Add("href", BlockInstance.Id.ToString());
                aMoveBlock.Attributes.Add("zone", BlockInstance.Zone);
                aMoveBlock.Attributes.Add("zoneloc", BlockInstance.BlockInstanceLocation.ToString());
                aMoveBlock.Attributes.Add("title", "Move");
                configControls.Add(aMoveBlock);

                // Delete
                HtmlGenericControl aDeleteBlock = new HtmlGenericControl("a");
                aDeleteBlock.Attributes.Add("class", "delete icon-button blockinstance-delete");
                aDeleteBlock.Attributes.Add("href", BlockInstance.Id.ToString());
                aDeleteBlock.Attributes.Add("title", "Delete");
                configControls.Add(aDeleteBlock);
            }

            return(configControls);
        }