Plex 2E

 View Only
  • 1.  ObPanelAPI::AddItemToListControl(FldCtrlNme,ItemVal); Analogous Needed for .Net Plex Generator

    Posted Nov 22, 2019 08:11 AM
    Hello All,

    At CA Plex WinC (C++) Generator we had been given the following:
    ObPanelAPI::AddItemToListControl(Field_Control_Name, Item_Value);
    which enabled us to use it in our templates so as to dynamically load 
    some of the combo boxes in our panel functions.
    Is there an analogous API for C# .Net Plex Generator ?
    We do really need such a capability.
    We have an application with near 1000 WinC panel functions and most of them
    are is-a from our template functions utilizing this dynamic combo box loading.
    So if we are to 'upgrade it to C# generator' we will surely need that.

    Kind Regards,
    Nicolas Mavroeidis

    ------------------------------
    Senior Software Engineer
    BASIS SA
    ------------------------------


  • 2.  RE: ObPanelAPI::AddItemToListControl(FldCtrlNme,ItemVal); Analogous Needed for .Net Plex Generator
    Best Answer

    Posted Dec 05, 2019 12:12 PM
    After looking the Plex generated code in C# and the related definitions in Plex provided classes, I finally found out how to do the Plex Panel combo box dynamic loading in C#,
    so here follows the related code I created as a source code API:
    // Comment ...
    // API Call Source code: Test Functions.TestCSharp.CS_ComboBoxAppendValues
    { ///////////////////////////////////////////////////////////////////////////////
    // By Date Purpose
    // NMDS 2019-12-05 Created : CS_ComboBoxAppendValues
    // e.g. <PanelRegionName> = <Function Impl Name> + "Panel" + "_" + <Region Name>
    // <PanelRegionName> = "TestCSh" + "Panel" + "_" + "Panel"
    // <PanelRegionName> = "TestCShPanel_Panel"
    ///////////////////////////////////////////////////////////////////////////////

    String sPanelRegionName, /*...PARAMETER:INPUT...*/
    sControlName, /*...PARAMETER:INPUT...*/
    sDatas; /*...PARAMETER:INPUT...*/
    Char[] cInListDelimiter = new char[]{';'}, /*...PARAMETER:INPUT...*/
    cListEndDelimiter = new char[]{'~'}; /*...PARAMETER:INPUT...*/

    ObWPF.ObWPFCtrl.ObComboData pnlComboData;
    String[] arDatas;
    int arDatasLength;

    sPanelRegionName = (&(1:).Value != null) ? (&(1:).Value).Trim() : "";
    sControlName = (&(2:).Value != null) ? (&(2:).Value).Trim() : "";
    sDatas = (&(3:).Value != null) ? (&(3:).Value).Trim() : "";
    cInListDelimiter = (&(4:).Value != null) ? (&(4:).Value).ToCharArray(0,1) : cInListDelimiter;
    cListEndDelimiter = (&(5:).Value != null) ? (&(5:).Value).ToCharArray(0,1) : cListEndDelimiter;

    if (sPanelRegionName != "" && sControlName != "")
    { pnlComboData = (ObWPF.ObWPFCtrl.ObComboData)panel.GetControlByName(sControlName);
    bool result = false;
    //...DEBUG_CODE: MessageBox.Show("sPanelRegionName:["+sPanelRegionName+"]"); // e.g. "TestCShPanel_Panel"
    result |= pnlComboData.exchangeData(Accessmode.CLEAR,
    v.getVariable(sPanelRegionName).getAsObCharFldField(sControlName));
    sDatas = sDatas.Replace(new String(cListEndDelimiter), new String(cInListDelimiter));
    arDatas = sDatas.Split(cInListDelimiter);
    arDatasLength = arDatas.Length;
    for(int i =0; i < arDatasLength; i++)
    { //...insert each value:
    v.getVariable(sPanelRegionName).getAsObCharFldField(sControlName).Value = arDatas[i];
    result |= pnlComboData.exchangeData(Accessmode.INSERT,
    v.getVariable(sPanelRegionName).getAsObCharFldField(sControlName));
    }/*for(int i =0; i < arDatas.Length; i++) End*/

    result |= pnlComboData.exchangeData(Accessmode.REFRESH,
    v.getVariable(sPanelRegionName).getAsObCharFldField(sControlName));
    }
    }

    ------------------------------
    Senior Software Engineer
    BASIS SA
    ------------------------------



  • 3.  RE: ObPanelAPI::AddItemToListControl(FldCtrlNme,ItemVal); Analogous Needed for .Net Plex Generator

    Posted Dec 05, 2019 12:21 PM
    Additionally, 
    the sControlName contains the Field implementation name for which we want to load its values dynamically in its combo box. Always remember to set all the combo box values from the Panel Palette to Exists = No, so as to allow us to dynamically load the combo box with values. The sDatas contains all the values we want to load to the combo box dynamically, delimited by the cInListDelimiter parameter.

    We can use the above API from related meta code to dynamically load the combo boxes we want to in a Panel. 

    Kind Regards, 
    N.Mavroeidis

    ------------------------------
    Senior Software Engineer
    BASIS SA
    ------------------------------