示例#1
0
        }//saveUserSettings()

        /// <summary>
        /// Reads BalanceReaderClient.cfg, and sets state accordingly
        /// </summary>
        public void loadUserSettings()
        {
            if (File.Exists(ConfigPath))
            {
                string[] ConfigurationFileLines = File.ReadAllLines(ConfigPath);


                string PasswordDecrypted;
                if (string.IsNullOrEmpty(ConfigurationFileLines[2]))
                {
                    //need to manually avoid calling decrypt on an empty string to avoid an infinite loop
                    PasswordDecrypted = "";
                }
                else
                {
                    CswEncryption Encryptor = new CswEncryption("");
                    PasswordDecrypted = Encryptor.decrypt(ConfigurationFileLines[2]);
                }
                AccessIdField.Text             = ConfigurationFileLines[0];
                UsernameField.Text             = ConfigurationFileLines[1];
                PasswordField.Text             = PasswordDecrypted;
                AddressField.Text              = ConfigurationFileLines[3];
                pollingFrequencyField.Value    = Decimal.Parse(ConfigurationFileLines[4]);
                _authenticationClient.AccessId = ConfigurationFileLines[0];
                _authenticationClient.UserId   = ConfigurationFileLines[1];
                _authenticationClient.Password = PasswordDecrypted;
                _authenticationClient.baseURL  = ConfigurationFileLines[3];
                constructPollTimer(int.Parse(ConfigurationFileLines[4]));


                //all the remaining lines in the configuration file contain balance data, which is handled by the Balances
                for (int line = 5; line < ConfigurationFileLines.Length; line++)
                {
                    string[] balanceDetails = ConfigurationFileLines[line].Split('|');
                    string   COM            = balanceDetails[0];

                    if (_balanceList.ContainsKey(COM))
                    {
                        //set a current cell to avoid a crash from the handleGridUpdate event, then apply data to Balance
                        HardwareGrid.BeginInvoke((Action)(() => { HardwareGrid.CurrentCell = _balanceList[COM].InterfaceRow.Cells["FriendlyName"]; }));

                        bool fileOutdated = _balanceList[COM].FromString(balanceDetails, _configurationList);

                        if (fileOutdated)
                        {
                            File.Delete(ConfigPath);
                        }

                        //unset current cell to avoid having a highlighted region that the user did not click
                        HardwareGrid.BeginInvoke((Action)(() => { HardwareGrid.CurrentCell = null; }));
                    } //if ( File.Exists( "BalanceReaderClient.cfg" ) )
                }     //for ( int line = 5; line < ConfigurationFileLines.Length; line++ )
            }         //if File.Exists
        }             //loadUserSettings()
示例#2
0
        }//handleGridUpdate()

        /// <summary>
        /// Attached to HardwareGrid's CurrentCellDirtyStateChanged event.
        /// Needed to make checkboxes send data immediately.
        /// </summary>
        /// <param name="Sender"></param>
        /// <param name="E"></param>
        private void handleCheckboxUpdate(object Sender, EventArgs E)
        {
            HardwareGrid.CommitEdit(DataGridViewDataErrorContexts.Commit);
        }