VB.Net by API/System.Drawing/Icon

Материал из VB Эксперт
Версия от 12:49, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Icon.Height

  
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


Icon.Size

  
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


Icon.ToBitmap()

  
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


Icon.Width

  
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


New Icon(String fileName)

  

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