Ejemplo n.º 1
0
        public CommandBarMenu AddMenu(string text, EventHandler dropDownHandler)
        {
            CommandBarMenu menu = this.AddMenu(text);

            menu.DropDown += dropDownHandler;
            return(menu);
        }
Ejemplo n.º 2
0
        public CommandBarMenu AddMenu(Image image, string text)
        {
            CommandBarMenu menu = this.AddMenu(text);

            menu.Image = image;
            return(menu);
        }
Ejemplo n.º 3
0
        public CommandBarMenu AddMenu(string text)
        {
            CommandBarMenu menu = new CommandBarMenu(text);

            this.Add(menu);
            return(menu);
        }
Ejemplo n.º 4
0
        // TODO
        internal CommandBarItem[] this[Keys shortcut]
        {
            get
            {
                ArrayList list = new ArrayList();

                foreach (CommandBarItem item in items)
                {
                    CommandBarButtonBase buttonBase = item as CommandBarButtonBase;
                    if (buttonBase != null)
                    {
                        if ((buttonBase.Shortcut == shortcut) && (buttonBase.Enabled) && (buttonBase.Visible))
                        {
                            list.Add(buttonBase);
                        }
                    }
                }

                foreach (CommandBarItem item in items)
                {
                    CommandBarMenu menu = item as CommandBarMenu;
                    if (menu != null)
                    {
                        list.AddRange(menu.Items[shortcut]);
                    }
                }

                CommandBarItem[] array = new CommandBarItem[list.Count];
                list.CopyTo(array, 0);
                return(array);
            }
        }
Ejemplo n.º 5
0
            protected override void OnPopup(EventArgs e)
            {
                CommandBarMenu menu = this.item as CommandBarMenu;

                if (menu != null)
                {
                    menu.PerformDropDown(EventArgs.Empty);
                }

                base.OnPopup(e);
                this.UpdateItems();
            }
Ejemplo n.º 6
0
        /**
         * Gets a menu by name
         */
        public CommandBarMenu GetCommandBarMenu(string name)
        {
            int count = this.xmlBuilder.Menus.Count;

            for (int i = 0; i < count; i++)
            {
                CommandBarMenu menu = (CommandBarMenu)this.xmlBuilder.Menus[i];
                if (menu.Name == name)
                {
                    return(menu);
                }
            }
            return(null);
        }
Ejemplo n.º 7
0
            private void UpdateItems()
            {
                this.OwnerDraw = true;

                CommandBarSeparator separator = this.item as CommandBarSeparator;

                if (separator != null)
                {
                    this.Text = "-";
                }
                else
                {
                    if (this.item.Text != null)
                    {
                        this.Text = (this.mnemonics) ? this.item.Text : this.item.Text.Replace("&", "");
                    }
                    else
                    {
                        this.Text = "";
                    }
                }

                CommandBarMenu menu = this.item as CommandBarMenu;

                if (menu != null)
                {
                    this.MenuItems.Clear();

                    Size imageSize = GetImageSize(menu.Items);

                    int visibleItemCount = 0;
                    foreach (CommandBarItem item in menu.Items)
                    {
                        this.MenuItems.Add(new MenuBarItem(item, imageSize, font, mnemonics));
                        visibleItemCount += (item.IsVisible) ? 1 : 0;
                    }

                    this.Enabled = (visibleItemCount == 0) ? false : this.item.IsEnabled;
                }
                else
                {
                    this.Enabled = this.item.IsEnabled;
                }

                this.Visible = this.item.IsVisible;
            }
