Keine Cache-Version

Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code LNG204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.

EventMethods.cs

Description du code

EventMethods.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.Runtime.InteropServices;
  3. using System.Threading;
  4. using System.Windows.Forms;
  5. using be.gaudry.model.drawing;
  6. using be.gaudry.view.dialogs;
  7.  
  8. namespace be.gaudry.events
  9. {
  10. /// <summary>
  11. /// more infos on http://www.codeproject.com/cs/media/DIBtoBitmap.asp
  12. /// </summary>
  13. public static class EventMethods
  14. {
  15.  
  16. public static void applicationThreadException(object sender, ThreadExceptionEventArgs e)
  17. {
  18. /*String msg = String.Format(
  19.   "Une erreur est survenue dans l'application :\r\n\r\n{0}\r\n\r\nDésirez-vous plus d'informations ?\r\nOui : afficher les erreurs\r\nNon : quitter l'application\r\nAnnuler : ne pas quitter et ne pas afficher l'erreur",
  20.   e.Exception.Message
  21.   );
  22.   DialogResult dr = MessageBox.Show(
  23.   msg,
  24.   "Erreur",
  25.   MessageBoxButtons.YesNoCancel,
  26.   MessageBoxIcon.Stop,
  27.   MessageBoxDefaultButton.Button2);
  28.   switch (dr)
  29.   {
  30.   case DialogResult.Yes:
  31.   new ThreadExceptionDialog(e.Exception).Show();
  32.   break;
  33.   case DialogResult.Cancel:
  34.   return;
  35.   default:
  36.   Application.Exit();
  37.   break;
  38.   }*/
  39. new CriticalExceptionDialog(e.Exception).Show();
  40. }
  41.  
  42. public static bool imageDragDrop(object sender, DragEventArgs e, PictureBox pictureBox)
  43. {
  44. bool modified = false;
  45.  
  46.  
  47. /*System.Diagnostics.Debug.WriteLine(string.Format("Un élément est déposé par {0}",sender));
  48.   string[] formats = e.Data.GetFormats();
  49.  
  50.   foreach (string sf in formats)
  51.   {
  52.   System.Diagnostics.Debug.WriteLine(string.Format("Type : {0}", sf)); ;
  53.   }
  54.   */
  55. /*
  56.   if (e.Data.GetDataPresent(typeof(UniformResourceLocator)))
  57.   {
  58.   //editSpImgRTB.AppendText("\r\nType : image web");
  59.   }*/
  60. if (e.Data.GetDataPresent(DataFormats.FileDrop))
  61. {
  62.  
  63. string[] dropFiles = (string[])e.Data.GetData(DataFormats.FileDrop);
  64. if (ImageHelper.isImg(dropFiles[0]))
  65. {
  66. pictureBox.ImageLocation = dropFiles[0];
  67. //modified = true;
  68. return true;
  69. }
  70. else
  71. {
  72. Form form = sender as Form;
  73. MessageBox.Show(
  74. form,
  75. string.Format(
  76. "Le fichier déposé n'est pas une image valide : {0}",
  77. System.IO.Path.GetFileName(dropFiles[0])
  78. ),
  79. "Modification d'image",
  80. MessageBoxButtons.OK,
  81. MessageBoxIcon.Exclamation,
  82. MessageBoxDefaultButton.Button1
  83. );
  84. }
  85.  
  86. /*StringBuilder str = new StringBuilder();
  87.   foreach (string s in dropFiles)
  88.   {
  89.   str.Append("\r\n");
  90.   str.Append(s);
  91.   }
  92.   editSpImgRTB.AppendText(str.ToString());*/
  93. }
  94. if (e.Data.GetDataPresent(typeof(string)))
  95. {
  96. //System.Diagnostics.Debug.WriteLine("Type2 : texte");
  97. string url = e.Data.GetData("UniformResourceLocator") as string;
  98. if (url == null) url = e.Data.GetData("UniformResourceLocatorW") as string;
  99. if(url!=null)
  100. {
  101. pictureBox.ImageLocation = url;
  102. return true;
  103. //System.Diagnostics.Debug.WriteLine("Type2 : url => "+url);
  104. }
  105. }
  106.  
  107.  
  108.  
  109. if (e.Data.GetDataPresent(typeof(System.Drawing.Bitmap)))
  110. {
  111. pictureBox.Image = (System.Drawing.Bitmap)e.Data.GetData(typeof(System.Drawing.Bitmap));
  112. //modified = true;
  113. return true;
  114. /*editSpImgPictureBox.Image = Image.FromStream(
  115.   System.Net.HttpWebRequest.Create(
  116.   "http://www.zeetelevision.com/images/today.jpg"
  117.   ).GetResponse().GetResponseStream()
  118.   );
  119.   */
  120. }
  121. else if (e.Data.GetDataPresent(typeof(System.Net.WebRequestMethods.File)))
  122. {
  123. string str = (string)e.Data.GetData(typeof(string));
  124. //System.Diagnostics.Debug.WriteLine("Type3 : " + str);
  125. pictureBox.Image = System.Drawing.Image.FromStream(
  126. System.Net.HttpWebRequest.Create(
  127. str
  128. ).GetResponse().GetResponseStream()
  129. );
  130. //modified = true;
  131. return true;
  132. }
  133. else if (e.Data.GetDataPresent(DataFormats.Dib))//DeviceIndependentBitmap
  134. {
  135. /*System.Drawing.Bitmap bmp = (System.Drawing.Bitmap)e.Data.GetData(DataFormats.Bitmap, true);
  136.   System.Diagnostics.Debug.WriteLine("DeviceIndependentBitmap bmp test");
  137.   try
  138.   {
  139.   if (bmp != null)
  140.   {
  141.   System.Diagnostics.Debug.WriteLine("DeviceIndependentBitmap bmp ok");
  142.   pictureBox.Image = bmp;
  143.   modified = true;
  144.   }
  145.   }
  146.   catch (Exception exept) { System.Diagnostics.Debug.WriteLine("DeviceIndependentBitmap error : " + exept.StackTrace); }
  147.  
  148.   object obj = e.Data.GetData(DataFormats.Dib);
  149.   //System.Diagnostics.Debug.WriteLine("DeviceIndependentBitmap bmp test");
  150.   System.IO.MemoryStream stream = obj as System.IO.MemoryStream;
  151.   if (stream != null)
  152.   {
  153.  
  154.   //System.Diagnostics.Debug.WriteLine("DeviceIndependentBitmap bmp ok");
  155.   byte[] img = stream.ToArray();
  156.   IntPtr p = Marshal.AllocCoTaskMem(Marshal.SizeOf(img[0]) * img.Length);
  157.   Marshal.Copy(img, 0, p, img.Length);
  158.   try
  159.   {
  160.   pictureBox.Image = TwainGui.DibToImage.WithStream(p);
  161.   }
  162.   catch (Exception exept) { System.Diagnostics.Debug.WriteLine("DeviceIndependentBitmap error : " + exept.StackTrace); }
  163.   finally
  164.   {
  165.   Marshal.FreeCoTaskMem(p);
  166.   }
  167.   }*/
  168. System.IO.MemoryStream stream = e.Data.GetData(DataFormats.Dib) as System.IO.MemoryStream;
  169. if (stream != null)
  170. {
  171.  
  172. byte[] img = stream.ToArray();
  173. IntPtr p = Marshal.AllocCoTaskMem(Marshal.SizeOf(img[0]) * img.Length);
  174. Marshal.Copy(img, 0, p, img.Length);
  175. try
  176. {
  177. pictureBox.Image = DibToImage.WithStream(p);
  178. return true;
  179. }
  180. catch (Exception exept)
  181. {
  182. System.Diagnostics.Debug.WriteLine("DeviceIndependentBitmap error : " + exept.StackTrace);
  183. }
  184. finally
  185. {
  186. Marshal.FreeCoTaskMem(p);
  187. }
  188. }
  189.  
  190. }
  191.  
  192. #region from the URL of the image file
  193. /*string hyperLinkUrl = null;
  194.   string hyperLinkText = null;
  195.   //
  196.   try
  197.   {
  198.   hyperLinkUrl = e.Data.GetData(typeof(string)) as string;
  199.   // some browser deliver url and text
  200.   // in UniformResourceLocator (Firebird)
  201.   string[] tokens = hyperLinkUrl.Split('\\');
  202.   if(tokens.Length>1)
  203.   {
  204.   hyperLinkUrl = tokens[0];
  205.   hyperLinkText = tokens[1];
  206.   }
  207.   // we have to read FILEGROUPDESCRIPTOR to get the text (IE)
  208.   else
  209.   {
  210.   System.IO.Stream ioStream=
  211.   (System.IO.Stream)e.Data.GetData("FileGroupDescriptor");
  212.   byte[] contents = new Byte[512];
  213.   ioStream.Read(contents,0,512);
  214.   ioStream.Close();
  215.   System.Text.StringBuilder sb = new System.Text.StringBuilder();
  216.   //The magic number 76 is the size of that part of the
  217.   //FILEGROUPDESCRIPTOR structure before
  218.   // the filename starts - cribbed
  219.   //from another usenet post.
  220.   for (int i=76; contents[i] != 0; i++)
  221.   {
  222.   sb.Append((char)contents[i]);
  223.   }
  224.   if (!sb.ToString(sb.Length-4,4).ToLower().Equals(".url"))
  225.   {
  226.   System.Diagnostics.Debug.WriteLine("filename does not end in '.url'");
  227.   }
  228.   hyperLinkText = sb.ToString(0,sb.Length-4);
  229.   }
  230.   // do what ever you wanna do with the hyperlink
  231.   //this.BeginInvoke(.....)
  232.   pictureBox.ImageLocation = hyperLinkText;
  233.   System.Diagnostics.Debug.WriteLine("url : " + hyperLinkText);
  234.   }
  235.   catch (System.Exception ex)
  236.   {
  237.   System.Diagnostics.Debug.WriteLine(ex.Message);
  238.   } */
  239. #endregion
  240.  
  241. return modified;
  242. }
  243. }
  244. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/events/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1711638773 28/03/2024 16:12:53
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/broldev/src/events/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csEventMethods.cs9.99 Ko31/10/2018 18:32:47-refusé-
Afficher le fichier .cs|.csFormatStringFromDoubleEventHandler.cs341 octets31/10/2018 18:32:47-refusé-
Afficher le fichier .cs|.csFormatStringEventHandler.cs409 octets31/10/2018 18:32:47-refusé-
Afficher le fichier .cs|.csFileSelectedEventHandler.cs373 octets31/10/2018 18:32:47-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.

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 16/10/2009, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/cs-broldev-source-rf-events/EventMethods.cs.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.