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

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Reflection;
  4. using System.Windows.Forms;
  5.  
  6. namespace be.gaudry.view
  7. {
  8. public partial class MDIChildForm : Form
  9. {
  10. #region declarations and constructors
  11. //internal delegate void ProgressBarDelegateHandler();
  12. //private ProgressBarDelegateHandler startProgressBarDelegate, stopProgressBarDelegate;
  13. private List<ToolStrip> toolStrips;
  14. private Assembly assembly;
  15. //private bool isClosing;
  16.  
  17. public MDIChildForm()
  18. {
  19. //isClosing = false;
  20. toolStrips = new List<ToolStrip>();
  21. assembly = Assembly.GetCallingAssembly();
  22. InitializeComponent();
  23. //startProgressBarDelegate += new ProgressBarDelegateHandler(startProgress);
  24. //stopProgressBarDelegate += new ProgressBarDelegateHandler(stopProgress);
  25. }
  26. #endregion
  27.  
  28. #region ToolStrip properties
  29.  
  30. /// <summary>
  31. /// Set enabled or not for all ToolStrip
  32. /// </summary>
  33. protected bool ToolStripsEnabled
  34. {
  35. set
  36. {
  37. foreach (ToolStrip ts in toolStrips)
  38. {
  39. //Console.WriteLine("debug : "+ts.Name+" ToolStripsEnabled");
  40. ts.Enabled = value;
  41. }
  42. }
  43. }
  44.  
  45. /// <summary>
  46. /// Set visible or not for all ToolStrip
  47. /// </summary>
  48. protected bool ToolStripsVisible
  49. {
  50. set
  51. {
  52. foreach (ToolStrip ts in toolStrips)
  53. {
  54. //Console.WriteLine("debug : " + ts.Name + " ToolStripsVisible");
  55. ts.Visible = value;
  56. }
  57. }
  58. }
  59. #endregion
  60.  
  61. #region ToolStrip methods
  62. /// <summary>
  63. /// Add a ToolStrip item in the MainView ToolStripPanel
  64. /// </summary>
  65. /// <param name="ts">ToolStrip to add</param>
  66. protected void addToolStrip(ToolStrip ts)
  67. {
  68. //Console.WriteLine("debug : " + ts.Name + " add");
  69. toolStrips.Add(ts);
  70. //((MainForm)MdiParent).topTSP.Controls.Add(ts);
  71. }
  72.  
  73. /// <summary>
  74. /// Remove a ToolStrip item from the MainView ToolStripPanel
  75. /// </summary>
  76. /// <param name="ts">ToolStrip to add</param>
  77. protected void removeToolStrip(ToolStrip ts)
  78. {
  79. //Console.WriteLine("debug : " + ts.Name + " remove");
  80. toolStrips.Remove(ts);
  81. //((MainForm)MdiParent).topTSP.Controls.Remove(ts);
  82. }
  83. #endregion
  84.  
  85. #region override of form's events
  86. /// <summary>
  87. /// Raises the <code>System.Windows.Forms.Form.Activated</code> event,
  88. /// sets visible the registred <code>ToolStrips</code>,
  89. /// and sets status message with copyright and version of the plugin.
  90. /// </summary>
  91. /// <param name="e">An <code>System.EventArgs</code> that contains the event data.</param>
  92. protected override void OnActivated(EventArgs e)
  93. {
  94. base.OnActivated(e);
  95. this.ToolStripsVisible = true;
  96. /*setStatusMessage(
  97.   "Copyright © 2006 BrolDev",
  98.   Application.ProductName + " " + Application.ProductVersion,
  99.   ""
  100.   );*/
  101. setStatusMessage(
  102. AssemblyCopyright + " " + AssemblyCompany,
  103. AssemblyTitle + " " + AssemblyVersion,
  104. AssemblyDescription
  105. );
  106.  
  107. /*IMDIParent parent = MdiParent as IMDIParent;
  108.   if (parent != null)
  109.   {
  110.   parent.mergeMenuStrip(mainMenuStrip);
  111.   }*/
  112. }
  113. /// <summary>
  114. /// Raises the <code>System.Windows.Forms.Form.Deactivate</code> event,
  115. /// hides the registred <code>ToolStrips</code>,
  116. /// and resets status message.
  117. /// </summary>
  118. /// <param name="e">An <code>System.EventArgs</code> that contains the event data.</param>
  119. protected override void OnDeactivate(EventArgs e)
  120. {
  121. base.OnDeactivate(e);
  122. //if (!isClosing)
  123. //{
  124. this.ToolStripsVisible = false;
  125.  
  126. /*IMDIParent parent = MdiParent as IMDIParent;
  127.   if (parent != null)
  128.   {
  129.   parent.revertMergeMenuStrip(mainMenuStrip);
  130.   }*/
  131. //}
  132.  
  133. //mdiParent.cleanToolStrips(toolStrips);
  134. /*
  135.   foreach (ToolStrip ts in toolStrips)
  136.   {
  137.   try
  138.   {
  139.   mdiParent.topTSP.Controls.Remove(ts);
  140.   }
  141.   catch (Exception ex)
  142.   {
  143.   System.Console.WriteLine("ex : " + ex.Message + " : " + ex.StackTrace);
  144.   }
  145.   }*/
  146. resetStatusStrip();
  147. }
  148. /// <summary>
  149. /// Raises the <code>System.Windows.Forms.Form.Shown</code> event,
  150. /// dockes and join the registred <code>ToolStrips</code> with the parent <code>ToolStrip</code>
  151. /// if parent implements the <code>be.gaudry.view.IDIParentForm</code> interface,
  152. /// and resets status message.
  153. /// </summary>
  154. /// <param name="e">An <code>System.EventArgs</code> that contains the event data.</param>
  155. protected override void OnShown(EventArgs e)
  156. {
  157. base.OnShown(e);
  158. IMDIParent parent = MdiParent as IMDIParent;
  159. if (parent != null)
  160. {
  161. foreach (ToolStrip ts in toolStrips)
  162. {
  163. //Console.WriteLine("debug : " + ts.Name + " MDIChildForm_Shown");
  164. ts.Dock = DockStyle.Left;
  165. parent.joinToolStrip(ts);
  166.  
  167. //ToolStripManager.Merge(ts, "mainTS");
  168. }
  169. }
  170. }
  171. /*
  172.   /// <summary>
  173.   /// Raises the <code>System.Windows.Forms.Form.FormClosing</code> event,
  174.   /// and set the isClosing value.
  175.   /// </summary>
  176.   /// <param name="e">An <code>System.EventArgs</code> that contains the event data.</param>
  177.   protected override void OnFormClosing(FormClosingEventArgs e)
  178.   {
  179.   isClosing = true;
  180.   base.OnFormClosing(e);
  181.   }
  182.   */
  183. protected override void OnFormClosed(FormClosedEventArgs e)
  184. {
  185. foreach (ToolStrip ts in toolStrips)
  186. {
  187. if (ts != null)
  188. {
  189. //Console.WriteLine("debug : " + ts.Name + " MDIChildForm_FormClosing");
  190. ts.Parent.Controls.Remove(ts);
  191. ts.Dispose();
  192. }
  193. }
  194. base.OnFormClosed(e);
  195. }
  196. /*
  197.   protected override void OnParentChanged(EventArgs e)
  198.   {
  199.   base.OnParentChanged(e);
  200.   if (this.MdiParent != null && this.MdiParent is IMDIParent)
  201.   {
  202.   //reset toolstrips
  203.   }
  204.   }
  205.   */
  206. #endregion
  207.  
  208. #region StatusStrip methods
  209.  
  210. /// <summary>
  211. /// Show the progressBar
  212. /// </summary>
  213. public void startProgress()
  214. {
  215. IMDIParent parent = MdiParent as IMDIParent;
  216. if (parent != null)
  217. {
  218. parent.startProgress();
  219. }
  220. }
  221. /// <summary>
  222. /// Hide the progressBar
  223. /// </summary>
  224. public void stopProgress()
  225. {
  226. IMDIParent parent = MdiParent as IMDIParent;
  227. if (parent != null)
  228. {
  229. parent.stopProgress();
  230. }
  231. }
  232. public void setStatusMessage(string copyright, string version, string message)
  233. {
  234. IMDIParent parent = MdiParent as IMDIParent;
  235. if (parent != null)
  236. {
  237. parent.setStatusMessage(copyright, version, message);
  238. }
  239. }
  240.  
  241. public void setStatusMessage(string message)
  242. {
  243. IMDIParent parent = MdiParent as IMDIParent;
  244. if (parent != null)
  245. {
  246. parent.setStatusMessage(message);
  247. }
  248. }
  249. /// <summary>
  250. /// todo : reset with copyright and version of the active form (call for that a reset method on the mdiparentform)
  251. /// </summary>
  252. public void resetStatusStrip()
  253. {
  254. IMDIParent parent = MdiParent as IMDIParent;
  255. if (parent != null)
  256. {
  257. //parent.resetStatusStrip();
  258. parent.setStatusMessage(
  259. "Copyright 2006 BrolDev",
  260. Application.ProductName + " " + Application.ProductVersion,
  261. ""
  262. );
  263. }
  264. }
  265. #endregion
  266.  
  267. #region private Assembly properties
  268.  
  269. private string AssemblyTitle
  270. {
  271. get
  272. {
  273. // Get all Title properties on this assembly
  274. object[] properties = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
  275. // If there is at least one Title attribute
  276. if (properties.Length > 0)
  277. {
  278. // Select the first one
  279. AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)properties[0];
  280. // If it is not an empty string, return it
  281. if (titleAttribute.Title != "")
  282. return titleAttribute.Title;
  283. }
  284. // If there was no Title attribute, or if the Title attribute was the empty string, return the .exe name
  285. return System.IO.Path.GetFileNameWithoutExtension(assembly.CodeBase);
  286. }
  287. }
  288.  
  289. private string AssemblyVersion
  290. {
  291. get
  292. {
  293. return assembly.GetName().Version.ToString();
  294. }
  295. }
  296.  
  297. private string AssemblyDescription
  298. {
  299. get
  300. {
  301. // Get all Description properties on this assembly
  302. object[] properties = assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
  303. // If there aren't any Description properties, return an empty string
  304. if (properties.Length == 0)
  305. return "";
  306. // If there is a Description attribute, return its value
  307. return ((AssemblyDescriptionAttribute)properties[0]).Description;
  308. }
  309. }
  310.  
  311. private string AssemblyCopyright
  312. {
  313. get
  314. {
  315. // Get all Copyright properties on this assembly
  316. object[] properties = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
  317. // If there aren't any Copyright properties, return an empty string
  318. if (properties.Length == 0)
  319. return "";
  320. // If there is a Copyright attribute, return its value
  321. return ((AssemblyCopyrightAttribute)properties[0]).Copyright;
  322. }
  323. }
  324.  
  325. private string AssemblyCompany
  326. {
  327. get
  328. {
  329. // Get all Company properties on this assembly
  330. object[] properties = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false);
  331. // If there aren't any Company properties, return an empty string
  332. if (properties.Length == 0)
  333. return "";
  334. // If there is a Company attribute, return its value
  335. return ((AssemblyCompanyAttribute)properties[0]).Company;
  336. }
  337. }
  338. #endregion
  339. }
  340. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/ 
