Loading
Uniconta
Get Uniconta
  • Visit a Country Site
    • Danmark
    • Deutschland
    • Eesti
    • Ísland
    • Lithuania
    • Nederland
    • Norge
    • Österreich
    • United Kingdom
  • Search
  • Uniconta
    • Ledger
    • Customer
    • Sales Order
    • Vendor
    • Purchase
    • Inventory
    • Logistics
    • Project
    • Light Manufacturing
    • CRM
    • Dashboard
    • Company
    • Adaptability
  • Download
    • Uniconta for Windows
    • Uniconta for Mac
  • Resellers
    • Find a reseller
    • Become a reseller
    • Become an integration partner
    • Partner Portal Login
    • Partner Portal sign up
  • Developers
    • Become an integration partner
    • Documentation
    • Downloads
    • Samples
    • Support
  • Accountants
    • Become a Univisor
  • News
  • About us
    • About us
    • Management
    • Contact

Developers Unipedia

  • API
    • API
    • User defined fields
    • User defined tables
    • Saving a Session
    • Posting an Invoice
    • Post Invoice and get PDF
    • Localization
    • Attach physical voucher to entities
    • Server-Login User
    • How to find C# Property from Uniconta Label
    • Minimize network traffic and optimize speed
  • Plugins
    • Plugins
    • Debug Uniconta Plugins
    • Refreshing UI with plugins
    • How to use Uniconta Plugin
    • Develop a user plugin
    • Event Handling
    • Global Script
    • How to capture menu events
    • How to open a form in Uniconta from Plugin
    • Open new content in a IContentPluginBase plugin
    • Adding plugin in a menu
    • How to add user parameter in plugin menu
    • How to create plugin with Devexpress Library
    • Synchronize Entity Support in form page
    • Develop a PageEventBase Plugin
    • Logging Exceptions on local machine
    • Create Custom Uniconta Pages From Github Code
  • OData
    • CRUD operations in OData
    • ODATA REST API – Testing with Postman

How to create plugin with Devexpress Library

488 1,462 September 1st, 2017 January 7th, 2021
Print Friendly, PDF & Email
Download Sample File
  • Create a new project and add Devexpress references including Uniconta’s library – ClientTools, Uniconta.Common, and Uniconta.WindowsAPI
  • It is required to register your plugin with Uniconta applicaiton. To do that make a class and inherit IPluginControlNow inside RegisterControls function, register all the pages you create
    public List<PluginControl> RegisterControls()
    {
        var ctrls = new List<PluginControl>();
        ctrls.Add(new PluginControl() { UniqueName = "DebtorPluginPage", PageType = typeof(GridPage), AllowMultipleOpen = false, PageHeader = "Plugin Debtors" });
        return ctrls;
    }

    There are two type of pages that can be created: Grid Page & Form Page.

