Advertisement
Guest User

Skiminok

a guest
Jul 19th, 2009
2,739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. <#@ template inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" language="C#v3.5" debug="true" hostSpecific="true" #>
  2. <#@ output extension=".html" #>
  3. <#@ Assembly Name="System.dll" #>
  4. <#@ Assembly Name="System.Core.dll" #>
  5. <#@ assembly name="mscorlib.dll" #>
  6. <#@ Assembly Name="System.Windows.Forms.dll" #>
  7. <#@ import namespace="System" #>
  8. <#@ import namespace="System.IO" #>
  9. <#@ import namespace="System.Diagnostics" #>
  10. <#@ import namespace="System.Linq" #>
  11. <#@ import namespace="System.Windows.Forms" #>
  12. <#@ import namespace="System.Collections" #>
  13. <#@ import namespace="System.Collections.Generic" #>
  14. <!-- This is generated code. Any changes will be lost the next time this code is being generated.
  15. Creation date: <#= System.DateTime.Now.ToString() #>
  16. -->
  17. <html>
  18. <head>
  19. <title>Code-Generated Image Gallery by T4-Editor</title>
  20. </head>
  21. <body style="Font-Family:Verdana;">
  22. <h1>T4 Generated Gallery</h1>
  23. <table style="Width:100%;">
  24. <# this.CreateHTMLGallery(); #>
  25. </table>
  26. <table style="Width:100%;">
  27. <tr>
  28. <td style="Font-Size:10px;"><#= selectedPath #></td>
  29. <td style="Font-Size:10px; Text-Align:right;">&copy; 2009 tangible engineering GmbH</td>
  30. </tr>
  31. </table>
  32. </body>
  33. </html>
  34. <#+
  35. private string selectedPath = string.Empty;
  36. private void CreateHTMLGallery()
  37. {
  38. // ask for a folder containing images to create the gallery from
  39. FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
  40. fbd.RootFolder = System.Environment.SpecialFolder.MyComputer;
  41. fbd.Description = "Please select a folder to create an image gallery from...";
  42. if (fbd.ShowDialog() != DialogResult.OK) { return; }
  43.  
  44. selectedPath = fbd.SelectedPath;
  45. string[] files = System.IO.Directory.GetFiles(fbd.SelectedPath, "*.jpg");
  46.  
  47. for (int i = 0; i < files.Length; i++)
  48. {
  49. // start a new row each 4 images
  50. if (i % 4 == 0)
  51. {
  52. #> <tr>
  53. <#+
  54. }
  55.  
  56. // display image
  57. #> <td style="Padding-Bottom:45px;">
  58. <img src="<#= files[i] #>" style="Width:200px;Height:150px;Margin-Bottom:5px;" /></br>
  59. <#= System.IO.Path.GetFileNameWithoutExtension(files[i]) #>
  60. </td>
  61. <#+
  62. // end a row each 4 images
  63. if (i % 4 == 3)
  64. {
  65. #> </tr>
  66. <#+
  67. }
  68. }
  69. }
  70. #>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement