To improve usability, Mi-Forms client provides the ability to change pen color during data capture. However, in some situations disabling the native functionality of this feature and taking active control of pen colors is an important task to accomplish the business requirements around the form.

Consider a form that is routed in the workflow during its life cycle. At each queue, a specific color could be used to determine which user has edited the form.

There are two steps to accomplish this requirement. First, change the pen's color

 

<MiCode(FormScriptEventType.AfterOpen)> _
    Public Sub Form_AfterOpen(ByVal e As AfterOpenEventArgs)
       If _Color.Value = "Blue" Then
          isScriptLogic = True
          Dim newPen As MiCo.MiForms.Pen = New MiCo.MiForms.Pen()
          newPen.Color = New MiCo.MiForms.Color(System.Drawing.Color.Blue)
          _component.CurrentPen = newPen
      End If
   End Sub

 



Second, prevent the user from changing pen color on the form

 

<MiCode(FormScriptEventType.BeforePenChange)> _
     Public Sub Form_BeforePenChange(ByVal e As BeforePenChangeEventArgs)
        If isScriptLogic = False Then
          e.Cancel = True
        Else
          isScriptLogic = False
        End If
    End Sub


 


isScriptLogic is a boolean variable that can be used to determine if the pen color change event can be raised by scripting or by user.