added SSCLI 1.0
[windows-sources.git] / sdk / samples / WPFSamples / BindToMethod / visualbasic / temperaturescale.vb
blob0e5f51f4a93ea166265087e1ef3156f98c06ddde
1 Imports System
2 Imports System.ComponentModel
3 Imports System.Runtime.CompilerServices
5 Public Class TemperatureScale
6 Implements INotifyPropertyChanged
8 ' Events
9 Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
11 ' Methods
12 Public Sub New()
13 End Sub
15 Public Sub New(ByVal type As TempType)
16 Me.type = type
17 End Sub
19 Public Function ConvertTemp(ByVal degree As Double, ByVal temptype As TempType) As String
20 If (temptype = temptype.Celsius) Then
21 degree = (((degree * 9) / 5) + 32)
22 Return (degree.ToString & " Fahrenheit")
23 End If
24 If (temptype = temptype.Fahrenheit) Then
25 degree = (((degree - 32) / 9) * 5)
26 Return (degree.ToString & " Celsius")
27 End If
28 Return "Unknown Type"
29 End Function
31 Protected Sub OnPropertyChanged(ByVal name As String)
32 RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(name))
33 End Sub
36 ' Properties
37 Public Property Type() As TempType
38 Get
39 Return Me._type
40 End Get
41 Set(ByVal value As TempType)
42 Me._type = value
43 Me.OnPropertyChanged("Type")
44 End Set
45 End Property
48 ' Fields
49 Private _type As TempType
50 End Class