Ejemplo n.º 8
0
		public ProjectContextMenu(FDMenus menus)
		{
			this.menus = menus;

			AddNewClass = CreateButton("New &Class..",Icons.ActionScript.Img);
			AddNewXml = CreateButton("New &Xml File..",Icons.XmlFile.Img);
			AddNewFile = CreateButton("New &File..",Icons.AddFile.Img);
			AddNewFolder = CreateButton("New F&older",Icons.Folder.Img);
			AddLibraryAsset = CreateButton("Library &Asset..",Icons.ImageResource.Img);
			AddExistingFile = CreateButton("&Existing File..",Icons.HiddenFile.Img);
			Open = CreateButton("&Open",Icons.OpenFile.Img);
			Insert = CreateButton("&Insert Into Document",Icons.EditFile.Img);
			Execute = CreateButton("&Execute");
			Cut = CreateButton("Cu&t",Icons.Cut.Img);
			Copy = CreateButton("Cop&y");
			Paste = CreateButton("&Paste",Icons.Paste.Img);
			Delete = CreateButton("&Delete",Icons.Delete.Img);
			Rename = CreateButton("Rena&me");
			AlwaysCompile = new CommandBarCheckBox("Always &Compile");
			AddLibrary = new CommandBarCheckBox("Add to &Library");
			LibraryOptions = CreateButton("&Options...",Icons.Options.Img);
			Hide = new CommandBarCheckBox("&Hide File");
			ShowHidden = new CommandBarCheckBox(Icons.HiddenFile.Img,"&Show Hidden Items");
			NothingToDo = new CommandBarButton("Not a valid group");
			NothingToDo.IsEnabled = false;
			NoProjectOutput = new CommandBarButton("(Project output not built)");
			NoProjectOutput.IsEnabled = false;

			AddMenu = new CommandBarMenu("&Add");
			AddMenu.Items.Add(AddNewClass);
			AddMenu.Items.Add(AddNewXml);
			AddMenu.Items.Add(AddNewFile);
			AddMenu.Items.Add(AddNewFolder);
			AddMenu.Items.AddSeparator();
			AddMenu.Items.Add(AddLibraryAsset);
			AddMenu.Items.Add(AddExistingFile);
		}
Ejemplo n.º 9
0
		/**
		* Creates a menu from the specified xml node
		*/
		public CommandBarMenu GetMenu(XmlNode node)
		{
			CommandBarMenu menu = new CommandBarMenu();
			if (this.HasAttribute(node, "label"))
			{
				menu.Text = this.GetAttribute(node, "label");
			}
			if (this.HasAttribute(node, "image"))
			{
				string image = this.GetAttribute(node, "image");
				menu.Image = this.Images.GetImage(Convert.ToInt32(image));
			}
			if (this.HasAttribute(node, "name"))
			{
				string name = this.GetAttribute(node, "name");
				menu.Name = name;
			}
			if (this.HasAttribute(node, "enabled"))
			{
				string enabled = this.GetAttribute(node, "enabled");
				menu.IsEnabled = Convert.ToBoolean(enabled);
			}
			if (this.HasAttribute(node, "visible"))
			{
				string visible = this.GetAttribute(node, "visible");
				menu.IsVisible = Convert.ToBoolean(visible);
			}
			if(this.HasAttribute(node, "dropdown"))
			{
				string dropDown = this.GetAttribute(node, "dropdown");
				menu.DropDown += this.ToClickHandler(dropDown);
			}
			if (this.HasAttribute(node, "propertychanged"))
			{
				string propertyChanged = this.GetAttribute(node, "propertychanged");
				menu.PropertyChanged += this.ToChangedHandler(propertyChanged);
			}
			if (this.HasAttribute(node, "tag"))
			{
				string tag = this.GetAttribute(node, "tag");
				menu.Tag = tag;
			}
			int count = node.ChildNodes.Count;
			for (int i = 0; i<count; i++)
			{
				if (node.ChildNodes[i].Name == "menu")
				{
					ArrayList menuItem = new ArrayList();
					menuItem.Add(this.GetMenu(node.ChildNodes[i]));
					menu.Items.AddRange(menuItem);
				}
				if (node.ChildNodes[i].Name == "button")
				{
					menu.Items.Add(this.GetButton(node.ChildNodes[i]));
				}
				if (node.ChildNodes[i].Name == "checkbox")
				{
					menu.Items.Add(this.GetCheckBox(node.ChildNodes[i]));
				}
				if (node.ChildNodes[i].Name == "separator")
				{
					menu.Items.AddSeparator();
				}
			}
			this.Items.Add(menu);
			this.Menus.Add(menu);
			return menu;
		}
