private static ImageMenuItem GetMenuItem(ImageMenuItemParams @params)
 {
     var menuItem = new ImageMenuItem(@params.Text)
     {
         Image = ToImage(@params.Image),
         Visible = true
     };
     if (@params.Handler != null)
     {
         menuItem.Activated += ((sender, e) =>
         {
             @params.Handler(@params, new EventArgs());
         });
     }
     if (@params.OpeningHandler != null)
     {
         @params.OpeningHandler(@params, new OpeningEventArgs { MenuItem = new GtkMenuItemHanlder(menuItem) });
     }
     return menuItem;
 }
 private static ToolStripMenuItem GetMenuItem(ImageMenuItemParams @params)
 {
     var menuItem = new ToolStripMenuItem
     {
         Image = @params.Image,
         Text = @params.Text
     };
     if (@params.Handler != null)
     {
         menuItem.Click +=((sender, e)=>
         {
             @params.Handler(@params, new EventArgs());
         });
     }
     return menuItem;
 }
 private static Widget[] GetList(IEnumerable<IMenuItemParams> items, ImageMenuItemParams parent)
 {
     var list = new List<Widget>();
     foreach (var item in items)
     {
         if (item.Text == "-")
         {
             list.Add(new SeparatorMenuItem { Visible = true });
             continue;
         }
         var menuitem = item as ImageMenuItemParams;
         if (menuitem != null)
         {
             menuitem.Parent = parent;
             var menuItem = GetMenuItem(menuitem);
             if (menuitem.Items != null)
             {
                 var submenu = new Menu();
                 var subitems = GetList(menuitem.Items, menuitem);
                 foreach (var subitem in subitems)
                 {
                     submenu.Add(subitem);
                 }
                 menuItem.Submenu = submenu;
             }
             list.Add(menuItem);
             continue;
         }
         var checkedmenuitem = item as CheckedMenuItemParams;
         if (checkedmenuitem != null)
         {
             var menuItem = GetCheckedMenuItem(checkedmenuitem);
             list.Add(menuItem);
             continue;
         }
     }
     return list.ToArray();
 }
 private static ToolStripItem[] GetList(IEnumerable<IMenuItemParams> items, ImageMenuItemParams parent)
 {
     var list = new List<ToolStripItem>();
     foreach (var item in items)
     {
         if (item.Text == "-")
         {
             list.Add(new ToolStripSeparator());
             continue;
         }
         var menuitem = item as ImageMenuItemParams;
         if (menuitem != null)
         {
             menuitem.Parent = parent;
             var menuItem = GetMenuItem(menuitem);
             if (menuitem.Items != null)
             {
                 menuItem.DropDownItems.AddRange(GetList(menuitem.Items, menuitem));
             }
             menuItem.Tag = item;
             list.Add(menuItem);
             continue;
         }
         var checkedmenuitem = item as CheckedMenuItemParams;
         if (checkedmenuitem != null)
         {
             var menuItem = GetCheckedMenuItem(checkedmenuitem);
             menuItem.Tag = item;
             list.Add(menuItem);
             continue;
         }
     }
     return list.ToArray();
 }