예제 #1
0
        /// <summary>
        /// When overridden in an abstract class, creates the control hierarchy that is used to render the composite data-bound control based on the values from the specified data source.
        /// </summary>
        /// <param name="dataSource">An <see cref="T:System.Collections.IEnumerable"/> that contains the values to bind to the control.</param>
        /// <param name="dataBinding">true to indicate that the <see cref="M:System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls(System.Collections.IEnumerable,System.Boolean)"/> is called during data binding; otherwise, false.</param>
        /// <returns>
        /// The number of items created by the <see cref="M:System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls(System.Collections.IEnumerable,System.Boolean)"/>.
        /// </returns>
        protected override int CreateChildControls(System.Collections.IEnumerable dataSource, bool dataBinding)
        {
            divContainer      = new Panel();
            divInnerContainer = new Panel();
            divIcons          = new Panel();
            divSubIcons       = new Panel();

            divIcons.CssClass          = "iconBlock";
            divSubIcons.CssClass       = "subiconBlock";
            divContainer.CssClass      = "itemcontainerBlock";
            divInnerContainer.CssClass = "innerContainerBlock";

            #region Create and init controls
            #region ddType/lblType/extType
            ddType    = new DropDownList();
            ddType.ID = "_ddType";
            List <string> typeItems = ActivityFactory.GetAvailableActivities();
            ddType.Items.Add(new ListItem("New activity", "0"));

            foreach (String s in typeItems)
            {
                ddType.Items.Add(new ListItem(s, s));
            }

            ddType.AutoPostBack          = true;
            ddType.SelectedIndexChanged += new EventHandler(ddType_SelectedIndexChanged);
            ddType.Style.Add(HtmlTextWriterStyle.Display, "none");

            lblType          = new Label();
            lblType.Text     = "New activity";
            lblType.ID       = "_lblType";
            lblType.CssClass = "createAssignmentLink";

            extType    = new HiderExtender();
            extType.ID = "_extType";

            extType.TargetControlID = ddType.ID;
            #endregion

            #region ddPrototype
            ddPrototype = new DropDownList();
            ddPrototype.Items.AddRange(this.Prototypes.ToArray());
            ddPrototype.DataBind();
            #endregion

            #region button Create
            btnCreate        = new Button();
            btnCreate.Text   = "Add";
            btnCreate.ID     = "_btnCreate";
            btnCreate.Click += new EventHandler(btnCreate_Click);
            #endregion

            #region button Delete
            btnDelete = new ImageButton();
            //btnDelete.Text = "Delete";
            btnDelete.OnClientClick = "return confirm('Delete?');";
            btnDelete.ImageUrl      = _imageDenyUrl;
            btnDelete.Click        += new ImageClickEventHandler(btnDelete_Click);
            #endregion

            #region btnUp
            btnUp = new ImageButton();
            //btnUp.Text = "Up";
            btnUp.ImageUrl = _imageUpUrl;
            btnUp.Click   += new ImageClickEventHandler(btnUp_Click);
            #endregion

            #region btnDown
            btnDown = new ImageButton();
            //btnDown.Text = "Down";
            btnDown.ID       = "btnDown";
            btnDown.ImageUrl = _imageDownUrl;
            #endregion

            #region btnEdit
            btnEdit        = new Button();
            btnEdit.ID     = "btnEdit";
            btnEdit.Text   = "Edit prototype";
            btnEdit.Click += new EventHandler(btnEdit_Click);
            #endregion

            lblEditPrototype = new HtmlGenericControl("DIV");
            lblEditPrototype.Attributes.Add("class", "editPrototypeLabel");
            lblEditPrototype.InnerHtml = string.Format("<img src='{0}' border='0'/><span>Edit prototype</span>", this.ResolveUrl(_imageEditUrl));
//			lblEditPrototype.Attributes.Add("onclick", "");

            #endregion

            divContainer.ID = this.ID + "_divContainer";
            divContainer.Style.Add(HtmlTextWriterStyle.Display, "inline");
            Control c = ActivityFactory.GetActivityPrimitive(this.CurrentActivity, this.CurrentContainer.Page);
            ((IWorkflowPrimitive)c).DataItem = this.CurrentActivity;
            //extType.TestPerform(lblType.ClientID);
            #region Create inner control structure
            divInnerContainer.Controls.Add(c);

            divIcons.Controls.Add(btnDelete);
            divIcons.Controls.Add(btnUp);
            divIcons.Controls.Add(btnDown);

            divIcons.Controls.Add(ddType);
            divIcons.Controls.Add(lblType);
            divIcons.Controls.Add(extType);

            //divIcons.Controls.Add(lblEditPrototype);

            btnCreate.Visible = false;
            divIcons.Controls.Add(btnCreate);

            divSubIcons.Controls.Add(ddPrototype);
            divSubIcons.Controls.Add(btnEdit);
            divIcons.Controls.Add(lblEditPrototype);

            divContainer.Controls.Add(divIcons);
            divContainer.Controls.Add(divSubIcons);
            divContainer.Controls.Add(divInnerContainer);
            #endregion

            this.Controls.Add(divContainer);
            //this.Controls.Add(extType);
            //lblEditPrototype.Attributes.Add("onclick", this.CurrentContainer.Page.ClientScript.GetPostBackEventReference(btnEdit, string.Empty));
            return(1);
        }