Adding to the Status Bar

3/30/2010 8:26 PM
You can subscribe to this wiki article using an RSS feed reader.


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

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
        }
    }

 


Tags:
Home: SoapBox Core What's new: Recently changed articles