VB.Net/GUI/Resources — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 12:42, 26 мая 2010
Содержание
Localization: Find Resources-VB\Module1.vb
Imports System.Reflection
Module Module1
Sub Main()
Dim Index As Integer
Dim ReflA As System.Reflection.Assembly
Dim ReflA_Types() As Type
Dim fname As String
fname = "C:\WINNT\Microsoft.NET\Framework\v1.0.3328\mscorlib.dll"
ReflA = ReflA.LoadFrom(fname)
ReflA_Types = ReflA.GetTypes()
Console.WriteLine(fname)
For Index = 0 To UBound(ReflA_Types)
If ReflA_Types(Index).Namespace = "System.Resources" Or _
ReflA_Types(Index).Namespace = "System.Globalization" Then
Console.WriteLine(" Found -> " + ReflA_Types(Index).FullName)
System.Threading.Thread.Sleep(100)
End If
Next
Console.WriteLine("End")
Console.ReadLine()
End Sub
End Module
ResourceReader demo
Imports System.Resources
Imports System.Collections
Module Module1
Sub Main()
Dim reader = New ResourceReader("my.resources")
Dim en As IDictionaryEnumerator = reader.GetEnumerator()
Do While (en.MoveNext)
Console.WriteLine("Name: {0} - Value: {1}", _
en.Key.ToString().PadRight(10, " "), _
en.Value)
Loop
reader.Close()
Dim rm As ResourceManager
rm = ResourceManager.CreateFileBasedResourceManager("my", ".", Nothing)
Console.WriteLine(rm.GetString("first"))
End Sub
End Module
ResourceSet demo
Imports System
Imports System.Resources
Module Module1
Sub Main()
Dim Rs As New ResourceSet("my.resources")
Console.WriteLine(Rs.GetString("first", True))
Console.WriteLine(Rs.GetString("second", True))
Console.WriteLine(Rs.GetString("third", True))
Console.WriteLine(Rs.GetString("fourth", True))
Console.WriteLine(Rs.GetString("not here", True))
Console.WriteLine(Rs.GetDefaultReader.ToString())
Rs.Close()
End Sub
End Module
ResourceWriter demo
Imports System
Imports System.Collections
Imports System.Resources
Module Module1
Sub Main()
Dim Rw As New ResourceWriter("my.resources")
Dim Rr As ResourceReader
Dim RrEn As IDictionaryEnumerator
Rw.AddResource("key 1", "First value")
Rw.AddResource("key 2", "Second value")
Rw.AddResource("key 3", "Third value")
Rw.Generate()
Rw.Close()
Rr = New ResourceReader("my.resources")
RrEn = Rr.GetEnumerator
Do While (RrEn.MoveNext)
Console.WriteLine("Name: {0} - Value: {1}", RrEn.Key.ToString().PadRight(10, " "),RrEn.Value)
Loop
Rr.Close()
End Sub
End Module
ResXResourceWriter Demo
Imports System.Collections
Imports System
Imports System.Resources
Imports System.Drawing
Module Module1
Sub Main()
Dim RwX As New ResXResourceWriter("my.resx")
Dim RrX As ResXResourceReader
Dim RrXEn As IDictionaryEnumerator
RwX.AddResource("key 1", "First value")
RwX.AddResource("key 2", "Second value")
RwX.AddResource("key 3", "Third value")
Dim img = Image.FromFile("a.jpg")
RwX.AddResource("crane", img)
RwX.Generate()
RwX.Close()
RrX = New ResXResourceReader("my.resx")
RrXEn = RrX.GetEnumerator
Do While (RrXEn.MoveNext)
Console.WriteLine("Name: {0} - Value: {1}", RrXEn.Key.ToString().PadRight(10, " "c), RrXEn.Value)
Loop
RrX.Close()
End Sub
End Module