Skip to content

Commit

Permalink
Add message about processed file to status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
awulkiew committed Jul 2, 2023
1 parent de16fcf commit 16022ac
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 21 deletions.
14 changes: 11 additions & 3 deletions solution/ExcludeFromBuild/ExcludeFromBuildActiveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.ComponentModel.Design;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ExcludeFromBuild
{
Expand All @@ -34,18 +36,20 @@ internal sealed class ExcludeFromBuildActiveCommand
private readonly AsyncPackage package;

private readonly DTE2 dte;
private readonly IVsStatusbar statusBar;

/// <summary>
/// Initializes a new instance of the <see cref="ExcludeFromBuildCommand"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
/// <param name="commandService">Command service to add command to, not null.</param>
private ExcludeFromBuildActiveCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte)
private ExcludeFromBuildActiveCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte, IVsStatusbar statusBar)
{
this.package = package ?? throw new ArgumentNullException(nameof(package));
commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));
this.dte = dte ?? throw new ArgumentNullException(nameof(dte));
this.statusBar = statusBar ?? throw new ArgumentNullException(nameof(statusBar));

var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.Execute, menuCommandID);
Expand Down Expand Up @@ -82,7 +86,8 @@ public static async Task InitializeAsync(AsyncPackage package)

OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
DTE2 dte = await package.GetServiceAsync(typeof(DTE)) as DTE2;
Instance = new ExcludeFromBuildActiveCommand(package, commandService, dte);
IVsStatusbar statusBar = await package.GetServiceAsync(typeof(SVsStatusbar)) as IVsStatusbar;
Instance = new ExcludeFromBuildActiveCommand(package, commandService, dte, statusBar);
}

/// <summary>
Expand All @@ -96,7 +101,10 @@ private void Execute(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();

Util.SetExcludedFromBuild(dte, true, Util.Configuration.Active);
Util.UnfreezeStatusBar(statusBar);
Util.SetExcludedFromBuild(dte, true, Util.Configuration.Active,
(string name) => { statusBar.SetText("Exclude (Active): " + name); });
statusBar.SetText("");
}
}
}
14 changes: 11 additions & 3 deletions solution/ExcludeFromBuild/ExcludeFromBuildAllCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.ComponentModel.Design;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ExcludeFromBuild
{
Expand All @@ -34,18 +36,20 @@ internal sealed class ExcludeFromBuildAllCommand
private readonly AsyncPackage package;

private readonly DTE2 dte;
private readonly IVsStatusbar statusBar;

/// <summary>
/// Initializes a new instance of the <see cref="ExcludeFromBuildCommand"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
/// <param name="commandService">Command service to add command to, not null.</param>
private ExcludeFromBuildAllCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte)
private ExcludeFromBuildAllCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte, IVsStatusbar statusBar)
{
this.package = package ?? throw new ArgumentNullException(nameof(package));
commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));
this.dte = dte ?? throw new ArgumentNullException(nameof(dte));
this.statusBar = statusBar ?? throw new ArgumentNullException(nameof(statusBar));

var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.Execute, menuCommandID);
Expand Down Expand Up @@ -82,7 +86,8 @@ public static async Task InitializeAsync(AsyncPackage package)

OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
DTE2 dte = await package.GetServiceAsync(typeof(DTE)) as DTE2;
Instance = new ExcludeFromBuildAllCommand(package, commandService, dte);
IVsStatusbar statusBar = await package.GetServiceAsync(typeof(SVsStatusbar)) as IVsStatusbar;
Instance = new ExcludeFromBuildAllCommand(package, commandService, dte, statusBar);
}

