Пример #1
0
        public CommandBarCheckBox AddCheckBox(Image image, string text)
        {
            CommandBarCheckBox checkBox = this.AddCheckBox(text);

            checkBox.Image = image;
            return(checkBox);
        }
Пример #2
0
        public CommandBarCheckBox AddCheckBox(string text, Keys shortcut)
        {
            CommandBarCheckBox checkBox = this.AddCheckBox(text);

            checkBox.Shortcut = shortcut;
            return(checkBox);
        }
Пример #3
0
        public CommandBarCheckBox AddCheckBox(string text)
        {
            CommandBarCheckBox checkBox = new CommandBarCheckBox(text);

            this.Add(checkBox);
            return(checkBox);
        }
Пример #4
0
        /**
         * Creates a checkbox from the specified xml node
         */
        public CommandBarCheckBox GetCheckBox(XmlNode node)
        {
            CommandBarCheckBox checkBox = new CommandBarCheckBox();

            if (this.HasAttribute(node, "label"))
            {
                checkBox.Text = this.GetAttribute(node, "label");
            }
            if (this.HasAttribute(node, "click"))
            {
                string handler = this.GetAttribute(node, "click");
                checkBox.Click += this.ToClickHandler(handler);
            }
            if (this.HasAttribute(node, "image"))
            {
                string image = this.GetAttribute(node, "image");
                checkBox.Image = this.Images.GetImage(Convert.ToInt16(image));
            }
            if (this.HasAttribute(node, "name"))
            {
                string name = this.GetAttribute(node, "name");
                checkBox.Name = name;
            }
            if (this.HasAttribute(node, "enabled"))
            {
                string enabled = this.GetAttribute(node, "enabled");
                checkBox.IsEnabled = Convert.ToBoolean(enabled);
            }
            if (this.HasAttribute(node, "visible"))
            {
                string visible = this.GetAttribute(node, "visible");
                checkBox.IsVisible = Convert.ToBoolean(visible);
            }
            if (this.HasAttribute(node, "tag"))
            {
                string tag = this.GetAttribute(node, "tag");
                checkBox.Tag = tag;
            }
            if (this.HasAttribute(node, "propertychanged"))
            {
                string propertyChanged = this.GetAttribute(node, "propertychanged");
                checkBox.PropertyChanged += this.ToChangedHandler(propertyChanged);
            }
            if (this.HasAttribute(node, "shortcut"))
            {
                string shortcut = this.GetAttribute(node, "shortcut");
                checkBox.Shortcut = this.ToShortcut(shortcut);
            }
            if (this.HasAttribute(node, "checked"))
            {
                string checkd = this.GetAttribute(node, "checked");
                checkBox.IsChecked = Convert.ToBoolean(checkd);
            }
            this.Items.Add(checkBox);
            this.CheckBoxes.Add(checkBox);
            return(checkBox);
        }
Пример #5
0
        /**
         * Gets a checkbox by name
         */
        public CommandBarCheckBox GetCommandBarCheckBox(string name)
        {
            int count = this.xmlBuilder.CheckBoxes.Count;

            for (int i = 0; i < count; i++)
            {
                CommandBarCheckBox checkBox = (CommandBarCheckBox)this.xmlBuilder.CheckBoxes[i];
                if (checkBox.Name == name)
                {
                    return(checkBox);
                }
            }
            return(null);
        }
Пример #6
0
		public TreeBar(FDMenus menus, ProjectContextMenu treeMenu)
		{
			this.menus = menus;
			this.treeMenu = treeMenu;

			Refresh = new CommandBarButton("Refresh");
			Refresh.Image = Icons.Refresh.Img;

			EnableTrace = new CommandBarCheckBox(Icons.Debug.Img,"Enable Trace");

			Items.Add(treeMenu.ShowHidden);
			Items.Add(Refresh);
			Items.Add(new CommandBarSeparator());
			Items.Add(menus.ProjectMenu.Properties);
			Items.Add(new CommandBarSeparator());
			Items.Add(EnableTrace);
		}
Пример #7
0
        private void NotifyCustomDrawToolBar(ref Message m)
        {
            m.Result = (IntPtr)NativeMethods.CDRF_DODEFAULT;

            NativeMethods.DLLVERSIONINFO dvi = new NativeMethods.DLLVERSIONINFO();
            dvi.cbSize = Marshal.SizeOf(typeof(NativeMethods.DLLVERSIONINFO));
            NativeMethods.DllGetVersion(ref dvi);
            if (dvi.dwMajorVersion < 6)
            {
                NativeMethods.LPNMTBCUSTOMDRAW tbcd = (NativeMethods.LPNMTBCUSTOMDRAW)m.GetLParam(typeof(NativeMethods.LPNMTBCUSTOMDRAW));
                NativeMethods.RECT             rc   = tbcd.nmcd.rc;

                Rectangle rectangle = new Rectangle(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);

                Graphics       graphics = Graphics.FromHdc(tbcd.nmcd.hdc);
                CommandBarItem item     = items[tbcd.nmcd.dwItemSpec];

                bool hot      = ((tbcd.nmcd.uItemState & NativeMethods.CDIS_HOT) != 0);
                bool selected = ((tbcd.nmcd.uItemState & NativeMethods.CDIS_SELECTED) != 0);
                bool disabled = ((tbcd.nmcd.uItemState & NativeMethods.CDIS_DISABLED) != 0);

                CommandBarCheckBox checkBox = item as CommandBarCheckBox;
                if ((checkBox != null) && (checkBox.IsChecked))
                {
                    ControlPaint.DrawBorder3D(graphics, rectangle, Border3DStyle.SunkenOuter);
                }
                else if (selected)
                {
                    ControlPaint.DrawBorder3D(graphics, rectangle, Border3DStyle.SunkenOuter);
                }
                else if (hot)
                {
                    ControlPaint.DrawBorder3D(graphics, rectangle, Border3DStyle.RaisedInner);
                }

                Image image = item.Image;
                if (image != null)
                {
                    Size  size  = image.Size;
                    Point point = new Point(rc.left + ((rc.right - rc.left - size.Width) / 2), rc.top + ((rc.bottom - rc.top - size.Height) / 2));
                    NativeMethods.DrawImage(graphics, image, point, disabled);
                }

                m.Result = (IntPtr)NativeMethods.CDRF_SKIPDEFAULT;
            }
        }
Пример #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);
		}
Пример #9
0
		/**
		* Creates a checkbox from the specified xml node
		*/
		public CommandBarCheckBox GetCheckBox(XmlNode node)
		{
			CommandBarCheckBox checkBox = new CommandBarCheckBox();
			if (this.HasAttribute(node, "label"))
			{
				checkBox.Text = this.GetAttribute(node, "label");
			}
			if (this.HasAttribute(node, "click"))
			{
				string handler = this.GetAttribute(node, "click");
				checkBox.Click += this.ToClickHandler(handler);
			}
			if (this.HasAttribute(node, "image"))
			{
				string image = this.GetAttribute(node, "image");
				checkBox.Image = this.Images.GetImage(Convert.ToInt16(image));
			}
			if (this.HasAttribute(node, "name"))
			{
				string name = this.GetAttribute(node, "name");
				checkBox.Name = name;
			}
			if (this.HasAttribute(node, "enabled"))
			{
				string enabled = this.GetAttribute(node, "enabled");
				checkBox.IsEnabled = Convert.ToBoolean(enabled);
			}
			if (this.HasAttribute(node, "visible"))
			{
				string visible = this.GetAttribute(node, "visible");
				checkBox.IsVisible = Convert.ToBoolean(visible);
			}
			if (this.HasAttribute(node, "tag"))
			{
				string tag = this.GetAttribute(node, "tag");
				checkBox.Tag = tag;
			}
			if (this.HasAttribute(node, "propertychanged"))
			{
				string propertyChanged = this.GetAttribute(node, "propertychanged");
				checkBox.PropertyChanged += this.ToChangedHandler(propertyChanged);
			}
			if(this.HasAttribute(node, "shortcut"))
			{
				string shortcut = this.GetAttribute(node, "shortcut");
				checkBox.Shortcut = this.ToShortcut(shortcut);
			}
			if (this.HasAttribute(node, "checked"))
			{
				string checkd = this.GetAttribute(node, "checked");
				checkBox.IsChecked = Convert.ToBoolean(checkd);
			}
			this.Items.Add(checkBox);
			this.CheckBoxes.Add(checkBox);
			return checkBox;
		}
Пример #10
0
            private void DrawImage(Graphics graphics, Rectangle bounds, bool selected, bool disabled)
            {
                Rectangle rectangle = new Rectangle(bounds.X, bounds.Y, imageSize.Width + 6, bounds.Height);

                Size      checkSize      = SystemInformation.MenuCheckSize;
                Rectangle checkRectangle = new Rectangle(bounds.X + 1 + ((imageSize.Width + 6 - checkSize.Width) / 2), bounds.Y + ((bounds.Height - checkSize.Height) / 2), checkSize.Width, checkSize.Height);

                CommandBarCheckBox checkBox = item as CommandBarCheckBox;

                if (this.IsFlatMenu)
                {
                    DrawBackground(graphics, rectangle, selected);

                    if ((checkBox != null) && (checkBox.IsChecked))
                    {
                        int height = bounds.Height - 2;
                        graphics.DrawRectangle(SystemPens.Highlight, new Rectangle(bounds.X + 1, bounds.Y + 1, imageSize.Width + 3, height - 1));
                        graphics.FillRectangle(SystemBrushes.Menu, new Rectangle(bounds.X + 2, bounds.Y + 2, imageSize.Width + 2, height - 2));
                    }

                    Image image = item.Image;
                    if (image != null)
                    {
                        Point point = new Point(bounds.X + 3, bounds.Y + ((bounds.Height - image.Height) / 2));
                        NativeMethods.DrawImage(graphics, image, point, disabled);
                    }
                    else
                    {
                        if ((checkBox != null) && (checkBox.IsChecked))
                        {
                            Color color = (disabled ? SystemColors.GrayText : SystemColors.MenuText);
                            this.DrawCheck(graphics, checkRectangle, color);
                        }
                    }
                }
                else
                {
                    Image image = item.Image;
                    if (image == null)
                    {
                        this.DrawBackground(graphics, rectangle, selected);

                        if ((checkBox != null) && (checkBox.IsChecked))
                        {
                            Color color = (disabled ? (selected ? SystemColors.GrayText : SystemColors.ControlDark) : (selected ? SystemColors.HighlightText : SystemColors.MenuText));
                            this.DrawCheck(graphics, checkRectangle, color);
                        }
                    }
                    else
                    {
                        DrawBackground(graphics, rectangle, false);
                        if ((checkBox != null) && (checkBox.IsChecked))
                        {
                            ControlPaint.DrawBorder3D(graphics, rectangle, Border3DStyle.SunkenOuter);
                        }
                        else if (selected)
                        {
                            ControlPaint.DrawBorder3D(graphics, rectangle, Border3DStyle.RaisedInner);
                        }

                        Point point = new Point(bounds.X + 3, bounds.Y + ((bounds.Height - image.Height) / 2));
                        NativeMethods.DrawImage(graphics, image, point, disabled);
                    }
                }
            }
Пример #11
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);
        }
Пример #12
0
 public CommandBarCheckBox AddCheckBox(string text)
 {
     CommandBarCheckBox checkBox = new CommandBarCheckBox(text);
     this.Add(checkBox);
     return checkBox;
 }