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.

ScrollablePictureBoxUserControl. cs

Description du code

ScrollablePictureBoxUserControl.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.Drawing;
  4. using System.Windows.Forms;
  5.  
  6. namespace be.gaudry.view.controls
  7. {
  8. public partial class ScrollablePictureBoxUserControl : UserControl
  9. {
  10. #region declarations and constructors
  11. private float zoom;
  12. private Bitmap bitmap;
  13. public ScrollablePictureBoxUserControl()
  14. {
  15. zoom = 0.05F;
  16. InitializeComponent();
  17. /*
  18.   this.SetStyle(ControlStyles.UserPaint, true);
  19.   this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  20.   this.SetStyle(ControlStyles.DoubleBuffer, true);
  21.   this.SetStyle(ControlStyles.ResizeRedraw, true);
  22.   */
  23. }
  24. #endregion
  25.  
  26. #region properties
  27. /// <summary>
  28. /// Image to display in the scrollable thumb panel
  29. /// </summary>
  30. [
  31. Category("Image options"),
  32. Description("Bitmap to display in the scrollable picturebox")
  33. ]
  34. public Bitmap Bitmap
  35. {
  36. get
  37. {
  38. return bitmap;
  39. }
  40. set
  41. {
  42. if (value != null && value.Width > 1 && value.Height > 1)
  43. {
  44. bitmap = value;
  45. thumbPB.Image = bitmap;
  46.  
  47. //setThumbPanel();
  48. //thumbPanel.AutoScrollMinSize = thumbPanel.Size;
  49. //zoom = (float)bitmap.Width / thumbPanel.Width;
  50. zoom = (float)thumbPanel.Width / bitmap.Width;
  51. zoomThumbTrkB.Minimum = 5;
  52. zoomThumbTrkB.Maximum = 210;
  53. setZoomTrkValue();
  54. zoomThumbTrkB.Visible = true;
  55. thumbSizeLbl.Visible = true;
  56. thumbPB.Invalidate(thumbPB.ClientRectangle);
  57. }
  58. }
  59. }
  60. /// <summary>
  61. /// Image to display in the scrollable thumb panel
  62. /// </summary>
  63. [
  64. Category("Image options"),
  65. Description("Zoom to apply on the displayed image")
  66. ]
  67. public float Zoom
  68. {
  69. get
  70. {
  71. return zoom;
  72. }
  73. /*set
  74.   {
  75.   if (value != null)
  76.   {
  77.   zoom = value;
  78.   if (bitmap != null)
  79.   {
  80.   setZoomTrkValue();
  81.   zoomThumbTrkB.Visible = true;
  82.   thumbSizeLbl.Visible = true;
  83.   }
  84.   }
  85.   }*/
  86. }
  87. public void setBitmap(Bitmap newBitmap)
  88. {
  89. thumbPB.Image = newBitmap;
  90. }
  91. public void zoomIn()
  92. {
  93. zoom += ((float)zoomThumbTrkB.LargeChange / 100);
  94. int i = zoomThumbTrkB.Value+zoomThumbTrkB.LargeChange;
  95. if (i > zoomThumbTrkB.Maximum)
  96. {
  97. zoomThumbTrkB.Maximum = i;
  98. zoomThumbTrkB.Invalidate();
  99. }
  100. setThumbPanel();
  101. setZoomTrkValue();
  102. }
  103. public void zoomOut()
  104. {
  105. zoom -= ((float)zoomThumbTrkB.LargeChange / 100);
  106. setThumbPanel();
  107. setZoomTrkValue();
  108. }
  109. public void zoomToFit()
  110. {
  111. thumbPanel.AutoScrollMinSize = thumbPanel.Size;
  112. zoom = (float)bitmap.Width / thumbPanel.Width;
  113. thumbPanel.Invalidate(thumbPanel.ClientRectangle);
  114. zoomThumbTrkB.Value = zoomThumbTrkB.Minimum;
  115. }
  116. public void zoomToRealSize()
  117. {
  118. zoom = 1F;
  119. setThumbPanel();
  120. setZoomTrkValue();
  121. }
  122.  
  123. private void setZoomTrkValue()
  124. {
  125. int trkVal = (int)(zoom * 100);
  126. if (trkVal < zoomThumbTrkB.Minimum)
  127. trkVal = zoomThumbTrkB.Minimum;
  128. if (trkVal > zoomThumbTrkB.Maximum)
  129. trkVal = zoomThumbTrkB.Maximum;
  130. zoom = (float)trkVal / 100;
  131. zoomThumbTrkB.Value = trkVal;
  132. }
  133. #endregion
  134.  
  135. private void zoomThumbTrkB_Scroll(object sender, EventArgs e)
  136. {
  137. zoom = (float)zoomThumbTrkB.Value / 100;
  138. setThumbPanel();
  139. }
  140.  
  141. private void setThumbPanel()
  142. {
  143. thumbPanel.AutoScrollMinSize = new Size((int)(bitmap.Width * zoom), (int)(bitmap.Height * zoom));
  144. thumbPanel.Invalidate(thumbPanel.ClientRectangle);
  145.  
  146. }
  147. private void thumbPanel_Paint(object sender, PaintEventArgs e)
  148. {
  149. /*if (bitmap != null)
  150.   {
  151.   Graphics g = e.Graphics;
  152.   g.DrawImage(bitmap, new Rectangle(
  153.   thumbPanel.AutoScrollPosition.X + ((thumbPanel.Width - newWidth) / 2),
  154.   thumbPanel.AutoScrollPosition.Y + ((thumbPanel.Height - newHeight) / 2),
  155.   newWidth,
  156.   newHeight)
  157.   );
  158.   }*/
  159. }
  160.  
  161. private void thumbPB_Paint(object sender, PaintEventArgs e)
  162. {
  163. if (bitmap != null)
  164. {
  165. zoom = (float)thumbPB.Width / bitmap.Width;
  166. zoomThumbTrkB.Minimum = (int)(((float)thumbPanel.Width / bitmap.Width)*100);
  167. thumbSizeLbl.Text = String.Format("Affichage : {0}% ({1} * {2} pixels)", (int)(zoom*100), thumbPB.Width, thumbPB.Height);
  168. }
  169. }
  170. }
  171. }

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 octets1727435626 27/09/2024 13:13:46
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//ScrollablePictureBoxUserControl.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.