Grid Page

  • Add a new WPF user control
  • Inside the .xaml file
    • Change <UserControl> tag to
      <Pages:GridBasePage xmlns:Pages="clr-namespace:Uniconta.ClientTools.Page;assembly=ClientTools"
    • Add reference of Uniconta.ClientTools.Controls
      xmlns:UnicontaControls="clr-namespace:Uniconta.ClientTools.Controls;assembly=ClientTools"
    • Add Ribbon Control
      <UnicontaControls:UnicontaRibbonControl x:Name="localMenu"/>
    • Add Grid (DebtorGrid used here is created in .cs file)
      <local:DebtorGrid x:Name="debtorGrid" AutoGenerateColumns="None" Grid.Row="1">
    • Add a column binded to property “Account” use x:Name
      <UnicontaControls:UnicontaDataGridTemplateColumn x:Name="Account"/>
  • Inside .cs file inherit class from GridBasePage public partial class GridPage : GridBasePage
    • Inherit the type of grid, in our example we are getting Debtor Grid
      public class DebtorGrid : UnicontaDataGrid
      {
        public override Type TableType
        {
          get
          {
            return typeof(DebtorClient);
          }
        }
      }
    • Give GridPage a unique name
      public override string NameOfControl
      {
        get
        {
          return "DebtorPluginPage";/* should be a unique name*/
        }
      }
    • Inherit Grid constructor with base(null) & initialize
      public GridPage(BaseAPI api): base(api, string.Empty)
      {
        InitializeComponent();
        debtorGrid.api = api;
      }
      
    • To bind the grid with Debitors & initialize it inside Grid constructor
      void BindGrid()
      {
        var t = debtorGrid.Filter(null);
        BindGrid();
      }
    • Now to add ribbon buttons to Ribbon Control call AddRibbonItems function with List<TreeRibbon>
      Then call SetRibbonControl with ribbon and grid as parameters.

      localMenu.AddRibbonItems(CreateRibbonItems());
      SetRibbonControl(localMenu, debtorGrid);
      localMenu.OnItemClicked += LocalMenu_OnItemClicked; // to add on-click function

      To add menu items

      List<TreeRibbon> CreateRibbonItems()
      {
        var ribbonItems = new List<TreeRibbon>();
        var addRowItem = new TreeRibbon();
        addRowItem.ActionName = "AddRow";
        addRowItem.Name = "Add Debtor";
        addRowItem.LargeGlyph = LargeIcon.Add.ToString();
      
        var editRowItem = new TreeRibbon();
        editRowItem.ActionName = "EditRow";
        editRowItem.Name = "Edit Debtor";
        editRowItem.LargeGlyph = LargeIcon.Edit.ToString();
      
        var refreshRowItem = new TreeRibbon();
        refreshRowItem.ActionName = "RefreshGrid";
        refreshRowItem.Name = "Refresh";
        refreshRowItem.LargeGlyph = LargeIcon.Refresh.ToString();
      
        ribbonItems.Add(addRowItem);
        ribbonItems.Add(editRowItem);
        ribbonItems.Add(refreshRowItem);
        return ribbonItems;
      }

      Full list of icons can be found here: https://www.uniconta.com/da/developers-unipedia-global/icon-dictionary/
      Clickable events for ribbon menu can be created like this

      private void LocalMenu_OnItemClicked(string ActionType)
      {
        var selectedItem = debtorGrid.SelectedItem as DebtorClient;
        switch (ActionType)
        {
          case "AddRow":
          // do something
          break;
          case "EditRow":
          // do something
          break;
          default:
          // do something
          break;
        }
      }

To hide User Field columns and create your own in XAML, the following function can be overridden and return false

public virtual bool CheckIfBindWithUserfield(out bool isReadOnly, out bool useBinding)

 

Form Page

Creating form page is similar to Grid page, except the following

  • Inside the .cs file
    • inherit from FormBasePage
      public partial class FormPage : FormBasePage
    • There are two type constructor required, one for edit and one for add
      /* for edit*/
      public FormPage(UnicontaBaseEntity sourcedata)
          : base(sourcedata, true)
      {
          InitializeComponent();
          InitPage(api);
      }
      /* for add */
      public FormPage(CrudAPI crudApi, string dummy)
          : base(crudApi, dummy)
      {
          InitializeComponent();
          InitPage(crudApi);
      }
    • Modified Row
      public override UnicontaBaseEntity ModifiedRow { get { return editrow; } set { editrow = (DebtorClient)value; } }
  • In .XAML
    • different editors like text editor or lookup editor can be added. E.g.
       <UnicontaControls:UnicontaLayoutItem FieldName="Name" x:Name="liName">
            <UnicontaControls:TextEditor Text="{Binding Name,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
       </UnicontaControls:UnicontaLayoutItem>
      
       <UnicontaControls:UnicontaLayoutItem FieldName="Group" x:Name="liGroup">
           <UnicontaControls:LookupEditor  x:Name="grouplookupeditor" Text="{Binding Group,Mode=TwoWay}" />
       </UnicontaControls:UnicontaLayoutItem>

To hide User fields and create your own in XAML, the following function can be overridden and return false

public virtual bool BeforeSetUserField(ref CorasauLayoutGroup parentGroup)
Guide to add plugin in a menu
Download Sample File
Categories: Developers Unipedia, Plugins

Get in touch with us

Uniconta

  • Uniconta
  • Subscription Terms
  • System Status

PARTNER

  • Resellers
  • Get Uniconta
  • Documentation

INFO

  • News
  • Video
  • Security

Support

  • Unipedia
  • API Support
  • Visit a Country Site
    • Danmark
    • Deutschland
    • Eesti
    • Ísland
    • Lithuania
    • Nederland
    • Norge
    • Österreich
    • United Kingdom
Uniconta
© Copyright 2019 | All rights reserved | info@uniconta.com | Terms & Conditions
Facebook Twitter LinkedIn Youtube