IcôneNomTailleModification
IcôneNomTailleModification
| _ Répertoire parent0 octets1730780156 05/11/2024 05:15:56
| _dialogs0 octets1541007195 31/10/2018 18:33:15
| _style0 octets1541007196 31/10/2018 18:33:16
| _utils0 octets1541007196 31/10/2018 18:33:16
| _controls0 octets1541007193 31/10/2018 18:33:13
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csDummyDoc.cs1.95 Ko31/10/2018 18:32:48-refusé-
Afficher le fichier .cs|.csIMDIParent.cs2.33 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csMDIChildForm.cs11.93 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csSplashForm.Designer.cs4.45 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csSourcesForm.Designer.cs8.14 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csDummyDoc.Designer.cs6.42 Ko31/10/2018 18:32:48-refusé-
Afficher le fichier .cs|.csSplashForm.cs1.02 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csMDIParentForm.cs13.52 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .resx|.resxSplashForm.resx5.68 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csMDIParentForm.MDIFeatures.cs14.33 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .resx|.resxMDIChildForm.resx5.68 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csTestForm.cs350 octets31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csSplasher.cs2.81 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .resx|.resxDummyDoc.resx7.02 Ko31/10/2018 18:32:48-refusé-
Afficher le fichier .cs|.csMDIParentForm.Designer.cs44.09 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .resx|.resxSourcesForm.resx41.87 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csSourcesForm.cs1.83 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csTestForm.Designer.cs1.15 Ko31/10/2018 18:32:50-refusé-
Afficher le fichier .resx|.resxMDIParentForm.resx42.14 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csMDIChildForm.Designer.cs1.46 Ko31/10/2018 18:32:49-refusé-
Afficher le fichier .cs|.csIMDIChild.cs151 octets31/10/2018 18:32:48-refusé-

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.