public PasswordInspectionControl()
            : base()
        {
            this.InitializeComponent();

            this.passwordCounter = OnlineFactory.Create <IPasswordCounter>();

            StandardContextMenu contextMenu = StandardContextMenu.Create(this.OnContextMenuItemClick);

            contextMenu.Opening += this.OnContextMenuOpening;

            this.txtSource.ContextMenu      = null;
            this.txtSource.ContextMenuStrip = contextMenu;

            this.txtSource.SetWatermark(true);
            this.txtResult.Text      = String.Empty;
            this.txtResult.BackColor = Color.Transparent;
            this.txtResult.TextAlign = ContentAlignment.TopLeft;

            this.lblText.LinkArea = new LinkArea();

            String url1 = "https://haveibeenpwned.com/passwords";
            String url2 = "https://haveibeenpwned.com/api/v3";

            this.lblText.Text = String.Format(
                "On this view you can run an online check for your source password.{0}{0}" +
                "For this purpose an API request for so-called “pwned passwords” is sent to URL https://api.pwnedpasswords.com/range.{0}{0}" +
                "Note that the plain password is never sent to that API.{0}{0}" +
                "More information about “pwned passwords” can be found under {1}.{0}{0}" +
                "More information about the API can be found under {2}.",
                Environment.NewLine, url1, url2);

            this.lblText.Links.Add(this.lblText.Text.IndexOf(url1), url1.Length, url1);
            this.lblText.Links.Add(this.lblText.Text.IndexOf(url2), url2.Length, url2);
        }
        private void OnContextMenuOpening(Object sender, CancelEventArgs args)
        {
            try
            {
                StandardContextMenu source = StandardContextMenu.MenuFromSender(sender, out Control control);

                if (source == null)
                {
                    return;
                }

                source.DisableAll();

                if (control == this.txtSource)
                {
                    source.Copy.Enabled  = this.txtSource.Text.Length > 0;
                    source.Cut.Enabled   = this.txtSource.Text.Length > 0;
                    source.Paste.Enabled = Clipboard.ContainsText();
                    source.Clear.Enabled = this.txtSource.Text.Length > 0;
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
        }
Beispiel #3
0
        private void OnContextMenuOpening(Object sender, CancelEventArgs args)
        {
            try
            {
                StandardContextMenu source = StandardContextMenu.MenuFromSender(sender, out Control control);

                if (source == null)
                {
                    return;
                }

                source.DisableAll();

                if (control == this.numLength)
                {
                    source.Clear.Enabled = true;
                }
                else if (control == this.numAmount)
                {
                    source.Clear.Enabled = true;
                }
                else if (control == this.lstPasswords)
                {
                    source.Copy.Enabled  = this.lstPasswords.SelectedIndices.Count > 0;
                    source.Cut.Enabled   = this.lstPasswords.SelectedIndices.Count > 0;
                    source.Clear.Enabled = this.lstPasswords.Items.Count > 0;
                }
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception);
            }
        }
Beispiel #4
0
        private void OnContextMenuItemClick(Object sender, EventArgs args)
        {
            try
            {
                ToolStripItem source = StandardContextMenu.ItemFromSender(sender, out StandardContextMenu parent);

                if (source == null)
                {
                    return;
                }

                if (parent.IsPaste(source))
                {
                    if (parent.SourceControl == this.txtPassword && Clipboard.ContainsText())
                    {
                        this.txtPassword.Text = Clipboard.GetText().ClearLineEndings();
                        this.cntEntropy.Reset();
                        this.cntDuration.Reset();
                    }
                }
                else if (parent.IsClear(source))
                {
                    if (parent.SourceControl == this.txtPassword)
                    {
                        this.txtPassword.Text = String.Empty;
                        this.cntEntropy.Reset();
                        this.cntDuration.Reset();
                    }
                }
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception);
            }
        }
