Example #1
0
 private static void AddItems(CommandBarEntryCollection entries, object[] items)
 {
     foreach (object item in items)
     {
         if (item is string || item is CommandId)
         {
             string commandIdentifier = item.ToString();
             if (commandIdentifier == "-")
             {
                 entries.Add(new CommandBarSeparatorEntry());
             }
             else if (commandIdentifier == " ")
             {
                 entries.Add(new CommandBarSpacerEntry());
             }
             else
             {
                 CommandBarButtonEntry cbbe = new CommandBarButtonEntry();
                 cbbe.CommandIdentifier = commandIdentifier;
                 entries.Add(cbbe);
             }
         }
         else if (item is CommandBarEntry)
         {
             entries.Add((CommandBarEntry)item);
         }
         else
         {
             Trace.Fail("Unexpected command bar definition item");
             throw new ArgumentException("Unexpected command bar definition item");
         }
     }
 }
Example #2
0
 /// <summary>
 /// Adds the entries from the specified CommandBarEntryCollection to the end of this CommandBarEntryCollection.
 /// </summary>
 /// <param name="value">The CommandBarEntryCollection to be added to the end of this CommandBarEntryCollection.</param>
 public void AddRange(CommandBarEntryCollection value)
 {
     foreach (CommandBarEntry commandBarEntry in value)
     {
         Add(commandBarEntry);
     }
 }
 private void AddCommandBarEntries(CommandBarEntryCollection entries, ArrayList list, bool rightAligned)
 {
     foreach (CommandBarEntry entry in entries)
     {
         LightweightControl control = entry.GetLightweightControl(this, rightAligned);
         list.Add(control);
     }
 }
        /// <summary>
        /// Sets the specified array as the items of the collection.
        /// </summary>
        /// <param name="editValue">The collection to edit.</param>
        /// <param name="value">An array of objects to set as the collection items.</param>
        /// <returns>The newly created collection object or, otherwise, the collection indicated by the editValue parameter.</returns>
        protected override object SetItems(object editValue, object[] value)
        {
            CommandBarEntryCollection commandBarEntryCollection = (CommandBarEntryCollection)editValue;

            commandBarEntryCollection.Clear();
            foreach (CommandBarEntry commandBarEntry in value)
            {
                commandBarEntryCollection.Add(commandBarEntry);
            }
            return(commandBarEntryCollection);
        }
        /// <summary>
        /// Gets an array of objects containing the specified collection.
        /// </summary>
        /// <param name="editValue">The collection to edit.</param>
        /// <returns>An array containing the collection objects.</returns>
        protected override object[] GetItems(object editValue)
        {
            CommandBarEntryCollection commandBarEntryCollection = (CommandBarEntryCollection)editValue;

            CommandBarEntry[] commandBarEntries = new CommandBarEntry[commandBarEntryCollection.Count];
            if (commandBarEntryCollection.Count > 0)
            {
                commandBarEntryCollection.CopyTo(commandBarEntries, 0);
            }
            return(commandBarEntries);
        }
 /// <summary>
 /// Adds the entries from the specified CommandBarEntryCollection to the end of this CommandBarEntryCollection.
 /// </summary>
 /// <param name="value">The CommandBarEntryCollection to be added to the end of this CommandBarEntryCollection.</param>
 public void AddRange(CommandBarEntryCollection value)
 {
     foreach (CommandBarEntry commandBarEntry in value)
         Add(commandBarEntry);
 }
 /// <summary>
 /// Initializes a new instance of the CommandBarEntryCollection class.
 /// </summary>
 /// <param name="value">Command bar entry collection to initializes this command bar entry collection with.</param>
 public CommandBarEntryCollection(CommandBarEntryCollection value)
 {
     AddRange(value);
 }
 /// <summary>
 /// Initializes a new instance of the CommandBarEntryEnumerator class.
 /// </summary>
 /// <param name="mappings">The CommandBarEntryCollection to enumerate.</param>
 public CommandBarEntryEnumerator(CommandBarEntryCollection mappings)
 {
     temp = (IEnumerable)mappings;
     baseEnumerator = temp.GetEnumerator();
 }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the CommandBarEntryCollection class.
 /// </summary>
 /// <param name="value">Command bar entry collection to initializes this command bar entry collection with.</param>
 public CommandBarEntryCollection(CommandBarEntryCollection value)
 {
     AddRange(value);
 }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the CommandBarEntryEnumerator class.
 /// </summary>
 /// <param name="mappings">The CommandBarEntryCollection to enumerate.</param>
 public CommandBarEntryEnumerator(CommandBarEntryCollection mappings)
 {
     temp           = (IEnumerable)mappings;
     baseEnumerator = temp.GetEnumerator();
 }
 private void AddCommandBarEntries(CommandBarEntryCollection entries, ArrayList list, bool rightAligned)
 {
     foreach (CommandBarEntry entry in entries)
     {
         LightweightControl control = entry.GetLightweightControl(this, rightAligned);
         list.Add(control);
     }
 }
 private static void AddItems(CommandBarEntryCollection entries, object[] items)
 {
     foreach (object item in items)
     {
         if (item is string || item is CommandId)
         {
             string commandIdentifier = item.ToString();
             if (commandIdentifier == "-")
             {
                 entries.Add(new CommandBarSeparatorEntry());
             }
             else if (commandIdentifier == " ")
             {
                 entries.Add(new CommandBarSpacerEntry());
             }
             else
             {
                 CommandBarButtonEntry cbbe = new CommandBarButtonEntry();
                 cbbe.CommandIdentifier = commandIdentifier;
                 entries.Add(cbbe);
             }
         }
         else if (item is CommandBarEntry)
         {
             entries.Add((CommandBarEntry)item);
         }
         else
         {
             Trace.Fail("Unexpected command bar definition item");
             throw new ArgumentException("Unexpected command bar definition item");
         }
     }
 }