示例#1
0
        public DataSourceControl(LibTreeNode funcNode)
        {
            this._funNode = funcNode;
            InitializeComponent();
            _dsProperty          = new DataSourceProperty();
            _defTBPropertylst    = new List <DefTBProperty>();
            _tbStructPropertylst = new List <TBStructProperty>();
            _fieldPropertylst    = new List <DefFieldProperty>();
            this.splitContainer1.Panel2.Controls.Add(_dsProperty);

            this.treeView1.DrawMode      = TreeViewDrawMode.OwnerDrawText;
            this.treeView1.HideSelection = false;
            this.treeView1.DrawNode     += new DrawTreeNodeEventHandler(treeView1_DrawNode);
        }
示例#2
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            LibTreeNode libnode = (LibTreeNode)e.Node;

            if (libnode == null)
            {
                return;
            }
            bool exists = false;

            switch (libnode.NodeType)
            {
            case NodeType.DefDataSet:
                if (this._dsProperty == null)
                {
                    _dsProperty = new DataSourceProperty();
                    this.splitContainer1.Panel2.Controls.Add(_dsProperty);
                }
                SetPanel2ControlsVisible(_dsProperty);

                _ds.DataSourceName = string.IsNullOrEmpty(_ds.DataSourceName) ? _funNode.Text : _ds.DataSourceName;
                _ds.Package        = string.IsNullOrEmpty(_ds.Package) ? _funNode.Package : _ds.Package;
                _dsProperty.SetPropertyValue(_ds, libnode);
                break;

            case NodeType.DefindTable:
                if (this._defTBPropertylst != null)
                {
                    foreach (DefTBProperty item in _defTBPropertylst)
                    {
                        if (string.Compare(item.Name, libnode.NodeId) == 0)
                        {
                            SetPanel2ControlsVisible(item);
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)     //还未创建对应的控件
                    {
                        DefTBProperty deftbp = new DefTBProperty(libnode.NodeId);
                        deftbp.Dock = DockStyle.Fill;
                        this._defTBPropertylst.Add(deftbp);
                        this.splitContainer1.Panel2.Controls.Add(deftbp);
                        deftbp.SetPropertyValue(_ds.DefTables.FindFirst("ID", libnode.NodeId), libnode);

                        SetPanel2ControlsVisible(deftbp);
                    }
                }

                break;

            case NodeType.TableStruct:
                if (this._tbStructPropertylst != null)
                {
                    foreach (TBStructProperty item in _tbStructPropertylst)
                    {
                        if (string.Compare(item.Name, libnode.NodeId) == 0)
                        {
                            SetPanel2ControlsVisible(item);
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)     //还未创建对应的控件
                    {
                        TBStructProperty tbstrucp = new TBStructProperty(libnode.NodeId);
                        tbstrucp.Dock = DockStyle.Fill;
                        this._tbStructPropertylst.Add(tbstrucp);
                        this.splitContainer1.Panel2.Controls.Add(tbstrucp);
                        LibDefineTable deftb = _ds.DefTables.FindFirst("ID", ((LibTreeNode)libnode.Parent).NodeId);
                        tbstrucp.SetPropertyValue(deftb.TableStruct.FindFirst("ID", libnode.NodeId), libnode);

                        SetPanel2ControlsVisible(tbstrucp);
                    }
                }
                break;

            case NodeType.Field:
                if (this._fieldPropertylst != null)
                {
                    foreach (DefFieldProperty item in _fieldPropertylst)
                    {
                        if (string.Compare(item.Name, libnode.NodeId) == 0)
                        {
                            SetPanel2ControlsVisible(item);
                            exists = true;
                            break;
                        }
                    }
                    if (!exists)     //还未创建对应的控件
                    {
                        DefFieldProperty fieldp = new DefFieldProperty(libnode.NodeId);
                        fieldp.Dock = DockStyle.Fill;
                        this._fieldPropertylst.Add(fieldp);
                        this.splitContainer1.Panel2.Controls.Add(fieldp);
                        LibDefineTable     deftb    = _ds.DefTables.FindFirst("ID", ((LibTreeNode)libnode.Parent.Parent).NodeId);
                        LibDataTableStruct dtstruct = deftb.TableStruct.FindFirst("ID", ((LibTreeNode)libnode.Parent).NodeId);
                        fieldp.SetPropertyValue(dtstruct.Fields.FindFirst("ID", libnode.NodeId), libnode);

                        SetPanel2ControlsVisible(fieldp);
                    }
                }
                break;
            }
        }