Beispiel #5
0
        private void OnContextMenuItemClick(Object sender, EventArgs args)
        {
            try
            {
                ToolStripItem source = StandardContextMenu.ItemFromSender(sender, out StandardContextMenu parent);

                if (source == null)
                {
                    return;
                }

                if (parent.IsCopy(source))
                {
                    if (parent.SourceControl == this.numLength)
                    {
                        Clipboard.SetText(this.numLength.Text);
                    }
                    else if (parent.SourceControl == this.numAmount)
                    {
                        Clipboard.SetText(this.numAmount.Text);
                    }
                    else if (parent.SourceControl == this.lstPasswords)
                    {
                        this.CopySelectedPasswords(false);
                    }
                }
                else if (parent.IsCut(source))
                {
                    if (parent.SourceControl == this.lstPasswords)
                    {
                        this.CopySelectedPasswords(true);
                    }
                }
                else if (parent.IsClear(source))
                {
                    if (parent.SourceControl == this.numLength)
                    {
                        this.controlSettings.Reset(nameof(this.controlSettings.Length));
                    }
                    else if (parent.SourceControl == this.numAmount)
                    {
                        this.controlSettings.Reset(nameof(this.controlSettings.Amount));
                    }
                    else if (parent.SourceControl == this.lstPasswords)
                    {
                        this.lstPasswords.Items.Clear();
                    }
                }
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception);
            }
        }
