Esempio n. 1
0
        public UserTab(Session session)
        {
            MainPage = new UserMainPageContent(session)
            {
                Dock = DockStyle.Fill
            };
            Controls.Add(MainPage);

            Text = session.DisplayText;
            session.UserKeyData.DisplayNameChanged += (s, e) =>
            {
                var action = new Action(() =>
                {
                    Text = Session.DisplayText;
                });
                AppContext.MainForm.UiInvoke(action);
            };
            TaskManager.Instance.EnqueueTask("获得账号【" + session.UserName + "】的注册用户姓名", () => new GetDisplayNameWorker()
            {
                Session = Session
            }.Run());
            ImageIndex = session.TemporaryMode ? 5 : 1;

            Session = session;
        }
        public UserTabDnb(Session session, SuperTabControl parent)
        {
            InitSession(session);

            _userPage = new UserMainPageContent(session)
            {
                Dock      = DockStyle.Fill,
                BackColor = SystemColors.Window
            };
            _panel = new SuperTabControlPanel();
            _panel.Controls.Add(_userPage);
            _panel.TabItem  = this;
            AttachedControl = _panel;
            parent.Controls.Add(_panel);

            //set property
            Text = session.DisplayText;
            session.UserKeyData.DisplayNameChanged += (s, e) =>
            {
                var action = new Action(() =>
                {
                    Text = Session.DisplayText;
                });
                AppContext.MainForm.UiInvoke(action);
            };
            TaskManager.Instance.EnqueueTask("获得账号【" + session.UserName + "】的注册用户姓名", () => new GetDisplayNameWorker()
            {
                Session = Session
            }.Run());
            Image = session.TemporaryMode ? Properties.Resources.cou_16_protection : session.ShadowMode ? Properties.Resources.cou_16_users : Properties.Resources.user_16;


            //find index
            _controlParent = parent;
            var last = parent.Tabs.OfType <UserTabDnb>().LastOrDefault();
            var idx  = last == null ? 1 : parent.Tabs.IndexOf(last) + 1;

            parent.Tabs.Add(this, idx);
        }