ARMs. Getting Started

By default, any XAF application is equipped with a standard navigation system. This topic describes how to replace XAF Navigation System on Xafari Arms. After reading this topic,  you will be able to use the advanced Arms features instead of the standard Navigation Items. As an example, a description refers to code snippets from the Xafari Northwind demo.

  • Open the existing XAF solution or create a new one.
  • Add XafariArmsModule to the Module Project.
  • Add XafariArmsWebModule to the Web Application Project.
  • Add XafariArmsWinModule to the Windows Forms Application Project.

Each built-in XAF Template that represents the main Window contains the navigation Action Container. To display Arm Items it is necessary to add new Template, moreover, this procedure is done differently for Windows Forms and ASP.NET applications.

Windows Forms

  • Implement Application.CreateCustomTemplate event handler and specify a new Template of the Xafari.Arms.Win.Templates.ArmsMainForm type. The code snippet below shows Application_CreateCustomTemplate event handler in the Northwind demo source code:
  • c#
  • VB

public sealed partial class NorthwindAppModuleWin : ModuleBase
{
  //...
  public override void Setup(XafApplication application)
  {
    //...
    this.Application.CreateCustomTemplate += Application_CreateCustomTemplate;
    //...
  }
  //...
  void Application_CreateCustomTemplate(object sender, CreateCustomTemplateEventArgs e)
  {
    if (this.Application == null || this.Application.Model == null)
      return;
    if (e.Context == TemplateContext.ApplicationWindow)
    {
      e.Template = ((IModelNorthwind)this.Application.Model.Xafari().Arms().ArmDesign).EnableARMs ? new ArmsMainForm() : null;
    }
    else if (e.Context == TemplateContext.View)
      e.Template = new DetailViewForm();
  }
}

Public Partial NotInheritable Class NorthwindAppModuleWin
  Inherits ModuleBase
  '...
  Public Overrides Sub Setup(ByVal application As XafApplication)
    '...
    Me.Application.CreateCustomTemplate += Application_CreateCustomTemplate
    '...
  End Sub
  '...
  Private Sub Application_CreateCustomTemplate(ByVal sender As Object, ByVal e As CreateCustomTemplateEventArgs)
    If Me.Application Is Nothing OrElse Me.Application.Model Is Nothing Then
      Return
    End If
    If e.Context = TemplateContext.ApplicationWindow Then
      e.Template = If(CType(Me.Application.Model.Xafari().Arms().ArmDesign, IModelNorthwind).EnableARMs, New ArmsMainForm(), Nothing)
    Else
      If e.Context = TemplateContext.View Then
        e.Template = New DetailViewForm()
      End If
    End If
  End Sub
End Class

Note

You can see the code demonstrated here in the Xafari.Northwind.AppModule.Win|Module.cs  file of the Northwind demo installed with Xafari. This sample uses a special technique to configure the application instance, it is a so-called App Module. But you can apply this code where you want it, for more information, see Template Customization topic.

  • Run Windows application and see Arms bar as shown in the image below.

arm_4

  • The Arm configuration to suit the needs of the customer is performed in the Application Model, more precisely, in the Xafari|ArmDesign node.

ASP. NET

  • Modify Default.aspx.cs file to implement Xafari.Arms.ISupportArms interface in Default class as follows:
  • c#
  • VB

public partial class Default : BaseXafPage, ISupportArms
{
  //...
  public void SetArmsCaption(string caption)
  {
  }
}

Public Partial Class Default
  Inherits BaseXafPage
  Implements ISupportArms
  '...
  Public Sub SetArmsCaption(ByVal caption As String)
  End Sub
End Class

  • Add Xafari.Arms.Web.TabArmsActionContainer control to the ASP.NET Template. You can add and customize a new Default Template Content (see How to: Customize an ASP.NET Template) or use Xafari Default Template Content from the Xafari Templates Gallery, that includes TabArmsActionContainer by default. Right-click the ASP.NET application project and choose Add | New Item.... In the invoked Add New Item dialog, select the Xafari category and the Xafari Default Template Content item ( or DevExpress XAF category and the DevExpress XAF ASP.NET Default Template Content item). Specify a name and press Add.
  • To customize arbitrary DevExpress XAF Default Template Content, place the following code to the corresponding .ascx file:
  • xml

<%@ Register TagPrefix="cc5" Namespace="Xafari.Arms.Web" Assembly="Xafari.Arms.Web" %>
 <%@ Register TagPrefix="cc6" Namespace="Xafari.Web.Templates.ActionContainers" Assembly="Xafari.Web" %>
 //...
  <cc3:XafUpdatePanel ID="UPNTAC" UpdatePanelForASPxGridListCallback="False" runat="server">
     <cc5:TabArmsActionContainer ID="NTAC" runat="server" ContainerId="Arms" Width="100%" >
      <spaceaftertabstemplate>
         <cc6:XafariActionContainerHolder ID="VN" runat="server" ContainerStyle="Links" CssClass="TabsContainer">
          <ActionContainers>
             <cc2:WebActionContainer ContainerId="RootObjectsCreation" IsDropDown="false" />
             <cc2:WebActionContainer ContainerId="Appearance" IsDropDown="false" />
             <cc2:WebActionContainer ContainerId="Search" IsDropDown="false" />
             <cc2:WebActionContainer ContainerId="FullTextSearch" IsDropDown="false" />
             <cc2:WebActionContainer ContainerId="Panels" IsDropDown="false" />
          </ActionContainers>
         </cc6:XafariActionContainerHolder>
      </spaceaftertabstemplate>
     </cc5:TabArmsActionContainer>
  </cc3:XafUpdatePanel>
 //...

  • To use the modified content instead of default, open the Global.asax.cs file and modify the Session_Start event handler. Specify a path to the new Template as shown below.
  • c#
  • VB

protected void Session_Start(Object sender, EventArgs e)
{
  //...
  WebApplication.Instance.Settings.DefaultTemplateContentPath = "~/DefaultTemplateContent.ascx";
  WebApplication.PreferredApplicationWindowTemplateType = TemplateType.Horizontal;
}

Protected Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
  '...
  WebApplication.Instance.Settings.DefaultTemplateContentPath = "~/DefaultTemplateContent.ascx"
  WebApplication.PreferredApplicationWindowTemplateType = TemplateType.Horizontal
End Sub

  • Invoke the Model Editor and navigate to the Xafari|ArmDesign|Arms node. Add new Arm and set Id property to the First Arm value, right-click First Arm node and choose Add|Folder, for the new item set Id property to the Group value.

arm_41

  • Run ASP.NET application and see Arms bar as shown in the image below.

arm_42

  • The Arm configuration to suit the needs of the customer is performed in the Application Model, more precisely, in the Xafari|ArmDesign node.

You can view the code used in this lesson in the following files of the Northwind demo installed with Xafari:

  • Xafari.Northwind.Web.App|Default.aspx.cs
  • Xafari.Northwind.Web.App|DefaultTemplateContent.ascx
  • Xafari.Northwind.Web.App|Global.asax.cs