static IList ExpandMenuBuilders(ICollection input, bool addDummyEntryIfMenuEmpty)
        {
            List <object> result = new List <object>(input.Count);

            foreach (object o in input)
            {
                MenuItemBuilderPlaceholder p = o as MenuItemBuilderPlaceholder;
                if (p != null)
                {
                    IEnumerable <object> c = p.BuildItems();
                    if (c != null)
                    {
                        result.AddRange(c);
                    }
                }
                else
                {
                    result.Add(o);
                    IStatusUpdate statusUpdate = o as IStatusUpdate;
                    if (statusUpdate != null)
                    {
                        statusUpdate.UpdateStatus();
                        statusUpdate.UpdateText();
                    }
                }
            }
            if (addDummyEntryIfMenuEmpty && result.Count == 0)
            {
                result.Add(new MenuItem {
                    Header = "(empty menu)", IsEnabled = false
                });
            }
            return(result);
        }
Exemple #2
0
        internal static IList ExpandMenuBuilders(ICollection input)
        {
            ArrayList result = new ArrayList(input.Count);

            foreach (object o in input)
            {
                MenuItemBuilderPlaceholder p = o as MenuItemBuilderPlaceholder;
                if (p != null)
                {
                    ICollection c = p.BuildItems();
                    if (c != null)
                    {
                        result.AddRange(c);
                    }
                }
                else
                {
                    result.Add(o);
                    IStatusUpdate statusUpdate = o as IStatusUpdate;
                    if (statusUpdate != null)
                    {
                        statusUpdate.UpdateStatus();
                        statusUpdate.UpdateText();
                    }
                }
            }
            return(result);
        }
 public static void UpdateText(IEnumerable menuItems)
 {
     if (menuItems == null)
     {
         return;
     }
     foreach (object o in menuItems)
     {
         IStatusUpdate cmi = o as IStatusUpdate;
         if (cmi != null)
         {
             cmi.UpdateText();
         }
     }
 }