Attribute VB_Name = "z_UIMessages"
' Messaging module
Option Private Module
Option Explicit

Public Enum MsgCode
  MSG_OK = 0
  
 ' EM_INVALID_SELECTION
  
  IM_CREATION_COMPLETE

  QM_CLEAR_ALL
End Enum

Private g_UI As API_UserInteraction

Public Function UserInteraction() As API_UserInteraction
  If g_UI Is Nothing Then _
    Set g_UI = New API_UserInteraction
  Set UserInteraction = g_UI
End Function

Public Function SetUserInteraction(newUI As API_UserInteraction)
  Set g_UI = newUI
End Function

Public Function UIShowMessage(theCode As MsgCode, ParamArray params() As Variant)
  Dim unwrapped As Variant: unwrapped = params
  unwrapped = FixForwardedParams(unwrapped)
  
  Select Case theCode
'  Case EM_INVALID_SELECTION
'    Call MsgBox("Invalid selection, please select single data item", vbExclamation)
    
  Case IM_CREATION_COMPLETE
    Call MsgBox(Fmt("Обновление завершено" & vbNewLine & _
                    "Документов: {1}" & vbNewLine & _
                    "Связей: {2}", unwrapped), vbInformation)
  Case Else
    Call MsgBox("Invalid message code", vbCritical)
  End Select
End Function

Public Function UIAskQuestion(theCode As MsgCode, ParamArray params() As Variant) As Boolean
  Dim unwrapped As Variant: unwrapped = params
  unwrapped = FixForwardedParams(unwrapped)
  
  Dim answer&: answer = vbNo
  Select Case theCode
  Case QM_CLEAR_ALL
    answer = MsgBox("Удалить все фигуры с текущей страницы?", vbYesNo + vbQuestion)
    
  Case Else
    Call MsgBox("Invalid message code", vbCritical)
  End Select
  UIAskQuestion = answer = vbYes
End Function