/// <summary>
Expand All @@ -96,7 +101,10 @@ private void Execute(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();

Util.SetExcludedFromBuild(dte, true, Util.Configuration.All);
Util.UnfreezeStatusBar(statusBar);
Util.SetExcludedFromBuild(dte, true, Util.Configuration.All,
(string name) => { statusBar.SetText("Exclude (All): " + name); });
statusBar.SetText("");
}
}
}
20 changes: 16 additions & 4 deletions solution/ExcludeFromBuild/ExcludeFromBuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.ComponentModel.Design;
using System.Drawing;
using System.Net;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace ExcludeFromBuild
{
Expand All @@ -34,18 +38,20 @@ internal sealed class ExcludeFromBuildCommand
private readonly AsyncPackage package;

private readonly DTE2 dte;
private readonly IVsStatusbar statusBar;

/// <summary>
/// Initializes a new instance of the <see cref="ExcludeFromBuildCommand"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
/// <param name="commandService">Command service to add command to, not null.</param>
private ExcludeFromBuildCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte)
private ExcludeFromBuildCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte, IVsStatusbar statusBar)
{
this.package = package ?? throw new ArgumentNullException(nameof(package));
commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));
this.dte = dte ?? throw new ArgumentNullException(nameof(dte));
this.statusBar = statusBar ?? throw new ArgumentNullException(nameof(statusBar));

var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.Execute, menuCommandID);
Expand Down Expand Up @@ -82,9 +88,13 @@ public static async Task InitializeAsync(AsyncPackage package)

OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
DTE2 dte = await package.GetServiceAsync(typeof(DTE)) as DTE2;
Instance = new ExcludeFromBuildCommand(package, commandService, dte);
IVsStatusbar statusBar = await package.GetServiceAsync(typeof(SVsStatusbar)) as IVsStatusbar;
Instance = new ExcludeFromBuildCommand(package, commandService, dte, statusBar);
}

[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);

/// <summary>
/// This function is the callback used to execute the command when the menu item is clicked.
/// See the constructor to see how the menu item is associated with this function using
Expand All @@ -96,8 +106,10 @@ private void Execute(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();

Util.SetExcludedFromBuild(dte, true, Util.GetConfigurationOption());
Util.UnfreezeStatusBar(statusBar);
Util.SetExcludedFromBuild(dte, true, Util.GetConfigurationOption(),
(string name) => { statusBar.SetText("Exclude: " + name); });
statusBar.SetText("");
}

}
}
14 changes: 11 additions & 3 deletions solution/ExcludeFromBuild/IncludeInBuildActiveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.ComponentModel.Design;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ExcludeFromBuild
{
Expand All @@ -34,18 +36,20 @@ internal sealed class IncludeInBuildActiveCommand
private readonly AsyncPackage package;

private readonly DTE2 dte;
private readonly IVsStatusbar statusBar;

/// <summary>
/// Initializes a new instance of the <see cref="IncludeInBuildCommand"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
/// <param name="commandService">Command service to add command to, not null.</param>
private IncludeInBuildActiveCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte)
private IncludeInBuildActiveCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte, IVsStatusbar statusBar)
{
this.package = package ?? throw new ArgumentNullException(nameof(package));
commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));
this.dte = dte ?? throw new ArgumentNullException(nameof(dte));
this.statusBar = statusBar ?? throw new ArgumentNullException(nameof(statusBar));

var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.Execute, menuCommandID);
Expand Down Expand Up @@ -82,7 +86,8 @@ public static async Task InitializeAsync(AsyncPackage package)

OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
DTE2 dte = await package.GetServiceAsync(typeof(DTE)) as DTE2;
Instance = new IncludeInBuildActiveCommand(package, commandService, dte);
IVsStatusbar statusBar = await package.GetServiceAsync(typeof(SVsStatusbar)) as IVsStatusbar;
Instance = new IncludeInBuildActiveCommand(package, commandService, dte, statusBar);
}

