Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#@ template inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" language="C#v3.5" debug="true" hostSpecific="true" #>
- <#@ output extension=".html" #>
- <#@ Assembly Name="System.dll" #>
- <#@ Assembly Name="System.Core.dll" #>
- <#@ assembly name="mscorlib.dll" #>
- <#@ Assembly Name="System.Windows.Forms.dll" #>
- <#@ import namespace="System" #>
- <#@ import namespace="System.IO" #>
- <#@ import namespace="System.Diagnostics" #>
- <#@ import namespace="System.Linq" #>
- <#@ import namespace="System.Windows.Forms" #>
- <#@ import namespace="System.Collections" #>
- <#@ import namespace="System.Collections.Generic" #>
- <!-- This is generated code. Any changes will be lost the next time this code is being generated.
- Creation date: <#= System.DateTime.Now.ToString() #>
- -->
- <html>
- <head>
- <title>Code-Generated Image Gallery by T4-Editor</title>
- </head>
- <body style="Font-Family:Verdana;">
- <h1>T4 Generated Gallery</h1>
- <table style="Width:100%;">
- <# this.CreateHTMLGallery(); #>
- </table>
- <table style="Width:100%;">
- <tr>
- <td style="Font-Size:10px;"><#= selectedPath #></td>
- <td style="Font-Size:10px; Text-Align:right;">© 2009 tangible engineering GmbH</td>
- </tr>
- </table>
- </body>
- </html>
- <#+
- private string selectedPath = string.Empty;
- private void CreateHTMLGallery()
- {
- // ask for a folder containing images to create the gallery from
- FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog();
- fbd.RootFolder = System.Environment.SpecialFolder.MyComputer;
- fbd.Description = "Please select a folder to create an image gallery from...";
- if (fbd.ShowDialog() != DialogResult.OK) { return; }
- selectedPath = fbd.SelectedPath;
- string[] files = System.IO.Directory.GetFiles(fbd.SelectedPath, "*.jpg");
- for (int i = 0; i < files.Length; i++)
- {
- // start a new row each 4 images
- if (i % 4 == 0)
- {
- #> <tr>
- <#+
- }
- // display image
- #> <td style="Padding-Bottom:45px;">
- <img src="<#= files[i] #>" style="Width:200px;Height:150px;Margin-Bottom:5px;" /></br>
- <#= System.IO.Path.GetFileNameWithoutExtension(files[i]) #>
- </td>
- <#+
- // end a row each 4 images
- if (i % 4 == 3)
- {
- #> </tr>
- <#+
- }
- }
- }
- #>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement