No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

DgvFactory.cs

Description du code

DgvFactory.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.Windows.Forms;
  3. using be.gaudry.model.config;
  4. using be.gaudry.model.enums;
  5. using be.gaudry.view.dialogs;
  6. using be.gaudry.view.utils.dgvFactory;
  7.  
  8. namespace be.gaudry.view.utils
  9. {
  10. public static class DgvFactory
  11. {
  12. #region declarations ans initializationa
  13. private static TextDgv textDGV;
  14. private static PrintDgv printDGV;
  15. private static CSVDgv csvDGV;
  16. private static HtmlDgv htmlDGV;
  17. private static XMLDgv xmlDGV;
  18. private static ExcelDgv excelDGV;
  19.  
  20. private static Settings settings = new Settings();
  21. private static string exportFormatSettingString = "display/dgvOutputFormat";
  22. private static DGVLayoutOptionsDialog dlg = new DGVLayoutOptionsDialog();
  23. #endregion
  24.  
  25. #region public methods
  26. public static void save(DataGridView dgv, string documentTitle, Form ownerForm)
  27. {
  28. dlg.layoutControl.setOutputFormat(loadPreferedFormat());
  29. setLayoutOptions(dgv, documentTitle, ownerForm);
  30. }
  31.  
  32.  
  33. public static void print(DataGridView dgv, string documentTitle, Form ownerForm)
  34. {
  35. dlg.layoutControl.setOutputFormat(DGV_EXPORT_FORMAT.Print);
  36. setLayoutOptions(dgv, documentTitle, ownerForm);
  37. }
  38. #endregion
  39.  
  40. #region persistance of prefered output format
  41. private static DGV_EXPORT_FORMAT loadPreferedFormat()
  42. {
  43. DGV_EXPORT_FORMAT format = DGV_EXPORT_FORMAT.Text;
  44. try
  45. {
  46. string formatStr = settings.getSetting(
  47. exportFormatSettingString,
  48. Enum.GetName(typeof(DGV_EXPORT_FORMAT), format)
  49. );
  50. return (DGV_EXPORT_FORMAT)Enum.Parse(
  51. typeof(DGV_EXPORT_FORMAT),
  52. formatStr,
  53. false
  54. );
  55. }
  56. catch
  57. {
  58. return format;
  59. }
  60. }
  61. private static void savePreferedFormat(DGV_EXPORT_FORMAT format)
  62. {
  63. settings.putSetting(
  64. exportFormatSettingString,
  65. Enum.GetName(typeof(DGV_EXPORT_FORMAT), format),
  66. true
  67. );
  68. }
  69. #endregion
  70.  
  71. #region private methods
  72. private static bool setLayoutOptions(DataGridView dgv, string outputTitle, Form ownerForm)
  73. {
  74. dlg.layoutControl.setAvailableColumns(dgv);
  75. dlg.layoutControl.setTitle(outputTitle);
  76. DialogResult dr;
  77. if (ownerForm != null)
  78. {
  79. dr = dlg.ShowDialog(ownerForm);
  80. }
  81. else
  82. {
  83. dr = dlg.ShowDialog();
  84. }
  85. if (dr != DialogResult.OK) return false;
  86.  
  87. AbstractDgv abstractDgv = null;
  88.  
  89. DGV_EXPORT_FORMAT format = dlg.layoutControl.getOutputFormat();
  90. savePreferedFormat(format);
  91. switch (format)
  92. {
  93. case DGV_EXPORT_FORMAT.Text:
  94. if (textDGV == null) textDGV = new TextDgv();
  95. abstractDgv = textDGV;
  96. ((TextDgv)abstractDgv).Separator = dlg.layoutControl.getSeparator();
  97. break;
  98. case DGV_EXPORT_FORMAT.CSV:
  99. if (csvDGV == null) csvDGV = new CSVDgv();
  100. abstractDgv = csvDGV;
  101. ((CSVDgv)abstractDgv).Separator = dlg.layoutControl.getSeparator();
  102. break;
  103. case DGV_EXPORT_FORMAT.Print:
  104. if (printDGV == null) printDGV = new PrintDgv();
  105. abstractDgv = printDGV;
  106. break;
  107. case DGV_EXPORT_FORMAT.HTML:
  108. if (htmlDGV == null) htmlDGV = new HtmlDgv();
  109. abstractDgv = htmlDGV;
  110. break;
  111. case DGV_EXPORT_FORMAT.XML:
  112. if (xmlDGV == null) xmlDGV = new XMLDgv();
  113. abstractDgv = xmlDGV;
  114. break;
  115. case DGV_EXPORT_FORMAT.Excel:
  116. if (excelDGV == null) excelDGV = new ExcelDgv();
  117. abstractDgv = excelDGV;
  118. break;
  119. default:
  120. if (printDGV == null) printDGV = new PrintDgv();
  121. abstractDgv = printDGV;
  122. break;
  123. }
  124. abstractDgv.PrintTitle = dlg.layoutControl.getTitle();
  125. abstractDgv.PrintAllRows = dlg.layoutControl.getPrintAllRows();
  126. abstractDgv.FitToPageWidth = dlg.layoutControl.getFitToPageWidth();
  127. abstractDgv.SelectedColumns = dlg.layoutControl.getSelectedColumns();
  128. abstractDgv.PageCounterFormat = dlg.layoutControl.getPageCounterFormat();
  129. abstractDgv.DisplayDate = dlg.layoutControl.getDisplayDate();
  130. abstractDgv.pageOrientation = dlg.layoutControl.getPageOrientation();
  131. abstractDgv.dialogOwner = ownerForm;
  132.  
  133. abstractDgv.print(dgv);
  134.  
  135. return true;
  136. }
  137. #endregion
  138. }
  139. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/utils/ 
IcôneNomTailleModification
IcôneNomTailleModification
| _ Répertoire parent0 octets1719795175 01/07/2024 02:52:55
| _dgvFactory0 octets1541007203 31/10/2018 18:33:23
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/utils/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csDgvFactory.cs5.19 Ko31/10/2018 18:33:16-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/utils/DgvFactory.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.