I would like my add-in to display some information in the status bar. How can I add controls there?

asked 01 Jun '10, 21:21

Scott%20Whitlock's gravatar image

Scott Whitlock ♦♦
696262833
accept rate: 50%


IStatusBarItem

The Workbench will import a collection of IStatusBarItem objects. These derive from IExtension, so they are sorted using the ID, InsertRelativeToID, and BeforeOrAfter properties. There are various types of status bar items, which all derive from IStatusBarItem, and all of them have a handy AbstractXXX class that you can derive from to easily instantiate your own items:

  • AbstractStatusBarButton
  • AbstractStatusBarLabel
  • AbstractStatusBarRadioButton
  • AbstractStatusBarSeparator
  • AbstractStatusBarToggleButton
  • AbstractStatusBarProgressBar

Button

[Export(SoapBox.Core.ExtensionPoints.Workbench.StatusBar, typeof(IStatusBarItem))]
public class MyButton : AbstractStatusBarButton
{
    public MyButton()
    {
        ID = "MyButton";
        ToolTip = "Click Me!"; 
        Text = "My Button Text";
        SetIconFromBitmap(Resources.Images.Icon);
    }
    protected override void Run()
    {
        base.Run();
        // Stuff that happens when the button is clicked goes here
    }
}

Label

[Export(SoapBox.Core.ExtensionPoints.Workbench.StatusBar, typeof(IStatusBarItem))]
public class MyLabel : AbstractStatusBarLabel
{
    public MyLabel()
    {
        ID = "MyLabel";
        Text = "My Label Text";
    }
}

RadioButton

// Same as Button, but set the GroupName property in the constructor

Separator

[Export(SoapBox.Core.ExtensionPoints.Workbench.StatusBar, typeof(IStatusBarItem))]
public class MySeparator : AbstractStatusBarSeparator
{
    public MySeparator()
    {
        ID = "MySeparator";
        InsertRelativeToID = "MyButton";
        BeforeOrAfter = RelativeDirection.After;
    }
}

ToggleButton

[Export(SoapBox.Core.ExtensionPoints.Workbench.StatusBar, typeof(IStatusBarItem))]
public class MyToggleButton : AbstractStatusBarToggleButton
{
    public MyToggleButton()
    {
        ID = "MyToggleButton";
        SetIconFromBitmap(Resources.Images.Icon);
        IsChecked = false;
    }
    protected override void OnIsCheckedChanged()
    {
        base.OnIsCheckedChanged();
        // Put stuff in here
    }
}

ProgressBar

[Export(SoapBox.Core.ExtensionPoints.Workbench.StatusBar, typeof(IStatusBarItem))]
public class MyProgressBar : AbstractStatusBarProgressBar
{
    public MyProgressBar()
    {
        ID = "MyProgressBar";
        Minimum = 50;
        Maximum = 150;
        Value = 75;
        Width = 250;
    }
}

Just update the Value during operation to move the progress bar.

link

answered 01 Jun '10, 21:25

Scott%20Whitlock's gravatar image

Scott Whitlock ♦♦
696262833
accept rate: 50%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×23
×1

Asked: 01 Jun '10, 21:21

Seen: 1,018 times

Last updated: 01 Jun '10, 21:25

powered by OSQA