Skip to content

Commit 329209e

Browse files
committed
Makes deploy and debug buttons disable eachother
closes #15
1 parent afd115f commit 329209e

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

FRC-Extension.sln.DotSettings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=71229261_002D404c_002D4480_002D9672_002Dd4a58843c057/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Protected" Description="Protected Static Fields"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="s_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
3+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=b73d7327_002D5826_002D45d7_002Daebd_002D0fc3da8126ce/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Protected" Description="Protected Instance Fields"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="m_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String></wpf:ResourceDictionary>

FRC-Extension/Buttons/DeployDebugButton.cs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using EnvDTE;
45
using EnvDTE80;
@@ -9,12 +10,32 @@ namespace RobotDotNet.FRC_Extension.Buttons
910
{
1011
public class DeployDebugButton : ButtonBase
1112
{
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>();
1416

1517
public DeployDebugButton(Frc_ExtensionPackage package, int pkgCmdIdOfButton, bool debug) : base(package, true, GuidList.guidFRC_ExtensionCmdSet, pkgCmdIdOfButton)
1618
{
1719
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;
1839
}
1940

2041
public override async void ButtonCallback(object sender, EventArgs e)
@@ -24,7 +45,7 @@ public override async void ButtonCallback(object sender, EventArgs e)
2445
{
2546
return;
2647
}
27-
if (!m_deploying)
48+
if (!s_deploying)
2849
{
2950
try
3051
{
@@ -35,20 +56,17 @@ public override async void ButtonCallback(object sender, EventArgs e)
3556

3657
if (teamNumber == null) return;
3758

38-
//Disable the deploy button
39-
m_deploying = true;
40-
menuCommand.Visible = false;
59+
//Disable the deploy buttons
60+
DisableAllButtons();
4161
DeployManager m = new DeployManager(m_package.PublicGetService(typeof(DTE)) as DTE);
4262
await m.DeployCode(teamNumber, page, m_debugButton);
43-
m_deploying = false;
44-
menuCommand.Visible = true;
63+
EnableAllButtons();
4564
m_output.ProgressBarLabel = "Robot Code Deploy Successful";
4665
}
4766
catch (Exception ex)
4867
{
4968
m_output.WriteLine(ex.ToString());
50-
m_deploying = false;
51-
menuCommand.Visible = true;
69+
EnableAllButtons();
5270
m_output.ProgressBarLabel = "Robot Code Deploy Failed";
5371
}
5472

@@ -78,7 +96,7 @@ public override void QueryCallback(object sender, EventArgs e)
7896
}
7997
}
8098
}
81-
if (m_deploying)
99+
if (s_deploying)
82100
visable = false;
83101

84102
menuCommand.Visible = visable;

0 commit comments

Comments
 (0)