Ejemplo n.º 10
0
        private NativeMethods.TBBUTTONINFO GetButtonInfo(int index)
        {
            CommandBarItem item = items[index];

            NativeMethods.TBBUTTONINFO buttonInfo = new NativeMethods.TBBUTTONINFO();
            buttonInfo.cbSize = Marshal.SizeOf(typeof(NativeMethods.TBBUTTONINFO));

            buttonInfo.dwMask    = NativeMethods.TBIF_IMAGE | NativeMethods.TBIF_STATE | NativeMethods.TBIF_STYLE | NativeMethods.TBIF_COMMAND;
            buttonInfo.idCommand = index;
            buttonInfo.iImage    = NativeMethods.I_IMAGECALLBACK;
            buttonInfo.fsStyle   = NativeMethods.BTNS_BUTTON | NativeMethods.BTNS_AUTOSIZE;
            buttonInfo.fsState   = 0;
            buttonInfo.cx        = 0;
            buttonInfo.lParam    = IntPtr.Zero;
            buttonInfo.pszText   = IntPtr.Zero;
            buttonInfo.cchText   = 0;

            if (!item.Visible)
            {
                buttonInfo.fsState |= NativeMethods.TBSTATE_HIDDEN;
            }

            CommandBarComboBox comboBox = item as CommandBarComboBox;

            if (comboBox != null)
            {
                buttonInfo.cx     = (short)(comboBox.Width + 4);
                buttonInfo.dwMask = NativeMethods.TBIF_SIZE;
            }

            if (item is CommandBarSeparator)
            {
                buttonInfo.fsStyle |= NativeMethods.BTNS_SEP;
            }
            else
            {
                if (item.Enabled)
                {
                    buttonInfo.fsState |= NativeMethods.TBSTATE_ENABLED;
                }

                CommandBarMenu menu = item as CommandBarMenu;
                if ((menu != null) && (menu.Items.Count > 0))
                {
                    buttonInfo.fsStyle |= NativeMethods.BTNS_DROPDOWN;
                }

                if (style == CommandBarStyle.ToolBar)
                {
                    if (item is CommandBarMenu)
                    {
                        buttonInfo.fsStyle |= NativeMethods.BTNS_WHOLEDROPDOWN;
                    }
                }

                CommandBarCheckBox checkBox = item as CommandBarCheckBox;
                if ((checkBox != null) && (checkBox.IsChecked))
                {
                    buttonInfo.fsState |= NativeMethods.TBSTATE_CHECKED;
                }
            }

            if (item is CommandBarSeparator)
            {
                buttonInfo.iImage = NativeMethods.I_IMAGENONE;
            }
            else if (item.Image != null)
            {
                buttonInfo.iImage = index;
            }

            if ((this.Style == CommandBarStyle.Menu) && (item.Text != null) && (item.Text.Length != 0))
            {
                buttonInfo.dwMask |= NativeMethods.TBIF_TEXT;
                buttonInfo.pszText = Marshal.StringToHGlobalUni(item.Text + "\0");
                buttonInfo.cchText = item.Text.Length;
            }

            return(buttonInfo);
        }
