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.
answered
01 Jun '10, 21:25
Scott Whitlock ♦♦
696●25●28●33
accept rate:
52%