Xafari Dialog Controller

Introduction

Xafari Dialog Controller makes it possible to use a several OK an Cancel buttons within the Dialog Window. To see the Xafari Dialog Controller in action, refer to the Controllers section in the Feature Center demo installed with Xafari.

dialog_controller_1

Each additional button has its own Execute event, as you can see in the image above, the different buttons generate the corresponding messages.

Getting Started

XafariDialogController class is provided by the Xafari.dll assembly. All you need to use this function is to create an instance, specify the number of additional Actions and subscribe to the appropriate Execute events.

The code snippet below demonstrates XafariDialogViewController class which contains two OK  and three Cancel Actions.

  • c#
  • VB

public partial class XafariDialogViewController : ViewController
{
  public XafariDialogViewController()
  {
    InitializeComponent();
  }
  private void simpleAction1_Execute(object sender, SimpleActionExecuteEventArgs e)
  {
    var controller = this.Application.CreateController<XafariDialogController>();
    controller.AcceptActionCountVisible = CountVisibleAction.x2; // 2 кнопки Ok
    controller.CancelActionCountVisible = CountVisibleAction.x3; // 3 кнопки Cancel
    controller.AcceptAction.Execute += Action_Execute;
    controller.AcceptAction2.Execute += Action_Execute;
    controller.AcceptAction3.Execute += Action_Execute;
    controller.CancelAction.Execute += Action_Execute;
    controller.CancelAction2.Execute += Action_Execute;
    controller.CancelAction3.Execute += Action_Execute;
    e.ShowViewParameters.CreateAllControllers = true;
    e.ShowViewParameters.Controllers.Add(controller);
    e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow;
    e.ShowViewParameters.Context = TemplateContext.PopupWindow;
    var objectSpace = ObjectSpaceInMemory.CreateNew();
    e.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpace, this.Application.FindDetailViewId(typeof(XafariDialogControllerObject)), true);
  }
  private void Action_Execute(object sender, SimpleActionExecuteEventArgs e)
  {
    MessageObject.CreateMessageInfo(e.ShowViewParameters, e.Action.Controller.Application, "XafariDialogController", "'{0}' is executing", e.Action.Caption);
  }
}

Public Partial Class XafariDialogViewController
  Inherits ViewController
  Public Sub New()
    InitializeComponent()
  End Sub
  Private Sub simpleAction1_Execute(ByVal sender As Object, ByVal e As SimpleActionExecuteEventArgs)
    Dim controller = Me.Application.CreateController(Of XafariDialogController)()
    controller.AcceptActionCountVisible = CountVisibleAction.x2 ' 2 кнопки Ok
    controller.CancelActionCountVisible = CountVisibleAction.x3 ' 3 кнопки Cancel
    controller.AcceptAction.Execute += Action_Execute
    controller.AcceptAction2.Execute += Action_Execute
    controller.AcceptAction3.Execute += Action_Execute
    controller.CancelAction.Execute += Action_Execute
    controller.CancelAction2.Execute += Action_Execute
    controller.CancelAction3.Execute += Action_Execute
    e.ShowViewParameters.CreateAllControllers = True
    e.ShowViewParameters.Controllers.Add(controller)
    e.ShowViewParameters.TargetWindow = TargetWindow.NewModalWindow
    e.ShowViewParameters.Context = TemplateContext.PopupWindow
    Dim objectSpace = ObjectSpaceInMemory.CreateNew()
    e.ShowViewParameters.CreatedView = Application.CreateDetailView(objectSpace, Me.Application.FindDetailViewId(GetType(XafariDialogControllerObject)), True)
  End Sub
  Private Sub Action_Execute(ByVal sender As Object, ByVal e As SimpleActionExecuteEventArgs)
    MessageObject.CreateMessageInfo(e.ShowViewParameters, e.Action.Controller.Application, "XafariDialogController", "'{0}' is executing", e.Action.Caption)
  End Sub
End Class

Note

You can view the code used in this lesson in the Xafari.FeatureCenter | XafariDialogController |XafariDialogViewController.cs file of the Feature Center demo installed with Xafari. By default, the Feature Center application is installed in %PUBLIC%\Documents\Xafari Framework vXX.X.XXXX Demos\Feature Center.