- 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"/>
- Change <UserControl> tag to
- 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 thisprivate 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; } }
- Inherit the type of grid, in our example we are getting Debtor Grid
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; } }
- inherit from FormBasePage
- 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>
- different editors like text editor or lookup editor can be added. E.g.
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)