//[Route("CommandBar")]
        public CommandBarItemCollection Get()
        {
            var rnd = new Random();
            CommandBarItemCollection collection = new CommandBarItemCollection();

            collection.Key       = "1";
            collection.Name      = "CommandBar";
            collection.AriaLabel = "CommandBar";
            collection.Items     = Enumerable.Range(1, 10).Select(index => new CommandBarItem
            {
                Key          = rnd.Next().ToString(),
                Name         = $"Menu {rnd.Next().ToString()}",
                IconProps    = new IconProp().RandomIcon(),
                SubMenuProps = new CommandBarItemCollection()
                {
                    Items = Enumerable.Range(1, rnd.Next(0, 10)).Select(index => new CommandBarItem
                    {
                        Key       = rnd.Next().ToString(),
                        Name      = $"Sub menu {rnd.Next().ToString()}",
                        IconProps = new IconProp().RandomIcon()
                    })
                            .ToArray()
                }
            })
                                   .ToArray();

            return(collection);
        }
예제 #2
0
		public CommandBar()
		{
			this.items = new CommandBarItemCollection(this);
			this.SetStyle(ControlStyles.UserPaint, false);
			this.TabStop = false;
			this.Font = SystemInformation.MenuFont;
			this.Dock = DockStyle.Top;
		}	
예제 #3
0
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				this.items.Clear();
				this.items = null;

				this.contextMenu = null;
			}

			base.Dispose(disposing);
		}
예제 #4
0
        /// <summary>
        /// Add the contents of this MergableMenu to a CommandBarMenu
        /// </summary>
        /// <param name="menu"></param>
        public void Apply(CommandBarItemCollection items)
        {
            int lastGroup = -1;

            foreach (MergableItem item in List)
            {
                if (item.Group != lastGroup && lastGroup > -1)
                {
                    items.AddSeparator();
                }

                items.Add(item.Apply());
                lastGroup = item.Group;
            }
        }
예제 #5
0
        public void ReLoadMenuBarContents()
        {
#if Failed
            Assembly adaptorAssembly = GetAdapterAssembly();
            //add the menubar
            Control menubar;
#endif
            // reload information from the configuration file; its contents have probably changed
            XmlDocument configuration = XWindow.LoadConfigurationWithIncludes(ConfigurationFileFullPath);
            m_windowConfigurationNode = configuration.SelectSingleNode("window");



            CommandBar commandBar = (MenuAdapter as IUIMenuAdapter).GetMenuBar();
            CommandBarItemCollection currentMenuItems = commandBar.Items;
            int iCurrentMenuItem = 0;

            XmlNode menubar = configuration.SelectSingleNode("//menubar");
            foreach (XmlNode node in menubar)
            {
                if (node.LocalName == "menu")
                {
                    RenameMenuItems(configuration, node, currentMenuItems[iCurrentMenuItem]);
                    iCurrentMenuItem++;
                }
            }

#if Failed
            m_menusChoiceGroupCollection = MakeMajorUIPortion(
                adaptorAssembly,
                m_windowConfigurationNode,
                "menubar",
                "XCore.MenuAdapter",
                out menubar,
                out m_menuBarAdapter);

            if (menubar != null && menubar.Parent != null)
            {
                System.Windows.Forms.Control parent = menubar.Parent;
                if (parent.AccessibleName == null)
                {
                    parent.AccessibleName = "ParentOf" + menubar.AccessibleName;
                }
            }
            this.Menu = (m_menuBarAdapter as IUIMenuAdapter).GetMainMenu();
#endif
        }
        private static Size GetImageSize(CommandBarItemCollection items)
        {
            Size imageSize = new Size(16, 16);
            for (int i = 0; i < items.Count; i++)
            {
                Image image = items[i].Image;
                if (image != null)
                {
                    if (image.Width > imageSize.Width)
                    {
                        imageSize.Width = image.Width;
                    }

                    if (image.Height > imageSize.Height)
                    {
                        imageSize.Height = image.Height;
                    }
                }
            }

            return imageSize;
        }
예제 #7
0
        public void Show(Control control, Point point)
        {
            CommandBarItemCollection chevronItems = new CommandBarItemCollection();
            Size size = ClientSize;
            for (int i = 0; i < items.Count; i++)
            {
                NativeMethods.RECT rect = new NativeMethods.RECT();
                NativeMethods.SendMessage(Handle, NativeMethods.TB_GETITEMRECT, i, ref rect);
                if (rect.right > size.Width)
                {
                    CommandBarItem item = items[i];
                    if (item.Visible)
                    {
                        if ((!(item is CommandBarSeparator)) || (chevronItems.Count != 0))
                            chevronItems.Add(item);
                    }
                }
            }

            this.contextMenu.Mnemonics = false;
            this.contextMenu.Items.Clear();
            this.contextMenu.Items.AddRange(chevronItems);
            this.contextMenu.Show(control, point);
        }
예제 #8
0
		protected override void Dispose(bool disposing)
		{
			System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
			if (disposing)
			{
				IsDisposing = true;
				try
				{
					if (contextMenu != null)
						contextMenu.Dispose();

					if (items != null)
					{
						// Disposing the item might remove it from the collection, so we better work on
						// a copy of the collection.
						var copiedItems = new CommandBarItem[items.Count];
						items.CopyTo(copiedItems, 0);
						foreach (var item in copiedItems)
							item.Dispose();

						this.items.Clear();
					}
				}
				finally
				{
					IsDisposing = false;
				}
			}
			this.items = null;
			this.contextMenu = null;

			base.Dispose(disposing);
		}
예제 #9
0
        protected override void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            if (disposing)
            {
                this.items.Clear();
                this.items = null;

                this.contextMenu = null;
            }

            base.Dispose(disposing);
        }