/// <summary>
Expand All @@ -96,7 +101,10 @@ private void Execute(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();

Util.SetExcludedFromBuild(dte, false, Util.Configuration.Active);
Util.UnfreezeStatusBar(statusBar);
Util.SetExcludedFromBuild(dte, false, Util.Configuration.Active,
(string name) => { statusBar.SetText("Include (Active): " + name); });
statusBar.SetText("");
}
}
}
14 changes: 11 additions & 3 deletions solution/ExcludeFromBuild/IncludeInBuildAllCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.ComponentModel.Design;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ExcludeFromBuild
{
Expand All @@ -34,18 +36,20 @@ internal sealed class IncludeInBuildAllCommand
private readonly AsyncPackage package;

private readonly DTE2 dte;
private readonly IVsStatusbar statusBar;

/// <summary>
/// Initializes a new instance of the <see cref="IncludeInBuildCommand"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
/// <param name="commandService">Command service to add command to, not null.</param>
private IncludeInBuildAllCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte)
private IncludeInBuildAllCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte, IVsStatusbar statusBar)
{
this.package = package ?? throw new ArgumentNullException(nameof(package));
commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));
this.dte = dte ?? throw new ArgumentNullException(nameof(dte));
this.statusBar = statusBar ?? throw new ArgumentNullException(nameof(statusBar));

var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.Execute, menuCommandID);
Expand Down Expand Up @@ -82,7 +86,8 @@ public static async Task InitializeAsync(AsyncPackage package)

OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
DTE2 dte = await package.GetServiceAsync(typeof(DTE)) as DTE2;
Instance = new IncludeInBuildAllCommand(package, commandService, dte);
IVsStatusbar statusBar = await package.GetServiceAsync(typeof(SVsStatusbar)) as IVsStatusbar;
Instance = new IncludeInBuildAllCommand(package, commandService, dte, statusBar);
}

/// <summary>
Expand All @@ -96,7 +101,10 @@ private void Execute(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();

Util.SetExcludedFromBuild(dte, false, Util.Configuration.All);
Util.UnfreezeStatusBar(statusBar);
Util.SetExcludedFromBuild(dte, false, Util.Configuration.All,
(string name) => { statusBar.SetText("Include (All): " + name); });
statusBar.SetText("");
}
}
}
14 changes: 11 additions & 3 deletions solution/ExcludeFromBuild/IncludeInBuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.ComponentModel.Design;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ExcludeFromBuild
{
Expand All @@ -34,18 +36,20 @@ internal sealed class IncludeInBuildCommand
private readonly AsyncPackage package;

private readonly DTE2 dte;
private readonly IVsStatusbar statusBar;

/// <summary>
/// Initializes a new instance of the <see cref="IncludeInBuildCommand"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
/// <param name="commandService">Command service to add command to, not null.</param>
private IncludeInBuildCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte)
private IncludeInBuildCommand(AsyncPackage package, OleMenuCommandService commandService, DTE2 dte, IVsStatusbar statusBar)
{
this.package = package ?? throw new ArgumentNullException(nameof(package));
commandService = commandService ?? throw new ArgumentNullException(nameof(commandService));
this.dte = dte ?? throw new ArgumentNullException(nameof(dte));
this.statusBar = statusBar ?? throw new ArgumentNullException(nameof(statusBar));

var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.Execute, menuCommandID);
Expand Down Expand Up @@ -82,7 +86,8 @@ public static async Task InitializeAsync(AsyncPackage package)

OleMenuCommandService commandService = await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
DTE2 dte = await package.GetServiceAsync(typeof(DTE)) as DTE2;
Instance = new IncludeInBuildCommand(package, commandService, dte);
IVsStatusbar statusBar = await package.GetServiceAsync(typeof(SVsStatusbar)) as IVsStatusbar;
Instance = new IncludeInBuildCommand(package, commandService, dte, statusBar);
}

/// <summary>
Expand All @@ -96,7 +101,10 @@ private void Execute(object sender, EventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();

Util.SetExcludedFromBuild(dte, false, Util.GetConfigurationOption());
Util.UnfreezeStatusBar(statusBar);
Util.SetExcludedFromBuild(dte, false, Util.GetConfigurationOption(),
(string name) => { statusBar.SetText("Include: " + name); });
statusBar.SetText("");
}
}
}

0 comments on commit 16022ac

Please sign in to comment.