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

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

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

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