Exemplo n.º 1
0
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        public async Task <bool> ShowDialog(CertificateIdentifier certificateIdentifier)
        {
            CertificateStoreCTRL.StoreType = null;
            CertificateStoreCTRL.StorePath = null;
            PrivateKeyCB.SelectedIndex     = 0;
            PropertiesCTRL.Initialize((X509Certificate2)null);

            if (certificateIdentifier != null)
            {
                X509Certificate2 certificate = await certificateIdentifier.Find();

                CertificateStoreCTRL.StoreType = certificateIdentifier.StoreType;
                CertificateStoreCTRL.StorePath = certificateIdentifier.StorePath;

                if (certificate != null && certificateIdentifier.Find(true) != null)
                {
                    PrivateKeyCB.SelectedIndex = 1;
                }
                else
                {
                    PrivateKeyCB.SelectedIndex = 0;
                }

                PropertiesCTRL.Initialize(certificate);
            }

            if (ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        //----------------------------------------------------------------------------------------------------------------------
        // btnConnect_Click
        //-----------------------
        // This method tries to connect to the specified OPC Server.
        // If connected successfully, this method also registers the name of the client with the server and
        // adds an OPC Group.
        //----------------------------------------------------------------------------------------------------------------------
        private void btnConnect_Click(object sender, EventArgs e)
        {
            TsCDaBrowseElement[] BrowserElement;
            TsCDaBrowsePosition  BrowserPos;
            OpcItem Path = new OpcItem("");

            _filter.BrowseFilter         = TsCDaBrowseFilter.All;
            _filter.ReturnAllProperties  = true;
            _filter.ReturnPropertyValues = true;

            try
            {
                Cursor = Cursors.WaitCursor;
                if (!_myServer.IsConnected)
                {
                    // No connection to server, connect to it
                    _textBoxServerUrl.Enabled = false;

                    _myServer.Connect(_textBoxServerUrl.Text);          // Connect now with Server
                    BrowserElement = _myServer.Browse(Path, _filter, out BrowserPos);

                    /// All succeeded, update buttons and text fields
                    _textBoxServerUrl.Enabled = false;
                    _btnConnect.Text          = "Disconnect";
                    BrowseCTRL.ShowSingleServer(_myServer, _filter);
                    PropertiesCTRL.Initialize(null);
                }
                else
                {
                    // connection to server exists, disconnect to it
                    _textBoxServerUrl.Enabled = true;

                    BrowseCTRL.Clear();
                    PropertiesCTRL.Initialize(null);
                    _myServer.Disconnect();
                    _btnConnect.Text = "Connect";
                }
                Cursor = Cursors.Default;                                                       // Set default cursor
            }
            catch (OpcResultException exe)
            {
                Cursor = Cursors.Default;                                                       /// Set default cursor
                MessageBox.Show(exe.Message, exe.Source, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                _textBoxServerUrl.Enabled = true;
                _btnConnect.Text          = "Connect";
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;                                                       /// Set default cursor
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                _textBoxServerUrl.Enabled = true;
                _btnConnect.Text          = "Connect";
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        public bool ShowDialog(X509Certificate2 certificate)
        {
            CertificateStoreCTRL.StoreType = null;
            CertificateStoreCTRL.StorePath = null;
            PrivateKeyCB.SelectedIndex     = 0;
            PropertiesCTRL.Initialize(certificate);

            if (ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Called when a server is picked in the browse control.
 /// </summary>
 private void OnElementSelected(TsCDaBrowseElement element)
 {
     PropertiesCTRL.Initialize(element);
 }