Ejemplo n.º 11
0
        private void TrackDropDown(int index)
        {
            while (index >= 0)
            {
                this.trackNextItem = -1;

                this.BeginUpdate();

                CommandBarMenu menu = this.items[index] as CommandBarMenu;
                if (menu != null)
                {
                    menu.PerformDropDown(EventArgs.Empty);
                    this.contextMenu.Items.Clear();
                    this.contextMenu.Items.AddRange(menu.Items);                     // = menu.Items;
                    this.contextMenu.Mnemonics = true;
                }
                else
                {
                    this.contextMenu.Items.Clear();                     // .Items = new CommandBarItemCollection();
                    this.contextMenu.Mnemonics = true;
                }

                // Item state
                NativeMethods.SendMessage(this.Handle, NativeMethods.TB_PRESSBUTTON, index, -1);

                // Trick to get the first menu item selected
                NativeMethods.PostMessage(this.Handle, NativeMethods.WM_KEYDOWN, (int)Keys.Down, 1);
                NativeMethods.PostMessage(this.Handle, NativeMethods.WM_KEYUP, (int)Keys.Down, 1);

                this.SetState(State.HotTracking, index);

                // Hook
                NativeMethods.HookProc hookProc = new NativeMethods.HookProc(DropDownHook);
                GCHandle hookProcHandle         = GCHandle.Alloc(hookProc);
                this.hookHandle = NativeMethods.SetWindowsHookEx(NativeMethods.WH_MSGFILTER, hookProc, IntPtr.Zero, NativeMethods.GetCurrentThreadId());
                if (this.hookHandle == IntPtr.Zero)
                {
                    throw new SecurityException();
                }

                // Ask for position
                NativeMethods.RECT rect = new NativeMethods.RECT();
                NativeMethods.SendMessage(Handle, NativeMethods.TB_GETRECT, index, ref rect);
                Point position = new Point(rect.left, rect.bottom);

                this.EndUpdate();
                this.Update();

                this.contextMenu.Show(this, position);

                // Unhook
                NativeMethods.UnhookWindowsHookEx(hookHandle);
                hookProcHandle.Free();
                this.hookHandle = IntPtr.Zero;

                // Item state
                NativeMethods.SendMessage(Handle, NativeMethods.TB_PRESSBUTTON, index, 0);
                this.SetState(trackEscapePressed ? State.Hot : State.None, index);

                index = trackNextItem;
            }
        }
Ejemplo n.º 12
0
 public CommandBarMenu AddMenu(string text)
 {
     CommandBarMenu menu = new CommandBarMenu(text);
     this.Add(menu);
     return menu;
 }
Ejemplo n.º 13
0
        /**
         * Creates a menu from the specified xml node
         */
        public CommandBarMenu GetMenu(XmlNode node)
        {
            CommandBarMenu menu = new CommandBarMenu();

            if (this.HasAttribute(node, "label"))
            {
                menu.Text = this.GetAttribute(node, "label");
            }
            if (this.HasAttribute(node, "image"))
            {
                string image = this.GetAttribute(node, "image");
                menu.Image = this.Images.GetImage(Convert.ToInt32(image));
            }
            if (this.HasAttribute(node, "name"))
            {
                string name = this.GetAttribute(node, "name");
                menu.Name = name;
            }
            if (this.HasAttribute(node, "enabled"))
            {
                string enabled = this.GetAttribute(node, "enabled");
                menu.IsEnabled = Convert.ToBoolean(enabled);
            }
            if (this.HasAttribute(node, "visible"))
            {
                string visible = this.GetAttribute(node, "visible");
                menu.IsVisible = Convert.ToBoolean(visible);
            }
            if (this.HasAttribute(node, "dropdown"))
            {
                string dropDown = this.GetAttribute(node, "dropdown");
                menu.DropDown += this.ToClickHandler(dropDown);
            }
            if (this.HasAttribute(node, "propertychanged"))
            {
                string propertyChanged = this.GetAttribute(node, "propertychanged");
                menu.PropertyChanged += this.ToChangedHandler(propertyChanged);
            }
            if (this.HasAttribute(node, "tag"))
            {
                string tag = this.GetAttribute(node, "tag");
                menu.Tag = tag;
            }
            int count = node.ChildNodes.Count;

            for (int i = 0; i < count; i++)
            {
                if (node.ChildNodes[i].Name == "menu")
                {
                    ArrayList menuItem = new ArrayList();
                    menuItem.Add(this.GetMenu(node.ChildNodes[i]));
                    menu.Items.AddRange(menuItem);
                }
                if (node.ChildNodes[i].Name == "button")
                {
                    menu.Items.Add(this.GetButton(node.ChildNodes[i]));
                }
                if (node.ChildNodes[i].Name == "checkbox")
                {
                    menu.Items.Add(this.GetCheckBox(node.ChildNodes[i]));
                }
                if (node.ChildNodes[i].Name == "separator")
                {
                    menu.Items.AddSeparator();
                }
            }
            this.Items.Add(menu);
            this.Menus.Add(menu);
            return(menu);
        }