Container Control Methodology Question

Hello again,

I have a design situation that I have almost implemented, but before I went to far I wanted to ask about experienced methodologies you have used.

Situation:

  1. I have a window with two identical Container controls
  2. Each Container control has a progress bar
  3. I have an array of Classes in which each instantiated class holds four properties and one being the Job ID and the progress bar value integer

What I want:

  1. When I point Container Control 1’s progress bar to point to the proper value inside of the array it works well.
  2. What happens is that when we get to say Array element #10 the Job ID Changes and I need that to signal a switch to Container Control #2’s Progress bar to process the values. (The same array is in tact through this).

I can’t figure out a way to design/implement this change over and wanted to see how you would tackle this as it should be popular among status update controls for others. This is my first deep dive into it so I figured I’d ask before getting way too deep.

Hopefully this makes sense and Thank you again. I always appreciate the advice.
Mike

So you want to map the job ID to a container control? I would think a method on the window would be good for that, since the window owns the containers. If I understand your requirements, then you need

A method to map a job id to a container.
A mechanism to call a method on the container and pass in the value to display.

But your description of “a way to design/implement this change over” makes me wonder if there’s more going on.

Using “Changeover” meaning I have a TCP based protocol delivering all four pieces of information (IP address, Job ID, Value, and ICP ID). Each “set” is put into a new instantiated Class. That class is appended to one array and my containers pull from this one array. When the container is pulling the data from the array I want it to see the job ID change and then container 2 begins to process that data.

Sounds crazy when I put it into words so I am just wondering if my vehicle of one array is not such a good idea? :slight_smile:

What i have using only the ONE Container Control.

  if ICP_Scheduler.EVIP_Connect <> Nil Then
    
    for i as Integer = 0 To UBound(ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray)
      
      ICPMonitor_Status_ContainerControl1.ProgressBar1.Value = CDbl(ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(i).Status_Percentage)
      ICPMonitor_Status_ContainerControl1.ICPMonitorStatusLabelTitle.Text = "EVIP Host: " + ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(i).IPAddress + "(" + ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(i).ICP_ID +")   - Job ID: " + ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(i).Job_ID
      if ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(i).Status_Percentage <> "100" Then
        ICPMonitor_Status_ContainerControl1.ICPMonitorStatusLabeldescription.Text = ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(i).Status_Percentage + "%  of  100% remaining"
      Else
        ICPMonitor_Status_ContainerControl1.ICPMonitorStatusLabeldescription.Text ="Complete"
      End if
      
    Next i
    Redim ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(-1)
    
  End If 

First of all, you want the container control to encapsulate the logic of updating the screen. You’re using a label and a progressbar now, but later on you might want a different visual indicator. Add a Method to the container control that accepts a string and an integer. For now all it does is just stuff the string into the label and set the progressbar to the integer, but you can change that later to draw a graph or change the opacity of an image, without having to change the code that calls it.

That reduces your code to

dim title as string
dim value as integer

if ICP_Scheduler.EVIP_Connect <> Nil Then
    
    for i as Integer = 0 To UBound(ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray)
      
      value = CDbl(ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(i).Status_Percentage)
      title = "EVIP Host: " + ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(i).IPAddress + "(" +  ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(i).ICP_ID +")   - Job ID: " + ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(i).Job_ID
       ICPMonitor_Status_ContainerControl1.UpdateDisplay(title, value)
    Next i
    Redim ICP_Scheduler.EVIP_Connect.EVIPStatusUpdateArray(-1)
    
  End If 

The method in the container control would be

Sub UpdateDisplay(title as string, percent as integer)
   me.ProgressBar1.Value = percent
   me.ICPMonitorStatusLabelTitle.Text = title
   if percent <> 100 then
      me.ICPMonitorStatusLabeldescription.Text = str(percent) + "%  of  100% remaining"
   else
      me.ICPMonitorStatusLabeldescription.Text = "Complete"
   end if
end sub

The next step is to add some code that selects which container’s method to call based on the jobid.

Awesome advice Tim as always! Thank you once again!