/// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            OutProc outProc = new OutProc();

            try
            {
                outProc.CreateOpcClient();
                OpcClient opcClient = outProc.OpcClient;

                //	initialize the client instance
                if (!ResultCode.SUCCEEDED(opcClient.Initialize()))
                {
                    opcClient = null;
                    return;
                }                   //	end if


                OpcForm opcForm = new OpcForm(outProc);

                System.Windows.Forms.Application.Run(opcForm);


                opcClient.Terminate();
                opcClient = null;
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.ToString());
            }       //	end try...catch
        }           //	end Main
        private void CreateMainTree()
        {
            TreeNode local = new TreeNode("Local", 1, 1);

            this.tvServers.Nodes.Add(local);

            TreeNode da1 = new TreeNode("Data Access V1", 4, 4);

            local.Nodes.Add(da1);
            da1.Nodes.Add(new TreeNode("", 1, 1));

            TreeNode da2 = new TreeNode("Data Access V2", 4, 4);

            local.Nodes.Add(da2);
            da2.Nodes.Add(new TreeNode("", 1, 1));

            TreeNode da3 = new TreeNode("Data Access V3", 4, 4);

            local.Nodes.Add(da3);
            da3.Nodes.Add(new TreeNode("", 1, 1));

            TreeNode ae = new TreeNode("Alarms and Events", 4, 4);

            local.Nodes.Add(ae);
            ae.Nodes.Add(new TreeNode("", 1, 1));

            TreeNode remote = new TreeNode("Remote", 6, 6);

            this.tvServers.Nodes.Add(remote);

            ArrayList domains = OpcForm.GetServerList(SV_101_TYPES.SV_TYPE_DOMAIN_ENUM, null);

            for (int i = 0; i < domains.Count; i++)
            {
                TreeNode domain = new TreeNode(((SERVER_INFO_101)domains[i]).sv101_name.ToString(), 3, 3);
                remote.Nodes.Add(domain);
                domain.Nodes.Add(new TreeNode("", 1, 1));
            }
        }
        private void tvServers_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
        {
            tvServers.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            string ipAddress = null;

            if (e.Node.Text.Equals("Data Access V1"))
            {
                if (e.Node.Parent.Text.Equals("Local"))
                {
                    ipAddress = "localhost";
                    CreateBrowseTree(ipAddress, EnumOPCSpecification.DA10, e.Node);
                }
            }
            if (e.Node.Text.Equals("Data Access V2"))
            {
                if (e.Node.Parent.Text.Equals("Local"))
                {
                    ipAddress = "localhost";
                    CreateBrowseTree(ipAddress, EnumOPCSpecification.DA20, e.Node);
                }
            }
            if (e.Node.Text.Equals("Data Access V3"))
            {
                if (e.Node.Parent.Text.Equals("Local"))
                {
                    ipAddress = "localhost";
                    CreateBrowseTree(ipAddress, EnumOPCSpecification.DA30, e.Node);
                }
            }
            if (e.Node.Text.Equals("Alarms and Events"))
            {
                if (e.Node.Parent.Text.Equals("Local"))
                {
                    ipAddress = "localhost";
                    CreateBrowseTree(ipAddress, EnumOPCSpecification.AE10, e.Node);
                }
            }

            if (e.Node.Parent != null)
            {
                if (e.Node.Parent.Text.Equals("Remote"))
                {
                    if (e.Node.Nodes[0].ImageIndex == 1)
                    {
                        e.Node.Nodes.Clear();
                        ArrayList hosts = OpcForm.GetServerList(SV_101_TYPES.SV_TYPE_WORKSTATION, e.Node.Text.ToLower());
                        for (int j = 0; j < hosts.Count; j++)
                        {
                            TreeNode host = new TreeNode(((SERVER_INFO_101)hosts[j]).sv101_name.ToLower(), 0, 0);
                            e.Node.Nodes.Add(host);
                            host.Nodes.Add(new TreeNode("Data Access V1", 4, 4));
                            host.Nodes[0].Nodes.Add(new TreeNode("", 0, 0));
                            host.Nodes.Add(new TreeNode("Data Access V2", 4, 4));
                            host.Nodes[1].Nodes.Add(new TreeNode("", 0, 0));
                            host.Nodes.Add(new TreeNode("Data Access V3", 4, 4));
                            host.Nodes[2].Nodes.Add(new TreeNode("", 0, 0));
                            host.Nodes.Add(new TreeNode("Alarms and Events", 4, 4));
                            host.Nodes[3].Nodes.Add(new TreeNode("", 0, 0));
                        }
                    }
                }
                if (e.Node.Parent.Parent != null)
                {
                    if (e.Node.Parent.Parent.Parent != null)
                    {
                        if (e.Node.Parent.Parent.Parent.Text.Trim().Equals("Remote"))
                        {
                            ipAddress = e.Node.Parent.Text.ToLower();
                            if (e.Node.Text.Equals("Data Access V1"))
                            {
                                CreateBrowseTree(ipAddress, EnumOPCSpecification.DA10, e.Node);
                            }
                            if (e.Node.Text.Equals("Data Access V2"))
                            {
                                CreateBrowseTree(ipAddress, EnumOPCSpecification.DA20, e.Node);
                            }
                            if (e.Node.Text.Equals("Data Access V3"))
                            {
                                CreateBrowseTree(ipAddress, EnumOPCSpecification.DA30, e.Node);
                            }
                            if (e.Node.Text.Equals("Alarms and Events"))
                            {
                                CreateBrowseTree(ipAddress, EnumOPCSpecification.AE10, e.Node);
                            }
                        }
                    }
                }
            }
            tvServers.Cursor = System.Windows.Forms.Cursors.Default;
        }