Пример #1
0
 /// <summary>
 /// 添加选项卡
 /// </summary>
 /// <param name="title"></param>
 /// <param name="item"></param>
 public void _AddItem(MyTabButton item)
 {
     if (!this._Items.ContainsKey(item._ContentFormName))
     {
         item._Index            = this._Items.Count;
         item._TabClick        += tab_Click;
         item._TabClosed       += tab_Close;
         item._SelectionChange += tab_SelectionChange;
         this._Items.Add(item._ContentFormName, item);
         pnlItems.Children.Add(item);
     }
     else
     {
         _SelectTab(ControllerUIAssembly, item._ContentFormName);
     }
 }
Пример #2
0
        /// <summary>
        /// 选中选项
        /// </summary>
        /// <param name="formName"></param>
        public void _SelectTab(Assembly assembly, string formName)
        {
            ControllerUIAssembly = ControllerUIAssembly == null ? assembly : ControllerUIAssembly;
            bool        hasIndex = false;
            MyTabButton btn      = null;

            foreach (var item in this._Items)
            {
                if (formName.Equals(item.Value._ContentFormName) && (!item.Value._IsSelected || pnlBody.Children.Count == 0))
                {
                    btn      = item.Value;
                    hasIndex = true;
                    break;
                }
            }

            if (!hasIndex)
            {
                return;
            }

            foreach (var item in this._Items)
            {
                if (!item.Value._ContentFormName.Equals(formName))
                {
                    item.Value._IsSelected = false;
                }
            }

            btn._IsSelected = true;
            pnlBody.Children.Clear();
            if (btn._ContentForm == null)
            {
                var form = assembly.CreateInstance(btn._ContentFormName, true);
                if (form == null)
                {
                    // 转换失败/画面不存在
                    return;
                }
                var contentForm = form as ContentControl;
                contentForm.Width = SystemParameters.WorkArea.Width - 150;
                //contentForm.Height = SystemParameters.WorkArea.Width - 70;
                btn._ContentForm = contentForm;
            }

            pnlBody.Children.Add(btn._ContentForm);
        }