MDIParentForm.MDIFeatures.cs
Description du code
MDIParentForm.MDIFeatures.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.MDIFeatures.cs) (356 lignes)
using System; using System.Collections.Generic; using System.Windows.Forms; using be.gaudry.model.exceptions; namespace be.gaudry.view { partial class MDIParentForm { #region declarations /// <summary> /// Used to prevent toolstrip bug with the office style /// </summary> private string toolStripPadding=" "; /// <summary> /// Available menus on the <code>MDIParentForm</code> /// Used e.g. to define where putting a menu item /// </summary> public enum MENU { file, display, tools, toolBars, window, help } /// <summary> /// Used to store instances of childs /// </summary> //private System.ComponentModel.BackgroundWorker openMdiChildBGW; #endregion #region single instance of child /// <summary> /// Ensure having only one instance of this type of child form in the MDI parent (this) /// Create new child if not exists, <b>and show it</b>. /// Use this method only if you don't have to call some method before opening the form. /// Otherwise, call the <code>createMDIChild()</code> method to get the instance, call the needed method on the child, and call the /// </summary> /// <typeparam name="T">Type of the form to show.</typeparam> /// <returns>New form if not existed, or existing form</returns> { return showMDIChild<T>(""); } /// <summary> /// Ensure having only one instance of this type of child form in the MDI parent (this) /// Create new child if not exists, <b>and show it</b>. /// Use this method only if you don't have to call some method before opening the form. /// Otherwise, call the <code>createMDIChild()</code> method to get the instance, call the needed method on the child, and call the /// </summary> /// <typeparam name="T">Type of the form to show.</typeparam> /// <param name="progressInfo">Text to display along the progress of creating instance</param> /// <returns>New form if not existed, or existing form</returns> { T child = createMDIChild<T>(progressInfo); showMDIChild(child); child.WindowState = FormWindowState.Maximized; return child; } /// <summary> /// Show an instance of form. /// This method <b>may not ensure single instance of child form</b>. /// To ensure single instance, use <code>createMDIChild()</code> method to get the single instance of the child form /// to have this method parameter. /// </summary> /// <param name="child">Form to show</param> protected void showMDIChild(Form child) { if (child != null) { child.Show(); child.Activate(); } } /// <summary> /// Ensure having only one instance of this type of child form in the MDI parent (this) /// Create new child if not exists, <b>but don't show it</b>. /// </summary> /// <typeparam name="T">Type of the form to show.</typeparam> /// <returns>New form if not existed, or existing form</returns> { return createMDIChild<T>(""); } /// <summary> /// Ensure having only one instance of this type of child form in the MDI parent (this) /// Create new child if not exists, <b>but don't show it</b>. /// </summary> /// <typeparam name="T">Type of the form to show.</typeparam> /// <param name="progressInfo">Text to display along the progress of creating instance</param> /// <returns>New form if not existed, or existing form</returns> { // Create new child if not exists in the collection and add it { bool showProgress = !string.Empty.Equals(progressInfo); if (showProgress) { /*if (statusStrip.Visible) { startProgress(); setStatusMessage(progressInfo); } else {*/ Splasher.show(progressInfo); //} //System.Threading.Thread.Sleep(10000); } // Set up the necessary properties mdiChildForm.MdiParent = this; mdiChildForm.WindowState = FormWindowState.Maximized; { MenuStrip menuStrip = ((IMDIChild)mdiChildForm).getMainMenuStrip(); if (menuStrip != null) { menuStrip.Visible = false; } } // Remove form from the collection when the mdiChild is closed mdiChildForm.FormClosed += new FormClosedEventHandler(delegate(object sender, FormClosedEventArgs e) { this.mdiChilds.Remove(sender.GetType()); }); // //if (showProgress) //{ /*if (statusStrip.Visible) { stopProgress(); resetStatusStrip(); } else {*/ Splasher.close(); //} //} } // return the child return formToActivate; } #endregion #region menu /// <summary> /// Add a menuItem on the main <code>MenuStrip</code> to open a single instance of the mdiChild. /// Add necessary actions on click. /// </summary> /// <typeparam name="T">Type of the mdiChild to open</typeparam> /// <param name="childTsMi"><code>ToolStripMenuItem</code> to use on the main MenuStrip.</param> /// <param name="progressInfo">Text to display along the progress of creating instance. Empty string or null value may be used to avoid displaying progression.</param> /// <exception cref="be.gaudry.exceptions.PluginException">Plugin exception if childTsMi is null or don't have text to display.</exception> { if (childTsMi == null || string.Empty.Equals(childTsMi.Text)) { } mainMenuStrip.Items.Insert(2, childTsMi); //Console.WriteLine("add menu : " + typeof(T)); { if (string.Empty.Equals(progressInfo)) { showMDIChild<T>(); } else { showMDIChild<T>(progressInfo); } }); } /// <summary> /// Add a menuItem on the main <code>MenuStrip</code> to open a single instance of the mdiChild. /// Add necessary actions on click. /// </summary> /// <typeparam name="T">Type of the mdiChild to open</typeparam> /// <param name="childTsMi"><code>ToolStripMenuItem</code> to use on the main MenuStrip.</param> /// <param name="menu">Location of the <code>ToolStripMenuItem</code></param> /// <param name="progressInfo">Text to display along the progress of creating instance. Empty string or null value may be used to avoid displaying progression.</param> /// <exception cref="be.gaudry.exceptions.PluginException">Plugin exception if childTsMi is null or don't have text to display.</exception> public void addChildMenu<T>(ToolStripMenuItem childTsMi, MENU menu, string progressInfo) where T : Form, new() { if (childTsMi == null || string.Empty.Equals(childTsMi.Text)) { } switch (menu) { case MENU.display: displayTsMi.DropDownItems.Add(childTsMi); break; case MENU.file: fileTsMi.DropDownItems.Add(childTsMi); break; case MENU.help: helpTsMi.DropDownItems.Add(childTsMi); break; case MENU.tools: toolsTsMi.DropDownItems.Add(childTsMi); break; case MENU.toolBars: displayToolBarTsMi.DropDownItems.Add(childTsMi); break; case MENU.window: windowTsMi.DropDownItems.Add(childTsMi); break; } //Console.WriteLine("add menu : " + typeof(T)); { if (string.Empty.Equals(progressInfo)) { showMDIChild<T>(); } else { showMDIChild<T>(progressInfo); } }); } #endregion #region open child in another thread /*private void initBackgroundWorker() { this.openMdiChildBGW = new System.ComponentModel.BackgroundWorker(); this.openMdiChildBGW.WorkerReportsProgress = true; this.openMdiChildBGW.WorkerSupportsCancellation = true; this.openMdiChildBGW.DoWork += new System.ComponentModel.DoWorkEventHandler(this.openMdiChildBGW_DoWork); this.openMdiChildBGW.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.openMdiChildBGW_RunWorkerCompleted); this.openMdiChildBGW.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.openMdiChildBGW_ProgressChanged); } private void openMdiChildBGW_DoWork(object sender, DoWorkEventArgs e) { } private void openMdiChildBGW_ProgressChanged(object sender, ProgressChangedEventArgs e) { } private void openMdiChildBGW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { }*/ #endregion #region IMDIParent Membres public bool joinToolStrip(ToolStrip ts) { this.topTSP.Join(ts);//this.topTSP.Join(ts, 1); return true; } public void setStatusMessage(string copyright, string version, string message) { if (InvokeRequired) { Invoke((MethodInvoker)delegate() { setStatusMessage(copyright, version, message); }); } else { copyrightTssLbl.Text = copyright; versionTssLbl.Text = version; infosTssLbl.Image = null; infosTssLbl.Text = message + toolStripPadding; } } public void setStatusMessage(string message) { if (InvokeRequired) { Invoke((MethodInvoker)delegate() { setStatusMessage(message); }); } else { infosTssLbl.Image = null; infosTssLbl.Text = message + toolStripPadding; } } /// <summary> /// Displays a message on the StatusStrip /// </summary> /// <param name="image">Image to display</param> /// <param name="message">Text to display on the status label</param> /// <param name="tooltip">Text to display on the status tooltip</param> public void setStatusMessage(System.Drawing.Image image, string message, string tooltip) { if (InvokeRequired) { Invoke((MethodInvoker)delegate() { setStatusMessage(message); }); } else { infosTssLbl.Image = image; infosTssLbl.Text = message + toolStripPadding; infosTssLbl.ToolTipText = tooltip; } } public void resetStatusStrip() { setStatusMessage( "Copyright © 2006 BrolDev", Application.ProductName + " " + Application.ProductVersion, "" ); } public void startProgress() { /*if (InvokeRequired) { Invoke((MethodInvoker)delegate() { startProgress(); }); } else { toolStripProgressBar.Style = ProgressBarStyle.Marquee; toolStripProgressBar.Width = 300; toolStripProgressBar.Visible = true; }*/ } public void stopProgress() { /*if (InvokeRequired) { Invoke((MethodInvoker)delegate() { stopProgress(); }); } else { toolStripProgressBar.Visible = false; toolStripProgressBar.Width = 1; toolStripProgressBar.Style = ProgressBarStyle.Blocks; }*/ } #endregion } }
Structure et Fichiers du projet
Afficher/masquer...Icône | Nom | Taille | Modification |
Icône | Nom | Taille | Modification |
| _ | Répertoire parent | 0 octets | 1732241423 22/11/2024 03:10:23 |
| _ | 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.
Version en cache
22/11/2024 03:10:23 Cette version de la page est en cache (à la date du 22/11/2024 03:10:23) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 16/10/2009, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/cs-broldev-source-rf-view//MDIParentForm.MDIFeatures.cs.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.