コガネブログ

平日更新を目標に Unity や C#、Visual Studio、ReSharper などのゲーム開発アレコレを書いていきます

【Visual Studio 拡張機能作成】拡張機能実装時にステータスバーを変更する方法

文字を変更する

var statusBar = ServiceProvider.GetService( typeof( SVsStatusbar ) ) as IVsStatusbar;
statusBar.SetText( "ピカチュウ" );

f:id:baba_s:20171206173200p:plain

プログレスバーを表示する

var statusBar = ServiceProvider.GetService( typeof( SVsStatusbar ) ) as IVsStatusbar;
uint cookie = 0;
uint total = 100;
statusBar.Progress( ref cookie, 1, "", 0, 0 ); // プログレスバー表示開始
for ( uint i = 0; i <= total; i++ )
{
    statusBar.Progress( ref cookie, 1, "進捗", i, total );
    Thread.Sleep( 10 );
}
statusBar.Progress( ref cookie, 0, "", 0, 0 ); // プログレスバー表示終了

f:id:baba_s:20171206173313g:plain

アニメーションを表示する

var statusBar = ServiceProvider.GetService( typeof( SVsStatusbar ) ) as IVsStatusbar;
object icon = ( short )Constants.SBAI_Build;
statusBar.Animation( 1, ref icon ); // アニメーション開始
Thread.Sleep( 1000 );
statusBar.Animation( 0, ref icon ); // アニメーション終了

f:id:baba_s:20171206173559g:plain