コード例 #1
0
        private void CheckNativeMessagingHost()
        {
            var t = new Task <bool>(() => _host.GetBrowserStatuses().Any(bs => bs.Value == BrowserStatus.Installed));

            var t2 = t.ContinueWith((ti) =>
            {
                if (ti.IsCompleted && !ti.Result)
                {
                    var nmiInstall = MessageBox.Show(this, $"The native messaging host was not detected. It must be installed for KeePassNatMsg to work. Do you want to install it now?", "Native Messaging Host Not Detected", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (nmiInstall == DialogResult.Yes)
                    {
                        var bsf = new BrowserSelectForm(_host);
                        if (bsf.ShowDialog(this) == DialogResult.OK)
                        {
                            _host.Install(bsf.SelectedBrowsers);
                            _host.UpdateProxy();
                            MessageBox.Show(this, "The native messaging host installed completed successfully.", "Install Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                GetNativeMessagingStatus();
            });

            lblProxyVersion.Text = "Loading Native Messaging Status...";

            t.Start();
        }
コード例 #2
0
        private void PromptInstall()
        {
            var nmiInstall = MessageBox.Show(this, $"The native messaging host was not detected. It must be installed for KeePassNatMsg to work. Do you want to install it now?", "Native Messaging Host Not Detected", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (nmiInstall == DialogResult.Yes)
            {
                var bsf = new BrowserSelectForm(_host);
                if (bsf.ShowDialog(this) == DialogResult.OK)
                {
                    _host.Install(bsf.SelectedBrowsers);
                    _host.UpdateProxy();
                    MessageBox.Show(this, "The native messaging host installed completed successfully.", "Install Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
コード例 #3
0
        private void btnInstallNativeMessaging_Click(object sender, EventArgs e)
        {
            var bsf = new BrowserSelectForm(_host);

            if (bsf.ShowDialog(this) == DialogResult.OK)
            {
                var t = new Task(() =>
                {
                    _host.Install(bsf.SelectedBrowsers);
                    _host.UpdateProxy();
                    GetNativeMessagingStatus();
                    MessageBox.Show(this, "The native messaging host installed completed successfully.", "Install Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                });
                t.Start();
            }
        }