示例#1
0
 public CommandBar(CommandBarManager commandBarManager)
 {
     this.commandBarManager = commandBarManager;
     this.items             = new CommandBarItemCollection(this);
     this.SetStyle(ControlStyles.UserPaint, false);
     this.TabStop = false;
     this.Font    = SystemInformation.MenuFont;
     this.Dock    = DockStyle.Top;
 }
 public CommandBarCollection(CommandBarManager commandBarManager)
 {
     this.commandBarManager = commandBarManager;
 }
示例#3
0
 public CommandBar(CommandBarManager commandBarManager, CommandBarStyle style) : this(commandBarManager)
 {
     this.style = style;
 }
        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;
        }