1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using System . Linq ;
3
4
using EnvDTE ;
4
5
using EnvDTE80 ;
@@ -9,12 +10,32 @@ namespace RobotDotNet.FRC_Extension.Buttons
9
10
{
10
11
public class DeployDebugButton : ButtonBase
11
12
{
12
- protected bool m_debugButton ;
13
- protected bool m_deploying = false ;
13
+ protected readonly bool m_debugButton ;
14
+ protected static bool s_deploying = false ;
15
+ protected static readonly List < OleMenuCommand > s_deployCommands = new List < OleMenuCommand > ( ) ;
14
16
15
17
public DeployDebugButton ( Frc_ExtensionPackage package , int pkgCmdIdOfButton , bool debug ) : base ( package , true , GuidList . guidFRC_ExtensionCmdSet , pkgCmdIdOfButton )
16
18
{
17
19
m_debugButton = debug ;
20
+ s_deployCommands . Add ( m_oleMenuItem ) ;
21
+ }
22
+
23
+ private void DisableAllButtons ( )
24
+ {
25
+ foreach ( var oleMenuCommand in s_deployCommands )
26
+ {
27
+ oleMenuCommand . Visible = false ;
28
+ }
29
+ s_deploying = true ;
30
+ }
31
+
32
+ private void EnableAllButtons ( )
33
+ {
34
+ foreach ( var oleMenuCommand in s_deployCommands )
35
+ {
36
+ oleMenuCommand . Visible = true ;
37
+ }
38
+ s_deploying = false ;
18
39
}
19
40
20
41
public override async void ButtonCallback ( object sender , EventArgs e )
@@ -24,7 +45,7 @@ public override async void ButtonCallback(object sender, EventArgs e)
24
45
{
25
46
return ;
26
47
}
27
- if ( ! m_deploying )
48
+ if ( ! s_deploying )
28
49
{
29
50
try
30
51
{
@@ -35,20 +56,17 @@ public override async void ButtonCallback(object sender, EventArgs e)
35
56
36
57
if ( teamNumber == null ) return ;
37
58
38
- //Disable the deploy button
39
- m_deploying = true ;
40
- menuCommand . Visible = false ;
59
+ //Disable the deploy buttons
60
+ DisableAllButtons ( ) ;
41
61
DeployManager m = new DeployManager ( m_package . PublicGetService ( typeof ( DTE ) ) as DTE ) ;
42
62
await m . DeployCode ( teamNumber , page , m_debugButton ) ;
43
- m_deploying = false ;
44
- menuCommand . Visible = true ;
63
+ EnableAllButtons ( ) ;
45
64
m_output . ProgressBarLabel = "Robot Code Deploy Successful" ;
46
65
}
47
66
catch ( Exception ex )
48
67
{
49
68
m_output . WriteLine ( ex . ToString ( ) ) ;
50
- m_deploying = false ;
51
- menuCommand . Visible = true ;
69
+ EnableAllButtons ( ) ;
52
70
m_output . ProgressBarLabel = "Robot Code Deploy Failed" ;
53
71
}
54
72
@@ -78,7 +96,7 @@ public override void QueryCallback(object sender, EventArgs e)
78
96
}
79
97
}
80
98
}
81
- if ( m_deploying )
99
+ if ( s_deploying )
82
100
visable = false ;
83
101
84
102
menuCommand . Visible = visable ;
0 commit comments