VB.Net by API/System.Drawing/Icon — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 15:49, 26 мая 2010

Icon.Height

<source lang="vbnet"> Imports System.Drawing.Drawing2D Imports System.Windows.Forms Imports System.Drawing public class MainClass

  public Shared Sub Main
       " Create an Icon
       Dim curIcon As New Icon("1.ico")
       " Set Form"s icon
       "Me.Icon = curIcon
       
       Console.WriteLine(curIcon.Height)
       Console.WriteLine(curIcon.Width)
       Console.WriteLine(curIcon.Size)
  End Sub

End class


 </source>


Icon.Size

<source lang="vbnet"> Imports System.Drawing.Drawing2D Imports System.Windows.Forms Imports System.Drawing public class MainClass

  public Shared Sub Main
       " Create an Icon
       Dim curIcon As New Icon("1.ico")
       " Set Form"s icon
       "Me.Icon = curIcon
       
       Console.WriteLine(curIcon.Height)
       Console.WriteLine(curIcon.Width)
       Console.WriteLine(curIcon.Size)
  End Sub

End class


 </source>


Icon.ToBitmap()

<source lang="vbnet"> Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class DrawIcons

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class

Public Class Form1

   Inherits System.Windows.Forms.Form
   Public Sub New()
       MyBase.New()
       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
       Me.ClientSize = New System.Drawing.Size(344, 273)
   End Sub
   Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       Dim curIcon As New Icon("1.ico")
       Dim bmp As Bitmap = curIcon.ToBitmap()
       Dim g As Graphics = e.Graphics
       g.Clear(Me.BackColor)
       g.DrawImage(bmp, 10, 10)
       g.Dispose()
   End Sub

End Class


 </source>


Icon.Width

<source lang="vbnet"> Imports System.Drawing.Drawing2D Imports System.Windows.Forms Imports System.Drawing public class MainClass

  public Shared Sub Main
       " Create an Icon
       Dim curIcon As New Icon("1.ico")
       " Set Form"s icon
       "Me.Icon = curIcon
       
       Console.WriteLine(curIcon.Height)
       Console.WriteLine(curIcon.Width)
       Console.WriteLine(curIcon.Size)
  End Sub

End class


 </source>


New Icon(String fileName)

<source lang="vbnet">

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class DrawIcons

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class

Public Class Form1

   Inherits System.Windows.Forms.Form
   Public Sub New()
       MyBase.New()
       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
       Me.ClientSize = New System.Drawing.Size(344, 273)
   End Sub
   Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       Dim curIcon As New Icon("1.ico")
       Dim bmp As Bitmap = curIcon.ToBitmap()
       Dim g As Graphics = e.Graphics
       g.Clear(Me.BackColor)
       g.DrawImage(bmp, 10, 10)
       g.Dispose()
   End Sub

End Class


 </source>