I tried to understand this link however could not get it to work. http://www.neolisk.com/techblog/vbnet-read-write-appconfig. Below is my code snippet relative to the question.
I am writing a WPF app that has to retain colored squares through the life of the program. The squares represent pass (p) green, fail (f) red, not complete (y) not complete. I have a grid of 20 x20 square that change color due to where the operator is at a certain time. These square must retain their color throughout the production process. I am simulating for operator 0790 to allow the colored square to turn red. The array represents the amount of times squares are checked for the color status due to a certain time period. I need to store these colors statuses even when the ChangeColor method goes out of scope. When ChangColor method goes out of scope I lose my color associated with the array element. Holding on to these colors associated with the element in some special place allows me to continue retaining the colored squares as time moves on as other methods are called due to other processes. I was thinking appconfig could hold this color changes associated with the array elements in each array. I can then call them out of appconfig and place them in the correct square. Can this be done with appconfig or is there a better way. I can save to an INI file however that is not the best way I am sure there are better ways. The 0790 operator in the code below results in array element 1 being associated with red. The next time 0790 is called it will look at element 2 and a color will be assigned to it.
Public Sub ChangColor()
Dim test As String = "F"
Dim var As Integer = "0"
Dim MainWindow1 As New MainWindow1
Opeator = "0970"
Dim bAns As Boolean = False
If Opeator = "0970" Then ''0-19
Dim numbers As Integer() = {1, 2, 3, 4, 5, 66, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}
If test = "F" Then
Do Until var = 1
flagR = numbers(ctr)
Me.Resources("DynamicBG" + flagR) = New SolidColorBrush(Colors.Red)
ctr = ctr + 1
var = 1
Loop
ElseIf test = "P" Then
Me.Resources("DynamicBG" + flagG) = New SolidColorBrush(Colors.Green)
ElseIf test = "x" Then
Me.Resources("DynamicBG" + flagY) = New SolidColorBrush(Colors.Yellow)
End If
End If
If Opeator = "0985" Then
Dim intData() As Integer = {20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39}
If test = "F" Then '20-39
Me.Resources("DynamicBG" + flagR) = New SolidColorBrush(Colors.Red)
ElseIf test = "P" Then
Me.Resources("DynamicBG" + flagG) = New SolidColorBrush(Colors.Green)
ElseIf test = "x" Then
Me.Resources("DynamicBG" + flagY) = New SolidColorBrush(Colors.Yellow)
End If
End If
If Opeator = "1318" Then
Dim intData() As Integer = {40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}
If test = "F" Then '40-59
Me.Resources("DynamicBG" + flagR) = New SolidColorBrush(Colors.Red)
ElseIf test = "P" Then
Me.Resources("DynamicBG" + flagG) = New SolidColorBrush(Colors.Green)
ElseIf test = "x" Then
Me.Resources("DynamicBG" + flagY) = New SolidColorBrush(Colors.Yellow)
End If
End If
If Opeator = "23187" Then
If test = "F" Then '60-79
Me.Resources("DynamicBG" + flagR) = New SolidColorBrush(Colors.Red)
ElseIf test = "P" Then
Me.Resources("DynamicBG" + flagG) = New SolidColorBrush(Colors.Green)
ElseIf test = "x" Then
Me.Resources("DynamicBG" + flagY) = New SolidColorBrush(Colors.Yellow)
End If
End If
End Sub