internal virtual void CreateMenuItem()
 {
     if ((this.data.State & 0x10000) == 0)
     {
         System.Windows.Forms.NativeMethods.MENUITEMINFO_T lpmii = this.CreateMenuItemInfo();
         System.Windows.Forms.UnsafeNativeMethods.InsertMenuItem(new HandleRef(this.menu, this.menu.handle), -1, true, lpmii);
         this.hasHandle         = lpmii.hSubMenu != IntPtr.Zero;
         this.dataVersion       = this.data.version;
         this.menuItemIsCreated = true;
         if (this.RenderIsRightToLeft)
         {
             this.Menu.UpdateRtl(true);
         }
     }
 }
 internal void UpdateMenuItem(bool force)
 {
     if (((this.menu != null) && this.menu.created) && ((force || (this.menu is MainMenu)) || (this.menu is ContextMenu)))
     {
         System.Windows.Forms.NativeMethods.MENUITEMINFO_T lpmii = this.CreateMenuItemInfo();
         System.Windows.Forms.UnsafeNativeMethods.SetMenuItemInfo(new HandleRef(this.menu, this.menu.handle), this.MenuID, false, lpmii);
         if (this.hasHandle && (lpmii.hSubMenu == IntPtr.Zero))
         {
             base.ClearHandles();
         }
         this.hasHandle   = lpmii.hSubMenu != IntPtr.Zero;
         this.dataVersion = this.data.version;
         if (this.menu is MainMenu)
         {
             Form formUnsafe = ((MainMenu)this.menu).GetFormUnsafe();
             if (formUnsafe != null)
             {
                 System.Windows.Forms.SafeNativeMethods.DrawMenuBar(new HandleRef(formUnsafe, formUnsafe.Handle));
             }
         }
     }
 }
 internal void UpdateItemRtl(bool setRightToLeftBit)
 {
     if (this.menuItemIsCreated)
     {
         System.Windows.Forms.NativeMethods.MENUITEMINFO_T menuiteminfo_t;
         menuiteminfo_t = new System.Windows.Forms.NativeMethods.MENUITEMINFO_T {
             fMask      = 0x15,
             dwTypeData = new string('\0', this.Text.Length + 2),
             cbSize     = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.MENUITEMINFO_T)),
             cch        = menuiteminfo_t.dwTypeData.Length - 1
         };
         System.Windows.Forms.UnsafeNativeMethods.GetMenuItemInfo(new HandleRef(this.menu, this.menu.handle), this.MenuID, false, menuiteminfo_t);
         if (setRightToLeftBit)
         {
             menuiteminfo_t.fType |= 0x6000;
         }
         else
         {
             menuiteminfo_t.fType &= -24577;
         }
         System.Windows.Forms.UnsafeNativeMethods.SetMenuItemInfo(new HandleRef(this.menu, this.menu.handle), this.MenuID, false, menuiteminfo_t);
     }
 }
 internal void UpdateItemRtl(bool setRightToLeftBit)
 {
     if (this.menuItemIsCreated)
     {
         System.Windows.Forms.NativeMethods.MENUITEMINFO_T menuiteminfo_t;
         menuiteminfo_t = new System.Windows.Forms.NativeMethods.MENUITEMINFO_T {
             fMask = 0x15,
             dwTypeData = new string('\0', this.Text.Length + 2),
             cbSize = Marshal.SizeOf(typeof(System.Windows.Forms.NativeMethods.MENUITEMINFO_T)),
             cch = menuiteminfo_t.dwTypeData.Length - 1
         };
         System.Windows.Forms.UnsafeNativeMethods.GetMenuItemInfo(new HandleRef(this.menu, this.menu.handle), this.MenuID, false, menuiteminfo_t);
         if (setRightToLeftBit)
         {
             menuiteminfo_t.fType |= 0x6000;
         }
         else
         {
             menuiteminfo_t.fType &= -24577;
         }
         System.Windows.Forms.UnsafeNativeMethods.SetMenuItemInfo(new HandleRef(this.menu, this.menu.handle), this.MenuID, false, menuiteminfo_t);
     }
 }
 private System.Windows.Forms.NativeMethods.MENUITEMINFO_T CreateMenuItemInfo()
 {
     System.Windows.Forms.NativeMethods.MENUITEMINFO_T menuiteminfo_t = new System.Windows.Forms.NativeMethods.MENUITEMINFO_T {
         fMask = 0x37,
         fType = this.data.State & 0x360
     };
     bool flag = false;
     if (this.menu == base.GetMainMenu())
     {
         flag = true;
     }
     if (this.data.caption.Equals("-"))
     {
         if (flag)
         {
             this.data.caption = " ";
             menuiteminfo_t.fType |= 0x40;
         }
         else
         {
             menuiteminfo_t.fType |= 0x800;
         }
     }
     menuiteminfo_t.fState = this.data.State & 0x100b;
     menuiteminfo_t.wID = this.MenuID;
     if (this.IsParent)
     {
         menuiteminfo_t.hSubMenu = base.Handle;
     }
     menuiteminfo_t.hbmpChecked = IntPtr.Zero;
     menuiteminfo_t.hbmpUnchecked = IntPtr.Zero;
     if (this.uniqueID == 0)
     {
         lock (allCreatedMenuItems)
         {
             this.uniqueID = (uint) Interlocked.Increment(ref nextUniqueID);
             allCreatedMenuItems.Add(this.uniqueID, new WeakReference(this));
         }
     }
     if (IntPtr.Size == 4)
     {
         if (this.data.OwnerDraw)
         {
             menuiteminfo_t.dwItemData = this.AllocMsaaMenuInfo();
         }
         else
         {
             menuiteminfo_t.dwItemData = (IntPtr) this.uniqueID;
         }
     }
     else
     {
         menuiteminfo_t.dwItemData = this.AllocMsaaMenuInfo();
     }
     if ((this.data.showShortcut && (this.data.shortcut != System.Windows.Forms.Shortcut.None)) && (!this.IsParent && !flag))
     {
         menuiteminfo_t.dwTypeData = this.data.caption + "\t" + TypeDescriptor.GetConverter(typeof(Keys)).ConvertToString((Keys) this.data.shortcut);
     }
     else
     {
         menuiteminfo_t.dwTypeData = (this.data.caption.Length == 0) ? " " : this.data.caption;
     }
     menuiteminfo_t.cch = 0;
     return menuiteminfo_t;
 }
        private System.Windows.Forms.NativeMethods.MENUITEMINFO_T CreateMenuItemInfo()
        {
            System.Windows.Forms.NativeMethods.MENUITEMINFO_T menuiteminfo_t = new System.Windows.Forms.NativeMethods.MENUITEMINFO_T {
                fMask = 0x37,
                fType = this.data.State & 0x360
            };
            bool flag = false;

            if (this.menu == base.GetMainMenu())
            {
                flag = true;
            }
            if (this.data.caption.Equals("-"))
            {
                if (flag)
                {
                    this.data.caption     = " ";
                    menuiteminfo_t.fType |= 0x40;
                }
                else
                {
                    menuiteminfo_t.fType |= 0x800;
                }
            }
            menuiteminfo_t.fState = this.data.State & 0x100b;
            menuiteminfo_t.wID    = this.MenuID;
            if (this.IsParent)
            {
                menuiteminfo_t.hSubMenu = base.Handle;
            }
            menuiteminfo_t.hbmpChecked   = IntPtr.Zero;
            menuiteminfo_t.hbmpUnchecked = IntPtr.Zero;
            if (this.uniqueID == 0)
            {
                lock (allCreatedMenuItems)
                {
                    this.uniqueID = (uint)Interlocked.Increment(ref nextUniqueID);
                    allCreatedMenuItems.Add(this.uniqueID, new WeakReference(this));
                }
            }
            if (IntPtr.Size == 4)
            {
                if (this.data.OwnerDraw)
                {
                    menuiteminfo_t.dwItemData = this.AllocMsaaMenuInfo();
                }
                else
                {
                    menuiteminfo_t.dwItemData = (IntPtr)this.uniqueID;
                }
            }
            else
            {
                menuiteminfo_t.dwItemData = this.AllocMsaaMenuInfo();
            }
            if ((this.data.showShortcut && (this.data.shortcut != System.Windows.Forms.Shortcut.None)) && (!this.IsParent && !flag))
            {
                menuiteminfo_t.dwTypeData = this.data.caption + "\t" + TypeDescriptor.GetConverter(typeof(Keys)).ConvertToString((Keys)this.data.shortcut);
            }
            else
            {
                menuiteminfo_t.dwTypeData = (this.data.caption.Length == 0) ? " " : this.data.caption;
            }
            menuiteminfo_t.cch = 0;
            return(menuiteminfo_t);
        }