Beispiel #1
0
        /// <summary>
        /// Filter
        /// </summary>
        void Filter()
        {
            List <XmlField>       dataSource = null;
            string                layoutXml  = string.Empty;
            string                formId     = this.lueForm.Properties.DBValue;
            List <EntityFormCtrl> formCtrls  = null;
            EntityObjectList      vo         = DataSourceForm.FirstOrDefault(t => t.formId == formId);

            if (formId.StartsWith("a"))
            {
                using (ProxyFormDesign proxy = new ProxyFormDesign())
                {
                    EntityFormDesign vo1 = proxy.Service.GetForm(int.Parse(formId.Substring(1)), true)[0];
                    layoutXml = vo1.Layout;
                }
                formCtrls = FormTool.Entities(layoutXml).FindAll(t => t.ItemType == "1" || t.ItemType == "2" || t.ItemType == "6");
                if (formCtrls != null)
                {
                    dataSource = new List <XmlField>();
                    foreach (EntityFormCtrl item in formCtrls)
                    {
                        dataSource.Add(new XmlField()
                        {
                            check = 0, itemName = item.ItemName, itemCaption = item.ItemCaption
                        });
                    }
                }
            }
            else if (formId.StartsWith("b"))
            {
                using (ProxyFormDesign proxy = new ProxyFormDesign())
                {
                    List <EntityEmrTableFieldInfo> tabFields = proxy.Service.GetTableFieldInfo(formId.Substring(1));
                    if (tabFields != null && tabFields.Count > 0)
                    {
                        dataSource = new List <XmlField>();
                        foreach (EntityEmrTableFieldInfo item in tabFields)
                        {
                            dataSource.Add(new XmlField()
                            {
                                check = 0, itemName = item.fieldName, itemCaption = item.fieldCaptain
                            });
                        }
                    }
                }
            }
            this.gcFields.DataSource = dataSource;
        }
Beispiel #2
0
        /// <summary>
        /// InitDesigner
        /// </summary>
        /// <param name="formId"></param>
        /// <param name="version"></param>
        void InitDesigner(int formId, int version)
        {
            if (this.isSelected)
            {
                return;
            }
            this.Loading = true;
            try
            {
                SuspendLayoutUc();
                this.Cursor   = Cursors.WaitCursor;
                designSurface = new DesignSurface();
                this.pnlDesignPanel.Controls.Clear();

                //服务容器
                IServiceContainer serviceContainer = designSurface.GetService(typeof(IServiceContainer)) as IServiceContainer;

                idh = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                _KeyStrokeMessageFilter.SetHostAndMDIForm(idh, designSurface);

                //工具箱服务
                this.toolboxServiceXtraTree.host = idh;
                serviceContainer.AddService(typeof(IToolboxService), this.toolboxServiceXtraTree);
                PopulateToolbox(this.toolboxServiceXtraTree);
                this.toolboxServiceXtraTree.designPanel = this.pnlDesignPanel;

                //菜单命令服务
                menuService = new MenuCommandServiceImpl(serviceContainer);
                serviceContainer.AddService(typeof(IMenuCommandService), menuService);

                //命名服务
                serviceContainer.AddService(typeof(INameCreationService), new NameCreationService(idh));

                //控件序列化反序列化服务
                serviceContainer.AddService(typeof(IDesignerSerializationService), new DesignerSerializationServiceForm(idh));
                //获取控件信息
                EntityFormDesign formVo = new EntityFormDesign();

                if (formId > 0)
                {
                    this.IsExists = true;
                    ProxyFormDesign proxy = new ProxyFormDesign();
                    proxy.Service.GetForm(formId, version, out formVo);
                    proxy = null;
                    this.PrintTemplateId = formVo.Printtemplateid;
                }
                if (formVo != null && formVo.Formid > 0)
                {
                    SetMainInfo(formVo);
                    if (!string.IsNullOrEmpty(formVo.Layout))
                    {
                        formCtrlData = FormTool.Entities(formVo.Layout);
                    }
                }
                else
                {
                    this.cboEfStatus.SelectedIndex = 1;
                    this.pnlDesignPanel.Height     = this.Height - 80;
                }

                if ((this.FormType > 2 && formId <= 0 && (formVo == null || string.IsNullOrEmpty(formVo.Layout))))
                {
                    this.txtEfCode.Properties.ReadOnly = true;
                    this.txtEfName.Properties.ReadOnly = true;
                }
                if (this.FormType > 2)
                {
                    this.cboVersion.Text = "1";
                    this.cboVersion.Properties.ReadOnly  = true;
                    this.cboEfStatus.SelectedIndex       = 1;
                    this.cboEfStatus.Properties.ReadOnly = true;
                }
                if (this.FormType > 10)
                {
                    this.txtEfCode.Properties.ReadOnly = true;
                    this.txtEfName.Properties.ReadOnly = true;
                    this.cboVersion.Text = "1";
                    this.cboVersion.Properties.ReadOnly  = true;
                    this.cboEfStatus.SelectedIndex       = 1;
                    this.cboEfStatus.Properties.ReadOnly = true;
                }
                //if (this.TemplateMainVo != null)
                //{
                //    this.txtEfCode.Text = this.TemplateMainVo.templateCode;
                //    this.txtEfName.Text = this.TemplateMainVo.templateName;
                //}
                if (this.txtEfCode.Text.Trim() == string.Empty)
                {
                    this.txtEfCode.Text = DateTime.Now.ToString("yyMMddHHmm");
                }
                loader            = new DesignLoaderForm(idh, formCtrlData);
                loader.InitWidth  = this.pnlDesignPanel.Width - 30;
                loader.InitHeight = this.pnlDesignPanel.Height - 30;
                loader.FormFlag   = true;

                //绑定事件
                loader.ComponentAdded   -= new ComponentEventHandler(loader_ComponentAdded);
                loader.ComponentAdded   += new ComponentEventHandler(loader_ComponentAdded);
                loader.ComponentChanged -= new ComponentChangedEventHandler(loader_ComponentChanged);
                loader.ComponentChanged += new ComponentChangedEventHandler(loader_ComponentChanged);
                loader.ComponentRemoved -= new ComponentEventHandler(loader_ComponentRemoved);
                loader.ComponentRemoved += new ComponentEventHandler(loader_ComponentRemoved);

                designSurface.BeginLoad(loader);

                Control ctrl = designSurface.View as Control;
                ctrl.Parent = pnlDesignPanel;
                ctrl.Dock   = DockStyle.Fill;

                ISelectionService selectionService = designSurface.GetService(typeof(ISelectionService)) as ISelectionService;
                selectionService.SelectionChanged -= new EventHandler(selectionService_SelectionChanged);
                selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);

                BehaviorService bhsvc = idh.GetService(typeof(BehaviorService)) as BehaviorService;

                //undo/redo服务
                serializationService = new ComponentSerializationServiceImpl(idh);
                serviceContainer.AddService(typeof(ComponentSerializationService), serializationService);
                undoEngine = new UndoEngineImpl(idh);
                serviceContainer.AddService(typeof(UndoEngine), undoEngine);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ResumeLayoutUc();
                Loading     = false;
                this.Cursor = Cursors.Default;
            }
        }
Beispiel #3
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();
            }
        }