Example #1
0
 /// <summary>
 /// SetDisplayText
 /// </summary>
 /// <param name="itemName"></param>
 /// <param name="value"></param>
 public void SetDisplayText(string itemName, string value)
 {
     if (!string.IsNullOrEmpty(itemName))
     {
         EntityFormCtrl eaf = FormCtrls.FirstOrDefault(t => t.ItemName.Trim() == itemName.Trim());
         if (eaf != null)
         {
             Control ctrl = FormTool.CreateControl(eaf, FormCtrls) as Control;
             if (ctrl != null)
             {
                 ctrl.Text = value;
             }
         }
     }
 }
Example #2
0
        /// <summary>
        /// Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ShowPanelEF_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }
            try
            {
                this.SuspendLayout();
                if (!string.IsNullOrEmpty(this.FormLayout))
                {
                    FormCtrls = FormTool.Entities(this.FormLayout);
                }
                else
                {
                    if (Formid > 0)
                    {
                        EntityFormDesign vo    = null;
                        ProxyFormDesign  proxy = new ProxyFormDesign();
                        proxy.Service.GetForm(Formid, out vo);
                        FormCtrls = FormTool.Entities(vo.Layout);
                    }
                }

                #region 用下面代码设定:宽*高
                //if (!string.IsNullOrEmpty(eafMain.PanelSize))
                //{
                //    string[] size = eafMain.PanelSize.Split('|');
                //    if (size.Length == 2)
                //    {
                //        int height = HopeBridge.FrameWork.Utils.Function.Int(size[0]);
                //        if (height > 0)
                //        {
                //            this.Height = height + 8;
                //        }
                //        int width = HopeBridge.FrameWork.Utils.Function.Int(size[1]);
                //        if (width > 0)
                //        {
                //            this.Width = width + 8;
                //        }
                //    }
                //}
                #endregion

                #region Controls
                int intMaxTop  = 0;
                int intMaxLeft = 0;
                if (FormCtrls != null)
                {
                    int                    diffTableHeight = 0;
                    object                 obj             = null;
                    Control                ctrl            = null;
                    EntityCtrlPoint        point           = null;
                    IRuntimeDesignControl  ICtrl           = null;
                    List <EntityCtrlPoint> lstCtrlPoint    = new List <EntityCtrlPoint>();
                    FormTool.SetParentObject(this, ControlContainer);
                    FormCtrls.Sort();
                    foreach (EntityFormCtrl node in FormCtrls)
                    {
                        if (!string.IsNullOrEmpty(node.Parent))
                        {
                            continue;
                        }
                        obj = FormTool.CreateControl(node, FormCtrls);
                        if (obj == null)
                        {
                            continue;
                        }
                        if (obj is Control)
                        {
                            ctrl      = obj as Control;
                            ctrl.Name = node.ControlName;
                            ControlContainer.Controls.Add(ctrl);
                            if (ctrl is IRuntimeDesignControl)
                            {
                                if (diffTableHeight > 0 && intMaxTop > node.Top)
                                {
                                    node.Top += diffTableHeight;
                                }
                                ICtrl          = ctrl as IRuntimeDesignControl;
                                ICtrl.Location = new System.Drawing.Point(node.Left, node.Top);
                                ICtrl.Width    = node.Width;
                                ICtrl.Height   = node.Height;
                                if (ctrl is IRtfEditor)
                                {
                                }
                                else
                                {
                                    ICtrl.Text = node.Text;
                                }
                                ICtrl.ForeColor = node.ForeColor;
                                if (!string.IsNullOrEmpty(node.TextFont))
                                {
                                    ((Control)ctrl).Font = FontSerializationService.Deserialize(node.TextFont);
                                }

                                if (ctrl is ICheckBox && node.Checked == "1")
                                {
                                    ctrl.ForeColor = Color.Blue;
                                }
                                if (ctrl is IFormCtrl)
                                {
                                    ((Control)ctrl).Tag = node;
                                }
                            }
                            else if (ctrl is ctlTableCase)
                            {
                                node.Top       += diffTableHeight;
                                ctrl.Location   = new System.Drawing.Point(node.Left, node.Top);
                                diffTableHeight = ctrl.Height - node.Height;
                                node.Width      = ctrl.Width;
                                node.Height     = ctrl.Height;
                                ctrl.Width      = node.Width;
                                ctrl.Height     = node.Height;
                            }
                            else
                            {
                                if (diffTableHeight > 0 && intMaxTop > node.Top)
                                {
                                    node.Top += diffTableHeight;
                                }
                                ctrl.Location = new System.Drawing.Point(node.Left, node.Top);
                                ctrl.Width    = node.Width;
                                ctrl.Height   = node.Height;
                            }
                            point          = new EntityCtrlPoint();
                            point.CtrlName = node.ControlName;
                            point.X        = node.Left;
                            point.Y        = node.Top;
                            lstCtrlPoint.Add(point);

                            intMaxTop  = Math.Max(node.Top + node.Height, intMaxTop);
                            intMaxLeft = Math.Max(node.Left + node.Width, intMaxLeft);
                        }
                    }

                    ButtonItemClick(ControlContainer);
                    this.Width         = intMaxLeft + 20;
                    this.Height        = intMaxTop + 20;
                    FormTool.maxHeight = this.Height;

                    #region 多个表格时,有时需要重整坐标
                    if (diffTableHeight > 0)
                    {
                        foreach (Control ctrl1 in ControlContainer.Controls)
                        {
                            EntityCtrlPoint point1 = lstCtrlPoint.FirstOrDefault(t => t.CtrlName == ctrl1.Name);
                            ctrl1.Location = new Point(point1.X, point1.Y);
                        }
                    }
                    #endregion
                }
                #endregion
            }
            finally
            {
                this.ResumeLayout();
            }
        }