예제 #1
0
 protected void RefreshTool()
 {
     BaseBar.BeginUpdate();
     BaseTool.BeginUpdate();
     BaseTool.ItemLinks.Clear();
     BaseStatus.BeginUpdate();
     BaseStatus.ItemLinks.Clear();
     BaseBar.Items.Clear();
     foreach (Sys_Button sys_Button in ButtonList.OrderBy(b => b.Button_Parent).ThenBy(b => b.Button_Sort))
     {
         BarLargeButtonItem barButtonItem = null;
         if (barButtonItem == null)
         {
             barButtonItem             = new BarLargeButtonItem();
             barButtonItem.Name        = sys_Button.Button_Id;
             sys_Button.Button_BarItem = barButtonItem;
             RefreshTool(sys_Button);
             //按钮存在父级
             if (!string.IsNullOrEmpty(sys_Button.Button_Parent))
             {
                 BarLargeButtonItem parentBarItem = (BarLargeButtonItem)BaseBar.Items[sys_Button.Button_Parent];
                 if (parentBarItem != null)
                 {
                     PopupMenu popupMenu = (PopupMenu)parentBarItem.DropDownControl;
                     if (popupMenu == null)
                     {
                         popupMenu = new PopupMenu();
                         parentBarItem.DropDownControl = popupMenu;
                         popupMenu.Manager             = BaseBar; //没有这一行会导致按钮Enabled=false时候出错
                         parentBarItem.ActAsDropDown   = true;
                         parentBarItem.ButtonStyle     = BarButtonStyle.DropDown;
                     }
                     BarItemLink itemLink = popupMenu.AddItem(barButtonItem);
                     itemLink.BeginGroup = sys_Button.Button_BeginGroup;
                 }
             }
             else
             {
                 if (sys_Button.Button_Assign.Equals(0))
                 {
                     BarItemLink itemLink = BaseTool.AddItem(barButtonItem);
                     itemLink.BeginGroup = sys_Button.Button_BeginGroup;
                 }
                 else
                 {
                     BarItemLink itemLink = BaseStatus.AddItem(barButtonItem);
                     itemLink.BeginGroup = sys_Button.Button_BeginGroup;
                 }
             }
             barButtonItem.ItemClick += new ItemClickEventHandler(this.InitializeToolClick);
         }
     }
     if (BaseTool.ItemLinks.Count.Equals(0))
     {
         BaseTool.Visible = false;
     }
     else
     {
         BaseTool.Visible = true;
     }
     if (BaseStatus.ItemLinks.Count.Equals(0))
     {
         BaseStatus.Visible = false;
     }
     else
     {
         BaseStatus.Visible = true;
     }
     BaseTool.EndUpdate();
     BaseStatus.EndUpdate();
     BaseBar.EndUpdate();
 }