/// <summary>
        /// Handles the NavigationAction event of the navigation addon.
        /// </summary>
        void OnNavigationAction(object sender, NavigationActionEventArgs args)
        {
            try
            {
                Logger.LogTrace("MainForm handling OnNavigationAction ...");

                Application.UseWaitCursor = true;
                this.SuspendLayoutEx();

                bool           isVoidAction    = false;
                bool           isPreviewAction = false;
                ActionRequest  request         = new ActionRequest();
                ActionResponse response        = null;

                Logger.LogTrace("Action is of type: " + args.ActionType.ToString());

                pnlPreview.SuspendLayoutEx();
                pnlProperties.SuspendLayoutEx();

                lblNoPreview.Text = Translator.Translate("TXT_THEREARENOITEMS");

                prepareAutoPreview =
                    (args.ActionType == NavActionType.ActionPrepareAutoPreview &&
                     args.ActionType != NavActionType.ActionCancelAutoPreview);

                switch (args.ActionType)
                {
                case NavActionType.ActionSaveProperties:
                    // It is a save property request.
                    request.ActionType = ActionManagement.ActionType.ActionSaveProperties;
                    request.Items      = args.Paths; // don't matter any way
                    break;

                case NavActionType.ActionSelectDirectory:
                case NavActionType.ActionSelectFile:
                case NavActionType.ActionSelectMultipleItems:
                    // It is a property request.
                    request.ActionType = ActionManagement.ActionType.ActionBeginEdit;
                    request.Items      = args.Paths;
                    break;

                case NavActionType.ActionDoubleClickFile:
                    // It is a regular preview request.
                    request.ActionType = ActionManagement.ActionType.ActionBeginPreview;
                    request.Items      = args.Paths;
                    isPreviewAction    = true;
                    break;

                case NavActionType.ActionNotifyNonPreviewableItem:
                    lblNoPreview.Text = Translator.Translate("TXT_NOTIFY_NON_PREVIEW");
                    isPreviewAction   = true;
                    break;

                case NavActionType.ActionNotifyPreviewableItem:
                    lblNoPreview.Text = Translator.Translate("TXT_NOTIFY_PREVIEW");
                    isPreviewAction   = true;
                    break;

                case NavActionType.ActionPrepareAutoPreview:
                    lblNoPreview.Text  = Translator.Translate("TXT_PREPARE_PREVIEW");
                    prepareAutoPreview = true;
                    isPreviewAction    = true;
                    break;

                case NavActionType.ActionCancelAutoPreview:
                    if (args.AdditionalData == null && prepareAutoPreview)
                    {
                        lblNoPreview.Text = Translator.Translate("TXT_PREVIEW_CANCELED");
                    }
                    else
                    {
                        lblNoPreview.Text = Translator.Translate("TXT_NOTIFY_PREVIEW");
                    }
                    isPreviewAction = true;
                    break;

                case NavActionType.ActionReloadNavigation:
                {
                    // Don't reselct addons, send command to the ones already selected.
                    isVoidAction = true;

                    NavBaseCtl ctl = GetNavigationControl();
                    if (ctl != null)
                    {
                        ctl.Reload(args.AdditionalData);
                    }
                }
                break;

                case NavActionType.ActionReloadPreview:
                {
                    // Don't reselct addons, send command to the ones already selected.
                    isVoidAction = true;

                    PreviewBaseCtl ctl = GetPreviewControl();
                    if (ctl != null)
                    {
                        ctl.Reload(args.AdditionalData);
                    }
                }
                break;

                case NavActionType.ActionReloadProperties:
                {
                    // Don't reselct addons, send command to the ones already selected.
                    isVoidAction = true;

                    PropBaseCtl ctl = GetPropertiesControl();
                    if (ctl != null)
                    {
                        ctl.Reload(args.AdditionalData);
                    }
                }
                break;

                case NavActionType.ActionDoubleClickDirectory:
                default:
                    // No actions currently taken in this situation.
                    isVoidAction = true;
                    break;
                }

                if (!isVoidAction)
                {
                    response = AddonsCore.Instance.DispatchAction(request);
                    bool failed = ActionResponse.IsFailedAction(response);

                    if (isPreviewAction)
                    {
                        PreviewBaseCtl previewCtl = GetPreviewControl();
                        if (previewCtl != null)
                        {
                            previewCtl.EndPreview();
                            previewCtl.NavigationAction -=
                                new BaseAddonCtl.NavigationActionEventHandler(OnNavigationAction);
                        }

                        if (failed)
                        {
                            Logger.LogTrace("Preview action has failed.");
                            if (!pnlPreview.Controls.Contains(lblNoPreview))
                            {
                                pnlPreview.Controls.Clear();
                                pnlPreview.Controls.Add(lblNoPreview);
                            }
                        }
                        else
                        {
                            // Note that only a single item can be previewed.
                            PreviewAddon addon = response.TargetAddon as PreviewAddon;
                            if (!pnlPreview.Controls.Contains(addon.AddonPanel))
                            {
                                pnlPreview.Controls.Clear();
                                addon.AddonPanel.Dock     = DockStyle.Fill;
                                addon.AddonPanel.Location = new System.Drawing.Point(10, 10);
                                addon.AddonPanel.TabIndex = 0;
                                pnlPreview.Controls.Add(addon.AddonPanel);
                            }

                            previewCtl = GetPreviewControl();
                            if (previewCtl != null)
                            {
                                previewCtl.NavigationAction +=
                                    new BaseAddonCtl.NavigationActionEventHandler(OnNavigationAction);

                                previewCtl.BeginPreview(args.Paths[0], args.AdditionalData);
                            }
                        }
                    }
                    else
                    {
                        PropBaseCtl propCtl = GetPropertiesControl();
                        if (propCtl != null)
                        {
                            propCtl.NavigationAction -=
                                new BaseAddonCtl.NavigationActionEventHandler(OnNavigationAction);
                        }

                        if (failed)
                        {
                            Logger.LogTrace("View Properties Action has failed.");
                            pnlProperties.Controls.Clear();
                            pnlProperties.Controls.Add(lblNoProperties);
                        }
                        else
                        {
                            PropertyAddon addon = response.TargetAddon as PropertyAddon;
                            if (!pnlProperties.Controls.Contains(addon.AddonPanel))
                            {
                                pnlProperties.Controls.Clear();
                                addon.AddonPanel.Dock = DockStyle.Fill;
                                pnlProperties.Controls.Add(addon.AddonPanel);
                            }

                            propCtl = GetPropertiesControl();
                            if (propCtl != null)
                            {
                                propCtl.NavigationAction +=
                                    new BaseAddonCtl.NavigationActionEventHandler(OnNavigationAction);

                                propCtl.BeginEdit(args.Paths, args.AdditionalData);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorDispatcher.DispatchError(ex, false);
            }
            finally
            {
                pnlPreview.ResumeLayoutEx();
                pnlProperties.ResumeLayoutEx();
                this.ResumeLayoutEx();
                Application.UseWaitCursor = false;

                Logger.LogTrace("MainForm handled OnNavigationAction.");
            }
        }