예제 #1
0
        public void initData()
        {
            //Create&Drop
            if (this.Database == null)
            {
                this.Database = new nwdbConnection();
            }
            sessionFactory = this.Database.Factory;
            if (this.Repository == null)
            {
                this.Repository = new nwdbRepository(sessionFactory.OpenSession());
            }
            sess = this.Repository.GetSession();
            stm  = new sysTreeManager();
            //repo.SeedMockData();

            bs_sysAlignment.DataSource = sess.QueryOver <sysBaseAlignment>().List();

            if (this.Logon != null)
            {
                isAdmin = (this.Logon.UserType.LongName == "Administrator");
                SetMessage("isAdmin calulated" + isAdmin.ToString() + " for Logon" + this.Logon.LongName);
            }

            if (this.Character != null)
            {
                bs_nwChar.List.Clear();
                bs_nwChar.List.Add(Character);

                lboxLogon.Visible      = false;
                lboxCharacters.Visible = false;
                btnDelete.Visible      = false;
                btnAdd.Visible         = false;
                nwCharBindingSource_CurrentChanged(this, null);
                return;
            }

            if (this.Logon == null || isAdmin)
            {
                bs_logons.DataSource = sess.QueryOver <hostUser>().List();
            }
            else
            {
                bs_logons.DataSource = sess.QueryOver <hostUser>().Where(tx => tx.id == this.Logon.id).List();
            }
            LoadCharacters();
            bs_sysTreeStatistic.DataSource = sess.QueryOver <sysTreeStatistic>().List();
            stm.FillTreeNodeCollection <sysTreeStatistic>(sess, treeStatistic.Nodes);
            //catch late binding controls
            nwCharBindingSource_CurrentChanged(this, null);
        }
        protected void PaintTree()
        {
            tboxTreeName.Text = "";
            lblTreeID.Text    = "";
            refreshBindings();
            tabData.SelectedTab = tbTree;
            switch (cEditor.Description)
            {
            case strStatTree:
                treeman.FillTreeNodeCollection <sysTreeStatistic>(sess, treeData.Nodes);
                break;

            case strItemTree:
                treeman.FillTreeNodeCollection <sysTreeItemType>(sess, treeData.Nodes);
                break;

            case strDevType:
                treeman.FillTreeNodeCollection <sysTreeDevelopment>(sess, treeData.Nodes);
                break;

            case strMilestoneTree:
                treeman.FillTreeNodeCollection <campTreeMileStone>(sess, treeData.Nodes);
                break;

            case strFactionTree:
                treeman.FillTreeNodeCollection <campTreeFaction>(sess, treeData.Nodes);
                break;

            case strLocationTree:
                treeman.FillTreeNodeCollection <campTreeLocation>(sess, treeData.Nodes);
                break;

            case strTerrainTree:
                treeman.FillTreeNodeCollection <mapTreeTerrain>(sess, treeData.Nodes);
                break;

            default:
                break;
            }

            tboxTreeName.DataBindings.Clear();
            tboxTreeName.DataBindings.Add(cEditor.bindName);
            lblTreeID.DataBindings.Clear();
            lblTreeID.DataBindings.Add(cEditor.bindID);
            treeData.ExpandAll();
            if (cEditor.tabControl != null)
            {
                tabTree.Enabled     = true;
                tabTree.Visible     = true;
                tabTree.SelectedTab = cEditor.tabControl;
            }
            else
            {
                tabTree.Enabled = false;
                tabTree.Visible = false;
            }
        }