Exemplo n.º 1
0
        private void GenerateStructure()
        {
            foreach (State toState in sm.States)
            {
                string stateName = toState.Name;

                if (stateName == FromState)
                {
                    continue;
                }

                MetaObject mo = StateMachineManager.GetState(ClassName, stateName);

                HtmlTableRow tr = new HtmlTableRow();
                tr.Style.Add(HtmlTextWriterStyle.Height, "25px");

                HtmlTableCell td1 = new HtmlTableCell();
                HtmlTableCell td2 = new HtmlTableCell();
                td1.NoWrap = true;

                CheckBox cb = new CheckBox();
                cb.ID = String.Format("chk{0}", stateName);

                TextBox txt = new TextBox();
                txt.ID    = String.Format("txt{0}", stateName);
                txt.Width = Unit.Percentage(100);


                if (!IsPostBack)
                {
                    cb.Text = CHelper.GetResFileString(mo.Properties["FriendlyName"].Value.ToString());

                    StateTransition st = sm.FindTransition(FromState, stateName);
                    if (st != null)
                    {
                        cb.Checked = true;
                        txt.Text   = st.Name;
                    }
                    else
                    {
                        txt.Text = mo.Properties["FriendlyName"].Value.ToString();
                        txt.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                }

                td1.Controls.Add(cb);
                td2.Controls.Add(txt);
                tr.Cells.Add(td1);
                tr.Cells.Add(td2);
                tblMain.Rows.Add(tr);

                cb.Attributes.Add("onclick", String.Format("ShowHide('{0}', '{1}')", cb.ClientID, txt.ClientID));
            }
        }
        private void GenerateStructure()
        {
            MetaObject mo        = StateMachineManager.GetState(ClassName, StateId);
            string     fromState = mo.Properties["Name"].Value.ToString();

            foreach (State state in sm.States)
            {
                StateTransition st = sm.FindTransition(fromState, state.Name);
                if (st != null)
                {
                    HtmlTableRow  tr   = new HtmlTableRow();
                    HtmlTableCell td   = new HtmlTableCell();
                    CheckControl  ctrl = (CheckControl)LoadControl("~/Apps/Common/Design/CheckControl.ascx");
                    ctrl.Text = CHelper.GetResFileString(st.Name);

                    td.Controls.Add(ctrl);
                    tr.Cells.Add(td);
                    tblRights.Rows.Add(tr);

                    checkControls.Add(ctrl);
                    states.Add(state.Name);
                }
            }
        }
        private void GenerateStructure()
        {
            if (sm == null)
            {
                sm = new Mediachase.Ibn.Data.Services.StateMachine(mc, int.Parse(ddlStateMachine.SelectedValue));
            }

            if (grdMain.Columns.Count > 0)
            {
                grdMain.Columns.Clear();
            }

            BoundField field = new BoundField();

            field.DataField  = principalColumn;
            field.HeaderText = GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Principal").ToString();
            field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;
            field.ItemStyle.HorizontalAlign   = HorizontalAlign.Left;
            field.HeaderStyle.CssClass        = "ibn-vh";
            field.HtmlEncode = false;
            grdMain.Columns.Add(field);

            int        transitionCounter = 0;
            MetaObject mo        = StateMachineManager.GetState(mc, int.Parse(ddlState.SelectedValue));
            string     fromState = mo.Properties["Name"].Value.ToString();

            foreach (State state in sm.States)
            {
                StateTransition st = sm.FindTransition(fromState, state.Name);
                if (st != null)
                {
                    transitionCounter++;
                    field                      = new BoundField();
                    field.DataField            = state.Name;
                    field.HeaderText           = CHelper.GetResFileString(st.Name);
                    field.HeaderStyle.CssClass = "thCenter";
                    field.HtmlEncode           = false;
                    grdMain.Columns.Add(field);
                }
            }

            grdMain.Visible = true;
            if (transitionCounter == 0)
            {
                grdMain.Visible = false;
                return;
            }

            for (int i = 1; i <= transitionCounter; i++)
            {
                grdMain.Columns[i].HeaderStyle.Width = Unit.Percentage(percentsForTransition / transitionCounter);
            }

            // Edit
            field                   = new BoundField();
            field.DataField         = editColumn;
            field.HeaderText        = String.Empty;
            field.HtmlEncode        = false;
            field.HeaderStyle.Width = Unit.Pixel(25);
            field.ItemStyle.Width   = Unit.Pixel(25);
            grdMain.Columns.Add(field);

            BindGrid();
        }