MDIParentForm.cs
Description du code
MDIParentForm.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# (MDIParentForm.cs) (338 lignes)
using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using be.gaudry.model.enums; using be.gaudry.view.controls; using be.gaudry.view.dialogs; using be.gaudry.view.style; namespace be.gaudry.view { public partial class MDIParentForm : Form, IMDIParent { #region declarations and constructors //private Dictionary<STYLE,ToolStripRenderer>renderers; private ToolBarHomeControl toolBarHome; private STYLE style; public MDIParentForm() { //renderers = new Dictionary<STYLE,ToolStripRenderer>(); //todo : get style from settings style = STYLE.Office2007; //StyleFactory.setStyle(style);//default style Splasher.Status = "Initialisation des composants"; this.InitializeComponent(); resetStatusStrip(); addToolBars(); Splasher.Status = "Initialisation des styles"; initRenderers(); /* this.DataBindings.Add(new System.Windows.Forms.Binding("Location", global::be.gaudry.Properties.Settings.Default, "mainFormLocation", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); this.DataBindings.Add(new System.Windows.Forms.Binding("WindowState", global::be.gaudry.Properties.Settings.Default, "mainFormWindowState", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); this.DataBindings.Add(new System.Windows.Forms.Binding("StartPosition", global::be.gaudry.Properties.Settings.Default, "mainFormStartPosition", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); this.DataBindings.Add(new System.Windows.Forms.Binding("ClientSize", global::be.gaudry.Properties.Settings.Default, "mainFormClientSize", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); */ } private void addToolBars() { toolBarManagerControl.addToolBar(toolBarHome); } #endregion #region misc menu methods private void exitTsMi_Click(object sender, EventArgs e) { this.Close(); //Application.Exit(); } private void sourcesTsMi_Click(object sender, EventArgs e) { showMDIChild<SourcesForm>(); } protected void showOnlineHelp_Click(object sender, EventArgs e) { showMDIChild<InfobrolForm>(); } private void updateTsMi_Click(object sender, EventArgs e) { showMDIChild<UpdateDialog>(); } /// <summary> /// Override it to show another about box /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void showAboutBox_Click(object sender, EventArgs e) { } /// <summary> /// Override it to show some options /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void showOptions_Click(object sender, EventArgs e) { MessageBox.Show( this, "Aucune option disponible", "Options", MessageBoxButtons.OK, MessageBoxIcon.Information ); } protected void showToolBar(IToolBarControl toolBar) { if (!toolBarManagerControl.Visible) { toolBarManagerControl.Visible = true; } toolBarManagerControl.CurrentToolBar = toolBar; } private void showHideDisplayTools_Click(object sender, EventArgs e) { displayTS.Visible = !displayTS.Visible; } private void showHideAssistant_Click(object sender, EventArgs e) { toolBarManagerControl.Visible = !toolBarManagerControl.Visible; } protected void displayMenuLeftTsB_Click(object sender, EventArgs e) { leftPanel.Visible = !leftPanel.Visible; } private void showHideStatusStrip_Click(object sender, EventArgs e) { statusStrip.Visible = !statusStrip.Visible; } #endregion #region styles private void checkStyleItem(string current) { foreach (ToolStripMenuItem tsMi in customTSMenuItem.DropDownItems) { } } private void initRenderers() { //Binding of ToolStripComboBox.ComboBox does not work... Known bug in.net /* styleTsCB.ComboBox.DataSource = EnumHelper.ToList(typeof(STYLE)); styleTsCB.ComboBox.DisplayMember = "Value"; styleTsCB.ComboBox.ValueMember = "Key"; */ //add all STYLE enum items in the ComboBox { /* * We must initialize a new STYLE item to avoid than all anonym methods * share the same local variable type. * All instances of our anonym methods are executed by different thread than iterator method. * That makes all delegates have the last KeyValuePair object return by the iterator. */ STYLE style = (STYLE)kvp.Key; string text = kvp.Value; kvp.Value, null, delegate { StyleFactory.setStyle(style); //ToolStripManager.Renderer = renderers[style]; checkStyleItem(text); } ); customTSMenuItem.DropDownItems.Add(tsMi); } /* renderers.Add(STYLE.Grey3D, new ToolStripProfessionalRenderer(new ControlStyleColors())); renderers.Add(STYLE.Office2007, new Office2007Renderer.Office2007Renderer()); renderers.Add(STYLE.Orange, new ToolStripProfessionalRenderer(new OrangeStyleColors())); renderers.Add( STYLE.Aero, new ToolStripProfessionalRenderer(new ProfessionalColorTableFactory(STYLE.Aero)) ); renderers.Add( STYLE.Classic, new ToolStripProfessionalRenderer(new ProfessionalColorTableFactory(STYLE.Classic)) ); renderers.Add( STYLE.HomeStead, new ToolStripProfessionalRenderer(new ProfessionalColorTableFactory(STYLE.HomeStead)) ); renderers.Add( STYLE.MediaCenter, new ToolStripProfessionalRenderer(new ProfessionalColorTableFactory(STYLE.MediaCenter)) ); renderers.Add( STYLE.Metallic, new ToolStripProfessionalRenderer(new ProfessionalColorTableFactory(STYLE.Metallic)) ); renderers.Add( STYLE.NormalColor, new ToolStripProfessionalRenderer(new ProfessionalColorTableFactory(STYLE.NormalColor)) ); renderers.Add( STYLE.ReBar, new RebarRenderer() ); */ //defaultRenderer = new ToolStripProfessionalRenderer(); //systemRenderer = new ToolStripSystemRenderer(); } #endregion #region Windows layout menu private void dispWinCTSMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.Cascade); } private void dispWinHTSMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.TileHorizontal); } private void dispWinVTSMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.TileVertical); } private void dispWinAIconsTSMenuItem_Click(object sender, EventArgs e) { LayoutMdi(MdiLayout.ArrangeIcons); } #endregion #region override of form events /// <summary> /// Sets text on splasher, /// raises the System.Windows.Forms.Form.Load event, /// loads some form's properties like position, state, size, /// and closes the splasher /// </summary> /// <param name="e">An System.EventArgs that contains the event data.</param> protected override void OnLoad(EventArgs e) { Splasher.Status = "Tentative de lecture des paramètres de la fenêtre"; base.OnLoad(e); /*try { WindowState = (FormWindowState)Enum.Parse( typeof(FormWindowState), System.Configuration.ConfigurationManager.AppSettings["mainFormState"] ); } catch (Exception) { WindowState = FormWindowState.Normal; }*/ try { this.Size = Properties.Settings.Default.mainFormClientSize; this.Location = Properties.Settings.Default.mainFormLocation; this.WindowState = Properties.Settings.Default.mainFormWindowState; this.StartPosition = Properties.Settings.Default.mainFormStartPosition; } catch{} //ToolStripManager.Renderer = StyleFactory.ToolStripRenderer;//renderers[style]; checkStyleItem(EnumHelper.GetDescription(style)); //toolBarManagerControl.CurrentToolBar = toolBarHome;//set console as current if displayed on the config //Splasher.close();//close splasher in the inherited form } /// <summary> /// Save some form's properties like position, state, size, and /// raises the System.Windows.Forms.Form.FormClosing event /// </summary> /// <param name="e">An System.EventArgs that contains the event data.</param> protected override void OnFormClosing(FormClosingEventArgs e) { //Config.saveAppSetting("mainFormState", Enum.GetName(typeof(FormWindowState), WindowState)); Properties.Settings.Default.mainFormWindowState = this.WindowState; if (this.WindowState == FormWindowState.Normal) { Properties.Settings.Default.mainFormClientSize = this.Size; Properties.Settings.Default.mainFormLocation = this.Location; } else { Properties.Settings.Default.mainFormClientSize = this.RestoreBounds.Size; Properties.Settings.Default.mainFormLocation = this.RestoreBounds.Location; } Properties.Settings.Default.mainFormStartPosition = this.StartPosition; Properties.Settings.Default.Save(); base.OnFormClosing(e); } #endregion protected Image AboutImage { get { return this.toolBarHome.AboutImage; } set { this.toolBarHome.AboutImage = value; this.BackgroundImage = toolBarHome.AboutImage; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; } } private void toolBarManagerControl_onPickPushpin_Click(object sender, EventArgs e) { //wizardToolBarCMS.Show(rightPanel, 0, 0); if (toolBarManagerControl.Width == toolBarManagerControl.MinimumWidth) { toolBarManagerControl.Width = toolBarManagerControl.PreferedWidth; } else { toolBarManagerControl.Width = toolBarManagerControl.MinimumWidth; } } private void panelSizeTsMi_Click(object sender, EventArgs e) { /*ToolStripMenuItem curTsMi = sender as ToolStripMenuItem; foreach (ToolStripMenuItem tsMi in panelSizeTsMi.DropDownItems) { if (!tsMi.Equals(curTsMi)) { ((ToolStripMenuItem)sender).Checked = false; } } int width; if( int.TryParse( ((ToolStripMenuItem)sender).Text,out width ) ) { rightPanel.Width = width; toolBarManagerControl.CurrentToolBar.Visible = (width > 40); }*/ } } }
Structure et Fichiers du projet
Afficher/masquer...Icône | Nom | Taille | Modification |
Icône | Nom | Taille | Modification |
| _ | Répertoire parent | 0 octets | 1735875395 03/01/2025 04:36:35 |
| _ | dialogs | 0 octets | 1541007195 31/10/2018 18:33:15 |
| _ | style | 0 octets | 1541007196 31/10/2018 18:33:16 |
| _ | utils | 0 octets | 1541007196 31/10/2018 18:33:16 |
| _ | controls | 0 octets | 1541007193 31/10/2018 18:33:13 |
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/MDIParentForm.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.