Beispiel #1
0
        private void AddTabItem(string s)  //按Button時,新增一個同名的TabItem
        {
            UCTabItemWithClose NewTab = new UCTabItemWithClose()
            {
                Header = s, Name = s, Width = 84.4, Height = 30, FontSize = 12
            };

            NewTab.CheckClose += NewTab_CheckClose;
            for (int i = 0; i < CheckList.Count(); i++)  //判斷有沒有重複的TabItem
            {
                if (NewTab.Name == CheckList[i])
                {
                    Repeat = true;
                    break;
                }
                else
                {
                    Repeat = false;
                }
            }

            if (Repeat == false)  //沒有重複才新增TabItem
            {
                TabControl1.Items.Add(NewTab);
                TabControl1.SelectedItem = NewTab;
            }
        }
Beispiel #2
0
        private void NewTab_CheckClose(object sender, EventArgs e)
        {
            UCTabItemWithClose SelectedTab = sender as UCTabItemWithClose;

            //刪除List裡面重複的
            for (int i = 0; i < CheckList.Count; i++)         //循環的次數
            {
                for (int j = CheckList.Count - 1; j > i; j--) //比較的次數
                {
                    if (CheckList[i] == CheckList[j])
                    {
                        CheckList.RemoveAt(j);
                    }
                }
            }

            CheckList.Remove(SelectedTab.Name);
        }
Beispiel #3
0
        private void Window_ContentRendered(object sender, EventArgs e)
        {
            Login login = new Login();

            login.ShowDialog();

            if (login.login_ok)
            {
                string str = null;
                if (Account_ViewModel.Permission == "director")
                {
                    str = "主任 " + Account_ViewModel.User;
                }
                if (Account_ViewModel.Permission == "Volunteer_supervision")
                {
                    str = "志工督導 " + Account_ViewModel.User;
                }

                this.username.Content = str;
            }
            else
            {
                this.Close();
            }

            UCTabItemWithClose NewTab = new UCTabItemWithClose()
            {
                Header = "首頁", Name = "首頁", Width = 84.4, Height = 30, FontSize = 12
            };

            //NewTab.SetValue(UCTabItemWithClose.StyleProperty, Application.Current.Resources["TabItemStyle1"]);
            Style style = this.FindResource("TabItemStyle1") as Style;

            NewTab.Style = style;

            Home   home    = new Home();
            object content = home.Content;

            home.Content   = null;
            NewTab.Content = content as UIElement;

            TabControl1.Items.Add(NewTab);
            TabControl1.SelectedItem = NewTab;
        }