Beispiel #6
0
        public SecurityGeneratorControl()
        {
            this.InitializeComponent();

            StandardContextMenu contextMenu = StandardContextMenu.Create(this.OnContextMenuItemClick);

            contextMenu.Opening += this.OnContextMenuOpening;

            this.txtPassword.ContextMenu      = null;
            this.txtPassword.ContextMenuStrip = contextMenu;
            this.txtPassword.SetWatermark(true);
        }
        private void OnContextMenuItemClick(Object sender, EventArgs args)
        {
            try
            {
                ToolStripItem source = StandardContextMenu.ItemFromSender(sender, out StandardContextMenu parent);

                if (source == null)
                {
                    return;
                }

                if (parent.IsCopy(source))
                {
                    if (parent.SourceControl == this.txtSource)
                    {
                        Clipboard.SetText(this.txtSource.Text);
                    }
                }
                else if (parent.IsCut(source))
                {
                    if (parent.SourceControl == this.txtSource)
                    {
                        Clipboard.SetText(this.txtSource.Text);
                        this.txtSource.Text      = String.Empty;
                        this.txtResult.Text      = String.Empty;
                        this.txtResult.BackColor = Color.Transparent;
                        this.txtResult.TextAlign = ContentAlignment.TopLeft;
                    }
                }
                else if (parent.IsPaste(source))
                {
                    if (parent.SourceControl == this.txtSource && Clipboard.ContainsText())
                    {
                        this.txtSource.Text = Clipboard.GetText().ClearLineEndings();
                    }
                }
                else if (parent.IsClear(source))
                {
                    if (parent.SourceControl == this.txtSource)
                    {
                        this.txtSource.Text      = String.Empty;
                        this.txtResult.Text      = String.Empty;
                        this.txtResult.BackColor = Color.Transparent;
                        this.txtResult.TextAlign = ContentAlignment.TopLeft;
                    }
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
        }
        public ExchangeGeneratorControl()
            : base()
        {
            this.InitializeComponent();

            StandardContextMenu contextMenu = StandardContextMenu.Create(this.OnContextMenuItemClick);

            contextMenu.Opening += this.OnContextMenuOpening;

            this.txtSource.ContextMenu      = null;
            this.txtSource.ContextMenuStrip = contextMenu;
            this.txtSource.SetWatermark(true);

            this.txtResult.ContextMenu      = null;
            this.txtResult.ContextMenuStrip = contextMenu;
            this.txtResult.SetWatermark(true);
        }
Beispiel #9
0
        public ExtendedGeneratorControl()
            : base()
        {
            this.InitializeComponent();
            this.lstPasswords.Items.Clear();

            this.entropyCalculator  = CalculatorFactory.Create <IEntropyCalculator>();
            this.strengthCalculator = CalculatorFactory.Create <IStrengthCalculator>();

            StandardContextMenu contextMenu = StandardContextMenu.Create(this.OnContextMenuItemClick);

            contextMenu.Opening += this.OnContextMenuOpening;

            this.numLength.ContextMenuStrip    = contextMenu;
            this.numAmount.ContextMenuStrip    = contextMenu;
            this.lstPasswords.ContextMenuStrip = contextMenu;
        }
        public QwertyGeneratorControl()
            : base()
        {
            this.InitializeComponent();

            this.qwertyValidator = KeyboardFactory.Create <IQwertyValidator>();

            StandardContextMenu contextMenu = StandardContextMenu.Create(this.OnContextMenuItemClick);

            contextMenu.Opening += this.OnContextMenuOpening;

            this.txtSource.ContextMenu      = null;
            this.txtSource.ContextMenuStrip = contextMenu;

            this.txtSource.SetWatermark(true);
            this.txtResult.Text = String.Empty;
        }
        private void OnContextMenuItemClick(Object sender, EventArgs args)
        {
            try
            {
                ToolStripItem source = StandardContextMenu.ItemFromSender(sender, out StandardContextMenu parent);

                if (source == null)
                {
                    return;
                }

                if (parent.IsCopy(source))
                {
                    if (parent.SourceControl == this.txtPhrase)
                    {
                        Clipboard.SetText(this.txtPhrase.Text);
                    }
                    else if (parent.SourceControl == this.lstPasswords)
                    {
                        this.CopySelectedPasswords(false);
                    }
                }
                else if (parent.IsCut(source))
                {
                    if (parent.SourceControl == this.txtPhrase)
                    {
                        Clipboard.SetText(this.txtPhrase.Text);
                        this.txtPhrase.Text = String.Empty;
                    }
                    else if (parent.SourceControl == this.lstPasswords)
                    {
                        this.CopySelectedPasswords(true);
                    }
                }
                else if (parent.IsPaste(source))
                {
                    if (parent.SourceControl == this.txtPhrase && Clipboard.ContainsText())
                    {
                        this.txtPhrase.Text = Clipboard.GetText().ClearLineEndings();
                    }
                }
                else if (parent.IsClear(source))
                {
                    if (parent.SourceControl == this.numLength)
                    {
                        this.numLength.Value = this.numLength.Minimum;
                    }
                    else if (parent.SourceControl == this.numAmount)
                    {
                        this.numAmount.Value = this.numAmount.Minimum;
                    }
                    else if (parent.SourceControl == this.txtPhrase)
                    {
                        this.txtPhrase.Clear();
                    }
                    else if (parent.SourceControl == this.lstPasswords)
                    {
                        this.lstPasswords.Items.Clear();
                    }
                }
            }
            catch (Exception exception)
            {
                System.Diagnostics.Debug.WriteLine(exception);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Creates and adds the required GUI
        /// </summary>
        private void CreateGUI()
        {
            // Lock the menu
            VerticalMenu.MenuLocked = true;

            // For every sub page map...
            foreach (var pageMap in PageMap.Pages.OrderBy(x => x.Order))
            {
                // Create the button
                var button = new VerticalMenuButton(VerticalMenu, async(menu, button) =>
                {
                    // If there are other pages...
                    if (pageMap.Pages.Count() > 0)
                    {
                        // Create a sub pages page
                        return(await Task.FromResult(new PageMapPage(pageMap)));
                    }
                    // Else...
                    else
                    {
                        // Get the presenter
                        var presenter = pageMap.Presenter;

                        // Create and return a page
                        return(await Task.FromResult(PresenterPagesFactory.CreatePresenterPage(presenter, pageMap)));
                    }
                })
                {
                    Text         = pageMap.Name,
                    VectorSource = pageMap.PathData,
                    BackColor    = pageMap.Color.ToColor(),
                    ForeColor    = pageMap.Color.ToColor().DarkOrWhite(),
                    IsEnabled    = !(pageMap.Presenter == null && pageMap.Pages.Count == 0)
                };

                // Create the context menu
                var contextMenu = new StandardContextMenu();

                contextMenu.AddOpenOption((button) =>
                {
                    WindowsControlsDI.GetWindowsDialogManager.OpenAsync(pageMap.Name, pageMap.PathData, () =>
                    {
                        // If there are other pages...
                        if (pageMap.Pages.Count() > 0)
                        {
                            // Create a sub pages page
                            return(new PageMapPage(pageMap));
                        }
                        // Else...
                        else
                        {
                            // Get the presenter
                            var presenter = pageMap.Presenter;

                            // Create and return a page
                            return(PresenterPagesFactory.CreatePresenterPage(presenter, pageMap));
                        }
                    }, pageMap.Id);
                });

                // Set it to the button
                button.ContextMenu = contextMenu;

                // Add it to the menu
                Add(button, pageMap.Category);
            }
        }