Esempio n. 1
0
        void LoadData()
        {
            if (Window == null)
            {
                return;
            }

            this.Width          = Window.Width;
            this.Height         = Window.Height;
            panelTop.Height     = Window.TopPanelHeight;
            panelBottom.Height  = Window.BottomPanelHeight;
            panelLeft.Width     = Window.LeftPanelWidth;
            panelRight.Width    = Window.RightPanelWidth;
            panelTop.Visible    = Window.TopPanelVisible;
            panelBottom.Visible = Window.BottomPanelVisible;
            panelLeft.Visible   = Window.LeftPanelVisible;
            panelRight.Visible  = Window.RightPanelVisible;

            List <CBaseObject> lstWindowControl = Window.WindowControlMgr.GetList();

            foreach (CBaseObject obj in lstWindowControl)
            {
                CWindowControl WindowControl = (CWindowControl)obj;
                Panel          panel         = null;
                if (WindowControl.Dock == (int)DockStyle.Top)
                {
                    panel = panelTop;
                }
                else if (WindowControl.Dock == (int)DockStyle.Bottom)
                {
                    panel = panelBottom;
                }
                else if (WindowControl.Dock == (int)DockStyle.Left)
                {
                    panel = panelLeft;
                }
                else if (WindowControl.Dock == (int)DockStyle.Right)
                {
                    panel = panelRight;
                }
                else
                {
                    panel = panelFill;
                }

                if (WindowControl.CtrlType == ControlType.NavBar)
                {
                    UIToolbar toolbar = new UIToolbar();
                    toolbar.WindowControl = WindowControl;
                    toolbar.Name          = WindowControl.Name;
                    panel.Controls.Add(toolbar);
                    toolbar.Dock = DockStyle.Fill;
                    toolbar.SendToBack();
                }
                else if (WindowControl.CtrlType == ControlType.TableGrid)
                {
                    if (WindowControl.TableInWindowControlMgr.GetList().Count == 0)
                    {
                        continue;
                    }
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.FW_Table_id);
                    if (table == null)
                    {
                        continue;
                    }

                    CBaseObjectMgr objMgr = new CBaseObjectMgr();
                    objMgr.TbCode = table.Code;
                    objMgr.Ctx    = Program.Ctx;
                    TableGrid te = new TableGrid();
                    te.TableInWindowControl = TableInWindowControl;
                    te.BaseObjectMgr        = objMgr;
                    te.Name         = WindowControl.Name;
                    te.ShowToolBar  = TableInWindowControl.ShowToolBar;
                    te.ShowTitleBar = TableInWindowControl.ShowTitleBar;
                    te.CaptionText  = WindowControl.Name;
                    te.Tag          = WindowControl;
                    panel.Controls.Add(te);
                    te.Dock = (DockStyle)WindowControl.Dock;
                    te.BringToFront();
                    te.dataGridView.CellClick += new DataGridViewCellEventHandler(dataGridView_CellClick);
                }
                else if (WindowControl.CtrlType == ControlType.TableTree)
                {
                    TableTree tt = new TableTree();
                    tt.CaptionText   = WindowControl.Name;
                    tt.ShowTitleBar  = WindowControl.ShowTitleBar;
                    tt.WindowControl = WindowControl;
                    tt.Name          = WindowControl.Name;
                    tt.Tag           = WindowControl;
                    panel.Controls.Add(tt);
                    tt.Dock = DockStyle.Fill;
                    tt.BringToFront();

                    tt.treeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(treeView_NodeMouseClick);
                }
                else if (WindowControl.CtrlType == ControlType.TableTab)
                {
                    TableTab tab = new TableTab();
                    tab.WindowControl = WindowControl;
                    tab.CaptionText   = WindowControl.Name;
                    tab.Name          = WindowControl.Name;
                    tab.ShowTitleBar  = WindowControl.ShowTitleBar;
                    tab.Tag           = WindowControl;
                    panel.Controls.Add(tab);
                    tab.Dock = DockStyle.Fill;
                    tab.BringToFront();
                }
                else if (WindowControl.CtrlType == ControlType.ComboBox)
                {
                    if (WindowControl.TableInWindowControlMgr.GetList().Count == 0)
                    {
                        continue;
                    }
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.FW_Table_id);
                    if (table == null)
                    {
                        continue;
                    }

                    CBaseObjectMgr objMgr = new CBaseObjectMgr();
                    objMgr.TbCode = table.Code;
                    objMgr.Ctx    = Program.Ctx;

                    UIComboBox cb = new UIComboBox();
                    cb.CaptionText          = WindowControl.Name + ":";
                    cb.TableInWindowControl = TableInWindowControl;
                    cb.BaseObjectMgr        = objMgr;
                    cb.Name = WindowControl.Name;
                    cb.Tag  = WindowControl;
                    panel.Controls.Add(cb);
                    cb.Dock = DockStyle.Top;
                    cb.BringToFront();

                    cb.comboBox.SelectedIndexChanged += new EventHandler(comboBox_SelectedIndexChanged);
                }
                else if (WindowControl.CtrlType == ControlType.ListBox)
                {
                    if (WindowControl.TableInWindowControlMgr.GetList().Count == 0)
                    {
                        continue;
                    }
                    CTableInWindowControl TableInWindowControl = (CTableInWindowControl)WindowControl.TableInWindowControlMgr.GetFirstObj();
                    CTable table = (CTable)Program.Ctx.TableMgr.Find(TableInWindowControl.FW_Table_id);
                    if (table == null)
                    {
                        continue;
                    }

                    CBaseObjectMgr objMgr = new CBaseObjectMgr();
                    objMgr.TbCode = table.Code;
                    objMgr.Ctx    = Program.Ctx;

                    UIListBox listBox = new UIListBox();
                    listBox.CaptionText          = WindowControl.Name;
                    listBox.TableInWindowControl = TableInWindowControl;
                    listBox.BaseObjectMgr        = objMgr;
                    listBox.Name = WindowControl.Name;
                    listBox.Tag  = WindowControl;
                    panel.Controls.Add(listBox);
                    listBox.Dock = DockStyle.Fill;
                    listBox.BringToFront();

                    listBox.listBox.SelectedIndexChanged += new EventHandler(listBox_SelectedIndexChanged);
                }
            }
        }