public MainWindow()
        {
            InitializeComponent();

            // Retrieve the AES key & vector
            var key = new byte[Constants.KeySize];
            var vector = new byte[Constants.VectorSize];

            using (var writer = new BinaryReader(File.Open(Constants.AesKeyFile, FileMode.Open)))
            {
                writer.Read(key, 0, Constants.KeySize);
                writer.Read(vector, 0, Constants.VectorSize);
            }

            _crypto = new CryptoAes(key, vector);
        }
        /// <summary>
        ///     Return the PG connection string based on the parsing of the .ini file.
        /// </summary>
        /// <param name="conn">The connection key in the INI file</param>
        /// <param name="test">
        ///     True = use the user and password from the ini
        ///     file. This is for testing purposes only
        /// </param>
        /// <returns>The connection string</returns>
        private string GetPgConnectionString(string conn, bool test)
        {
            var sb = new StringBuilder();
            var keyComp = conn + ".";

            if (_param.ContainsKey(keyComp + "server")) {
                sb.Append("Server=" + _param[keyComp + "server"] + ";");
            }

            if (_param.ContainsKey(keyComp + "port")) {
                sb.Append("Port=" + _param[keyComp + "port"] + ";");
            }

            if (_param.ContainsKey(keyComp + "database")) {
                sb.Append("database=" + _param[keyComp + "database"] + ";");
            }

            if (test) {
                sb.Append("User Id='{0}';Password='******';");
            }
            else
            {
                var crypto = new CryptoAes(_key, _vector);
                if (_param.ContainsKey(keyComp + "userid"))
                {
                    sb.Append("User Id='" +
                              _param[keyComp + "userid"] + "';");
                }
                if (_param.ContainsKey(keyComp + "password"))
                {
                    sb.Append("Password='******';");
                }
            }

            if (_param.ContainsKey(keyComp + "sslmode")) {
                sb.Append("SSL Mode=" + _param[keyComp + "sslmode"] + ";");
            }

            if (_param.ContainsKey(keyComp + "timeout")) {
                sb.Append("Timeout=" + _param[keyComp + "timeout"] + ";");
            }

            if (_param.ContainsKey(keyComp + "commandtimeout"))
            {
                sb.Append("CommandTimeout=" +
                          _param[keyComp + "commandtimeout"] + ";");
            }

            if (_param.ContainsKey(keyComp + "buffersize"))
            {
                sb.Append("Buffer Size=" +
                          _param[keyComp + "buffersize"] + ";");
            }

            return sb.ToString();
        }