예제 #1
0
        private void HsWebBar_MouseClick(object sender, MouseEventArgs e)
        {
            for (int index = 0; index < ItemLists.Count; index++)
            {
                TabItem    item    = ItemLists[index];
                PtPosition posType = item.getPointPosition(e.Location);

                if (posType == PtPosition.InMain)
                {
                    if (_selectIndex != index)
                    {
                        _selectIndex = index;

                        HsWebForm.g_WebForm.TabChange(ItemLists[_selectIndex]);

                        this.Invalidate();
                        return;
                    }
                }
                else if (posType == PtPosition.InClose)
                {
                    ItemLists.RemoveAt(index);

                    if (ItemLists.Count <= 0)
                    {
                        Application.Exit();
                    }

                    if (this.SelectIndex == index)
                    {
                        this.SelectIndex = 0;
                    }
                    else if (this.SelectIndex > index)
                    {
                        this.SelectIndex = this.SelectIndex - 1;
                    }

                    this.Invalidate();
                }
            }

            if (addRect.Contains(e.Location))
            {
                if (ItemLists.Count >= 5)
                {
                    MessageBox.Show("不能再开启更多窗口了");
                    return;
                }
                ItemLists.Add(new TabItem());
                _selectIndex = ItemLists.Count - 1;

                // 通知主窗体
                HsWebForm.g_WebForm.TabChange(ItemLists[_selectIndex]);
                this.Invalidate();
                return;
            }
        }
예제 #2
0
        private void HsWebBar_Load(object sender, EventArgs e)
        {
            if (_itemLists == null)
            {
                _itemLists = new List <TabItem>();
            }

            // 如果没有可选项
            if (ItemLists.Count <= 0)
            {
                TabItem item = new TabItem();

                item.Url = String.Format("{0}://{1}", GlobalConfig.ProtocolPre, GlobalConfig.LoginAddress);
                ItemLists.Add(item);
                _selectIndex = 0;
            }
        }
예제 #3
0
        public void addItem(TabItem item)
        {
            ItemLists.Add(item);

            this.Invalidate();
        }