Esempio n. 1
0
        /// <summary>
        /// This will add a new item that will appear on the standard toolbar or ribbon control.
        /// </summary>
        /// <remarks>Should only be called by the plugin (from the plugin assembly).</remarks>
        public virtual void Add(HeaderItem item)
        {
            Contract.Requires(item != null, "item is null.");

            HeaderItemDesc hid;
            if (_items.TryGetValue(item.Key, out hid))
            {
                throw new ArgumentException(String.Format("The key \"{0}\" was already added by {1}. The key may only be used by one HeaderItem.", item.Key, hid.AssemblyName));
            }

            // We don't add the root items to this list. The HeaderControl implementation should remove a root
            // automatically when all item in the root are removed.
            if (item is RootItem == false)
            {
                string assemblyName = Assembly.GetCallingAssembly().FullName;
                RecordItemAdd(item, assemblyName);
            }

            // Bypass static type checking until runtime.
            dynamic test = item;
            // The correct overload of Add will be called below as the specifc type of item is determined at runtime.
            // See http://msdn.microsoft.com/en-us/library/dd264736.aspx
            Add(test);
        }
Esempio n. 2
0
 public HeaderItemDesc(HeaderItem headerItem, string assemblyName)
 {
     HeaderItem = headerItem;
     AssemblyName = assemblyName;
 }
Esempio n. 3
0
 public HeaderItemDesc(HeaderItem headerItem, string assemblyName)
 {
     HeaderItem   = headerItem;
     AssemblyName = assemblyName;
 }
Esempio n. 4
0
        /// <summary>
        /// Adds the item to dictionary so that it can be removed later.
        /// </summary>
        /// <param name="item">Item to add.</param>
        /// <param name="assemblyFullName">Full name of the assembly.</param>
        protected void RecordItemAdd(HeaderItem item, string assemblyFullName)
        {
            Contract.Requires(!String.IsNullOrEmpty(assemblyFullName), "assemblyFullName is null or empty.");
            Contract.Requires(!String.IsNullOrEmpty(item.Key), "key is null or empty.");

            _items.Add(item.Key, new HeaderItemDesc(item, assemblyFullName));
        }
Esempio n. 5
0
 public void Add(HeaderItem item)
 {
     _menuBar.Add(item);
 }