Esempio n. 1
0
        void ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            int  count             = 0;
            bool isNumber          = int.TryParse(item.Text, out count);

            if (isNumber && count > 0)
            {
                var           passGen = new JocysCom.ClassLibrary.Security.Password.Generator();
                ToolStripItem owner   = item.OwnerItem;
                while (!owner.Name.StartsWith("Preset"))
                {
                    owner = owner.OwnerItem;
                }
                switch (owner.Text)
                {
                case "Easy": passGen.Preset = new Preset(PresetName.DefaultEasyToRemember); break;

                case "Hard": passGen.Preset = new Preset(PresetName.DefaultGood); break;

                case "Guid": passGen.Preset = new Preset(PresetName.GuidDefault); break;

                default: passGen.Preset = new Preset(PresetName.DefaultEasyToRemember); break;
                }
                string separator = Regex.Unescape(GeneratorPanel.ListSeparatorComboBox.Text);
                string list      = passGen.NewPasswordList(count, separator);
                if (list.Length > 0)
                {
                    Clipboard.SetText(list);
                }
                NotifyIconContextMenuStrip.Close();
            }
        }
Esempio n. 2
0
        void ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            int  count             = 0;
            bool isNumber          = int.TryParse(item.Text, out count);

            if (isNumber && count > 0)
            {
                ToolStripItem owner = item.OwnerItem;
                while (!owner.Name.StartsWith("Preset"))
                {
                    owner = owner.OwnerItem;
                }
                string favPresetName = null;
                if (owner.Text == Properties.Settings.Default.FavPreset1TextBox)
                {
                    favPresetName = Properties.Settings.Default.FavPreset1ComboBox;
                }
                else if (owner.Text == Properties.Settings.Default.FavPreset2TextBox)
                {
                    favPresetName = Properties.Settings.Default.FavPreset2ComboBox;
                }
                else if (owner.Text == Properties.Settings.Default.FavPreset3TextBox)
                {
                    favPresetName = Properties.Settings.Default.FavPreset3ComboBox;
                }
                var preset  = GeneratorPanel.Presets.FirstOrDefault(x => x.PresetName == favPresetName);
                var passGen = new JocysCom.ClassLibrary.Security.Password.Generator();
                passGen.Preset = (preset == null)
                                        ? new Preset(PresetName.DefaultEasyToRemember)
                                        : new Preset(preset.PresetTemplate);
                string separator = Regex.Unescape(GeneratorPanel.ListSeparatorComboBox.Text);
                string list      = passGen.NewPasswordList(count, separator);
                if (list.Length > 0)
                {
                    ClipboardHelper.SetClipboardText(list);
                }
                TrayNotifyIconContextMenuStrip.Close();
            }
        }
Esempio n. 3
0
 void ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ToolStripMenuItem item = (ToolStripMenuItem)sender;
     int count = 0;
     bool isNumber = int.TryParse(item.Text, out count);
     if (isNumber && count > 0)
     {
         var passGen = new JocysCom.ClassLibrary.Security.Password.Generator();
         ToolStripItem owner = item.OwnerItem;
         while (!owner.Name.StartsWith("Preset")) owner = owner.OwnerItem;
         switch (owner.Text)
         {
             case "Easy": passGen.Preset = new Preset(PresetName.DefaultEasyToRemember); break;
             case "Hard": passGen.Preset = new Preset(PresetName.DefaultGood); break;
             case "Guid": passGen.Preset = new Preset(PresetName.GuidDefault); break;
             default: passGen.Preset = new Preset(PresetName.DefaultEasyToRemember); break;
         }
         string separator = Regex.Unescape(GeneratorPanel.ListSeparatorComboBox.Text);
         string list = passGen.NewPasswordList(count, separator);
         if (list.Length > 0) Clipboard.SetText(list);
         NotifyIconContextMenuStrip.Close();
     }
 }