//--------------------------------------------------
        private void expWPA_Expanded(object sender, RoutedEventArgs e)
        {
            if (!initializeComponentIsCompleted) return;

            if (disableExpandersEvents) return;
            disableExpandersEvents = true;

            if (lockExpanders)
            {
                expWPA.IsExpanded = false;
                disableExpandersEvents = false;
                return;
            }

            lastExpanded_PswType = pswType.WPA;
            expPassword.IsExpanded = false;
            if (!expSingleGeneration.IsExpanded && !expBulkGeneration.IsExpanded)
                switch (lastExpanded_GenType)
                {
                    case genType.Single:
                        expSingleGeneration.IsExpanded = true;
                        break;
                    case genType.Bulk:
                        expBulkGeneration.IsExpanded = true;
                        break;
                }
            expCmdline.IsExpanded = false;
            expAbout.IsExpanded = false;

            cmdRegenerate_Click(null, null);    // generate password

            disableExpandersEvents = false;
        }
        //--------------------------------------------------
        public void PrepareToGeneration(genType gt, pswType pt, ref PasswordGenerator pg)
        {
            PasswordGenerator.PasswordGenerationOptions pgo = new PasswordGenerator.PasswordGenerationOptions();

            // options
            switch (gt)
            {
                case genType.Single:
                    pgo.easyToType = (bool)chkSingle_EasyToType.IsChecked;
                    pgo.excludeConfusing = (bool)chkSingle_ExcludeConfusingChars.IsChecked;
                    pgo.quantity = 1;
                    break;
                case genType.Bulk:
                    pgo.easyToType = (bool)chkBulkEasyToType.IsChecked;
                    pgo.excludeConfusing = (bool)chkBulkExcludeConfusingChars.IsChecked;
                    pgo.quantity = udBulkQuantity.Value ?? 0;
                    fileName = txtBulkFile.Text;
                    appendToFile = rbBulkAppend.IsChecked ?? true;
                    break;
                default:
                    pgo.pswLength = 0;  // mark structure as invalid
                    return;   // error
            }

            // fill the pgo.charsets array
            pgo.charsets = new string[0];

            switch (pt)
            {
                case pswType.Password:
                    pgo.pswLength = udPswLength.Value ?? 0;

                    // search for all checkboxes in the expPassword expander
                    foreach (object ctrl in FindAllChildren(expPassword))
                        if (ctrl.GetType().Name == "CheckBox" && (bool)((CheckBox)ctrl).IsChecked && ((CheckBox)ctrl).Tag != null)
                        {
                            Array.Resize(ref pgo.charsets, pgo.charsets.Length + 1);
                            pgo.charsets[pgo.charsets.Length - 1] = (string)((CheckBox)ctrl).Tag;
                        }

                    // user defined charset
                    if ((bool)chkPswUserDefinedCharacters.IsChecked)
                        pgo.userDefinedCharset = txtPswUserDefinedCharacters.Text;

                    break;
                case pswType.WPA:
                    if ((bool)rbWpaPassphrase.IsChecked)
                    {
                        pgo.pswLength = udWpaLength.Value ?? 0;

                        // search for all checkboxes in the expWPA expander
                        foreach (object ctrl in FindAllChildren(expWPA))
                            if (ctrl.GetType().Name == "CheckBox" && (bool)((CheckBox)ctrl).IsChecked && ((CheckBox)ctrl).Tag != null)
                            {
                                Array.Resize(ref pgo.charsets, pgo.charsets.Length + 1);
                                pgo.charsets[pgo.charsets.Length - 1] = (string)((CheckBox)ctrl).Tag;
                            }

                            // user defined charset
                        if ((bool)chkWpaUserDefinedCharacters.IsChecked)
                            pgo.userDefinedCharset = txtWpaUserDefinedCharacters.Text;
                    }
                    else  // rbWpa256bitKey is checked
                    {
                        pgo.pswLength = 64;

                        // use only one charset
                        pgo.charsets = new string[1];
                        pgo.charsets[0] = "hex";
                    }
                    break;
                default:
                    pgo.pswLength = 0;
                    return; // some error
            }

            pg = new PasswordGenerator(pgo);    // create and initialize the password generator class
        }