Beispiel #1
0
        private static void BuildParts(IUIElementAdapter parent,
                                       IEnumerable <MenuItemDescriptor> descriptors,
                                       string addInTreePath,
                                       ICommandRegister register)
        {
            //try
            //{
            descriptors = descriptors.OrderBy(c => c.OrderNumber);
            foreach (MenuItemDescriptor descriptor in descriptors)
            {
                //System.Diagnostics.Debug.WriteLine(descriptor.Codon.ToString());
                object uiElement = CreateMenuItemFromDescriptor(descriptor, addInTreePath, register);

                object uiElementCreated = parent.Add(uiElement);
                InitializeUIElement(descriptor, uiElementCreated);
                var children = descriptor.SubItems;
                if (children != null)
                {
                    var subDescriptors = children.Cast <MenuItemDescriptor>();
                    if (!subDescriptors.Any())
                    {
                        continue;
                    }
                    var uiElementAapter = GetUIElementAdapter(uiElement);
                    BuildParts(uiElementAapter, subDescriptors, addInTreePath + "/" + descriptor.Codon.Id, register);
                }
            }
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
Beispiel #2
0
        public void FactoryCreatesCorrectAdapterForMenuStrip()
        {
            ToolStripUIAdapterFactory factory = new ToolStripUIAdapterFactory();
            IUIElementAdapter         adapter = factory.GetAdapter(new MenuStrip());

            Assert.IsTrue(adapter is ToolStripItemCollectionUIAdapter);
        }
Beispiel #3
0
        private static IUIElementAdapter GetUIElementAdapter(object element)
        {
            var factoryCatalog = IoC.Get <IUIElementAdapterFactoryCatalog>();
            IUIElementAdapterFactory factory = factoryCatalog.GetFactory(element);
            IUIElementAdapter        adapter = factory.GetAdapter(element);

            return(adapter);
        }
Beispiel #4
0
        public void FactoryCreatesCorrectAdapterForToolStripMenuItem()
        {
            ToolStripUIAdapterFactory factory = new ToolStripUIAdapterFactory();
            ToolStrip         strip           = new ToolStrip();
            ToolStripMenuItem item            = new ToolStripMenuItem();

            strip.Items.Add(item);
            IUIElementAdapter adapter = factory.GetAdapter(item);

            Assert.IsTrue(adapter is ToolStripItemOwnerCollectionUIAdapter);
        }
        /// <summary>
        /// Registers a site for the given UI element by asking the adapter factory to
        /// automatically allocate an adapter based on the element type.
        /// </summary>
        /// <param name="siteName">The site name to register.</param>
        /// <param name="uiElement">The UI element.</param>
        public void RegisterSite(string siteName, object uiElement)
        {
            Guard.ArgumentNotNullOrEmptyString(siteName, "siteName");
            Guard.ArgumentNotNull(uiElement, "uiElement");

            IUIElementAdapterFactory factory = FactoryCatalog.GetFactory(uiElement);
            IUIElementAdapter        adapter = factory.GetAdapter(uiElement);

            createdAdapters.Add(adapter);
            RegisterSite(siteName, adapter);
        }
        /// <summary>
        /// Registers a site using the given adapter.
        /// </summary>
        /// <param name="siteName">The site name to register.</param>
        /// <param name="adapter">The UI element adapter for the site.</param>
        public void RegisterSite(string siteName, IUIElementAdapter adapter)
        {
            Guard.ArgumentNotNullOrEmptyString(siteName, "siteName");
            Guard.ArgumentNotNull(adapter, "adapter");

            if (Contains(siteName))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                                                          Properties.Resources.DuplicateUIExtensionSite, siteName), "siteName");
            }

            sites.Add(siteName, new UIExtensionSite(adapter));
        }
 private static void BuildParts(IUIElementAdapter parent, IEnumerable <NavItemDescriptor> descriptors)
 {
     foreach (NavItemDescriptor descriptor in descriptors)
     {
         object uiElement = CreateMenuItemFromDescriptor(descriptor);
         parent.Add(uiElement);
         var children = descriptor.SubItems;
         if (children != null)
         {
             var subDescriptors = children.Cast <NavItemDescriptor>();
             if (!subDescriptors.Any())
             {
                 continue;
             }
             var uiElementAapter = GetUIElementAdapter(uiElement);
             BuildParts(uiElementAapter, subDescriptors);
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UIExtensionSite"/> class with the provided
 /// adapter.
 /// </summary>
 public UIExtensionSite(IUIElementAdapter adapter)
 {
     this.adapter = adapter;
 }