Example #1
0
        private void BindData()
        {
            if (activity == null)               // new
            {
                ActivityMaster[] list = shemaMaster.GetAllowedActivities(ParentActivityName);
                if (list != null && list.Length > 0)
                {
                    foreach (ActivityMaster item in list)
                    {
                        ActivityTypeList.Items.Add(new ListItem(CHelper.GetResFileString(item.Description.Comment), item.Description.Name));
                    }

                    ActivityMaster currentActivityMaster = list[0];
                    CHelper.SafeSelect(ActivityTypeList, currentActivityMaster.Description.Name);
                    ControlName = currentActivityMaster.Description.UI.CreateControl;
                }
            }
            else             // edit
            {
                ActivityMaster currentActivityMaster = WorkflowActivityWrapper.GetActivityMaster(shemaMaster, activity, ActivityName);

                ActivityTypeList.Items.Add(new ListItem(CHelper.GetResFileString(currentActivityMaster.Description.Comment), currentActivityMaster.Description.Name));
                ActivityTypeList.Enabled = false;

                ControlName = currentActivityMaster.Description.UI.EditControl;
            }
        }
Example #2
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)
		{
			InitImages(this.CurrentContainer.Page);
			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 = this.ID + "_ddType";
			List<string> typeItems = AssignmentFactory.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 = this.CurrentContainer.AddText;
			lblType.Visible = (this.CurrentActivity is CompositeActivity);
			lblType.ID = this.ID + "_lblType";
			lblType.CssClass = "createAssignmentLink";
			if (!String.IsNullOrEmpty(this.CurrentContainer.NewActivityScript))
			{
				//string parentActivity = string.Empty;
				//if (this.CurrentActivity.Parent != null)
				//    parentActivity = this.CurrentActivity.Parent.Name;
				//else
				//    parentActivity = this.CurrentActivity.Name;

				string _newActivityScript = this.CurrentContainer.NewActivityScript.Replace("_parentName_", this.CurrentActivity.Name);
				lblType.Attributes.Add("onclick", _newActivityScript);
			}

			//extType = new HiderExtender();
			//extType.ID = this.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 = this.ID + "_btnCreate";
			btnCreate.Click += new EventHandler(btnCreate_Click);
			#endregion

			#region button Delete
			btnDelete = new ImageButton();
			//btnDelete.Text = "Delete";
			btnDelete.OnClientClick = String.Format("return confirm('{0}');", this.CurrentContainer.DeleteText);
			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.ImageUrl = _imageDownUrl;
			btnDown.Click += new ImageClickEventHandler(btnDown_Click);
			#endregion

			#region btnEdit
			btnEdit = new Button();
			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>{1}</span>", this.ResolveUrl(_imageEditUrl), this.CurrentContainer.EditText);
			if (!String.IsNullOrEmpty(this.CurrentContainer.EditActivityScript))
			{
				string _editActivityScript = this.CurrentContainer.EditActivityScript.Replace("_activityName_", this.CurrentActivity.Name);
				lblEditPrototype.Attributes.Add("onclick", _editActivityScript);
			}
			lblEditPrototype.Visible = (WorkflowActivityWrapper.GetActivityMaster(this.CurrentContainer.CurrentSchemaMaster, this.CurrentActivity, this.CurrentActivity.Name) != null);
			//if (this.CurrentContainer.CurrentSchemaMaster
//			lblEditPrototype.Attributes.Add("onclick", "");

			#endregion

			divContainer.ID = this.ID + "_divContainer";
			divContainer.Style.Add(HtmlTextWriterStyle.Display, "inline");
			Control c = AssignmentFactory.GetActivityPrimitive(this.CurrentActivity, this.CurrentContainer.CurrentSchemaMaster, this.CurrentContainer.Page);
			//extType.TestPerform(lblType.ClientID);
			#region Create inner control structure
			if (c != null)
			{
				divInnerContainer.Controls.Add(c);
				((MCDataBoundControl)c).DataItem = this.CurrentActivity;
				((MCDataBoundControl)c).DataBind();
			}

			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);

			return 1;
		}