8 Replies Latest reply on Sep 4, 2013 4:21 PM by Gael

    How to display all PI AF Servers in the afElementFindCtrl?

    Gael

      Hello vcampus,

       

       

       

      I would like to see all PI AF servers in the afElementFindCtrl. I only found how to set the current database (as shown in the AF UI reference) but I would like to have the same result as when you select an "AF Element" object for an AF attribute in PI System Explorer.

       

      Maybe, afElementFindCtrl is not the good control!

       

       

       

      Thanks for your help.

       

       

       

      Best Regards,

       

       

       

       

        • Re: How to display all PI AF Servers in the afElementFindCtrl?
          hanyong

          Hi Gael,

           

          I am still not sure which control in the PI System Explorer that you want to use... When you say 

          Gael

          I would like to have the same result as when you select an "AF Element" object for an AF attribute in PI System Explorer.
          I would imagine it would be the control that shows the information of a selected AF Element

           

          8168.AFControl001.png

           

          If this is what you want, you can use an AFViewControl and the SetObject method to pass in the AFElement object. But I can't find a link between this and seeing all AF Servers, so I'm not sure if I am getting your requirement correctly or not.

            • Re: How to display all PI AF Servers in the afElementFindCtrl?
              Gael

              Hi Han,

               

               

               

              Thanks for your reply. However the control that I want is this one:

               

              8446.Sans-titre.png

               

              It really looks like afElementFindCtrl?

               

               

               

              Gael

                • Re: How to display all PI AF Servers in the afElementFindCtrl?
                  hanyong

                  Yeah, it is really AFElementFindCtrl, except that if you use the default eventhandler for the DialogButtonClick event, it is calling the AFElementFindCtrl.BrowseElement method with the 2nd parameter (enable database change) set to false, hence only allowing you to browse in the selected database.

                   

                  We can replace the default handler with your own implementation to change the behaviour. Something like:

                   
                          public Form1()
                          {
                              InitializeComponent();
                              afElementFindCtrl1.DialogButtonClick += new OSIsoft.AF.UI.AFBaseUserControl.DialogButtonClickEventHandler(afElementFindCtrl1_DialogButtonClick);
                          }
                  
                          void afElementFindCtrl1_DialogButtonClick(object sender, DialogClickEventArgs e)
                          {
                              // call BrowseElement to bring up dialog for browsing and selecting element
                              bool okpressed = false;
                              AFElement selected = afElementFindCtrl1.BrowseElement(afElementFindCtrl1.Database, true, ref okpressed);
                  
                              // if user pressed ok to close the pop up dialog, we set the AFElement to the selected element 
                              if (okpressed)
                              {
                                  afElementFindCtrl1.AFElement = selected;
                              }
                  
                              // prevent the default handler from getting call (so that the browse dialog doesn't show up twice
                              e.Cancel = true;
                          }
                  
                          private void Form1_Load(object sender, EventArgs e)
                          {
                              PISystems systems = new PISystems();
                              if (systems == null) return;
                              PISystem system = systems.DefaultPISystem;
                              if (system == null) return;
                              AFDatabase database = system.Databases.DefaultDatabase;
                              if (database == null) return;
                  
                              afElementFindCtrl1.Database = database;
                          }
                  

                  The code assumes that your form has an AFElementFindCtrl named afElementFindCtrl1.