src/RumahScarlett/RumahScarlett.Presentation/Helper/RoleManager.cs
/// <summary>
/// Recursive method untuk Enable/Disable ToolStripItem pada ToolStrip
/// </summary>
/// <param name="listRoleDetail">Data RoleDetail</param>
/// <param name="items">ToolStripItemCollection ToolStrip</param>
Recursive method untuk Enable/Disable ToolStripItem pada ToolStrip
Recursive method untuk Enable / Disable ToolStripItem pada ToolStrip
private void EnableToolStripMenuItem(List<IRoleDetailModel> listRoleDetail, ToolStripItemCollection items)
      {
         foreach (var item in items)
         {
            if (item is ToolStripMenuItem)
            {
               var menuItem = (ToolStripMenuItem)item;
               if (menuItem.TagIgnore()) continue;
               var status = listRoleDetail.Any(rd => rd.menu_name.Equals(menuItem.Tag.ToString()));
               if (!status) 
               {
                  menuItem.Enabled = status; 
                  continue;
               }
               EnableToolStripMenuItem(listRoleDetail, menuItem.DropDownItems); 
            }
         }
      }
private void EnableToolStripMenuItem ( List < IRoleDetailModel > listRoleDetail , ToolStripItemCollection items ) { foreach ( var item in items ) { if ( item is ToolStripMenuItem ) { var menuItem = ( ToolStripMenuItem ) item ; if ( menuItem . TagIgnore ( ) ) continue ; var status = listRoleDetail . Any ( rd => rd . menu_name . Equals ( menuItem . Tag . ToString ( ) ) ) ; if ( ! status ) { menuItem . Enabled = status ; continue ; } EnableToolStripMenuItem ( listRoleDetail , menuItem . DropDownItems ) ; } } }
Recursive method untuk Enable/Disable ToolStripItem pada ToolStrip
Recursive method untuk Enable / Disable ToolStripItem pada ToolStrip
// Lewati jika ToolStripMenuItem mempunyai Tag ignore // Cek jika ToolStripMenuItem terdapat pada list RoleDetail // Lewati jika ToolStripMenuItem tidak ditemukan // false // Recursive method
listRoleDetail
List<IRoleDetailModel>
None
items
ToolStripItemCollection
None