ToolBarManagerControl.cs
Description du code
ToolBarManagerControl.cs est un fichier du projet BrolDev.Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/broldev/src/.
Projet BrolDev : Librairie de composants réutilisables pour les applications BrolDev en CSharp.
Code source ou contenu du fichier
Code c# (ToolBarManagerControl.cs) (197 lignes)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using be.gaudry.view.style; namespace be.gaudry.view.controls { public partial class ToolBarManagerControl : UserControl { private Dictionary<string, IToolBarControl> toolBars; private int preferdWidth = 200, minimumWidth=25; public ToolBarManagerControl() { InitializeComponent(); } #region properties [ Category("Display"), Browsable(true), Description("Event called on click on the pushpin button (Auto-hide)") ] public event System.EventHandler onPickPushpin_Click; [ Category("Display"), Browsable(true), Description("Event called on click on the hide button (manual-hide)") ] public event System.EventHandler onHide_Click; /// <summary> /// Gets or sets the <code>be.gaudry.view.controls.IToolBarControl</code> that is selected in the <code>be.gaudry.view.controls.ToolBarControlManager</code>. /// </summary> [ Browsable(false), DefaultValue(null) ] public IToolBarControl CurrentToolBar { get { string currentToolBar = toolBarsICB.SelectedInnerText; if (currentToolBar!=null && toolBars.ContainsKey(currentToolBar)) { return toolBars[currentToolBar]; } return null; } set { toolBarsICB.SelectedInnerText = value.ToolBarText; } } /// <summary> /// Get the width of the panel. /// </summary> [ Browsable(false) ] public int PreferedWidth { get { return preferdWidth; } } /// <summary> /// Get the minimum width of the panel. /// </summary> [ Browsable(false) ] public int MinimumWidth { get { return minimumWidth; } } #endregion public void addToolBar(IToolBarControl toolBar) { { ((Control)toolBar).Dock = DockStyle.Fill; toolBars.Add(toolBar.ToolBarText, toolBar); toolBarsICB.addItem(toolBar.ToolBarText, toolBar.ToolBarImage); defineGradientBackground((Control)toolBar); //(Control)toolBar.Resize += new System.EventHandler(this.ToolBarHomeControl_Resize); } } /// <summary> /// Defines a bitmap as BackgroundImageLayout to avoid gradient background flickering on paint event /// </summary> private void defineGradientBackground(Control toolBarControl) { //todo : put this on an abstract class AbstractToolBarControl /*toolBarControl.SetStyle(ControlStyles.ResizeRedraw, true); toolBarControl.SetStyle(ControlStyles.UserPaint, true); toolBarControl.SetStyle(ControlStyles.AllPaintingInWmPaint, true); toolBarControl.SetStyle(ControlStyles.DoubleBuffer, true); System.Drawing.Drawing2D.LinearGradientBrush gradientBrush;*/ Point(0, 0), StyleFactory.CustomSystemColors.Control, StyleFactory.CustomSystemColors.ControlLightLight ); Graphics g = Graphics.FromImage(bmp); toolBarControl.BackgroundImage = bmp; toolBarControl.BackgroundImageLayout = ImageLayout.Stretch; } private void toolBarsICB_SelectedIndexChanged(object sender, EventArgs e) { string currentToolBar = toolBarsICB.SelectedInnerText; if (toolBars.ContainsKey(currentToolBar)) { Control toolBar = (Control)toolBars[currentToolBar]; splitContainer1.Panel2.Controls.Clear(); splitContainer1.Panel2.Controls.Add(toolBar); //toolBar.Dock = DockStyle.Fill; } } private void ToolBarManagerControl_Load(object sender, EventArgs e) { if (toolBarsICB.Items.Count > 0) { toolBarsICB.SelectedIndex = 0; } } private void autoHideButton_Click(object sender, EventArgs e) { if (onPickPushpin_Click != null) { onPickPushpin_Click(sender, e); } else { Width = (Width > minimumWidth) ? minimumWidth : preferdWidth; splitContainer1.Panel2Collapsed = (Width <= minimumWidth); } } private void panelSizeTsMi_Click(object sender, EventArgs e) { ToolStripMenuItem curTsMi = sender as ToolStripMenuItem; foreach (ToolStripMenuItem tsMi in panelSizeTsMi.DropDownItems) { if (!tsMi.Equals(curTsMi)) { } } int width; if (int.TryParse(((ToolStripMenuItem)sender).Text, out width)) { preferdWidth = width; Width = preferdWidth; splitContainer1.Panel2Collapsed = (Width > minimumWidth); //CurrentToolBar.Visible = (width > minimumWidth); } } private void hideButton_Click(object sender, EventArgs e) { if (onHide_Click != null) { onHide_Click(sender, e); } else { this.Visible = false; } } private void ToolBarManagerControl_MouseEnter(object sender, EventArgs e) { Width = preferdWidth; splitContainer1.Panel2Collapsed = false; } private void ToolBarManagerControl_MouseLeave(object sender, EventArgs e) { Width = minimumWidth; splitContainer1.Panel2Collapsed = true; } private void ToolBarManagerControl_SizeChanged(object sender, EventArgs e) { IToolBarControl control = CurrentToolBar; if(control!=null)control.PerformLayout(); } } }
Structure et Fichiers du projet
Afficher/masquer...Icône | Nom | Taille | Modification |
Pas de sous-répertoires. | |||
Icône | Nom | Taille | Modification |
| _ | Répertoire parent | 0 octets | 1732532941 25/11/2024 12:09:01 |
Utilisation de l'explorateur de code
- Navigation :
- Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
- Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
- La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
- Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
- Affichage :
- Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
- Actions :
- Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 16/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-broldev-source-rf-view/controls/ToolBarManagerControl.cs.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.