home *** CD-ROM | disk | FTP | other *** search
/ ftp.tcs3.com / ftp.tcs3.com.tar / ftp.tcs3.com / DRIVERS / Audio / Office2010 / InfoPath.en-us / InfLR.cab / FL_CreateaBitmapatRunTime_snippet_142648_ENU____.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Extensible Markup Language  |  2008-09-17  |  2KB  |  79 lines

  1. <?xml version="1.0"?>
  2. <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  3.   <CodeSnippet Format="1.0.0">
  4.     <Header>
  5.       <Title>Create a Bitmap at Run Time</Title>
  6.       <Author>Microsoft Corporation</Author>
  7.       <Description>Creates and fills a Bitmap object and displays it in an existing Windows Forms PictureBox control.</Description>
  8.       <Shortcut>drawBitmap</Shortcut>
  9.     </Header>
  10.     <Snippet>
  11.       <References>
  12.         <Reference>
  13.           <Assembly>System.Drawing.dll</Assembly>
  14.         </Reference>
  15.         <Reference>
  16.           <Assembly>System.Windows.Forms.dll</Assembly>
  17.         </Reference>
  18.       </References>
  19.       <Imports>
  20.         <Import>
  21.           <Namespace>Microsoft.VisualBasic</Namespace>
  22.         </Import>
  23.         <Import>
  24.           <Namespace>System</Namespace>
  25.         </Import>
  26.         <Import>
  27.           <Namespace>System.Drawing</Namespace>
  28.         </Import>
  29.         <Import>
  30.           <Namespace>System.Windows.Forms</Namespace>
  31.         </Import>
  32.       </Imports>
  33.       <Declarations>
  34.         <Literal>
  35.           <ID>Width</ID>
  36.           <Type>Integer</Type>
  37.           <ToolTip>Replace with width, in pixels, of the bitmap.</ToolTip>
  38.           <Default>10</Default>
  39.         </Literal>
  40.         <Literal>
  41.           <ID>Height</ID>
  42.           <Type>Integer</Type>
  43.           <ToolTip>Replace with height, in pixels, of the bitmap.</ToolTip>
  44.           <Default>10</Default>
  45.         </Literal>
  46.         <Literal>
  47.           <ID>pixelColor</ID>
  48.           <Type>System.Drawing.Color</Type>
  49.           <ToolTip>Replace with background color for the bitmap.</ToolTip>
  50.           <Default>Color.White</Default>
  51.         </Literal>
  52.         <Object>
  53.           <ID>control</ID>
  54.           <Type>PictureBox</Type>
  55.           <ToolTip>Replace with a Control.</ToolTip>
  56.           <Default>PictureBox1</Default>
  57.         </Object>
  58.       </Declarations>
  59.       <Code Language="VB" Kind="method body"><![CDATA[Dim flag As New Bitmap($Width$, $Height$)
  60. Dim x As Integer
  61. Dim y As Integer
  62. ' Make the entire bitmap white.
  63. For x = 0 To flag.Height - 1
  64.     For y = 0 To flag.Width - 1
  65.         flag.SetPixel(x, y, $pixelColor$)
  66.     Next
  67. Next
  68.  
  69. ' Draw a diagonal red stripe.
  70. For x = 0 To flag.Height - 1
  71.     flag.SetPixel(x, x, Color.Red)
  72. Next
  73. $control$.Image = flag
  74.  
  75.  
  76.             ]]></Code>
  77.     </Snippet>
  78.   </CodeSnippet>
  79. </CodeSnippets>