Beispiel #1
0
        public CommandBarItem Apply()
        {
            Item.IsEnabled = true;
            CommandBarCheckBox box = Item as CommandBarCheckBox;

            if (box != null)
            {
                box.IsChecked = Checked;
            }
            return(Item);
        }
        protected CommandBarItem CreateMenuItem(ChoiceBase choice)
        {
            //note that we could handle the details of display in two different ways.
            //either we can leave this up to the normal display mechanism, which will do its own polling,
            //or we could just build the menu in the desired state right here (enable checked etc.)

            UIItemDisplayProperties display = choice.GetDisplayProperties();

            string label          = display.Text;
            bool   isSeparatorBar = (label == "-");

            label = label.Replace("_", "&");
            Image image = null;

            if (display.ImageLabel != "default")
            {
                image = m_smallImages.GetImage(display.ImageLabel);
            }
            CommandBarItem menuItem;

            if (choice is CommandChoice)
            {
                if (isSeparatorBar)
                {
                    menuItem = new CommandBarSeparator();
                }
                else
                {
                    menuItem = new CommandBarButton(image, label, new EventHandler(OnClick));
                }
            }
            else
            {
                CommandBarCheckBox cb = new CommandBarCheckBox(image, label);
                cb.Click    += new System.EventHandler(choice.OnClick);
                cb.IsChecked = display.Checked;
                menuItem     = cb;
            }
            if (!isSeparatorBar)
            {
                ((CommandBarButtonBase)menuItem).Shortcut = choice.Shortcut;
            }

            menuItem.Tag           = choice;
            menuItem.IsEnabled     = !isSeparatorBar && display.Enabled;
            menuItem.IsVisible     = display.Visible;
            choice.ReferenceWidget = menuItem;
            return(menuItem);
        }
        private void SChk_Click(object sender, EventArgs e)
        {
//			if (richTextBox1.SelectionFont == null)
//				return;
            CommandBarCheckBox GButton = sender as CommandBarCheckBox;

            if (GButton.IsChecked)
            {
                ApplyStyle(FontStyle.Underline);
            }
            else
            {
                RemoveStyle(FontStyle.Underline);
            }
        }
        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);
        }
Beispiel #5
0
        private CommandState GetCommandState(string commandName, CommandBarControl control)
        {
            foreach (CommandState commandState in this.states)
            {
                if (commandName == commandState.CommandName)
                {
                    return(commandState);
                }
            }

            CommandBarButton button = control as CommandBarButton;

            if (button != null)
            {
                CommandButtonState commandState = new CommandButtonState(commandName);
                this.states.Add(commandState);
                return(commandState);
            }

            CommandBarCheckBox checkBox = control as CommandBarCheckBox;

            if (checkBox != null)
            {
                CommandCheckBoxState commandState = new CommandCheckBoxState(commandName);
                this.states.Add(commandState);
                return(commandState);
            }

            CommandBarComboBox comboBox = control as CommandBarComboBox;

            if (comboBox != null)
            {
                CommandComboBoxState commandState = new CommandComboBoxState(commandName);
                this.states.Add(commandState);
                return(commandState);
            }

            throw new NotSupportedException();
        }
        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);
        }
