All components that are used in the framework must implement the interface IComponentBase. A abstract class ComponentBase has been created to ease the implementation if inheriting from other classes is unnecessary. All components are required to provide an BitmapImage for an icon as well as a HelpView. There are two methods in the interface: Initialize and Execute. Initialize is called only one time when the application is initally loading. Execute is called anytime the component is clicked in the toolbar or it's hotkey has been entered.
IComponentBase
Only components that implement IComponentBase will be able to be loaded into the framework.
Properties
Name | Type | Description |
---|
HelpView | DependencyObject | This is a UIElement that will be displayed in the helpview for the component. It can be anything from a Textblock to an usercontrol. |
ComponentConfiguration | ApplicationComponentConfiguration | This is the configuration that has been defined for the component. |
Icon | BitmapImage | The icon that is used in the toolbar in the application. The icon is displayed at a size of 24X24 pixels. |
IsExecuting | bool | Used to tell the framework if the component is currently executing. |
IsInitialized | bool | Used by the framework to tell if the component has already been initialized. |
Methods
Name | Description |
---|
Execute() | Called when the component is clicked in the toolbar. The logic for what should kick off when the component is executed should be placed in this method. |
Initialize(IDictionary customSettings) | Initialize is called when the component is loaded in the application. This will only occur once. |
Sample Implementation
public class SampleComponent:IComponentBase
{
public void Initialize(IDictionary<string, string> customSettings)
{
IsInitialized = true;
}
public void Execute()
{
// Do Something
}
public BitmapImage Icon
{
get { return ResourceHelper.GetBitmap("Assets/Images/sample.png"); }
}
public bool IsInitialized { get; private set; }
public ApplicationComponentConfiguration ComponentConfiguration { get; set; }
public bool IsExecuting { get; private set; }
public DependencyObject HelpView
{
get { return new TextBlock {Text = "Help Text"}; }
}
}
ComponentBase
Most components that are being developed on the framework should inherit from ComponentBase. This base class reduces the boilerplate code that is required for a component. All that a developer needs to do is implement the abstract methods OnExecute and GetIconResourceUri.
Properties
Name | Type | Virtual | Description |
---|
ComponentConfiguration | ApplicationComponentConfiguration | false | This is the configuration that has been defined for the component. |
HelpView | DependencyObject | true | This is a UIElement that will be displayed in the helpview for the component. It can be anything from a Textblock to an usercontrol |
Icon | BitmapImage | false | The icon that is used in the toolbar in the application. The icon is displayed at a size of 24X24 pixels. |
IsExecuting | bool | false | Used to tell the framework if the component is currently executing. |
IsInitialized | bool | false | Used by the framework to tell if the component has already been initialized. |
SettingsViewModel | object | false | This is a viewModel that used by the component to expose component level user settings. |
Concrete Methods
ame | Return Type | Virtual | Description |
---|
CreateChildWindow(object viewModel) | GenericDialogViewModel | false | Shows the viewModel with a generated view with the onError method already wired up. |
Execute() | void | false | Called when the component is clicked in the toolbar. The logic for what should kick off when the component is executed should be placed in this method. |
GetImageFromResource(string uriString) | BitmapImage | false | This is a helper method to get a bitmapImager from a uri. |
Initialize(IDictionary customSettings) | void | false | Initialize is called when the component is loaded in the application. This will only occur once. |
OnError(ErrorEventArgs errorEventArgs) | void | true | If an exception occurs on Execute for the component this method gives the component a chance to handle the exception. If the exception is not handled then the exception will bubble up to the user. |
OnInitialize(IDictionary customSettings) | void | true | This method can be overridding so the component can perform an action at the time of initialization of the component. |
Abstract Methods
Name | Return Type | Description |
---|
GetIconResourceUri() | string | Used to set the uri for the icon for the component. |
OnExecute() | void | Called when the component is clicked in the toolbar. The logic for what should kick off when the component is executed should be placed in this method. |
Sample Implementation
[Export(typeof(IComponentBase))]
[PartCreationPolicy(CreationPolicy.Shared)]
public class SampleComponent : ComponentBase
{
protected override void OnExecute()
{
//Do Something
}
protected override string GetIconResourceUri()
{
return "/FDOT.GIS.Framework.Samples;component/Assets/Images/sample.png";
}
}
See Also