Skip to content

Commit c90f98d

Browse files
committed
Updates the download button to offer to install immediately.
1 parent 67d2aac commit c90f98d

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

FRC-Extension/Buttons/DownloadMonoButton.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
using Microsoft.VisualStudio.Shell;
77
using Microsoft.VisualStudio.Shell.Interop;
88
using RobotDotNet.FRC_Extension.MonoCode;
9-
using RobotDotNet.FRC_Extension.WPILibFolder;
109

1110
namespace RobotDotNet.FRC_Extension.Buttons
1211
{
1312
public class DownloadMonoButton : ButtonBase
1413
{
1514
private readonly MonoFile m_monoFile;
1615
private bool m_downloading = false;
16+
private readonly InstallMonoButton m_installButton;
1717

18-
public DownloadMonoButton(Frc_ExtensionPackage package, MonoFile monoFile)
19-
: base(package, false, GuidList.guidFRC_ExtensionCmdSet, (int) PkgCmdIDList.cmdidDownloadMono)
18+
public DownloadMonoButton(Frc_ExtensionPackage package, MonoFile monoFile, InstallMonoButton installButton)
19+
: base(package, false, GuidList.guidFRC_ExtensionCmdSet, (int)PkgCmdIDList.cmdidDownloadMono)
2020
{
2121
m_monoFile = monoFile;
22+
m_installButton = installButton;
2223
}
2324

2425

@@ -62,18 +63,23 @@ public override async void ButtonCallback(object sender, EventArgs e)
6263
IVsUIShell uiShell = (IVsUIShell)m_package.PublicGetService(typeof(SVsUIShell));
6364
Guid clsid = Guid.Empty;
6465
int result;
65-
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(
66+
uiShell.ShowMessageBox(
6667
0,
6768
ref clsid,
68-
"Mono Successfully Downloaded",
69+
"Mono Successfully Downloaded. Would you like to install it to the RoboRIO?",
6970
string.Format(CultureInfo.CurrentCulture, "", this.ToString()),
7071
string.Empty,
7172
0,
72-
OLEMSGBUTTON.OLEMSGBUTTON_OK,
73+
OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
7374
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
7475
OLEMSGICON.OLEMSGICON_INFO,
7576
0, // false
76-
out result));
77+
out result);
78+
if (result == 6)
79+
{
80+
//Install Mono.
81+
await m_installButton.DeployMono(m_installButton.GetMenuCommand());
82+
}
7783
}
7884
else
7985
{

FRC-Extension/Buttons/InstallMonoButton.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public InstallMonoButton(Frc_ExtensionPackage package, MonoFile monoFile)
1919
m_monoFile = monoFile;
2020
}
2121

22+
internal OleMenuCommand GetMenuCommand()
23+
{
24+
return m_oleMenuItem;
25+
}
26+
2227
public override async void ButtonCallback(object sender, EventArgs e)
2328
{
2429
var menuCommand = sender as OleMenuCommand;
@@ -59,11 +64,7 @@ public override async void ButtonCallback(object sender, EventArgs e)
5964
if (properFileExists)
6065
{
6166
//We can deploy
62-
m_installing = true;
63-
menuCommand.Visible = false;
6467
await DeployMono(menuCommand);
65-
m_installing = false;
66-
menuCommand.Visible = true;
6768
}
6869
else
6970
{
@@ -86,7 +87,7 @@ public override async void ButtonCallback(object sender, EventArgs e)
8687
}
8788
}
8889
}
89-
private async Task DeployMono(OleMenuCommand menuCommand)
90+
internal async Task DeployMono(OleMenuCommand menuCommand)
9091
{
9192
try
9293
{

FRC-Extension/FRC-ExtensionPackage.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,17 @@ protected override void Initialize()
100100

101101
m_deployButton = new DeployDebugButton(this, (int)PkgCmdIDList.cmdidDeployCode, false);
102102
m_debugButton = new DeployDebugButton(this, (int)PkgCmdIDList.cmdidDebugCode, true);
103+
103104

104105
string monoFolder = WPILibFolderStructure.CreateMonoFolder();
105106

106107
string monoFile = monoFolder + Path.DirectorySeparatorChar + DeployProperties.MonoVersion;
107108

108109
m_monoFile = new MonoFile(monoFile);
109110

110-
m_downloadMonoButton = new DownloadMonoButton(this, m_monoFile);
111111
m_installMonoButton = new InstallMonoButton(this, m_monoFile);
112-
112+
m_downloadMonoButton = new DownloadMonoButton(this, m_monoFile, m_installMonoButton);
113+
113114

114115
m_aboutButton = new AboutButton(this);
115116
m_netConsoleButton = new NetConsoleButton(this);

0 commit comments

Comments
 (0)