/// <summary>
        /// Converts a NodeType value to the OPCAEBROWSETYPE equivalent.
        /// </summary>
        internal static OpcRcw.Ae.OPCAEBROWSETYPE GetBrowseType(Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType input)
        {
            switch (input)
            {
            case Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType.Area: return(OpcRcw.Ae.OPCAEBROWSETYPE.OPC_AREA);

            case Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType.Source: return(OpcRcw.Ae.OPCAEBROWSETYPE.OPC_SOURCE);
            }

            return(OpcRcw.Ae.OPCAEBROWSETYPE.OPC_AREA);
        }
Пример #2
0
        /// <summary>
        /// Populates the tree with the elements within the specified area.
        /// </summary>
        private void BrowseArea(TreeNodeCollection nodes, Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType browseType, Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseElement area)
        {
            IOpcBrowsePosition position = null;

            try
            {
                // fetch first batch of elements.
                Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseElement[] elements = mServer_.Browse(
                    area?.QualifiedName,
                    browseType,
                    mBrowseFilter_,
                    mMaxElements_,
                    out position);


                do
                {
                    // add elements to tree.
                    for (int ii = 0; ii < elements.Length; ii++)
                    {
                        // create node.
                        TreeNode node = new TreeNode(elements[ii].Name)
                        {
                            ImageIndex         = (browseType == Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType.Area) ? Resources.IMAGE_CLOSED_BLUE_FOLDER : Resources.IMAGE_GREEN_SCROLL,
                            SelectedImageIndex = (browseType == Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType.Area) ? Resources.IMAGE_OPEN_BLUE_FOLDER : Resources.IMAGE_GREEN_SCROLL,
                            Tag = elements[ii]
                        };

                        // add dummy child to ensure '+' sign is visible.
                        node.Nodes.Add(new TreeNode());

                        // add to tree.
                        nodes.Add(node);
                    }

                    // check if browse is complete.
                    if (position == null)
                    {
                        break;
                    }

                    // prompt to continue browse.
                    DialogResult result = MessageBox.Show(
                        "More elements meeting search criteria exist. Continue browse?",
                        "Browse " + browseType + "s",
                        MessageBoxButtons.YesNo);

                    if (result == DialogResult.No)
                    {
                        break;
                    }

                    // continue browse.
                    elements = mServer_.BrowseNext(mMaxElements_, ref position);
                }while (true);
            }
            finally
            {
                // dipose position object on exit.
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
        }