//		protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
//		{
//			switch (keyData)
//			{
//				case Keys.Control | Keys.S:
//					try
//					{
//						CommitChanges();
//					}
//					catch (Exception ex)
//					{
//						MessageBox.Show("Error saving file: " + ex.ToString(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
//					}
//					return true;
//			}
//			return base.ProcessCmdKey(ref msg, keyData);
//		}

		#endregion Key processing

		#region Highlighting Strategy

		private CommandBarItem[] BuildHighlightingOptions()
		{
			ArrayList menuItems = new ArrayList();
			SortedList strategies = new SortedList(HighlightingManager.Manager.HighlightingDefinitions);

			foreach (DictionaryEntry entry in strategies /*HighlightingManager.Manager.HighlightingDefinitions*/)
			{
				CommandBarCheckBox item = new CommandBarCheckBox(entry.Key.ToString());
				item.Click += new System.EventHandler(ChangeSyntax);
				item.IsChecked = txtDocument.Document.HighlightingStrategy.Name == entry.Key.ToString();
				menuItems.Add(item);
			}
			highlightingOptions = (CommandBarItem[]) menuItems.ToArray(typeof (CommandBarItem));
			return highlightingOptions;
		}
 public CommandBarCheckBox AddCheckBox(string text)
 {
     CommandBarCheckBox checkBox = new CommandBarCheckBox(text);
     this.Add(checkBox);
     return checkBox;
 }
        /// <summary>
        /// Loads the plugin menus.
        /// </summary>
        /// <param name="sender"> Sender object.</param>
        /// <param name="e"> LoadPluginMenuEventArgs arguments.</param>
        public void inspector_LoadPluginMenusEvent(object sender, LoadPluginMenuEventArgs e)
        {
            // Root Menus
            MenuRootHashtable ht = e.MenuRoot;

            SortedList root = new SortedList(ht,null);

            this.SuspendLayout();

            //1: For each MenuRoot, add MenuItems
            foreach (DictionaryEntry de in root)
            {
                MenuRoot r = (MenuRoot)de.Value;

                // Create Menu Root
                CommandBarMenu menuRoot = new CommandBarMenu(r.Text);
                menuRoot.MenuShortcut = r.Shortcut;

                // add MenuRoot
                menubar.Items.Add(menuRoot);

                // if null then exit
                if ( r.MenuItems == null ) break;

                #region Create commands and commandlinks
                //2: Add Menu Children
                for (int i=0;i<r.MenuItems.Count;i++)
                {
                    Ecyware.GreenBlue.Controls.MenuItem mn = (Ecyware.GreenBlue.Controls.MenuItem)r.MenuItems[r.MenuItems.GetKey(i)];

                    if ( mn is Ecyware.GreenBlue.Controls.ToolbarItem )
                    {
                        #region Add Toolbar item

                        // Create Command and add to CommandHolder
                        Ecyware.GreenBlue.Controls.ToolbarItem tbItem = (Ecyware.GreenBlue.Controls.ToolbarItem)mn;

                        // add any submenu toolbar
                        if ( tbItem.IsDropDown )
                        {
                            /*
                            // for command with submenu
                            if ( tbItem.ImageIndex > -1 )
                            {
                                Image img = this.imgToolbar24.Images[tbItem.ImageIndex];
                            }
                            CommandBarMenu m = toolbar.Items.AddMenu(img, tbItem.Text);
                            m.DropDown += tbItem.DropDownDelegate;
                            */
                        }
                        else
                        {
                            if ( tbItem.Toggle )
                            {
                                #region Single Command for toggle or checked type
                                CommandBarCheckBox toolbarItem = new CommandBarCheckBox(tbItem.Text);

                                toolbarItem.IsEnabled = tbItem.Enabled;
                                toolbarItem.IsVisible = tbItem.Visible;
                                toolbarItem.MenuShortcut = tbItem.Shortcut;
                                if ( tbItem.ImageIndex > -1 )
                                    toolbarItem.Image = this.imgToolbar24.Images[tbItem.ImageIndex];

                                toolbarItem.Click += tbItem.CheckedChangedDelegate;
                                toolbar.Items.Add(toolbarItem);
                                #endregion

                            }
                            else
                            {
                                #region Single Command not checked
                                CommandBarButton toolbarItem = new CommandBarButton(tbItem.Text);

                                toolbarItem.IsEnabled = tbItem.Enabled;
                                toolbarItem.IsVisible = tbItem.Visible;
                                toolbarItem.MenuShortcut = tbItem.Shortcut;
                                if ( tbItem.ImageIndex > -1 )
                                    toolbarItem.Image = this.imgToolbar24.Images[tbItem.ImageIndex];

                                toolbarItem.Click += tbItem.ClickDelegate;
                                toolbar.Items.Add(toolbarItem);
                                #endregion
                            }
                            // Add delimiter
                            if ( mn.Delimiter )
                            {
                                toolbar.Items.AddSeparator();
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        if ( mn.Toggle )
                        {
                            #region Add menu with checked
                            CommandBarCheckBox menuItem = new CommandBarCheckBox(mn.Text);
                            menuItem.IsVisible = mn.Visible;
                            menuItem.IsEnabled = mn.Enabled;
                            //if ( mn.ImageIndex > -1 )
                            //	menuItem.Image = this.imgToolbar16.Images[mn.ImageIndex];
                            menuItem.MenuShortcut = mn.Shortcut;
                            menuItem.Click += mn.CheckedChangedDelegate;
                            #endregion
                            // Add delimiter
                            if ( mn.Delimiter )
                            {
                                menuRoot.Items.AddSeparator();
                            }

                            menuRoot.Items.Add(menuItem);
                        }
                        else
                        {
                            #region Add Menu
                            CommandBarButton menuItem = new CommandBarButton(mn.Text);
                            menuItem.IsVisible = mn.Visible;
                            menuItem.IsEnabled = mn.Enabled;
                            if ( mn.ImageIndex > -1 )
                                menuItem.Image = this.imgToolbar16.Images[mn.ImageIndex];
                            menuItem.MenuShortcut = mn.Shortcut;
                            menuItem.Click += mn.ClickDelegate;
                            #endregion
                            // Add delimiter
                            if ( mn.Delimiter )
                            {
                                menuRoot.Items.AddSeparator();
                            }

                            menuRoot.Items.Add(menuItem);
                        }
                    }
                }
                #endregion
            }
            this.ResumeLayout(false);
        }
Beispiel #10
0
		protected CommandBarItem CreateMenuItem(ChoiceBase choice)
		{
			//note that we could handle the details of display in two different ways.
			//either we can leave this up to the normal display mechanism, which will do its own polling,
			//or we could just build the menu in the desired state right here (enable checked etc.)

			UIItemDisplayProperties display = choice.GetDisplayProperties();

			string label = display.Text;
			bool isSeparatorBar = (label == "-");
			label = label.Replace("_", "&");
			Image image = null;
			if (display.ImageLabel!= "default")
				image = m_smallImages.GetImage(display.ImageLabel);
			CommandBarItem menuItem;
			if(choice is CommandChoice)
			{
				if (isSeparatorBar)
					menuItem = new CommandBarSeparator();
				else
					menuItem = new CommandBarButton(image, label, new EventHandler(OnClick));
			}
			else
			{
				CommandBarCheckBox cb = new CommandBarCheckBox(image, label);
				cb.Click += new System.EventHandler(choice.OnClick);
				cb.IsChecked = display.Checked;
				menuItem = cb;
			}
			if (!isSeparatorBar)
				((CommandBarButtonBase)menuItem).Shortcut = choice.Shortcut;

			menuItem.Tag = choice;
			menuItem.IsEnabled = !isSeparatorBar && display.Enabled;
			menuItem.IsVisible = display.Visible;
			choice.ReferenceWidget = menuItem;
			return menuItem;
		}
Beispiel #11
0
    public HelloWorld()
    {
        this.Icon = SystemIcons.Application;
        this.Text = "Hello World";
        this.Size = new Size(500, 500);
        this.Controls.Add(new StatusBar());

        this.commandBarManager = new CommandBarManager();
        this.menuBar           = new CommandBar(this.commandBarManager, CommandBarStyle.Menu);
        this.toolBar           = new CommandBar(this.commandBarManager, CommandBarStyle.ToolBar);

        // Menu and toolbar
        CommandBarButton newButton  = new CommandBarButton(Images.New, "&New", null, Keys.Control | Keys.N);
        CommandBarButton openButton = new CommandBarButton(Images.Open, "&Open...", null, Keys.Control | Keys.O);
        CommandBarButton saveButton = new CommandBarButton(Images.Save, "&Save", null, Keys.Control | Keys.S);

        toolBar.Items.Add(newButton);
        toolBar.Items.Add(openButton);
        toolBar.Items.Add(saveButton);
        toolBar.Items.AddSeparator();

        CommandBarButton cutButton    = new CommandBarButton(Images.Cut, "Cu&t", null, Keys.Control | Keys.X);
        CommandBarItem   copyButton   = new CommandBarButton(Images.Copy, "&Copy", null, Keys.Control | Keys.C);
        CommandBarItem   pasteButton  = new CommandBarButton(Images.Paste, "&Paste", null, Keys.Control | Keys.V);
        CommandBarItem   deleteButton = new CommandBarButton(Images.Delete, "&Delete", null, Keys.Delete);

        this.toolBar.Items.Add(cutButton);
        this.toolBar.Items.Add(copyButton);
        this.toolBar.Items.Add(pasteButton);
        this.toolBar.Items.Add(deleteButton);
        this.toolBar.Items.AddSeparator();

        CommandBarButton undoButton = new CommandBarButton(Images.Undo, "&Undo", null, Keys.Control | Keys.Z);
        CommandBarButton redoButton = new CommandBarButton(Images.Redo, "&Redo", null, Keys.Control | Keys.Y);

        this.toolBar.Items.Add(undoButton);
        this.toolBar.Items.Add(redoButton);
        this.toolBar.Items.AddSeparator();

        CommandBarMenu fileMenu = menuBar.Items.AddMenu("&File");

        fileMenu.Items.Add(newButton);
        fileMenu.Items.Add(openButton);
        fileMenu.Items.Add(saveButton);
        fileMenu.Items.AddButton("&Save As...", null);
        fileMenu.Items.AddSeparator();
        fileMenu.Items.AddButton(Images.Preview, "Print Pre&view", null);
        fileMenu.Items.AddButton(Images.Print, "&Print", null, Keys.Control | Keys.P);
        fileMenu.Items.AddSeparator();
        fileMenu.Items.AddButton("E&xit", new EventHandler(this.Exit_Click));

        CommandBarMenu editMenu = this.menuBar.Items.AddMenu("&Edit");

        editMenu.Items.Add(undoButton);
        editMenu.Items.Add(redoButton);
        editMenu.Items.AddSeparator();
        editMenu.Items.Add(cutButton);
        editMenu.Items.Add(copyButton);
        editMenu.Items.Add(pasteButton);
        editMenu.Items.Add(deleteButton);
        editMenu.Items.AddSeparator();
        editMenu.Items.AddButton("Select &All", null, Keys.Control | Keys.A);

        CommandBarMenu viewMenu = this.menuBar.Items.AddMenu("&View");
        CommandBarMenu goToMenu = viewMenu.Items.AddMenu("&Go To");

        goToMenu.Items.AddButton(Images.Back, "&Back", null, Keys.Alt | Keys.Left);
        goToMenu.Items.AddButton(Images.Forward, "&Forward", null, Keys.Alt | Keys.Right);
        goToMenu.Items.AddSeparator();
        goToMenu.Items.AddButton(Images.Home, "&Home", null);

        viewMenu.Items.AddButton(Images.Stop, "&Stop", null, Keys.Escape);
        viewMenu.Items.AddButton(Images.Refresh, "&Refresh", null, Keys.F5);

        this.enabledButton         = new CommandBarButton(Images.Tiles, "&Enabled", null);
        this.enabledButton.Enabled = false;
        this.visibleButton         = new CommandBarButton(Images.Icons, "&Visible", null);
        this.visibleButton.Visible = false;
        CommandBarCheckBox checkedPlainCheckBox = new CommandBarCheckBox("&Checked Plain");

        checkedPlainCheckBox.IsChecked = true;
        CommandBarCheckBox checkedBitmapCheckBox = new CommandBarCheckBox(Images.List, "&Checked Bitmap");

        checkedBitmapCheckBox.IsChecked = true;

        toolBar.Items.Add(enabledButton);
        toolBar.Items.Add(visibleButton);
        toolBar.Items.Add(checkedPlainCheckBox);
        toolBar.Items.Add(checkedBitmapCheckBox);

        toolBar.Items.AddSeparator();

        ComboBox comboBox = new ComboBox();

        comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
        comboBox.Width         = 100;
        toolBar.Items.AddComboBox("Combo Box", comboBox);

        toolBar.Items.AddSeparator();

        CommandBarMenu testMenu = menuBar.Items.AddMenu("&Test");

        testMenu.Items.AddButton("&Enabled On/Off", new EventHandler(ToggleEnabled_Click));
        testMenu.Items.Add(this.enabledButton);
        testMenu.Items.AddSeparator();
        testMenu.Items.AddButton("&Visible On/Off", new EventHandler(ToggleVisible_Click));
        testMenu.Items.Add(this.visibleButton);
        testMenu.Items.AddSeparator();
        testMenu.Items.Add(checkedPlainCheckBox);
        testMenu.Items.Add(checkedBitmapCheckBox);
        testMenu.Items.AddSeparator();
        testMenu.Items.AddButton("Change Font", new EventHandler(this.ChangeFont_Click));

        CommandBarMenu helpMenu = menuBar.Items.AddMenu("&Help");

        helpMenu.Items.AddButton(Images.Mail, "&Your Feedback", null);
        helpMenu.Items.AddSeparator();
        helpMenu.Items.AddButton("&About", null);

        this.commandBarManager.CommandBars.Add(this.menuBar);
        this.commandBarManager.CommandBars.Add(this.toolBar);
        this.Controls.Add(this.commandBarManager);

        // Context menu
        CommandBarContextMenu contextMenu = new CommandBarContextMenu();

        contextMenu.Items.Add(undoButton);
        contextMenu.Items.Add(redoButton);
        contextMenu.Items.AddSeparator();
        contextMenu.Items.Add(cutButton);
        contextMenu.Items.Add(copyButton);
        contextMenu.Items.Add(pasteButton);
        contextMenu.Items.Add(deleteButton);
        this.ContextMenu = contextMenu;
    }
		public CommandBarCheckBox AddCheckBox(string text)
		{
			CommandBarCheckBox checkBox = new CommandBarCheckBox(text);
			this.Add(checkBox);
//// clear hashes
			keyItems.Clear();
			return checkBox;
		}
Beispiel #13
0
    public HelloWorld()
    {
        this.Icon = SystemIcons.Application;
            this.Text = "Hello World";
            this.Size = new Size(500, 500);
            this.Controls.Add(new StatusBar());

            this.commandBarManager = new CommandBarManager();
            this.menuBar = new CommandBar(this.commandBarManager, CommandBarStyle.Menu);
            this.toolBar = new CommandBar(this.commandBarManager, CommandBarStyle.ToolBar);

            // Menu and toolbar
            CommandBarButton newButton = new CommandBarButton(Images.New, "&New", null, Keys.Control | Keys.N);
            CommandBarButton openButton = new CommandBarButton(Images.Open, "&Open...", null, Keys.Control | Keys.O);
            CommandBarButton saveButton = new CommandBarButton(Images.Save, "&Save", null, Keys.Control | Keys.S);

            toolBar.Items.Add(newButton);
            toolBar.Items.Add(openButton);
            toolBar.Items.Add(saveButton);
            toolBar.Items.AddSeparator();

            CommandBarButton cutButton = new CommandBarButton(Images.Cut, "Cu&t", null, Keys.Control | Keys.X);
            CommandBarItem copyButton = new CommandBarButton(Images.Copy, "&Copy", null, Keys.Control | Keys.C);
            CommandBarItem pasteButton = new CommandBarButton(Images.Paste, "&Paste", null, Keys.Control | Keys.V);
            CommandBarItem deleteButton = new CommandBarButton(Images.Delete, "&Delete", null, Keys.Delete);

            this.toolBar.Items.Add(cutButton);
            this.toolBar.Items.Add(copyButton);
            this.toolBar.Items.Add(pasteButton);
            this.toolBar.Items.Add(deleteButton);
            this.toolBar.Items.AddSeparator();

            CommandBarButton undoButton = new CommandBarButton(Images.Undo, "&Undo", null, Keys.Control | Keys.Z);
            CommandBarButton redoButton = new CommandBarButton(Images.Redo, "&Redo", null, Keys.Control | Keys.Y);

            this.toolBar.Items.Add(undoButton);
            this.toolBar.Items.Add(redoButton);
            this.toolBar.Items.AddSeparator();

            CommandBarMenu fileMenu = menuBar.Items.AddMenu("&File");
            fileMenu.Items.Add(newButton);
            fileMenu.Items.Add(openButton);
            fileMenu.Items.Add(saveButton);
            fileMenu.Items.AddButton("&Save As...", null);
            fileMenu.Items.AddSeparator();
            fileMenu.Items.AddButton(Images.Preview, "Print Pre&view", null);
            fileMenu.Items.AddButton(Images.Print, "&Print", null, Keys.Control | Keys.P);
            fileMenu.Items.AddSeparator();
            fileMenu.Items.AddButton("E&xit", new EventHandler(this.Exit_Click));

            CommandBarMenu editMenu = this.menuBar.Items.AddMenu("&Edit");
            editMenu.Items.Add(undoButton);
            editMenu.Items.Add(redoButton);
            editMenu.Items.AddSeparator();
            editMenu.Items.Add(cutButton);
            editMenu.Items.Add(copyButton);
            editMenu.Items.Add(pasteButton);
            editMenu.Items.Add(deleteButton);
            editMenu.Items.AddSeparator();
            editMenu.Items.AddButton("Select &All", null, Keys.Control | Keys.A);

            CommandBarMenu viewMenu = this.menuBar.Items.AddMenu("&View");
            CommandBarMenu goToMenu = viewMenu.Items.AddMenu("&Go To");
            goToMenu.Items.AddButton(Images.Back, "&Back", null, Keys.Alt | Keys.Left);
            goToMenu.Items.AddButton(Images.Forward, "&Forward", null, Keys.Alt | Keys.Right);
            goToMenu.Items.AddSeparator();
            goToMenu.Items.AddButton(Images.Home, "&Home", null);

            viewMenu.Items.AddButton(Images.Stop, "&Stop", null, Keys.Escape);
            viewMenu.Items.AddButton(Images.Refresh, "&Refresh", null, Keys.F5);

            this.enabledButton = new CommandBarButton(Images.Tiles, "&Enabled", null);
            this.enabledButton.Enabled = false;
            this.visibleButton = new CommandBarButton(Images.Icons, "&Visible", null);
            this.visibleButton.Visible = false;
            CommandBarCheckBox checkedPlainCheckBox = new CommandBarCheckBox("&Checked Plain");
            checkedPlainCheckBox.IsChecked = true;
            CommandBarCheckBox checkedBitmapCheckBox = new CommandBarCheckBox(Images.List, "&Checked Bitmap");
            checkedBitmapCheckBox.IsChecked = true;

            toolBar.Items.Add(enabledButton);
            toolBar.Items.Add(visibleButton);
            toolBar.Items.Add(checkedPlainCheckBox);
            toolBar.Items.Add(checkedBitmapCheckBox);

            toolBar.Items.AddSeparator();

            ComboBox comboBox = new ComboBox();
            comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox.Width = 100;
            toolBar.Items.AddComboBox("Combo Box", comboBox);

            toolBar.Items.AddSeparator();

            CommandBarMenu testMenu = menuBar.Items.AddMenu("&Test");
            testMenu.Items.AddButton("&Enabled On/Off", new EventHandler(ToggleEnabled_Click));
            testMenu.Items.Add(this.enabledButton);
            testMenu.Items.AddSeparator();
            testMenu.Items.AddButton("&Visible On/Off", new EventHandler(ToggleVisible_Click));
            testMenu.Items.Add(this.visibleButton);
            testMenu.Items.AddSeparator();
            testMenu.Items.Add(checkedPlainCheckBox);
            testMenu.Items.Add(checkedBitmapCheckBox);
            testMenu.Items.AddSeparator();
            testMenu.Items.AddButton("Change Font", new EventHandler(this.ChangeFont_Click));

            CommandBarMenu helpMenu = menuBar.Items.AddMenu("&Help");
            helpMenu.Items.AddButton(Images.Mail, "&Your Feedback", null);
            helpMenu.Items.AddSeparator();
            helpMenu.Items.AddButton("&About", null);

            this.commandBarManager.CommandBars.Add(this.menuBar);
            this.commandBarManager.CommandBars.Add(this.toolBar);
            this.Controls.Add(this.commandBarManager);

            // Context menu
            CommandBarContextMenu contextMenu = new CommandBarContextMenu();
            contextMenu.Items.Add(undoButton);
            contextMenu.Items.Add(redoButton);
            contextMenu.Items.AddSeparator();
            contextMenu.Items.Add(cutButton);
            contextMenu.Items.Add(copyButton);
            contextMenu.Items.Add(pasteButton);
            contextMenu.Items.Add(deleteButton);
            this.ContextMenu = contextMenu;
    }
        CommandBarCheckBox LeftAlign, Center, RightAlign; //, Justify;

        public RichEditBox()
        {
            // Cet appel est requis par le Concepteur de formulaires Windows.Forms.
            InitializeComponent();
            this.SetStyle(
                ControlStyles.SupportsTransparentBackColor,
                true);

            // TODO : ajoutez les initialisations après l'appel à InitializeComponent
            commandBarManager1 = new CommandBarManager();
            commandBar1        = new vbMaf.Windows.Forms.CommandBar.CommandBar(this.commandBarManager1, CommandBarStyle.ToolBar);

            //Création des combobox
            ComboFont           = new ComboBox();
            ComboFont.DrawMode  = DrawMode.OwnerDrawVariable;
            ComboFontSize       = new ComboBox();
            ComboFontSize.Width = 45;
            ComboColor          = new ComboBox();
            ComboColor.Width    = 75;

            LoadFont();
            LoadFontSize();
            LoadColor();
            ComboFontSize.Text = "10";
            ComboColor.Text    = "Noir";
            commandBar1.Items.AddComboBox("Font", ComboFont);
            commandBar1.Items.AddComboBox("Taille", ComboFontSize);
            commandBar1.Items.AddComboBox("Couleur", ComboColor);
            commandBar1.Items.AddSeparator();


            CommandBarCheckBox GChk = new CommandBarCheckBox(imageList1.Images[0], "Gras");

            GChk.Shortcut = Keys.Control | Keys.G;
            CommandBarCheckBox IChk = new CommandBarCheckBox(imageList1.Images[1], "Italic");

            IChk.Shortcut = Keys.Control | Keys.I;
            CommandBarCheckBox SChk = new CommandBarCheckBox(imageList1.Images[2], "Souligné");

            SChk.Shortcut = Keys.Control | Keys.U;

            commandBar1.Items.AddRange(new CommandBarCheckBox[] { GChk, IChk, SChk });
            commandBar1.Items.AddSeparator();

            LeftAlign  = new CommandBarCheckBox(imageList1.Images[3], "Aligner à gauche");
            Center     = new CommandBarCheckBox(imageList1.Images[4], "Centrer");
            RightAlign = new CommandBarCheckBox(imageList1.Images[5], "Aligner à droite");

            LeftAlign.IsChecked = true;
            commandBar1.Items.AddRange(new CommandBarCheckBox[] { LeftAlign, Center, RightAlign /*, Justify*/ });
            commandBar1.Items.AddSeparator();

            CommandBarButton Cut   = new CommandBarButton(imageList1.Images[8], "Couper", null, Keys.Control | Keys.X);
            CommandBarButton Copy  = new CommandBarButton(imageList1.Images[7], "Copier", null, Keys.Control | Keys.C);
            CommandBarButton Paste = new CommandBarButton(imageList1.Images[9], "Coller", null, Keys.Control | Keys.V);

            commandBar1.Items.AddRange(new CommandBarButton[] { Cut, Copy, Paste });
            commandBar1.Items.AddSeparator();
            CommandBarButton Undo = new CommandBarButton(imageList1.Images[10], "Annuler", null, Keys.Control | Keys.Z);
            CommandBarButton Redo = new CommandBarButton(imageList1.Images[11], "Refaire", null, Keys.Control | Keys.Y);

            commandBar1.Items.AddRange(new CommandBarButton[] { Undo, Redo });
            commandBar1.Items.AddSeparator();

            CommandBarButton Delete = new CommandBarButton(global::RichEditBox.Properties.Resources.delete, "Supprimer", null, Keys.Control | Keys.Delete);

            commandBar1.Items.AddRange(new CommandBarButton[] { Delete });
            commandBar1.Items.AddSeparator();
            CommandBarButton Print = new CommandBarButton(global::RichEditBox.Properties.Resources.imprimante, "Imprimer", null, Keys.Control | Keys.P);

            //commandBar1.Items.AddRange(new CommandBarButton[] { Print });


            // Menu contextuel
            contextMenu = new CommandBarContextMenu();
            contextMenu.Items.AddButton(imageList1.Images[10], "Annuler", new EventHandler(Undo_Click));
            contextMenu.Items.AddSeparator();
            contextMenu.Items.AddButton(null, "Sélectionner Tout", new EventHandler(SelectAll_Click));
            contextMenu.Items.AddButton(imageList1.Images[8], "Couper", new EventHandler(Cut_Click));
            contextMenu.Items.AddButton(imageList1.Images[7], "Copier", new EventHandler(Copy_Click));
            contextMenu.Items.AddButton(imageList1.Images[9], "Coller", new EventHandler(Paste_Click));
            contextMenu.Items.AddButton(imageList1.Images[12], "Supprimer", new EventHandler(Delete_Click));


            commandBarManager1.Dock = DockStyle.Top;
            commandBar1.Dock        = DockStyle.Fill;

            commandBarManager1.CommandBars.Add(commandBar1);
            this.Controls.Add(commandBarManager1);
            //this.Controls.Add(contextMenu);

            // branchement du menu sur le click droit
            // GUILLAUME : on retire car ça plante dans l appli FGA_FRONT
            //this.richTextBox1.ContextMenu = contextMenu;
            this.richTextBox1.Dock = DockStyle.Fill;

            if (!DesignMode)
            {
                ComboFont.MeasureItem += new MeasureItemEventHandler(ComboFont_MeasureItem);
                ComboFont.DrawItem    += new DrawItemEventHandler(ComboFont_DrawItem);
                GChk.Click            += new EventHandler(GChk_Click);
                IChk.Click            += new EventHandler(IChk_Click);
                SChk.Click            += new EventHandler(SChk_Click);
                LeftAlign.Click       += new EventHandler(LeftAlign_Click);
                Center.Click          += new EventHandler(Center_Click);
                RightAlign.Click      += new EventHandler(RightAlign_Click);
//				Justify.Click						+= new EventHandler(Justify_Click);
                Cut.Click    += new EventHandler(Cut_Click);
                Copy.Click   += new EventHandler(Copy_Click);
                Paste.Click  += new EventHandler(Paste_Click);
                Undo.Click   += new EventHandler(Undo_Click);
                Redo.Click   += new EventHandler(Redo_Click);
                Delete.Click += new EventHandler(Delete_Click);
                Print.Click  += new EventHandler(Print_Click);
                ComboFont.SelectedIndexChanged     += new EventHandler(ComboFont_SelectedIndexChanged);
                ComboFontSize.SelectedIndexChanged += new EventHandler(ComboFontSize_SelectedIndexChanged);
                ComboColor.SelectedIndexChanged    += new EventHandler(ComboColorSelectedIndexChanged);

                timer          = new System.Timers.Timer(100);
                timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
                timer.Start();
            }

            //ComboFont.Enabled = false;
        }
Beispiel #15
0
        public CommandBarManager(PluginCollection plugins, JournalWriterCollection journalWriters)
        {
            this.plugins        = plugins;
            this.journalWriters = journalWriters;



            // the bars
            menuBar = new CommandBar(CommandBarStyle.Menu);
            toolBar = new CommandBar(CommandBarStyle.ToolBar);

            // commandbarbuttons
            NewArchive = new CommandBarButton(Images.New, Localizer.GetString(this.GetType(), "NewArchive.Text"),
                                              new EventHandler(CommandButton_Click), Keys.Control | Keys.N);
            Open = new CommandBarButton(Images.Open, Localizer.GetString(this.GetType(), "Open.Text"),
                                        new EventHandler(CommandButton_Click), Keys.Control | Keys.O);
            Print = new CommandBarButton(Images.Print, Localizer.GetString(this.GetType(), "Print.Text"),
                                         new EventHandler(CommandButton_Click), Keys.Control | Keys.P);
            Exit = new CommandBarButton(Localizer.GetString(this.GetType(), "Exit.Text"),
                                        new EventHandler(CommandButton_Click));
            JournalSettings = new CommandBarButton(Images.Edit, Localizer.GetString(this.GetType(),
                                                                                    "JournalSettings.Text"), new EventHandler(CommandButton_Click));
            GotoEntry = new CommandBarButton(Images.Redo, Localizer.GetString(this.GetType(), "GotoEntry.Text"),
                                             new EventHandler(CommandButton_Click), Keys.Control | Keys.D);
            GoBack = new CommandBarButton(Images.Back, Localizer.GetString(this.GetType(), "GoBack.Text"),
                                          new EventHandler(CommandButton_Click), Keys.Control | Keys.Left);
            GoForward = new CommandBarButton(Images.Forward, Localizer.GetString(this.GetType(), "GoForward.Text"),
                                             new EventHandler(CommandButton_Click), Keys.Control | Keys.Right);
            Find            = new CommandBarCheckBox(Images.Search, Localizer.GetString(this.GetType(), "Find.Text"));
            Find.Click     += new EventHandler(CommandButton_Click);
            Calendar        = new CommandBarCheckBox(Images.Calendar, Localizer.GetString(this.GetType(), "Calendar.Text"));
            Calendar.Click += new EventHandler(CommandButton_Click);
            Grid            = new CommandBarCheckBox(Images.Details, Localizer.GetString(this.GetType(), "Grid.Text"));
            Grid.Click     += new EventHandler(CommandButton_Click);
            HtmlSettings    = new CommandBarCheckBox(Images.Languages, Localizer.GetString(this.GetType(),
                                                                                           "HtmlSettings.Text"));
            HtmlSettings.Click += new EventHandler(CommandButton_Click);
            Sync = new CommandBarButton(Images.Refresh, Localizer.GetString(this.GetType(), "Sync.Text"),
                                        new EventHandler(CommandButton_Click));
            Abort = new CommandBarButton(Images.Stop, Localizer.GetString(this.GetType(), "Abort.Text"),
                                         new EventHandler(CommandButton_Click));
            Options = new CommandBarButton(Images.Tools, Localizer.GetString(this.GetType(), "Options.Text"),
                                           new EventHandler(CommandButton_Click));
            Website = new CommandBarButton(Images.Help, Localizer.GetString(this.GetType(), "Website.Text"),
                                           new EventHandler(CommandButton_Click), Keys.F1);
            About = new CommandBarButton(Localizer.GetString(this.GetType(), "About.Text"),
                                         new EventHandler(CommandButton_Click));


            // toolbar
            toolBar.Items.Add(GoBack);
            toolBar.Items.Add(GoForward);
            toolBar.Items.AddSeparator();
            toolBar.Items.Add(Find);
            toolBar.Items.Add(Calendar);
            toolBar.Items.Add(Grid);
            toolBar.Items.Add(HtmlSettings);
            toolBar.Items.AddSeparator();
            toolBar.Items.Add(Sync);
            toolBar.Items.Add(Abort);
            toolBar.Items.AddSeparator();
            pluginsMenu = toolBar.Items.AddMenu(Images.Favorites, Localizer.GetString(this.GetType(), "pluginsMenu.Text"));

            // menus
            fileMenu = menuBar.Items.AddMenu(Localizer.GetString(this.GetType(), "fileMenu.Text"));
            fileMenu.Items.Add(NewArchive);
            fileMenu.Items.Add(Open);
            fileMenu.Items.Add(Print);
            exportMenu = fileMenu.Items.AddMenu(Localizer.GetString(this.GetType(), "exportMenu.Text"));
            fileMenu.Items.AddSeparator();
            fileMenu.Items.Add(Exit);
            editMenu = menuBar.Items.AddMenu(Localizer.GetString(this.GetType(), "editMenu.Text"));
            editMenu.Items.Add(JournalSettings);
            editMenu.Items.AddSeparator();
            editMenu.Items.Add(GotoEntry);
            editMenu.Items.AddSeparator();
            editMenu.Items.Add(GoBack);
            editMenu.Items.Add(GoForward);
            viewMenu = menuBar.Items.AddMenu(Localizer.GetString(this.GetType(), "viewMenu.Text"));
            viewMenu.Items.Add(Find);
            viewMenu.Items.Add(Calendar);
            viewMenu.Items.Add(HtmlSettings);
            viewMenu.Items.Add(Grid);
            toolsMenu = menuBar.Items.AddMenu(Localizer.GetString(this.GetType(), "toolsMenu.Text"));
            toolsMenu.Items.Add(Sync);
            toolsMenu.Items.Add(Abort);
            toolsMenu.Items.AddSeparator();
            toolsMenu.Items.Add(Options);
            toolsMenu.Items.AddSeparator();
            toolsMenu.Items.Add(pluginsMenu);
            helpMenu = menuBar.Items.AddMenu(Localizer.GetString(this.GetType(), "helpMenu.Text"));
            helpMenu.Items.Add(Website);
            helpMenu.Items.Add(About);

            // pluginsMenu
            foreach (Common.IPlugin plugin in plugins)
            {
                pluginsMenu.Items.AddButton(plugin.MenuIcon, plugin.Title, new EventHandler(Plugin_Click));
            }

            // exportMenu
            foreach (Common.IJournalWriter journalWriter in journalWriters)
            {
                exportMenu.Items.AddButton(journalWriter.Name, new EventHandler(JournalWriter_Click));
            }

            this.CommandBars.Add(menuBar);
            this.CommandBars.Add(toolBar);
        }