/// <summary>
/// Event handler for request to display a scanner. The
/// arg parameter contains information about which scanner
/// to display
/// </summary>
/// <param name="sender">event sender</param>
/// <param name="arg">event arg</param>
public void AppAgent_EvtPanelRequest(object sender, PanelRequestEventArgs arg)
{
Log.Debug("A request came in for panel " + arg.PanelClass + ". NewWindow is " +
arg.MonitorInfo.IsNewWindow);
if (_currentForm != null)
{
Log.Debug("_currentForm is " + _currentForm.Name + ", type: " + _currentForm.GetType() +
", IsModal: " + _currentForm.Modal);
Form owner = _currentForm.Owner;
if (owner != null)
{
Log.Debug("owner is : " + owner.Name + ", type: " + owner.GetType() +
", is owner ipanel? " + (_currentForm.Owner is IPanel));
}
else
{
Log.Debug("_currentForm.Owner is null");
}
// if a modal dialog is currently open, don't honor the request.
// the modal dialog has to be closed first.
if (arg.TargetPanel == null || arg.TargetPanel != _currentForm)
{
if (_currentForm.Modal || (_currentForm.Owner != null && _currentForm.Owner.Modal))
{
Log.Debug("A modal dialog is open. Will not honor panel request");
return;
}
}
}
// if no panel type, use the alphabet scanner as the
String requestedPanelClass = arg.PanelClass;
if (PanelConfigMap.AreEqual(arg.PanelClass, PanelClasses.None))
{
requestedPanelClass = PanelClasses.Alphabet;
}
IScannerPanel currentScanner = _currentPanel as IScannerPanel;
if (arg.MonitorInfo.IsNewWindow)
{
Log.Debug("This is a new window. winHandle: " + arg.MonitorInfo.FgHwnd);
if (currentScanner != null)
{
Log.Debug("currentpanel: " + currentScanner.PanelClass + ", requested: " + requestedPanelClass);
}
else
{
Log.Debug("_currentPanel is null or not IScannerPanel. Activate alphabet scanner");
requestedPanelClass = PanelClasses.Alphabet;
}
// if the current scanner is the same as the requested one, just show it
if (currentScanner != null && PanelConfigMap.AreEqual(currentScanner.PanelClass, requestedPanelClass) &&
_currentPanel.Owner == null)
{
Log.Debug("Current panel is already " + requestedPanelClass + ", calling Show()");
_currentPanel.TopMost = true;
if (_currentPanel is MenuPanelBase)
{
(_currentPanel as MenuPanelBase).SetTitle(arg.Title);
}
Show(null, (IPanel)_currentPanel);
}
else
{
// check with the agent if it is OK to switch panels.
if ((currentScanner == null) || currentScanner.OnQueryPanelChange(arg))
{
switchCurrentPanel(arg);
}
}
}
else
{
if (currentScanner == null)
{
Log.Debug("_currentPanel is null. returning");
return;
}
Log.Debug("Not a new window. _currentPanel is " + currentScanner.PanelClass +
" requested panel is " + requestedPanelClass);
// if the current panel is not the same as the requested one, query the
// agent if it is OK to switch and then do the switch
if (!PanelConfigMap.AreEqual(currentScanner.PanelClass, requestedPanelClass) &&
currentScanner.OnQueryPanelChange(arg))
{
switchCurrentPanel(arg);
}
else
{
Log.Debug("Will not switch panels. Current: " + currentScanner.PanelClass +
", requested: " + requestedPanelClass);
if (currentScanner is MenuPanelBase)
{
(currentScanner as MenuPanelBase).SetTitle(arg.Title);
}
}
}
}