Ejemplo n.º 1
0
        private Button NewCopyButton(TextBox parentTextBox, RecordType recordType, string tipText = null)
        {
            parentTextBox.Width -= parentTextBox.Height;
            var button = new Button()
            {
                Name     = "btnCopy",
                Location = new Point(parentTextBox.Right, parentTextBox.Top),
                Size     = new Size(parentTextBox.Height, parentTextBox.Height),
                TabStop  = false,
                Tag      = parentTextBox,
                Text     = "",
                Anchor   = AnchorStyles.Top | AnchorStyles.Right
            };

            Helpers.ScaleButton(button);

            tip.SetToolTip(button, tipText ?? "Copy to clipboard.");

            button.Click += (object sender, EventArgs e) => {
                var textBox = (TextBox)(((Control)sender).Tag);
                textBox.Select();
                ClipboardHelper.SetClipboardText(this, textBox.Text, recordType);
            };

            return(button);
        }
Ejemplo n.º 2
0
        private void mnxHistoricalPasswordCopy_Click(object sender, System.EventArgs e)
        {
            if (lsvHistoryPasswords.SelectedItems.Count != 1)
            {
                return;
            }

            var password = (string)(lsvHistoryPasswords.SelectedItems[0].Tag);

            ClipboardHelper.SetClipboardText(this, password, sensitiveData: true);
        }
Ejemplo n.º 3
0
        private Button NewCopyFilteredButton(TextBox parentTextBox, RecordType recordType, string tipText = null, char[] allowedCopyCharacters = null, GetText copyText = null)
        {
            parentTextBox.Width -= parentTextBox.Height;
            var button = new Button()
            {
                Name     = "btnCopyFiltered",
                Location = new Point(parentTextBox.Right, parentTextBox.Top),
                Size     = new Size(parentTextBox.Height, parentTextBox.Height),
                TabStop  = false,
                Tag      = parentTextBox,
                Text     = "",
                Anchor   = AnchorStyles.Top | AnchorStyles.Right
            };

            Helpers.ScaleButton(button);

            tip.SetToolTip(button, tipText ?? "Copy to clipboard.");

            button.Click += (object sender, EventArgs e) => {
                var textBox = (TextBox)(((Control)sender).Tag);
                textBox.Select();

                string text;
                if (copyText != null)
                {
                    text = copyText.Invoke();
                }
                else
                {
                    text = textBox.Text;
                }
                text = Helpers.FilterText(text, allowedCopyCharacters);

                ClipboardHelper.SetClipboardText(this, text, recordType);
            };

            return(button);
        }
Ejemplo n.º 4
0
 private void btnCopy_Click(object sender, EventArgs e)
 {
     ClipboardHelper.SetClipboardText(this, txtPassword.Text, sensitiveData: true);
 }