Table of Contents

Class ModuleTreeViewModel

Namespace
Loehnert.Lisrt.Modules.ViewModels
Assembly
Loehnert.Lisrt.Modules.dll

Represents a view model for ILisrtModule tree.

[Export(typeof(IModuleTree))]
public class ModuleTreeViewModel : Tool, IViewAware, IChild, IModuleTree, ITool, ILayoutItem, IScreen, IHaveDisplayName, IActivate, IDeactivate, IGuardClose, IClose, INotifyPropertyChangedEx, INotifyPropertyChanged
Inheritance
PropertyChangedBase
ViewAware
Screen
ModuleTreeViewModel
Implements
IViewAware
IChild
IScreen
IHaveDisplayName
IActivate
IDeactivate
IGuardClose
IClose
INotifyPropertyChangedEx
Inherited Members
Screen.OnInitialize()
Screen.OnActivate()
Screen.Parent
Screen.IsActive
Screen.IsInitialized
Screen.Activated
Screen.AttemptingDeactivation
Screen.Deactivated
ViewAware.DefaultContext
ViewAware.Views
ViewAware.ViewAttached
PropertyChangedBase.Refresh()
PropertyChangedBase.IsNotifying
PropertyChangedBase.PropertyChanged
Extension Methods

Remarks

The root module must be exported with this contract:

[Export(ModulesService.RootModuleName, typeof(ILisrtModule))]
.

Constructors

ModuleTreeViewModel(IMenuBuilder, IModulesService, IEnumerable<Lazy<ILisrtModule, IRootModuleMetadata>>, IModuleTreeViewFilter)

Initializes a new instance of the ModuleTreeViewModel class.

[ImportingConstructor]
public ModuleTreeViewModel(IMenuBuilder menuBuilder, IModulesService modulesService, IEnumerable<Lazy<ILisrtModule, IRootModuleMetadata>> rootModules, IModuleTreeViewFilter moduleFilter)

Parameters

menuBuilder IMenuBuilder

Menu builder that builds the menu.

modulesService IModulesService

Service for the modules.

rootModules IEnumerable<Lazy<ILisrtModule, IRootModuleMetadata>>

Root modules.

moduleFilter IModuleTreeViewFilter

Filter for filtering modules.

Exceptions

ArgumentNullException

Thrown when menuBuilder or modulesService is null.

Properties

ContextMenuItems

Gets the menu items for the context menu in the ModuleTreeView.

public IObservableCollection<MenuItemBase> ContextMenuItems { get; }

Property Value

IObservableCollection<MenuItemBase>

DisplayName

Gets the display name.

public override string DisplayName { get; }

Property Value

string

FirstGeneration

Gets the root modules.

public ObservableCollection<ModuleTreeItemViewModel> FirstGeneration { get; }

Property Value

ObservableCollection<ModuleTreeItemViewModel>

PreferredLocation

Gets the preferred PaneLocation for this Tool.

public override PaneLocation PreferredLocation { get; }

Property Value

PaneLocation

RootModuleIsNull

Gets a value indicating whether no root module is defined.

public bool RootModuleIsNull { get; }

Property Value

bool

SearchKey

Gets or sets the search key for filtering the modules and filters the FirstGeneration by setting.

public string SearchKey { get; set; }

Property Value

string

Methods

Fold(Func<int, ModuleTreeItemViewModel, bool?>)

Expands or folds the items of a module tree.

public void Fold(Func<int, ModuleTreeItemViewModel, bool?> shouldBeFolded)

Parameters

shouldBeFolded Func<int, ModuleTreeItemViewModel, bool?>

Function to determine whether ModuleTreeItemViewModel should be folded. The first argument is the generation (0 is the top level generation), the second argument is the module tree item view model. This function should return
true if the item should be folded
false if the item should be expanded
null if the IsExpanded value shouldn't be changed.

Examples

This example shows how fold all tree items, but not the top level items.

var moduleTree = (ModuleTreeViewModel)IoC.Get<IModuleTree>();
moduleTree.Fold((generation, vm) => generation >= 1);

This example shows how fold only the tree item named "Cavity1", all others are unchanged.

var moduleTree = (ModuleTreeViewModel)IoC.Get<IModuleTree>();
moduleTree.Fold((generation, vm) => vm.Module.Name == "Cavity1" ? (bool?)true : null);

Exceptions

ArgumentNullException

Thrown when shouldBeFolded is null.

GetSelectedModule()

Gets the selected ILisrtModule.

public ILisrtModule GetSelectedModule()

Returns

ILisrtModule

The selected ILisrtModule or null if no module is selected.