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.

UpdateControl.cs

Description du code

UpdateControl.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.ComponentModel;
  3. using System.Deployment.Application;
  4. using System.Windows.Forms;
  5. using be.gaudry.view.dialogs;
  6.  
  7. namespace be.gaudry.view.controls
  8. {
  9. public partial class UpdateControl : UserControl
  10. {
  11. long sizeOfUpdate = 0;
  12. public UpdateControl()
  13. {
  14. InitializeComponent();
  15. }
  16.  
  17. private void updateBtn_Click(object sender, EventArgs e)
  18. {
  19. UpdateApplication();
  20. }
  21. private void UpdateApplication()
  22. {
  23. if (ApplicationDeployment.IsNetworkDeployed)
  24. {
  25. updatePGB.Value = 0;
  26. updatePGB.Visible = true;
  27. ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
  28. ad.CheckForUpdateCompleted += new CheckForUpdateCompletedEventHandler(ad_CheckForUpdateCompleted);
  29. ad.CheckForUpdateProgressChanged += new DeploymentProgressChangedEventHandler(ad_CheckForUpdateProgressChanged);
  30.  
  31. ad.UpdateCompleted += new AsyncCompletedEventHandler(ad_UpdateCompleted);
  32. ad.UpdateProgressChanged += new DeploymentProgressChangedEventHandler(ad_UpdateProgressChanged);
  33.  
  34. ad.CheckForUpdateAsync();
  35. }
  36. else
  37. {
  38. MessageBox.Show("Cette version de Bibliobrol n'est pas une version déployée,\nou n'est pas démarrée depuis le menu \"Démarrer\" de Windows.",
  39. "Mise à jour",
  40. MessageBoxButtons.OK,
  41. MessageBoxIcon.Stop);
  42. }
  43. }
  44.  
  45. #region check for update
  46. void ad_CheckForUpdateProgressChanged(object sender, DeploymentProgressChangedEventArgs e)
  47. {
  48. updatePGB.Value = e.ProgressPercentage;
  49. updateLbl.Text = String.Format(
  50. "Téléchargement : {0}. {1:D}K de {2:D}K téléchargés.",
  51. GetProgressString(e.State),
  52. e.BytesCompleted / 1024,
  53. e.BytesTotal / 1024
  54. );
  55. }
  56.  
  57. string GetProgressString(DeploymentProgressState state)
  58. {
  59. if (state == DeploymentProgressState.DownloadingApplicationFiles)
  60. {
  61. return "fichier application";
  62. }
  63. else if (state == DeploymentProgressState.DownloadingApplicationInformation)
  64. {
  65. return "manifeste de l'application";
  66. }
  67. else
  68. {
  69. return "manifeste de deploiement";
  70. }
  71. }
  72.  
  73. void ad_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
  74. {
  75. if (e.Error != null)
  76. {
  77. ExceptionDialog.ShowDialog(
  78. "Erreur de mise à jour",
  79. "Impossible d'effectuer la mise à jour. Motif : \n" + e.Error.Message,
  80. e.Error,
  81. this.ParentForm
  82. );
  83. return;
  84. }
  85. else if (e.Cancelled == true)
  86. {
  87. MessageBox.Show("La mise à jour est abandonnée.",
  88. "Mise à jour",
  89. MessageBoxButtons.OK,
  90. MessageBoxIcon.Information);
  91. }
  92.  
  93. // Ask the user if they would like to update the application now.
  94. if (e.UpdateAvailable)
  95. {
  96. sizeOfUpdate = e.UpdateSizeBytes;
  97.  
  98. if (!e.IsUpdateRequired)
  99. {
  100. DialogResult dr = MessageBox.Show(
  101. String.Format("Une nouvelle version est disponible.\n\nMettre à jour maintenant ?\n\nTaille du téléchargement : {0} octets", e.UpdateSizeBytes),
  102. "Mise à jour",
  103. MessageBoxButtons.OKCancel,
  104. MessageBoxIcon.Question
  105. );
  106. if (DialogResult.OK == dr)
  107. {
  108. BeginUpdate();
  109. }
  110. }
  111. else
  112. {
  113. MessageBox.Show(
  114. "Une mise à jour critique est disponible pour BiblioBrol. La mise à jour va s'installer maintenant, un redémarrage de l'application sera nécessaire.",
  115. "Mise à jour",
  116. MessageBoxButtons.OK,
  117. MessageBoxIcon.Information);
  118. BeginUpdate();
  119. }
  120. }
  121. else
  122. {
  123. MessageBox.Show("Aucune mise à jour disponible.",
  124. "Mise à jour",
  125. MessageBoxButtons.OK,
  126. MessageBoxIcon.Information);
  127. }
  128. }
  129. #endregion
  130.  
  131. #region update
  132. private void BeginUpdate()
  133. {
  134. ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
  135. //ad.UpdateCompleted += new AsyncCompletedEventHandler(ad_UpdateCompleted);
  136. //ad.UpdateProgressChanged += new DeploymentProgressChangedEventHandler(ad_UpdateProgressChanged);
  137. try
  138. {
  139. ad.UpdateAsync();
  140. }
  141. catch (DeploymentDownloadException dde)
  142. {
  143. ExceptionDialog.ShowDialog(
  144. "Erreur de mise à jour",
  145. "L'application ne peut être mise à jour maintenant.\n\nVeuillez vérifier votre connexion réseau ou réessayer plus tard.\n\nErreur : " + dde.Message,
  146. dde,
  147. this.ParentForm
  148. );
  149. }
  150. }
  151.  
  152. void ad_UpdateProgressChanged(object sender, DeploymentProgressChangedEventArgs e)
  153. {
  154. updatePGB.Value = e.ProgressPercentage;
  155. String progressText = String.Format(
  156. "{0:D}K téléchargés sur {1:D}K - {2:D}% du total",
  157. e.BytesCompleted / 1024,
  158. e.BytesTotal / 1024,
  159. e.ProgressPercentage
  160. );
  161. updateLbl.Text = progressText;
  162. }
  163.  
  164. void ad_UpdateCompleted(object sender, AsyncCompletedEventArgs e)
  165. {
  166. if (e.Cancelled)
  167. {
  168. MessageBox.Show("La mise à jour est abandonnée.",
  169. "Mise à jour",
  170. MessageBoxButtons.OK,
  171. MessageBoxIcon.Information);
  172. return;
  173. }
  174. else if (e.Error != null)
  175. {
  176. ExceptionDialog.ShowDialog(
  177. "Erreur de mise à jour",
  178. "L'application ne peut être mise à jour maintenant.\n\nVeuillez vérifier votre connexion réseau ou réessayer plus tard.\n\nErreur : " + e.Error.Message,
  179. e.Error,
  180. this.ParentForm
  181. );
  182. return;
  183. }
  184.  
  185. DialogResult dr = MessageBox.Show(
  186. "L'application est mise à jour et un redémarrage est vivement conseillé. Souhaitez-vous redémarrer ?\n\nSi vous ne redémarrez pas maintenant, la nouvelle version ne pourra prendre effet qu'au prochain démarrage de l'application.",
  187. "Redémarrage de l'application",
  188. MessageBoxButtons.OKCancel
  189. );
  190. if (DialogResult.OK == dr)
  191. {
  192. Application.Restart();
  193. }
  194. }
  195. #endregion
  196.  
  197. }
  198. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/controls/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1715700058 14/05/2024 17:20:58
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/view/controls/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csToolBarHomeControl.Designer.cs7.41 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csWizardUserControl.Designer.cs6.79 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csHeaderPanel.Designer.cs1.19 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csDGVLayoutOptionsControl.cs7.55 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csXPGroupBox.cs15.83 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csWizardXpUserControl.Designer.cs7.85 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csToolBarHomeControl.cs2.32 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csVersionControl.Designer.cs4.09 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csWizardUserControl.cs2.01 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .resx|.resxWizardXpUserControl.resx5.68 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csBrolBoxUserControl.Designer.cs5.92 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .resx|.resxChartControl.resx6.58 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csHeaderPanel.cs35.93 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csIWizardUC.cs2.35 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .resx|.resxAboutUserControl.resx5.68 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .cs|.csTextBoxDragDrop.cs8.59 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csSystemInfoControl.cs5.46 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .resx|.resxXPGroupBox.resx17.7 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csHeaderPanelNativeMethods.cs21.09 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csToolBarManagerControl.cs6.99 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csTextBoxDragDrop.Designer.cs1.11 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .resx|.resxSystemInfoControl.resx6.22 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csSystemInfoControl.Designer.cs4.79 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .resx|.resxHeaderPanel.resx5.85 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csScrollablePictureBoxUserControl.cs5.55 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csBrolBoxUserControl.cs4.7 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .resx|.resxDGVLayoutOptionsControl.resx5.68 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .resx|.resxWizardUserControl.resx5.68 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csUpdateControl.cs7.55 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csIconList.cs2.68 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csVersionControl.cs463 octets31/10/2018 18:33:12-refusé-
Afficher le fichier .resx|.resxBrolBoxUserControl.resx5.68 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .cs|.csAboutUserControl.cs6.75 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .resx|.resxToolBarManagerControl.resx5.88 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csToolBarManagerControl.Designer.cs10.66 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csIToolBarControl.cs1.07 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csWizardXpUserControl.cs8.11 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csImageCombo.cs15.49 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csAboutUserControl.Designer.cs12.31 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .resx|.resxScrollablePictureBoxUserControl.resx5.68 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csScrollablePictureBoxUserControl.Designer.cs5.64 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .resx|.resxVersionControl.resx5.68 Ko31/10/2018 18:33:13-refusé-
Afficher le fichier .cs|.csChartControl.Designer.cs18.45 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .cs|.csUpdateControl.Designer.cs3.92 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .resx|.resxUpdateControl.resx5.68 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csChartControl.cs15.11 Ko31/10/2018 18:33:10-refusé-
Afficher le fichier .cs|.csDGVLayoutOptionsControl.Designer.cs17.39 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .cs|.csToolStrip.cs1.06 Ko31/10/2018 18:33:12-refusé-
Afficher le fichier .cs|.csIconList.Designer.cs1.1 Ko31/10/2018 18:33:11-refusé-
Afficher le fichier .resx|.resxToolBarHomeControl.resx48.51 Ko31/10/2018 18:33:12-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/controls/UpdateControl.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.