MDIChildForm.cs
Description du code
MDIChildForm.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# (MDIChildForm.cs) (340 lignes)
using System; using System.Collections.Generic; using System.Reflection; using System.Windows.Forms; namespace be.gaudry.view { public partial class MDIChildForm : Form { #region declarations and constructors //internal delegate void ProgressBarDelegateHandler(); //private ProgressBarDelegateHandler startProgressBarDelegate, stopProgressBarDelegate; private List<ToolStrip> toolStrips; private Assembly assembly; //private bool isClosing; public MDIChildForm() { //isClosing = false; assembly = Assembly.GetCallingAssembly(); InitializeComponent(); //startProgressBarDelegate += new ProgressBarDelegateHandler(startProgress); //stopProgressBarDelegate += new ProgressBarDelegateHandler(stopProgress); } #endregion #region ToolStrip properties /// <summary> /// Set enabled or not for all ToolStrip /// </summary> protected bool ToolStripsEnabled { set { foreach (ToolStrip ts in toolStrips) { //Console.WriteLine("debug : "+ts.Name+" ToolStripsEnabled"); ts.Enabled = value; } } } /// <summary> /// Set visible or not for all ToolStrip /// </summary> protected bool ToolStripsVisible { set { foreach (ToolStrip ts in toolStrips) { //Console.WriteLine("debug : " + ts.Name + " ToolStripsVisible"); ts.Visible = value; } } } #endregion #region ToolStrip methods /// <summary> /// Add a ToolStrip item in the MainView ToolStripPanel /// </summary> /// <param name="ts">ToolStrip to add</param> protected void addToolStrip(ToolStrip ts) { //Console.WriteLine("debug : " + ts.Name + " add"); toolStrips.Add(ts); //((MainForm)MdiParent).topTSP.Controls.Add(ts); } /// <summary> /// Remove a ToolStrip item from the MainView ToolStripPanel /// </summary> /// <param name="ts">ToolStrip to add</param> protected void removeToolStrip(ToolStrip ts) { //Console.WriteLine("debug : " + ts.Name + " remove"); toolStrips.Remove(ts); //((MainForm)MdiParent).topTSP.Controls.Remove(ts); } #endregion #region override of form's events /// <summary> /// Raises the <code>System.Windows.Forms.Form.Activated</code> event, /// sets visible the registred <code>ToolStrips</code>, /// and sets status message with copyright and version of the plugin. /// </summary> /// <param name="e">An <code>System.EventArgs</code> that contains the event data.</param> protected override void OnActivated(EventArgs e) { base.OnActivated(e); this.ToolStripsVisible = true; /*setStatusMessage( "Copyright © 2006 BrolDev", Application.ProductName + " " + Application.ProductVersion, "" );*/ setStatusMessage( AssemblyCopyright + " " + AssemblyCompany, AssemblyTitle + " " + AssemblyVersion, AssemblyDescription ); /*IMDIParent parent = MdiParent as IMDIParent; if (parent != null) { parent.mergeMenuStrip(mainMenuStrip); }*/ } /// <summary> /// Raises the <code>System.Windows.Forms.Form.Deactivate</code> event, /// hides the registred <code>ToolStrips</code>, /// and resets status message. /// </summary> /// <param name="e">An <code>System.EventArgs</code> that contains the event data.</param> protected override void OnDeactivate(EventArgs e) { base.OnDeactivate(e); //if (!isClosing) //{ this.ToolStripsVisible = false; /*IMDIParent parent = MdiParent as IMDIParent; if (parent != null) { parent.revertMergeMenuStrip(mainMenuStrip); }*/ //} //mdiParent.cleanToolStrips(toolStrips); /* foreach (ToolStrip ts in toolStrips) { try { mdiParent.topTSP.Controls.Remove(ts); } catch (Exception ex) { System.Console.WriteLine("ex : " + ex.Message + " : " + ex.StackTrace); } }*/ resetStatusStrip(); } /// <summary> /// Raises the <code>System.Windows.Forms.Form.Shown</code> event, /// dockes and join the registred <code>ToolStrips</code> with the parent <code>ToolStrip</code> /// if parent implements the <code>be.gaudry.view.IDIParentForm</code> interface, /// and resets status message. /// </summary> /// <param name="e">An <code>System.EventArgs</code> that contains the event data.</param> protected override void OnShown(EventArgs e) { base.OnShown(e); IMDIParent parent = MdiParent as IMDIParent; if (parent != null) { foreach (ToolStrip ts in toolStrips) { //Console.WriteLine("debug : " + ts.Name + " MDIChildForm_Shown"); ts.Dock = DockStyle.Left; parent.joinToolStrip(ts); //ToolStripManager.Merge(ts, "mainTS"); } } } /* /// <summary> /// Raises the <code>System.Windows.Forms.Form.FormClosing</code> event, /// and set the isClosing value. /// </summary> /// <param name="e">An <code>System.EventArgs</code> that contains the event data.</param> protected override void OnFormClosing(FormClosingEventArgs e) { isClosing = true; base.OnFormClosing(e); } */ protected override void OnFormClosed(FormClosedEventArgs e) { foreach (ToolStrip ts in toolStrips) { if (ts != null) { //Console.WriteLine("debug : " + ts.Name + " MDIChildForm_FormClosing"); ts.Parent.Controls.Remove(ts); ts.Dispose(); } } base.OnFormClosed(e); } /* protected override void OnParentChanged(EventArgs e) { base.OnParentChanged(e); if (this.MdiParent != null && this.MdiParent is IMDIParent) { //reset toolstrips } } */ #endregion #region StatusStrip methods /// <summary> /// Show the progressBar /// </summary> public void startProgress() { IMDIParent parent = MdiParent as IMDIParent; if (parent != null) { parent.startProgress(); } } /// <summary> /// Hide the progressBar /// </summary> public void stopProgress() { IMDIParent parent = MdiParent as IMDIParent; if (parent != null) { parent.stopProgress(); } } public void setStatusMessage(string copyright, string version, string message) { IMDIParent parent = MdiParent as IMDIParent; if (parent != null) { parent.setStatusMessage(copyright, version, message); } } public void setStatusMessage(string message) { IMDIParent parent = MdiParent as IMDIParent; if (parent != null) { parent.setStatusMessage(message); } } /// <summary> /// todo : reset with copyright and version of the active form (call for that a reset method on the mdiparentform) /// </summary> public void resetStatusStrip() { IMDIParent parent = MdiParent as IMDIParent; if (parent != null) { //parent.resetStatusStrip(); parent.setStatusMessage( "Copyright 2006 BrolDev", Application.ProductName + " " + Application.ProductVersion, "" ); } } #endregion #region private Assembly properties private string AssemblyTitle { get { // Get all Title properties on this assembly // If there is at least one Title attribute if (properties.Length > 0) { // Select the first one AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)properties[0]; // If it is not an empty string, return it if (titleAttribute.Title != "") return titleAttribute.Title; } // If there was no Title attribute, or if the Title attribute was the empty string, return the .exe name return System.IO.Path.GetFileNameWithoutExtension(assembly.CodeBase); } } private string AssemblyVersion { get { return assembly.GetName().Version.ToString(); } } private string AssemblyDescription { get { // Get all Description properties on this assembly // If there aren't any Description properties, return an empty string if (properties.Length == 0) return ""; // If there is a Description attribute, return its value return ((AssemblyDescriptionAttribute)properties[0]).Description; } } private string AssemblyCopyright { get { // Get all Copyright properties on this assembly // If there aren't any Copyright properties, return an empty string if (properties.Length == 0) return ""; // If there is a Copyright attribute, return its value return ((AssemblyCopyrightAttribute)properties[0]).Copyright; } } private string AssemblyCompany { get { // Get all Company properties on this assembly // If there aren't any Company properties, return an empty string if (properties.Length == 0) return ""; // If there is a Company attribute, return its value return ((AssemblyCompanyAttribute)properties[0]).Company; } } #endregion } }
Structure et Fichiers du projet
Afficher/masquer...Icône | Nom | Taille | Modification |
Icône | Nom | Taille | Modification |
| _ | Répertoire parent | 0 octets | 1730780156 05/11/2024 05:15:56 |
| _ | 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//MDIChildForm.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.