Exemple #1
0
        public override async void ButtonCallback(object sender, EventArgs e)
        {
            var menuCommand = sender as OleMenuCommand;

            if (menuCommand == null)
            {
                return;
            }

            if (!m_downloading)
            {
                try
                {
                    m_downloading       = true;
                    menuCommand.Visible = false;
                    if (!await CheckForInternetConnection())
                    {
                        m_downloading       = false;
                        menuCommand.Visible = true;
                        return;
                    }

                    m_monoFile.ResetToDefaultDirectory();

                    bool downloadNew = !m_monoFile.CheckFileValid();

                    if (downloadNew)
                    {
                        Output.ProgressBarLabel = "Downloading Mono";
                        await m_monoFile.DownloadMono(Output);

                        //Verify Download
                        bool verified = m_monoFile.CheckFileValid();

                        if (verified)
                        {
                            // Show a Message Box to prove we were here
                            IVsUIShell uiShell = (IVsUIShell)Package.PublicGetService(typeof(SVsUIShell));
                            Guid       clsid   = Guid.Empty;
                            int        result;
                            uiShell.ShowMessageBox(
                                0,
                                ref clsid,
                                "Mono Successfully Downloaded. Would you like to install it to the RoboRIO?",
                                string.Format(CultureInfo.CurrentCulture, "", ToString()),
                                string.Empty,
                                0,
                                OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
                                OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                                OLEMSGICON.OLEMSGICON_INFO,
                                0, // false
                                out result);
                            if (result == 6)
                            {
                                //Install Mono.
                                await m_installButton.DeployMono(m_installButton.GetMenuCommand());
                            }
                        }
                        else
                        {
                            // Show a Message Box to prove we were here
                            IVsUIShell uiShell = (IVsUIShell)Package.PublicGetService(typeof(SVsUIShell));
                            Guid       clsid   = Guid.Empty;
                            int        result;
                            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(
                                                                                   0,
                                                                                   ref clsid,
                                                                                   "Mono Download Failed. Please Try Again",
                                                                                   string.Format(CultureInfo.CurrentCulture, "", ToString()),
                                                                                   string.Empty,
                                                                                   0,
                                                                                   OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                                                                   OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                                                                                   OLEMSGICON.OLEMSGICON_INFO,
                                                                                   0, // false
                                                                                   out result));
                        }
                    }
                    else
                    {
                        // Show a Message Box to prove we were here
                        IVsUIShell uiShell = (IVsUIShell)Package.PublicGetService(typeof(SVsUIShell));
                        Guid       clsid   = Guid.Empty;
                        int        result;
                        Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(
                                                                               0,
                                                                               ref clsid,
                                                                               "Mono Already Downloaded",
                                                                               string.Format(CultureInfo.CurrentCulture, "", ToString()),
                                                                               string.Empty,
                                                                               0,
                                                                               OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                                                               OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                                                                               OLEMSGICON.OLEMSGICON_INFO,
                                                                               0, // false
                                                                               out result));
                    }
                }
                catch (Exception ex)
                {
                    Output.WriteLine(ex.ToString());
                    m_downloading       = false;
                    menuCommand.Visible = true;
                }
                m_downloading       = false;
                menuCommand.Visible = true;
            }
        }
Exemple #2
0
        public override async void ButtonCallback(object sender, EventArgs e)
        {
            var menuCommand = sender as OleMenuCommand;

            if (menuCommand == null)
            {
                return;
            }

            if (!m_installing)
            {
                try
                {
                    m_monoFile.ResetToDefaultDirectory();

                    var properFileExists = m_monoFile.CheckFileValid();

                    if (properFileExists)
                    {
                        //We can deploy
                        m_installing        = true;
                        menuCommand.Visible = false;
                        await DeployMono(menuCommand);

                        m_installing        = false;
                        menuCommand.Visible = true;
                    }
                    else
                    {
                        //Ask to see if we want to load the file or download it
                        string retVal = LoadMonoPopup();

                        if (!string.IsNullOrEmpty(retVal))
                        {
                            m_monoFile.FileName = retVal;
                            //Check for valid file.
                            properFileExists = m_monoFile.CheckFileValid();

                            if (properFileExists)
                            {
                                //We can deploy
                                await DeployMono(menuCommand);
                            }
                            else
                            {
                                InvalidMonoPopup();
                            }
                        }
                        else
                        {
                            DownloadMonoPopup();
                        }
                    }
                }
                catch (SshConnectionException)
                {
                    Output.WriteLine("Connection to RoboRIO lost. Install aborted.");
                    m_installing            = false;
                    menuCommand.Visible     = true;
                    Output.ProgressBarLabel = "Mono Install Failed";
                }
                catch (Exception ex)
                {
                    Output.WriteLine(ex.ToString());
                    m_installing            = false;
                    menuCommand.Visible     = true;
                    Output.ProgressBarLabel = "Mono Install Failed";
                }
            }
        }
Exemple #3
0
        public override void ButtonCallback(object sender, EventArgs e)
        {
            ThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                var menuCommand = sender as OleMenuCommand;
                if (menuCommand == null)
                {
                    return;
                }

                if (!m_downloading)
                {
                    try
                    {
                        m_downloading       = true;
                        menuCommand.Visible = false;
                        // We're just going right back to doing something on the UI thread, so just resume back on the UI thread.
                        if (!await CheckForInternetConnectionAsync().ConfigureAwait(true))
                        {
                            m_downloading       = false;
                            menuCommand.Visible = true;
                            return;
                        }

                        m_monoFile.ResetToDefaultDirectory();

                        bool downloadNew = !m_monoFile.CheckFileValid();

                        if (downloadNew)
                        {
                            Output.ProgressBarLabel = "Downloading Mono";
                            await m_monoFile.DownloadMonoAsync(Output).ConfigureAwait(false);

                            //Verify Download
                            bool verified = m_monoFile.CheckFileValid();

                            if (verified)
                            {
                                // Show a Message Box to prove we were here
                                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                                IVsUIShell uiShell = Package.PublicGetService <IVsUIShell, SVsUIShell>();
                                Guid clsid         = Guid.Empty;
                                int result         = await ShowMessageAsync("Mono Successfully Downloaded. Would you like to install it to the RoboRIO?",
                                                                            string.Empty).ConfigureAwait(false);
                                if (result == 6)
                                {
                                    //Install Mono.
                                    await m_installButton.DeployMonoAsync(m_installButton.GetMenuCommand()).ConfigureAwait(false);
                                }
                            }
                            else
                            {
                                // Show a Message Box to prove we were here
                                await ShowMessageAsync("Mono Download Failed. Please Try Again", string.Empty).ConfigureAwait(false);
                            }
                        }
                        else
                        {
                            // Show a Message Box to prove we were here
                            IVsUIShell uiShell = Package.PublicGetService <IVsUIShell, SVsUIShell>();
                            await ShowMessageAsync("Mono Already Downloaded", string.Empty).ConfigureAwait(false);
                        }
                    }
                    catch (Exception ex)
                    {
                        await Output.WriteLineAsync(ex.ToString()).ConfigureAwait(false);
                        await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                        m_downloading       = false;
                        menuCommand.Visible = true;
                    }
                    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                    m_downloading       = false;
                    menuCommand.Visible = true;
                }
            });
        }